/* ═══════════════════════════════════════════════════════════
   SMS TECHNOLOGY — Premium Modern License Manager
   Style: Clean White, Soft Shadows, Rounded Cards, Blue Accents
   ═══════════════════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

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

:root {
  --bg: #F8FAFC;
  --white: #FFFFFF;
  --text: #1E293B;
  --text-sec: #64748B;
  --text-muted: #94A3B8;
  --blue: #3B82F6;
  --blue-dark: #2563EB;
  --blue-light: #EFF6FF;
  --blue-50: #DBEAFE;
  --border: #E8ECF1;
  --green: #10B981;
  --green-bg: #ECFDF5;
  --red: #EF4444;
  --red-bg: #FEF2F2;
  --amber: #F59E0B;
  --amber-bg: #FFFBEB;
  --cyan: #06B6D4;
  --cyan-bg: #ECFEFF;
  --purple: #8B5CF6;
  --purple-bg: #F5F3FF;
  --sidebar-w: 260px;
  --radius: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.03);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.06);
  --transition: 0.2s ease;
}

html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

.sidebar {
  width: var(--sidebar-w);
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 100;
}

.main-content {
  margin-left: var(--sidebar-w);
  flex: 1; min-height: 100vh;
  background: var(--bg);
}

/* ════════════════════════════════════
   Sidebar
   ════════════════════════════════════ */
.sidebar-brand {
  padding: 28px 24px 24px;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand h1 {
  font-size: 15px; font-weight: 800;
  color: var(--blue); letter-spacing: 1.2px;
}

.sidebar-brand p {
  font-size: 12px; color: var(--text-muted);
  margin-top: 4px; font-weight: 400;
}

.sidebar-nav {
  flex: 1; padding: 16px 14px;
  display: flex; flex-direction: column; gap: 4px;
}

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-radius: var(--radius-sm);
  color: var(--text-sec); cursor: pointer;
  font-size: 14px; font-weight: 500;
  border: none; background: none;
  width: 100%; text-align: left;
  transition: all var(--transition);
}

.nav-item:hover {
  background: var(--blue-light);
  color: var(--blue);
}

.nav-item.active {
  background: var(--blue-light);
  color: var(--blue-dark);
  font-weight: 600;
}

.nav-item .icon { font-size: 18px; width: 24px; text-align: center; }

.nav-item .badge {
  margin-left: auto;
  background: var(--blue-50);
  color: var(--blue);
  font-size: 11px; padding: 2px 8px;
  border-radius: 20px; font-weight: 700;
}

.nav-item.active .badge {
  background: var(--blue);
  color: var(--white);
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 16px 14px;
  border-top: 1px solid var(--border);
}

.user-info {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
}

.user-avatar {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--blue), var(--purple));
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: var(--white);
  flex-shrink: 0;
}

.user-details { flex: 1; min-width: 0; }
.user-details .name {
  font-size: 13px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-details .role { font-size: 11px; color: var(--text-muted); }

.btn-logout {
  width: 100%; margin-top: 10px; padding: 9px;
  background: var(--white); border: 1px solid var(--border);
  color: var(--text-sec); border-radius: var(--radius-sm);
  cursor: pointer; font-family: inherit; font-size: 12px; font-weight: 500;
  transition: all var(--transition);
}

.btn-logout:hover {
  background: var(--red-bg); color: var(--red);
  border-color: #FECACA;
}

/* ════════════════════════════════════
   Page Header
   ════════════════════════════════════ */
.page-header {
  padding: 28px 32px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
}

.page-header h2 {
  font-size: 20px; font-weight: 700;
  display: flex; align-items: center; gap: 10px;
  color: var(--text);
}

.page-header .subtitle {
  font-size: 13px; color: var(--text-muted);
  margin-top: 3px; font-weight: 400;
}

/* ════════════════════════════════════
   Buttons
   ════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 20px; border-radius: var(--radius-sm);
  font-family: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer; border: none;
  transition: all var(--transition);
}

.btn-primary {
  background: var(--blue); color: var(--white);
  box-shadow: 0 2px 8px rgba(59,130,246,0.25);
}
.btn-primary:hover {
  background: var(--blue-dark);
  box-shadow: 0 4px 14px rgba(59,130,246,0.3);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--white); color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg); }

.btn-danger {
  background: var(--red-bg); color: var(--red);
  border: 1px solid #FECACA;
}
.btn-danger:hover { background: #FEE2E2; }

.btn-success {
  background: var(--green-bg); color: var(--green);
  border: 1px solid #A7F3D0;
}
.btn-success:hover { background: #D1FAE5; }

.btn-sm { padding: 7px 12px; font-size: 12px; border-radius: 8px; }

/* ════════════════════════════════════
   Page Body & Stats
   ════════════════════════════════════ */
.page-body { padding: 28px 32px; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 18px; margin-bottom: 28px;
}

.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  transition: all var(--transition);
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.stat-card .stat-icon { font-size: 28px; margin-bottom: 14px; }
.stat-card .stat-value { font-size: 32px; font-weight: 800; color: var(--text); line-height: 1; }
.stat-card .stat-label { font-size: 13px; color: var(--text-muted); margin-top: 6px; font-weight: 500; }
.stat-card .stat-sub { font-size: 12px; color: var(--blue); margin-top: 4px; font-weight: 600; }

/* ════════════════════════════════════
   Tables
   ════════════════════════════════════ */
.table-container {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.table-toolbar {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  gap: 12px; flex-wrap: wrap;
}

.search-input {
  flex: 1; min-width: 200px;
  padding: 10px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text); font-family: inherit;
  font-size: 13px; outline: none;
  transition: all var(--transition);
}

.search-input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
  background: var(--white);
}

