/* ─── QC NET Styles ─────────────────────────────────── */
:root {
  --primary: #2563EB;
  --primary-dark: #1D4ED8;
  --success: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;
  --dark: #1E293B;
  --light: #F8FAFC;
  --card-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--light);
  color: var(--dark);
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

/* ─── Welcome Screen ───────── */
.welcome-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #1E3A8A 0%, #2563EB 50%, #3B82F6 100%);
  color: white;
  text-align: center;
  padding: 2rem;
}

.welcome-screen .logo {
  font-size: 4rem;
  margin-bottom: 1rem;
}

.welcome-screen h1 {
  font-size: 2.2rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.welcome-screen p {
  font-size: 1.1rem;
  opacity: 0.9;
  margin-bottom: 2rem;
}

.welcome-screen .btn-group-custom {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
  max-width: 320px;
}

/* ─── Login Screen ──────────── */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #1E3A8A 0%, #2563EB 100%);
  padding: 1rem;
}

.login-card {
  background: white;
  border-radius: 16px;
  padding: 2rem;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.login-card h2 {
  text-align: center;
  color: var(--primary);
  margin-bottom: 1.5rem;
}

/* ─── App Shell ─────────────── */
.app-shell {
  display: none;
  flex-direction: column;
  min-height: 100vh;
}

.app-header {
  background: var(--primary);
  color: white;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(37,99,235,0.3);
}

.app-header h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.app-header .header-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.app-header .back-btn {
  background: none;
  border: none;
  color: white;
  font-size: 1.3rem;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 6px;
  display: none;
}

.app-header .back-btn:hover {
  background: rgba(255,255,255,0.15);
}

.app-content {
  flex: 1;
  padding: 1rem;
  padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  display: flex;
  justify-content: space-around;
  padding: 0.5rem 0;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.08);
  z-index: 100;
}

.bottom-nav .nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  padding: 0.25rem 0.75rem;
  border-radius: 8px;
  color: #94A3B8;
  font-size: 0.7rem;
  font-weight: 500;
  transition: all 0.2s;
  border: none;
  background: none;
}

.bottom-nav .nav-item.active {
  color: var(--primary);
}

.bottom-nav .nav-item .nav-icon {
  font-size: 1.4rem;
}

/* ─── Cards ─────────────────── */
.card-custom {
  background: white;
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--card-shadow);
  border: 1px solid #E2E8F0;
}

.card-custom .card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--dark);
  margin-bottom: 0.75rem;
}

/* ─── Stat Cards ────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.stat-card {
  background: white;
  border-radius: 12px;
  padding: 1rem;
  box-shadow: var(--card-shadow);
  border-left: 4px solid var(--primary);
  text-align: center;
}

.stat-card.success { border-left-color: var(--success); }
.stat-card.warning { border-left-color: var(--warning); }
.stat-card.danger { border-left-color: var(--danger); }

.stat-card .stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--dark);
}

.stat-card .stat-label {
  font-size: 0.75rem;
  color: #64748B;
  margin-top: 0.25rem;
}

/* ─── Menu Grid ─────────────── */
.menu-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.menu-item {
  background: white;
  border-radius: 12px;
  padding: 1.25rem 1rem;
  text-align: center;
  cursor: pointer;
  box-shadow: var(--card-shadow);
  border: 1px solid #E2E8F0;
  transition: all 0.2s;
}

.menu-item:hover, .menu-item:active {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  border-color: var(--primary);
}

.menu-item .menu-icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.menu-item .menu-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--dark);
}

/* ─── Forms ─────────────────── */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: #475569;
  margin-bottom: 0.35rem;
}

.form-control-custom {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1.5px solid #CBD5E1;
  border-radius: 8px;
  font-size: 0.95rem;
  color: var(--dark);
  background: white;
  transition: border-color 0.2s;
}

.form-control-custom:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

/* ─── Buttons ───────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #059669; }
.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover { background: #D97706; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #DC2626; }
.btn-secondary { background: #94A3B8; color: white; }
.btn-secondary:hover { background: #64748B; }
.btn-outline { background: white; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: var(--primary); color: white; }

.btn-block { width: 100%; }
.btn-lg { padding: 0.85rem 1.5rem; font-size: 1rem; }
.btn-sm { padding: 0.4rem 0.75rem; font-size: 0.8rem; }

.btn-welcome {
  padding: 1rem;
  border-radius: 12px;
  font-size: 1.1rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  transition: all 0.2s;
}

.btn-welcome-agen {
  background: white;
  color: var(--primary);
}

.btn-welcome-front {
  background: rgba(255,255,255,0.15);
  color: white;
  border: 2px solid rgba(255,255,255,0.3);
}

.btn-welcome:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

/* ─── Table ─────────────────── */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.data-table th {
  background: var(--primary);
  color: white;
  padding: 0.6rem 0.5rem;
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
}

.data-table td {
  padding: 0.5rem;
  border-bottom: 1px solid #E2E8F0;
  vertical-align: top;
}

.data-table tr:hover td {
  background: #F1F5F9;
}

/* ─── Badge ─────────────────── */
.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
}

