/* ===== CSS Reset & Variables ===== */
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}

:root {
  --primary: #4A90D9;
  --primary-light: #E8F0FE;
  --primary-dark: #2B5797;
  --accent: #5BA3E6;
  --bg: #F5F8FC;
  --white: #FFFFFF;
  --text: #1A1A2E;
  --text-light: #6B7280;
  --success: #10B981;
  --danger: #EF4444;
  --warning: #F59E0B;
  --radius: 10px;
  --shadow: 0 2px 8px rgba(74,144,217,0.10);
  --shadow-lg: 0 8px 24px rgba(74,144,217,0.15);
  --transition: 0.2s ease;
}

html { font-size: 16px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* ===== Navbar ===== */
.navbar {
  background: var(--white);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}
.navbar.hidden { display: none; }
.navbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.navbar-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--primary-dark);
}
.navbar-logo { width: 32px; height: 32px; }
.navbar-menu {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.nav-link {
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-weight: 500;
  color: var(--text);
  transition: background var(--transition), color var(--transition);
}
.nav-link:hover, .nav-link.active {
  background: var(--primary-light);
  color: var(--primary-dark);
}

/* Hamburger */
.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}
.hamburger span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform var(--transition), opacity var(--transition);
}
.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ===== Language Switcher ===== */
.lang-switcher {
  display: flex;
  gap: 2px;
  border: 1.5px solid #D1D5DB;
  border-radius: 6px;
  overflow: hidden;
}
.lang-btn {
  padding: 0.3rem 0.6rem;
  border: none;
  background: var(--white);
  color: var(--text-light);
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  letter-spacing: 0.5px;
}
.lang-btn + .lang-btn { border-left: 1px solid #D1D5DB; }
.lang-btn.active { background: var(--primary); color: var(--white); }
.lang-btn:hover:not(.active) { background: var(--primary-light); color: var(--primary-dark); }

/* Auth page lang switcher */
.auth-lang-switcher {
  display: flex;
  justify-content: flex-end;
  gap: 2px;
  margin-bottom: 1rem;
}
.auth-lang-switcher .lang-btn {
  border: 1.5px solid #D1D5DB;
  border-radius: 4px;
  padding: 0.25rem 0.55rem;
  font-size: 0.7rem;
}
.auth-lang-switcher .lang-btn + .lang-btn { border-left: 1.5px solid #D1D5DB; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1.4rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: var(--white); }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); box-shadow: var(--shadow); }
.btn-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover:not(:disabled) { background: var(--primary-light); }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-danger:hover:not(:disabled) { background: #dc2626; }
.btn-success { background: var(--success); color: var(--white); }
.btn-sm { padding: 0.35rem 0.9rem; font-size: 0.85rem; }
.btn-block { width: 100%; }

/* ===== Forms ===== */
.form-group { margin-bottom: 1rem; }
.form-label {
  display: block;
  margin-bottom: 0.3rem;
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text);
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 0.65rem 0.9rem;
  border: 1.5px solid #D1D5DB;
  border-radius: var(--radius);
  font-size: 0.95rem;
  color: var(--text);
  background: var(--white);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(74,144,217,0.15);
}
.form-input.error { border-color: var(--danger); }
.form-error { color: var(--danger); font-size: 0.8rem; margin-top: 0.25rem; }
.form-textarea { resize: vertical; min-height: 80px; }

/* ===== Cards ===== */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  transition: box-shadow var(--transition);
}
.card:hover { box-shadow: var(--shadow-lg); }
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}
.card-title { font-size: 1.1rem; font-weight: 700; color: var(--text); }

/* ===== Badges ===== */
.badge {
  display: inline-block;
  padding: 0.2rem 0.7rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-success { background: #D1FAE5; color: #065F46; }
.badge-danger { background: #FEE2E2; color: #991B1B; }
.badge-warning { background: #FEF3C7; color: #92400E; }
.badge-info { background: var(--primary-light); color: var(--primary-dark); }

/* ===== Page Layouts ===== */
.page { max-width: 1200px; margin: 0 auto; padding: 1.5rem 1rem; }
.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 1.5rem;
}
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

/* Auth pages — 2-column on desktop */
.auth-container {
  display: flex;
  min-height: 100dvh;
}

/* Left brand panel — image background */
.auth-brand {
  flex: 0 0 55%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  background: url('../assets/satdish_banner.jpeg') center/cover no-repeat;
  position: relative;
  overflow: hidden;
}
.auth-brand-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(15,35,70,0.92) 0%, rgba(20,50,100,0.6) 50%, rgba(30,70,130,0.3) 100%);
}
.auth-brand-content {
  position: relative;
  z-index: 1;
  padding: 3rem 2.5rem;
  color: var(--white);
}
.auth-brand-logo {
  width: 120px;
  height: auto;
  margin-bottom: 1.5rem;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.3));
}
.auth-brand-headline {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--white);
  margin-bottom: 0.75rem;
  line-height: 1.3;
}
.auth-brand-desc {
  font-size: 0.95rem;
  color: rgba(255,255,255,0.75);
  line-height: 1.6;
  margin-bottom: 1.5rem;
}
.auth-brand-features {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.auth-brand-features li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.9rem;
  color: rgba(255,255,255,0.85);
}
.auth-brand-features li::before {
  content: '';
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  border: 1.5px solid rgba(255,255,255,0.35);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 16 16' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4 8l3 3 5-5' stroke='white' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-size: 14px;
  background-position: center;
  background-repeat: no-repeat;
}

