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

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

:root {
  --primary: #1E2F9E;
  --primary-light: #4971FE;
  --primary-dark: #0f1a6b;
  --accent: #FFDD00;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --bg: #F0F2FF;
  --bg-card: #ffffff;
  --text: #1a1a2e;
  --text-muted: #6b7280;
  --border: rgba(30,47,158,0.1);
  --shadow: 0 4px 24px rgba(30,47,158,0.08);
  --shadow-lg: 0 8px 40px rgba(30,47,158,0.15);
  --sidebar-w: 260px;
  --radius: 16px;
}

html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

a { text-decoration: none; color: inherit; }
img { max-width: 100%; }
button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; }

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

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(160deg, #0d1a7a 0%, #1E2F9E 60%, #2a3db5 100%);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  padding: 0;
  z-index: 100;
  box-shadow: 4px 0 24px rgba(0,0,0,0.2);
  transition: transform 0.3s ease;
}

.sidebar-logo {
  padding: 28px 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-logo .logo-text {
  font-size: 22px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.5px;
}
.sidebar-logo .logo-sub {
  font-size: 11px;
  color: rgba(255,255,255,0.5);
  font-weight: 500;
  margin-top: 2px;
}

.sidebar-user {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.sidebar-user .user-email {
  font-size: 12px;
  color: rgba(255,255,255,0.6);
  word-break: break-all;
}
.sidebar-user .user-balance {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  margin-top: 4px;
}
.sidebar-user .user-role {
  display: inline-block;
  background: rgba(255,221,0,0.2);
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 12px;
  overflow-y: auto;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 12px;
  color: rgba(255,255,255,0.7);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
  margin-bottom: 2px;
  border: 1px solid transparent;
}
.nav-item:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
  transform: translateX(2px);
}
.nav-item.active {
  background: rgba(255,255,255,0.15);
  color: #fff;
  font-weight: 600;
  border-color: rgba(255,255,255,0.15);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.nav-item .nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.9;
}
.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

/* ===== MAIN CONTENT ===== */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: rgba(255,255,255,0.9);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.page-content {
  flex: 1;
  padding: 32px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

/* ===== CARDS ===== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
}
.card-body { padding: 24px; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary {
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  color: white;
  box-shadow: 0 4px 12px rgba(73,113,254,0.4);
}
.btn-primary:hover { box-shadow: 0 6px 20px rgba(73,113,254,0.5); }
.btn-success {
  background: linear-gradient(135deg, #34d399, var(--success));
  color: white;
  box-shadow: 0 4px 12px rgba(16,185,129,0.3);
}
.btn-danger {
  background: linear-gradient(135deg, #f87171, var(--danger));
  color: white;
  box-shadow: 0 4px 12px rgba(239,68,68,0.3);
}
.btn-warning {
  background: linear-gradient(135deg, #fbbf24, var(--warning));
  color: white;
  box-shadow: 0 4px 12px rgba(245,158,11,0.3);
}
.btn-outline {
  background: transparent;
  border: 2px solid var(--primary);
  color: var(--primary);
}
.btn-outline:hover { background: var(--primary); color: white; }
.btn-sm { padding: 6px 14px; font-size: 12px; border-radius: 8px; }
.btn-lg { padding: 14px 28px; font-size: 16px; border-radius: 12px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 20px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 6px;
}
.form-control {
  width: 100%;
  padding: 11px 16px;
  border: 2px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  color: var(--text);
  background: white;
  transition: all 0.2s;
  outline: none;
}
.form-control:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(73,113,254,0.1);
}
.form-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}
.input-group {
  display: flex;
  align-items: stretch;
}
.input-group .form-control {
  flex: 1;
  border-radius: 10px 0 0 10px;
  border-right: none;
}
.input-group .btn {
  border-radius: 0 10px 10px 0;
  padding: 0 16px;
}

/* ===== TABLES ===== */
.table-wrapper { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
}
thead th {
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 14px 16px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
tbody tr:hover { background: rgba(73,113,254,0.03); }
tbody tr:last-child td { border-bottom: none; }

/* ===== BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
}
.badge-success { background: rgba(16,185,129,0.1); color: #059669; }
.badge-danger { background: rgba(239,68,68,0.1); color: #dc2626; }
.badge-warning { background: rgba(245,158,11,0.1); color: #d97706; }
.badge-info { background: rgba(73,113,254,0.1); color: var(--primary); }
.badge-gray { background: #f3f4f6; color: #6b7280; }

/* ===== PRODUCT CARDS ===== */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}
.product-card {
  background: white;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  padding: 24px;
  transition: all 0.3s;
  position: relative;
  overflow: hidden;
}
.product-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary-light), var(--primary));
  opacity: 0;
  transition: opacity 0.3s;
}
.product-card:hover {
  border-color: var(--primary-light);
  box-shadow: var(--shadow-lg);
  transform: translateY(-4px);
}
.product-card:hover::before { opacity: 1; }