.badge-active { background: #DBEAFE; color: #1E40AF; }
.badge-returned { background: #D1FAE5; color: #065F46; }
.badge-overdue { background: #FEE2E2; color: #991B1B; }

/* ─── Alert ─────────────────── */
.alert {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.85rem;
}

.alert-success { background: #D1FAE5; color: #065F46; border: 1px solid #A7F3D0; }
.alert-danger { background: #FEE2E2; color: #991B1B; border: 1px solid #FECACA; }
.alert-info { background: #DBEAFE; color: #1E40AF; border: 1px solid #BFDBFE; }

/* ─── Empty State ───────────── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: #94A3B8;
}

.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.empty-state p {
  font-size: 0.9rem;
}

/* ─── Customer Card (mobile) ── */
.customer-card {
  background: white;
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: 0.75rem;
  box-shadow: var(--card-shadow);
  border: 1px solid #E2E8F0;
}

.customer-card .cust-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.customer-card .cust-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--dark);
}

.customer-card .cust-detail {
  font-size: 0.8rem;
  color: #64748B;
  margin-bottom: 0.15rem;
}

.customer-card .cust-detail span {
  color: var(--dark);
  font-weight: 500;
}

.customer-card .cust-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

/* ─── Report Card ───────────── */
.report-card {
  background: white;
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: 0.75rem;
  box-shadow: var(--card-shadow);
  border: 1px solid #E2E8F0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.report-card .report-info .report-title {
  font-weight: 600;
  font-size: 0.9rem;
}

.report-card .report-info .report-date {
  font-size: 0.75rem;
  color: #64748B;
}

.report-card .report-amount {
  font-weight: 700;
  color: var(--success);
  font-size: 0.95rem;
}

/* ─── Loading ───────────────── */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #E2E8F0;
  border-top: 4px solid var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ─── Toast ─────────────────── */
.toast-container {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  width: 90%;
  max-width: 400px;
}

.toast {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  animation: slideDown 0.3s ease;
}

.toast-success { background: #10B981; color: white; }
.toast-error { background: #EF4444; color: white; }
.toast-info { background: #3B82F6; color: white; }

@keyframes slideDown {
  from { transform: translateY(-20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ─── Page transitions ──────── */
.page { display: none; }
.page.active { display: block; animation: fadeIn 0.2s ease; }

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ─── Responsive ────────────── */
@media (max-width: 400px) {
  .stats-grid { grid-template-columns: 1fr; }
  .menu-grid { grid-template-columns: repeat(2, 1fr); }
  .app-content { padding: 0.75rem; padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }
}

/* ─── Print/Export styling ──── */
.recap-header {
  background: linear-gradient(135deg, #1E3A8A, #2563EB);
  color: white;
  padding: 1rem;
  border-radius: 12px;
  margin-bottom: 1rem;
  text-align: center;
}

.recap-header h4 { margin: 0; font-size: 1rem; }
.recap-header p { margin: 0.25rem 0 0; font-size: 0.8rem; opacity: 0.9; }

/* ─── Section Title ─────────── */
.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--dark);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--primary);
}

/* ─── User Info Bar ─────────── */
.user-info-bar {
  background: white;
  border-radius: 10px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  box-shadow: var(--card-shadow);
}

.user-info-bar .user-avatar {
  width: 40px;
  height: 40px;
  background: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 1.1rem;
}

.user-info-bar .user-detail {
  flex: 1;
}

.user-info-bar .user-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.user-info-bar .user-role {
  font-size: 0.75rem;
  color: #64748B;
}

/* ─── Summary table in recap ── */
.summary-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
}

.summary-table td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid #E2E8F0;
  font-size: 0.85rem;
}

.summary-table td:first-child {
  font-weight: 600;
  color: #475569;
}

.summary-table td:last-child {
  text-align: right;
  font-weight: 700;
  color: var(--dark);
}

/* ─── Agent list ────────────── */
.agent-card {
  background: white;
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: 0.75rem;
  box-shadow: var(--card-shadow);
  display: flex;
  align-items: center;
  gap: 1rem;
}

.agent-card .agent-info { flex: 1; }
.agent-card .agent-name { font-weight: 600; font-size: 0.95rem; }
.agent-card .agent-id { font-size: 0.8rem; color: #64748B; }
.agent-card .agent-actions { display: flex; gap: 0.5rem; }

/* ─── Modal ─────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-content {
  background: white;
  border-radius: 16px;
  padding: 1.5rem;
  width: 100%;
  max-width: 450px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.modal-content h3 {
  margin-top: 0;
  margin-bottom: 1rem;
  color: var(--dark);
  font-size: 1.1rem;
}

/* ─── Search & Filter Bar ────── */
.search-filter-bar {
  margin-bottom: 1rem;
}

.search-filter-bar input[type="text"] {
  width: 100%;
  margin-bottom: 0.5rem;
}

.filter-row {
  display: flex;
  gap: 0.5rem;
}

.filter-row select {
  flex: 1;
}

/* ─── Pagination ─────────────── */
.pagination-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 1rem;
  padding: 0.75rem 0;
}

.pagination-info {
  font-size: 0.8rem;
  color: #64748B;
  white-space: nowrap;
}

/* ─── Profile Page ─────────────── */
.profile-photo-section {
  text-align: center;
  padding: 1.5rem 0;
}

.profile-photo-wrapper {
  position: relative;
  display: inline-block;
  margin-bottom: 1rem;
  cursor: pointer;
}

.profile-photo-preview {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  font-weight: 700;
  color: white;
  overflow: hidden;
  border: 3px solid #e2e8f0;
  margin: 0 auto;
}

.profile-photo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-photo-edit-btn {
  position: absolute;
  bottom: 0;
  right: calc(50% - 60px);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #2563EB;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  cursor: pointer;
  border: 2px solid white;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  transition: background 0.2s;
  z-index: 10;
}

.profile-photo-edit-btn:hover {
  background: #1d4ed8;
}

.profile-name {
  font-size: 1.25rem;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 0.25rem;
}

.profile-role {
  font-size: 0.85rem;
  color: #64748B;
  margin-bottom: 0.25rem;
}

.profile-userid {
  font-size: 0.8rem;
  color: #94a3b8;
  font-family: monospace;
}
