@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700;800&display=swap');

:root {
  --bg-primary: #F0E1CA;
  --bg-card: #ffffff;
  --bg-card-hover: #faf5ee;
  --border: #572025;
  --border-light: rgba(87,32,37,0.15);
  --text: #2a1012;
  --text-dim: rgba(87,32,37,0.5);
  --text-light: rgba(87,32,37,0.65);
  --accent: #572025;
  --accent-light: rgba(87,32,37,0.1);
  --accent-hover: #6e2a30;
  --success: #2d7a3a;
  --danger: #c0392b;
  --gold: #b8860b;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 2px 12px rgba(87,32,37,0.08);
  --shadow-lg: 0 8px 32px rgba(87,32,37,0.12);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Poppins', -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ============ LOGIN ============ */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 20px;
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.5s ease-out;
}

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

.login-logo { font-size: 48px; margin-bottom: 12px; }
.login-title {
  font-size: 26px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 4px;
}
.login-subtitle {
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 32px;
  font-weight: 400;
}

.form-group { text-align: left; margin-bottom: 20px; }
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-light);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}
.form-group input,
.form-group select {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  transition: all 0.2s;
  outline: none;
}
.form-group input:focus,
.form-group select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(87,32,37,0.1);
}
.form-group select option { background: var(--bg-card); color: var(--text); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}
.btn-primary {
  width: 100%;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(87,32,37,0.2);
}
.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(87,32,37,0.25);
}
.btn-gold {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(87,32,37,0.2);
}
.btn-gold:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}
.btn-outline {
  background: transparent;
  border: 1px solid var(--border-light);
  color: var(--accent);
}
.btn-outline:hover { background: var(--accent-light); }
.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-sm { padding: 8px 16px; font-size: 13px; }
.btn-xs { padding: 5px 12px; font-size: 12px; border-radius: 6px; }

.error-msg {
  background: rgba(192,57,43,0.08);
  border: 1px solid rgba(192,57,43,0.2);
  color: var(--danger);
  padding: 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}

/* ============ ADMIN LAYOUT ============ */
.admin-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 250px;
  background: var(--accent);
  border-right: none;
  padding: 24px 0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  color: rgba(255,255,255,0.85);
}

.sidebar-header {
  padding: 0 24px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  margin-bottom: 24px;
}

.sidebar-logo { font-size: 28px; margin-bottom: 4px; }
.sidebar-title {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 1px;
}

.sidebar-section {
  font-size: 10px;
  font-weight: 700;
  color: rgba(255,255,255,0.4);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  padding: 0 24px;
  margin-bottom: 10px;
}

.section-badge {
  display: inline-block;
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  margin: 0 24px 20px;
  background: rgba(255,255,255,0.15);
  color: #fff;
}

.sidebar-nav { flex: 1; padding: 0 12px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  font-size: 13px;
  font-weight: 500;
  color: rgba(255,255,255,0.6);
  margin-bottom: 2px;
}
.nav-item:hover { background: rgba(255,255,255,0.1); color: #fff; }
.nav-item.active {
  background: rgba(255,255,255,0.15);
  color: #fff;
  font-weight: 600;
}
.nav-item .icon { font-size: 16px; width: 22px; text-align: center; }

.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid rgba(255,255,255,0.1);
  margin-top: auto;
}
.sidebar-footer a {
  color: rgba(255,255,255,0.5);
  text-decoration: none;
  font-size: 13px;
  transition: color 0.2s;
}
.sidebar-footer a:hover { color: #fff; }

.main-content {
  flex: 1;
  margin-left: 250px;
  padding: 32px;
  min-height: 100vh;
}

.page-header { margin-bottom: 28px; }
.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 4px;
}
.page-subtitle { color: var(--text-dim); font-size: 13px; }

/* ============ CARDS ============ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  transition: all 0.2s;
}
.card:hover { box-shadow: var(--shadow-lg); }
.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.stat-icon { font-size: 24px; margin-bottom: 8px; }
.stat-value { font-size: 26px; font-weight: 700; color: var(--accent); }
.stat-label { color: var(--text-dim); font-size: 12px; margin-top: 2px; font-weight: 500; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }

/* ============ TABLE ============ */
.table-container { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  border-bottom: 2px solid var(--border-light);
}
td {
  padding: 12px 14px;
  font-size: 13px;
  border-bottom: 1px solid rgba(87,32,37,0.06);
}
tr:hover td { background: rgba(87,32,37,0.02); }

.balance-positive { color: var(--success); font-weight: 700; }
.balance-negative { color: var(--danger); font-weight: 700; }
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}
.badge-pending { background: rgba(184,134,11,0.1); color: var(--gold); }
.badge-completed { background: rgba(45,122,58,0.1); color: var(--success); }
.badge-cancelled { background: rgba(192,57,43,0.1); color: var(--danger); }