.product-tags {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.product-tag {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.tag-imap { background: rgba(73,113,254,0.1); color: var(--primary); }
.tag-graph { background: rgba(16,185,129,0.1); color: #059669; }
.tag-hotmail { background: rgba(239,68,68,0.08); color: #dc2626; }
.tag-outlook { background: rgba(30,47,158,0.08); color: var(--primary-dark); }
.tag-gmail { background: rgba(234,67,53,0.08); color: #ea4335; }
.tag-temp { background: rgba(245,158,11,0.1); color: #d97706; }
.tag-long { background: rgba(16,185,129,0.1); color: #059669; }
.tag-default { background: #f3f4f6; color: #6b7280; }

.product-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(73,113,254,0.1), rgba(30,47,158,0.1));
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
  font-size: 24px;
}
.product-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 6px;
}
.product-duration {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 14px;
}
.product-price-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.product-price {
  font-size: 24px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.5px;
}
.product-price .currency {
  font-size: 13px;
  font-weight: 600;
  margin-left: 3px;
}
.product-stock {
  font-size: 12px;
  margin: 12px 0;
}
.stock-label { color: var(--text-muted); }
.stock-value { font-weight: 700; color: var(--text); }
.stock-value.low { color: var(--warning); }
.stock-value.out { color: var(--danger); }

.product-buy-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}
.qty-input {
  width: 70px;
  padding: 10px 12px;
  border: 2px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  outline: none;
  transition: border-color 0.2s;
}
.qty-input:focus { border-color: var(--primary-light); }

/* ===== TABS ===== */
.tabs {
  display: flex;
  gap: 4px;
  background: rgba(30,47,158,0.06);
  padding: 4px;
  border-radius: 12px;
  margin-bottom: 24px;
}
.tab-btn {
  padding: 8px 20px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--text-muted);
  transition: all 0.2s;
}
.tab-btn.active {
  background: white;
  color: var(--primary);
  box-shadow: 0 2px 8px rgba(30,47,158,0.12);
}
.tab-btn:hover:not(.active) { color: var(--primary); }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.modal-overlay.show {
  opacity: 1;
  pointer-events: all;
}
.modal {
  background: white;
  border-radius: 20px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  transform: translateY(20px);
  transition: transform 0.3s;
}
.modal-overlay.show .modal { transform: translateY(0); }
.modal-header {
  padding: 24px 28px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-size: 20px; font-weight: 800; color: var(--primary); }
.modal-close {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--bg);
  color: var(--text-muted);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}
.modal-close:hover { background: #fee2e2; color: var(--danger); }
.modal-body { padding: 24px 28px 28px; }

/* ===== ACCOUNT LIST (order result) ===== */
.account-list-wrapper {
  background: #0f172a;
  border-radius: 12px;
  padding: 16px;
  margin: 16px 0;
  max-height: 300px;
  overflow-y: auto;
}
.account-item {
  font-family: 'Courier New', monospace;
  font-size: 12px;
  color: #a5f3fc;
  padding: 4px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  word-break: break-all;
}
.account-item:last-child { border-bottom: none; }

/* ===== TOAST ===== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-radius: 12px;
  background: white;
  box-shadow: 0 8px 30px rgba(0,0,0,0.15);
  font-size: 14px;
  font-weight: 600;
  min-width: 280px;
  max-width: 400px;
  animation: toastIn 0.3s ease;
  border-left: 4px solid var(--primary);
}
.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }
.toast.warning { border-color: var(--warning); }
@keyframes toastIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ===== AUTH PAGES ===== */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0d1a7a 0%, var(--primary) 50%, #4971FE 100%);
  padding: 20px;
}
.auth-card {
  background: white;
  border-radius: 24px;
  padding: 48px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.3);
}
.auth-logo {
  text-align: center;
  margin-bottom: 32px;
}
.auth-logo-text {
  font-size: 28px;
  font-weight: 900;
  color: var(--primary);
  letter-spacing: -1px;
}
.auth-logo-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}
.auth-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 24px;
  text-align: center;
}
.auth-link {
  color: var(--primary-light);
  font-weight: 600;
}
.auth-link:hover { text-decoration: underline; }