/* Right form side — flat white */
.auth-form-side {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem 2.5rem;
  background: var(--white);
  position: relative;
  overflow-y: auto;
}
.auth-form-wrap {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 400px;
}
.auth-logo {
  text-align: center;
  margin-bottom: 1rem;
}
.auth-logo img {
  width: 100px;
  height: auto;
  object-fit: contain;
}
.auth-title {
  text-align: center;
  font-size: 1.8rem;
  font-weight: 700;
  color: #2d3748;
  margin-bottom: 2rem;
  text-transform: uppercase;
  letter-spacing: 2px;
}
/* Desktop: hide logo (shown in brand panel) */
@media (min-width: 641px) {
  .auth-logo { display: none; }
}

/* Flat underline inputs */
.form-input-flat {
  width: 100%;
  border: none;
  border-bottom: 2px solid #d1d5db;
  padding: 0.85rem 0.25rem;
  font-size: 1rem;
  color: var(--text);
  background: transparent;
  outline: none;
  transition: border-color 0.25s;
}
.form-input-flat::placeholder {
  color: #9ca3af;
  font-weight: 400;
}
.form-input-flat:focus {
  border-bottom-color: var(--primary);
}
.auth-form-side .form-group {
  margin-bottom: 1.5rem;
}
.auth-form-side .btn-primary {
  margin-top: 0.5rem;
  padding: 0.9rem;
  font-size: 1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  border-radius: 6px;
}
.auth-footer {
  text-align: center;
  margin-top: 1.5rem;
  font-size: 0.9rem;
  color: var(--text-light);
}
.auth-footer a { color: var(--primary); font-weight: 600; }
.auth-footer a:hover { color: var(--primary-dark); }

/* Lang switcher on form side */
.auth-form-side .auth-lang-switcher {
  position: absolute;
  top: 1.25rem;
  right: 1.5rem;
  z-index: 2;
}

/* ===== Grid for warranty/claim cards ===== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
}

/* Product card */
.product-card { position: relative; overflow: hidden; }
.product-card .product-name { font-weight: 700; font-size: 1.05rem; margin-bottom: 0.5rem; }
.product-card .product-info {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.25rem 0.75rem;
  font-size: 0.88rem;
  color: var(--text-light);
}
.product-card .product-info dt { font-weight: 600; color: var(--text); }
.product-card .product-info dd { margin: 0; }
.product-card .product-badge { position: absolute; top: 1rem; right: 1rem; }

/* Claim card */
.claim-card .claim-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}
.claim-card .claim-id { font-weight: 700; font-size: 0.95rem; color: var(--primary-dark); }
.claim-card .claim-product { font-weight: 600; margin-bottom: 0.5rem; }
.claim-card .claim-desc {
  font-size: 0.88rem;
  color: var(--text-light);
  margin-bottom: 0.75rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.claim-card .claim-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-light);
}
.claim-status-badge {
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--white);
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition), visibility var(--transition);
}
.modal-overlay.active { opacity: 1; visibility: visible; }
.modal {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 2rem;
  transform: translateY(20px);
  transition: transform var(--transition);
}
.modal-overlay.active .modal { transform: translateY(0); }
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}
.modal-title { font-size: 1.2rem; font-weight: 700; }
.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-light);
  line-height: 1;
}
.modal-close:hover { color: var(--text); }

/* ===== Toast ===== */
.toast {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 999;
  padding: 0.8rem 1.2rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--white);
  transform: translateX(calc(100% + 2rem));
  transition: transform 0.3s ease;
  max-width: 400px;
  word-break: break-word;
}
.toast.show { transform: translateX(0); }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }

/* ===== Loading ===== */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2.5px solid var(--primary-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
  color: var(--text-light);
  gap: 1rem;
}

/* ===== Empty state ===== */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-light);
}
.empty-state svg { margin-bottom: 1rem; opacity: 0.5; }
.empty-state p { font-size: 1rem; }

/* ===== Claim detail overlay ===== */
.claim-images { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; }
.claim-images img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
  cursor: pointer;
}

/* File upload area */
.upload-area {
  border: 2px dashed #D1D5DB;
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  color: var(--text-light);
  font-size: 0.9rem;
}
.upload-area:hover { border-color: var(--primary); background: var(--primary-light); }
.upload-preview { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; }
.upload-preview .preview-item {
  position: relative;
  width: 72px;
  height: 72px;
}
.upload-preview .preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 6px;
}
.upload-preview .preview-item .remove-img {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* ===== QR Scanner (inline in modal) ===== */
.scan-section { margin-bottom: 1rem; }
.scan-area {
  display: none;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 0.75rem;
  background: #000;
}
.scan-area.active { display: block; }
.scan-buttons { display: flex; flex-direction: column; gap: 0.5rem; }
.scan-status {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-light);
  margin-bottom: 0.75rem;
  min-height: 1.4em;
}
.scan-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.25rem 0;
  color: var(--text-light);
  font-size: 0.85rem;
}
.scan-divider::before, .scan-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #D1D5DB;
}
#qr-reader { border-radius: var(--radius); overflow: hidden; }
#qr-reader video { border-radius: var(--radius); }
#qr-reader__scan_region { border-radius: var(--radius); }
#qr-reader__dashboard { display: none !important; }