/* ============ SERVICES GRID ============ */
.service-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 18px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}
.service-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}
.service-card.selected {
  border-color: var(--accent);
  background: var(--accent-light);
  box-shadow: 0 0 0 2px rgba(87,32,37,0.15);
}
.service-icon { font-size: 28px; margin-bottom: 6px; }
.service-name { font-weight: 600; font-size: 13px; margin-bottom: 4px; color: var(--text); }
.service-price {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
}

/* ============ QR MODAL ============ */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(87,32,37,0.4);
  backdrop-filter: blur(6px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.modal-overlay.active { display: flex; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 20px;
  padding: 36px;
  max-width: 440px;
  width: 90%;
  animation: slideUp 0.3s ease-out;
  position: relative;
  box-shadow: var(--shadow-lg);
}
.modal-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
  text-align: center;
  color: var(--accent);
}

.qr-image {
  margin: 20px 0;
  border-radius: 12px;
  overflow: hidden;
  display: inline-block;
  box-shadow: var(--shadow-lg);
}
.qr-image img { display: block; }

.qr-amount {
  font-size: 40px;
  font-weight: 800;
  margin: 12px 0 4px;
  color: var(--accent);
}
.qr-service { color: var(--text-dim); font-size: 14px; }
.qr-client { font-size: 15px; margin-top: 4px; font-weight: 600; }

/* ============ CLIENT VIEW ============ */
.client-container {
  max-width: 440px;
  margin: 0 auto;
  padding: 20px;
  min-height: 100vh;
}

.client-header {
  text-align: center;
  padding: 16px 0;
}
.client-logo { font-size: 36px; }
.client-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 2px;
}

/* Virtual Card */
.virtual-card {
  background: linear-gradient(135deg, #572025, #7a2e35, #572025);
  border-radius: 20px;
  padding: 28px 24px;
  margin: 20px 0;
  position: relative;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(87,32,37,0.3);
  border: 1px solid rgba(255,255,255,0.1);
}

.virtual-card::before {
  content: '';
  position: absolute;
  top: -40%; right: -40%;
  width: 80%; height: 80%;
  background: radial-gradient(circle, rgba(240,225,202,0.08) 0%, transparent 70%);
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 28px;
  position: relative;
  z-index: 1;
}

.card-chip {
  width: 36px; height: 26px;
  background: linear-gradient(135deg, #d4a843, #b8960b);
  border-radius: 5px;
}

.card-brand {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 3px;
  color: rgba(255,255,255,0.7);
}

.card-balance-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: rgba(255,255,255,0.4);
  margin-bottom: 6px;
  position: relative;
  z-index: 1;
}

.card-balance {
  font-size: 44px;
  font-weight: 800;
  color: #fff;
  position: relative;
  z-index: 1;
}

.card-balance .currency {
  font-size: 20px;
  font-weight: 500;
  opacity: 0.6;
  margin-left: 4px;
}

.card-bottom {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-top: 24px;
  position: relative;
  z-index: 1;
}

.card-holder {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: rgba(255,255,255,0.4);
}
.card-name {
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  margin-top: 3px;
}
.card-id {
  font-size: 11px;
  color: rgba(255,255,255,0.25);
  font-family: monospace;
}

/* Client sections */
.client-section { margin: 24px 0; }
.client-section-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid rgba(87,32,37,0.06);
}
.history-left { display: flex; align-items: center; gap: 12px; }
.history-icon { font-size: 18px; }
.history-name { font-weight: 600; font-size: 13px; }
.history-date { font-size: 11px; color: var(--text-dim); }
.history-amount { font-weight: 700; font-size: 14px; color: var(--danger); }
.history-amount::before { content: '- '; }

.client-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 20px 0;
}
.action-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
}
.action-btn:hover { border-color: var(--accent); }
.action-icon { font-size: 24px; margin-bottom: 4px; }
.action-label { font-size: 11px; color: var(--text-dim); font-weight: 500; }

.altitude-badge {
  display: inline-block;
  padding: 4px 14px;
  background: var(--accent-light);
  border: 1px solid rgba(87,32,37,0.15);
  border-radius: 20px;
  font-size: 11px;
  color: var(--accent);
  margin-top: 6px;
  font-weight: 600;
}

/* Client enter */
.client-enter { text-align: center; padding: 40px 20px; }
.client-enter input {
  width: 100%;
  padding: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 15px;
  text-align: center;
  font-family: inherit;
  outline: none;
  margin-bottom: 14px;
}
.client-enter input:focus { border-color: var(--accent); }