/* ===== DEPOSIT INFO ===== */
.bank-info-box {
  background: linear-gradient(135deg, rgba(73,113,254,0.05), rgba(30,47,158,0.05));
  border: 1.5px solid rgba(73,113,254,0.2);
  border-radius: 16px;
  padding: 24px;
}
.bank-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid rgba(73,113,254,0.08);
}
.bank-info-row:last-child { border-bottom: none; }
.bank-info-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.bank-info-value {
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
}
.copy-btn {
  width: 28px; height: 28px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: white;
  color: var(--primary);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}
.copy-btn:hover { background: var(--primary); color: white; }

.transfer-content-box {
  background: linear-gradient(135deg, #fefce8, #fef9c3);
  border: 2px solid var(--accent);
  border-radius: 12px;
  padding: 16px 20px;
  font-size: 18px;
  font-weight: 800;
  color: #92400e;
  text-align: center;
  letter-spacing: 1px;
}

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state svg { opacity: 0.3; margin-bottom: 16px; }
.empty-state h3 { font-size: 18px; font-weight: 700; margin-bottom: 8px; color: var(--text); }
.empty-state p { font-size: 14px; }

/* ===== LOADING ===== */
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary-light);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px;
  gap: 16px;
  color: var(--text-muted);
  font-size: 14px;
}

/* ===== STAT CARDS ===== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}
.stat-card {
  background: white;
  border-radius: var(--radius);
  padding: 24px;
  border: 1.5px solid var(--border);
  position: relative;
  overflow: hidden;
}
.stat-card::after {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 80px; height: 80px;
  border-radius: 50%;
  background: var(--primary-light);
  opacity: 0.06;
  transform: translate(20px, -20px);
}
.stat-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.stat-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.5px;
}
.stat-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ===== ALERT ===== */
.alert {
  padding: 14px 18px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
}
.alert-warning { background: #fffbeb; border: 1px solid #fbbf24; color: #92400e; }
.alert-info { background: #eff6ff; border: 1px solid #93c5fd; color: #1d4ed8; }
.alert-success { background: #f0fdf4; border: 1px solid #86efac; color: #166534; }
.alert-danger { background: #fef2f2; border: 1px solid #fca5a5; color: #991b1b; }

/* ===== RESPONSIVE ===== */
.hamburger {
  display: none;
  background: none;
  border: none;
  font-size: 22px;
  color: var(--primary);
  cursor: pointer;
}

@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .hamburger { display: flex; }
  .sidebar {
    transform: translateX(-100%);
    width: 260px;
  }
  .sidebar.open {
    transform: translateX(0);
    width: 260px;
  }
  .main-content { margin-left: 0; }
  .page-content { padding: 16px; }
  .topbar { padding: 0 16px; }
  .product-grid { grid-template-columns: 1fr; }
  .auth-card { padding: 32px 24px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
}