.search-input::placeholder { color: var(--text-muted); }

.filter-select {
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text); font-family: inherit;
  font-size: 13px; outline: none; cursor: pointer;
}

.filter-select:focus { border-color: var(--blue); }
.filter-select option { background: var(--white); }

table { width: 100%; border-collapse: collapse; }

thead th {
  padding: 14px 18px; text-align: left;
  font-size: 11px; font-weight: 600;
  color: var(--text-muted); text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

tbody td {
  padding: 14px 18px; font-size: 13px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

tbody tr { transition: background var(--transition); }
tbody tr:hover { background: #F8FAFC; }
tbody tr:last-child td { border-bottom: none; }

.table-empty {
  padding: 56px 20px; text-align: center;
  color: var(--text-muted); font-size: 14px;
}
.table-empty .empty-icon { font-size: 36px; margin-bottom: 12px; }

/* ════════════════════════════════════
   Badges
   ════════════════════════════════════ */
.badge {
  display: inline-flex; align-items: center;
  padding: 4px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 600;
}

.badge-active { background: var(--green-bg); color: var(--green); }
.badge-surplus { background: var(--cyan-bg); color: var(--cyan); }
.badge-expired { background: var(--amber-bg); color: var(--amber); }
.badge-revoked { background: var(--red-bg); color: var(--red); }
.badge-admin { background: var(--purple-bg); color: var(--purple); }
.badge-user { background: var(--bg); color: var(--text-sec); }

/* ════════════════════════════════════
   Modals
   ════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.2);
  backdrop-filter: blur(4px);
  z-index: 1000; display: flex;
  align-items: center; justify-content: center;
  padding: 24px;
  opacity: 0; visibility: hidden;
  transition: all 0.25s ease;
}

.modal-overlay.active { opacity: 1; visibility: visible; }

.modal {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%; max-width: 580px;
  max-height: 85vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.12);
  transform: translateY(12px) scale(0.98);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.active .modal { transform: translateY(0) scale(1); }

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; background: var(--white); z-index: 1;
  border-radius: var(--radius) var(--radius) 0 0;
}

.modal-header h3 { font-size: 16px; font-weight: 700; }

.modal-close {
  width: 32px; height: 32px;
  background: var(--bg); border: none;
  border-radius: 8px; color: var(--text-muted);
  cursor: pointer; font-size: 15px;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}

.modal-close:hover { background: var(--red-bg); color: var(--red); }

.modal-body { padding: 24px; }

.modal-footer {
  padding: 18px 24px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
}

/* ════════════════════════════════════
   Forms
   ════════════════════════════════════ */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group { margin-bottom: 16px; }
.form-group.full { grid-column: 1 / -1; }

.form-group label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--text-sec); margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%; padding: 10px 14px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text); font-family: inherit;
  font-size: 13px; outline: none;
  transition: all var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}

.form-group input::placeholder { color: var(--text-muted); }
.form-group textarea { resize: vertical; min-height: 70px; }
.form-group select option { background: var(--white); }

/* ════════════════════════════════════
   Toast Notifications
   ════════════════════════════════════ */
.toast-container {
  position: fixed; top: 20px; right: 20px; z-index: 2000;
  display: flex; flex-direction: column; gap: 8px;
}

.toast {
  padding: 14px 20px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: toastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  max-width: 360px;
}

.toast-success { background: var(--green); color: var(--white); }
.toast-error { background: var(--red); color: var(--white); }
.toast-info { background: var(--blue); color: var(--white); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}
.toast-exit { animation: toastOut 0.2s ease forwards; }
@keyframes toastOut { to { opacity: 0; transform: translateY(-10px); } }

/* ════════════════════════════════════
   Sections & Actions
   ════════════════════════════════════ */
.section { display: none; }
.section.active { display: block; animation: fadeUp 0.3s ease; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.actions-cell { display: flex; gap: 6px; }

/* ════════════════════════════════════
   History Timeline
   ════════════════════════════════════ */
.history-list { padding: 0; list-style: none; }
.history-item {
  padding: 14px 0; border-bottom: 1px solid var(--border);
  display: flex; gap: 12px;
}
.history-item:last-child { border-bottom: none; }
.history-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--blue); margin-top: 6px; flex-shrink: 0;
}
.history-action { font-weight: 600; font-size: 13px; }
.history-details { font-size: 12px; color: var(--text-sec); margin-top: 2px; }
.history-meta { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ════════════════════════════════════
   Mobile Responsive
   ════════════════════════════════════ */
.mobile-toggle {
  display: none; position: fixed; top: 16px; left: 16px; z-index: 200;
  width: 40px; height: 40px; background: var(--white);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); font-size: 18px; cursor: pointer;
  align-items: center; justify-content: center;
  box-shadow: var(--shadow);
}

.mobile-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.2); z-index: 99;
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.25s ease; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .mobile-toggle { display: flex; }
  .mobile-overlay.active { display: block; }
  .page-header { padding: 20px 18px; padding-left: 60px; }
  .page-body { padding: 18px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .form-row { grid-template-columns: 1fr; }
  .table-toolbar { flex-direction: column; }
  .search-input { min-width: 100%; }
}

/* ════════════════════════════════════
   Utilities
   ════════════════════════════════════ */
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.mb-3 { margin-bottom: 16px; }
.hidden { display: none !important; }
.mono { font-family: 'SF Mono', 'Fira Code', monospace; font-size: 12px; color: var(--text-sec); }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; display: inline-block; }
.price { font-variant-numeric: tabular-nums; font-weight: 600; }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 3px; }