/* ============ TOAST ============ */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  z-index: 2000;
  animation: slideIn 0.3s ease-out;
  box-shadow: var(--shadow-lg);
}
.toast-success { background: var(--success); color: #fff; }
.toast-error { background: var(--danger); color: #fff; }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(16px); }
  to { opacity: 1; transform: translateX(0); }
}

.fade-in { animation: fadeIn 0.4s ease-out; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-dim);
}
.empty-state .icon { font-size: 40px; margin-bottom: 10px; }
.empty-state p { font-size: 14px; }

/* ============ HAMBURGER BUTTON ============ */
.hamburger {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 200;
  width: 42px;
  height: 42px;
  background: var(--accent);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 10px;
  box-shadow: 0 2px 12px rgba(87,32,37,0.3);
  transition: all 0.3s;
}
.hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: all 0.3s;
}
.hamburger.active span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}
.hamburger.active span:nth-child(2) {
  opacity: 0;
}
.hamburger.active span:nth-child(3) {
  transform: rotate(-45deg) translate(5px, -5px);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; }

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
  .hamburger { display: flex; }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    width: 260px;
  }
  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
    padding: 16px;
    padding-top: 64px;
  }

  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }

  /* Tables: horizontal scroll */
  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -12px;
    padding: 0 12px;
  }
  table {
    min-width: 580px;
  }
  th, td {
    padding: 8px 10px;
    font-size: 12px;
    white-space: nowrap;
  }

  /* Page header */
  .page-header {
    margin-bottom: 20px;
  }
  .page-title { font-size: 18px; }
  .page-subtitle { font-size: 12px; }

  /* Page header with button (clients page) */
  .page-header[style*="justify-content"] {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start !important;
  }

  /* Cards */
  .card {
    padding: 16px;
    border-radius: 10px;
  }

  /* Stat cards */
  .stat-card {
    padding: 14px;
  }
  .stat-value { font-size: 20px; }
  .stat-label { font-size: 11px; }
  .stat-icon { font-size: 20px; margin-bottom: 4px; }

  /* Service cards */
  .service-card {
    padding: 14px 10px;
  }
  .service-icon { font-size: 24px; }
  .service-name { font-size: 12px; }
  .service-price { font-size: 15px; }

  /* Buttons */
  .btn {
    padding: 10px 18px;
    font-size: 13px;
  }
  .btn-gold {
    width: 100%;
  }
  .btn-sm { padding: 8px 14px; font-size: 12px; }
  .btn-xs { padding: 5px 10px; font-size: 11px; }

  /* New TX page */
  #page-newtx .grid-2 {
    gap: 14px;
  }
  #generateQrBtn {
    padding: 14px 24px;
    font-size: 14px;
    width: 100%;
  }

  /* Forms */
  .form-group input,
  .form-group select {
    padding: 12px 14px;
    font-size: 14px;
  }
  #clientSearchAll, #clientSearch {
    max-width: 100% !important;
  }

  /* Modals */
  .modal {
    padding: 24px 20px;
    border-radius: 16px;
    width: 94%;
    max-height: 90vh;
    overflow-y: auto;
  }
  .qr-amount { font-size: 32px; }
  .qr-image img { width: 200px !important; height: 200px !important; }

  /* Token badge */
  .token-badge {
    font-size: 10px;
    padding: 2px 8px;
  }

  /* Lang switch in sidebar on mobile */
  .sidebar .lang-switch {
    margin: 0 16px 12px;
  }

  /* Toast */
  .toast {
    left: 16px;
    right: 16px;
    bottom: 16px;
    text-align: center;
  }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }

  .stat-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
  }
  .stat-icon { margin-bottom: 0; font-size: 22px; }
  .stat-value { font-size: 18px; }

  .main-content { padding: 12px; padding-top: 60px; }
  .page-title { font-size: 16px; }
}

/* ============ LANGUAGE SWITCHER ============ */
.lang-switch {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 500;
  display: flex;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.lang-btn {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  background: transparent;
  color: var(--text-dim);
  letter-spacing: 0.5px;
}
.lang-btn.active {
  background: var(--accent);
  color: #fff;
}
.lang-btn:hover:not(.active) {
  background: var(--accent-light);
  color: var(--accent);
}

/* Admin sidebar lang switcher */
.sidebar .lang-switch {
  position: relative;
  top: auto;
  right: auto;
  margin: 0 24px 16px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.1);
}
.sidebar .lang-btn {
  color: rgba(255,255,255,0.5);
}
.sidebar .lang-btn.active {
  background: rgba(255,255,255,0.2);
  color: #fff;
}
.sidebar .lang-btn:hover:not(.active) {
  background: rgba(255,255,255,0.1);
  color: #fff;
}

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(87,32,37,0.15); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(87,32,37,0.25); }