/* Entry mode toggle (claims) */
.entry-mode-toggle {
  display: flex;
  border: 1.5px solid #D1D5DB;
  border-radius: var(--radius);
  overflow: hidden;
}
.entry-mode-btn {
  flex: 1;
  padding: 0.55rem 0.75rem;
  border: none;
  background: var(--white);
  color: var(--text-light);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.entry-mode-btn + .entry-mode-btn {
  border-left: 1.5px solid #D1D5DB;
}
.entry-mode-btn.active {
  background: var(--primary);
  color: var(--white);
}
.entry-mode-btn:hover:not(.active) {
  background: var(--primary-light);
  color: var(--primary-dark);
}

/* Two column form */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* ===== Responsive ===== */

/* Tablet (640–1024) */
@media (max-width: 1024px) {
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
  .page { padding: 1.25rem 0.75rem; }
}

/* Mobile (<=640) */
@media (max-width: 640px) {
  /* Navbar */
  .hamburger { display: flex; }
  .navbar-inner { height: 52px; }
  .navbar-brand { font-size: 1.05rem; }
  .navbar-logo { width: 28px; height: 28px; }
  .navbar-menu {
    display: none;
    position: absolute;
    top: 52px;
    left: 0;
    right: 0;
    background: var(--white);
    flex-direction: column;
    padding: 0.75rem;
    box-shadow: var(--shadow);
    gap: 0.25rem;
  }
  .navbar-menu.open { display: flex; }
  .nav-link { padding: 0.75rem 1rem; }

  /* Page layout */
  .page { padding: 1rem 0.75rem; }
  .page-title { font-size: 1.25rem; margin-bottom: 1rem; }
  .page-header { flex-direction: column; align-items: stretch; gap: 0.5rem; }
  .page-header .btn { text-align: center; }

  /* Cards */
  .card { padding: 1rem; }
  .card-grid { grid-template-columns: 1fr; gap: 0.75rem; }
  .product-card .product-name { font-size: 0.95rem; }
  .product-card .product-info { font-size: 0.82rem; gap: 0.2rem 0.5rem; }
  .product-card .product-badge { top: 0.75rem; right: 0.75rem; }
  .claim-card .claim-id { font-size: 0.88rem; }
  .claim-card .claim-desc { font-size: 0.82rem; }
  .claim-card .claim-meta { font-size: 0.75rem; }

  /* Badges */
  .badge { font-size: 0.7rem; padding: 0.15rem 0.55rem; }

  /* Forms */
  .form-row { grid-template-columns: 1fr; }
  .form-label { font-size: 0.85rem; }

  /* Modals — full screen on mobile */
  .modal-overlay { padding: 0; align-items: stretch; }
  .modal {
    max-width: 100%;
    max-height: 100dvh;
    border-radius: 0;
    padding: 1.25rem;
  }
  .modal-title { font-size: 1.05rem; }

  /* Auth: single column on mobile */
  .auth-container { flex-direction: column; }
  .auth-brand { display: none; }
  .auth-form-side {
    padding: 2rem 1.5rem;
    min-height: 100dvh;
    align-items: flex-start;
    padding-top: 3rem;
  }
  .auth-logo { display: block; }
  .auth-logo img { width: 80px; }
  .auth-title { font-size: 1.4rem; margin-bottom: 1.5rem; }
  .auth-form-side .auth-lang-switcher {
    top: 1rem;
    right: 1rem;
  }

  /* Upload */
  .upload-area { padding: 1rem; font-size: 0.85rem; }
  .upload-preview .preview-item { width: 60px; height: 60px; }
  .claim-images img { width: 64px; height: 64px; }

  /* Scan */
  .scan-buttons .btn { font-size: 0.85rem; padding: 0.5rem 0.75rem; }
}

/* Very small phones (<=380) */
@media (max-width: 380px) {
  .auth-form-side { padding: 1.5rem 1rem; padding-top: 2.5rem; }
  .auth-logo img { width: 70px; }
  .auth-title { font-size: 1.2rem; }
  .form-input-flat { font-size: 0.9rem; }
  .page { padding: 0.75rem 0.5rem; }
  .page-title { font-size: 1.1rem; }
  .form-input, .form-select, .form-textarea { font-size: 0.88rem; padding: 0.5rem 0.7rem; }
  .btn { font-size: 0.88rem; padding: 0.5rem 0.9rem; }
  .modal { padding: 1rem; }
  .card { padding: 0.85rem; }
  .product-card .product-info { font-size: 0.78rem; }
}
