/* ═══════════════════════════════════════════════════════════════════════════
   Sendly Admin Panel — style.css
   Dark mode, glassmorphism, premium SaaS feel
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Variables ── */
:root {
  --bg:         #0a0b0f;
  --bg-2:       #111318;
  --bg-3:       #1a1d24;
  --glass:      rgba(255,255,255,0.04);
  --glass-bdr:  rgba(255,255,255,0.08);
  --primary:    #6366f1;
  --primary-h:  #818cf8;
  --purple:     #8b5cf6;
  --green:      #10b981;
  --red:        #ef4444;
  --amber:      #f59e0b;
  --text:       #f1f5f9;
  --text-2:     #94a3b8;
  --text-3:     #475569;
  --radius:     14px;
  --radius-sm:  8px;
  --shadow:     0 8px 32px rgba(0,0,0,0.4);
  --trans:      0.2s ease;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-family: 'Inter', system-ui, sans-serif; font-size: 15px; }
body { background: var(--bg); color: var(--text); min-height: 100vh; overflow-x: hidden; }
a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: inherit; border: none; background: none; }
input, textarea { font-family: inherit; }

/* ── Glass card mixin ── */
.glass {
  background: var(--glass);
  border: 1px solid var(--glass-bdr);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: var(--radius);
}

/* ── Animated grid background ── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 20%, rgba(99,102,241,.12) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(139,92,246,.10) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* ══════════════════════════════════════════════════════════════════════════
   SCREENS
══════════════════════════════════════════════════════════════════════════ */
.screen { display: none; position: relative; z-index: 1; }
.screen.active { display: flex; }

/* ══════════════════════════════════════════════════════════════════════════
   LOGIN
══════════════════════════════════════════════════════════════════════════ */
#login-screen {
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  padding: 48px 40px;
  box-shadow: var(--shadow);
  animation: fadeInUp .4s ease both;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
}

.login-card h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: 6px; }
.subtitle { color: var(--text-2); font-size: .9rem; margin-bottom: 32px; }

/* ══════════════════════════════════════════════════════════════════════════
   DASHBOARD LAYOUT
══════════════════════════════════════════════════════════════════════════ */
#dashboard-screen { min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: 220px;
  min-height: 100vh;
  position: fixed;
  left: 0; top: 0;
  border-radius: 0;
  border-right: 1px solid var(--glass-bdr);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  gap: 8px;
  z-index: 10;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.1rem;
  padding: 0 8px;
  margin-bottom: 24px;
  color: var(--text);
}

nav { flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: .9rem;
  font-weight: 500;
  transition: all var(--trans);
}
.nav-item:hover { background: rgba(255,255,255,.06); color: var(--text); }
.nav-item.active { background: rgba(99,102,241,.18); color: var(--primary-h); }

.sidebar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px;
  border-top: 1px solid var(--glass-bdr);
  margin-top: 8px;
  gap: 8px;
}

.admin-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  overflow: hidden;
}

.admin-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 700; flex-shrink: 0;
}

#admin-username {
  font-size: .85rem;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Main content */
.main {
  margin-left: 220px;
  padding: 32px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.topbar h2 { font-size: 1.4rem; font-weight: 700; }
.topbar-sub { color: var(--text-2); font-size: .85rem; margin-top: 2px; }
.topbar-actions { display: flex; gap: 10px; }

/* ══════════════════════════════════════════════════════════════════════════
   STATS
══════════════════════════════════════════════════════════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.stat-card {
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: transform var(--trans);
}
.stat-card:hover { transform: translateY(-2px); }

.stat-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon.total   { background: rgba(99,102,241,.2);  color: var(--primary-h); }
.stat-icon.active  { background: rgba(16,185,129,.2);  color: var(--green); }
.stat-icon.blocked { background: rgba(239,68,68,.2);   color: var(--red); }
.stat-icon.expired { background: rgba(245,158,11,.2);  color: var(--amber); }

.stat-val {
  display: block;
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1;
}

.stat-label {
  display: block;
  font-size: .8rem;
  color: var(--text-2);
  margin-top: 4px;
}

/* ══════════════════════════════════════════════════════════════════════════
   FILTERS
══════════════════════════════════════════════════════════════════════════ */
.filters {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  flex-wrap: wrap;
}

.search-input {
  flex: 1;
  min-width: 180px;
  background: rgba(255,255,255,.06);
  border: 1px solid var(--glass-bdr);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  color: var(--text);
  font-size: .9rem;
  outline: none;
  transition: border-color var(--trans);
}
.search-input:focus { border-color: var(--primary); }
.search-input::placeholder { color: var(--text-3); }

.filter-tabs { display: flex; gap: 6px; }

.filter-tab {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: .82rem;
  font-weight: 500;
  color: var(--text-2);
  border: 1px solid transparent;
  transition: all var(--trans);
}
.filter-tab:hover { color: var(--text); border-color: var(--glass-bdr); }
.filter-tab.active {
  background: rgba(99,102,241,.2);
  color: var(--primary-h);
  border-color: rgba(99,102,241,.4);
}

/* ══════════════════════════════════════════════════════════════════════════
   TABLE
══════════════════════════════════════════════════════════════════════════ */
.table-wrapper { overflow-x: auto; }

.keys-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}

.keys-table th {
  padding: 12px 16px;
  text-align: left;
  color: var(--text-3);
  font-weight: 600;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid var(--glass-bdr);
  white-space: nowrap;
}

.keys-table td {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,.04);
  color: var(--text);
  vertical-align: middle;
}

.keys-table tr:last-child td { border-bottom: none; }
.keys-table tbody tr { transition: background var(--trans); }
.keys-table tbody tr:hover { background: rgba(255,255,255,.03); }

/* Key preview cell */
.key-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

.key-preview {
  font-family: 'Courier New', monospace;
  font-size: .85rem;
  color: var(--primary-h);
  background: rgba(99,102,241,.12);
  padding: 3px 8px;
  border-radius: 6px;
}

.loading-row {
  text-align: center;
  color: var(--text-3);
  padding: 48px !important;
}

/* Status badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .78rem;
  font-weight: 600;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; display: inline-block; }

.badge-active  { background: rgba(16,185,129,.15);  color: #34d399; }
.badge-active::before  { background: #10b981; box-shadow: 0 0 6px #10b981; }

.badge-blocked { background: rgba(239,68,68,.15);   color: #f87171; }
.badge-blocked::before { background: #ef4444; }

.badge-expired { background: rgba(245,158,11,.15);  color: #fbbf24; }
.badge-expired::before { background: #f59e0b; }

/* Action buttons */
.actions { display: flex; gap: 6px; }

.btn-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-3);
  border: 1px solid transparent;
  transition: all var(--trans);
  background: none;
  cursor: pointer;
}
.btn-icon:hover { color: var(--text); border-color: var(--glass-bdr); background: rgba(255,255,255,.06); }
.btn-icon.danger:hover { color: var(--red); border-color: rgba(239,68,68,.3); background: rgba(239,68,68,.1); }
.btn-icon.success:hover { color: var(--green); border-color: rgba(16,185,129,.3); background: rgba(16,185,129,.1); }

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 16px;
  border-top: 1px solid var(--glass-bdr);
}

.page-btn {
  min-width: 32px; height: 32px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  font-size: .82rem;
  color: var(--text-2);
  border: 1px solid transparent;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--trans);
}
.page-btn:hover { color: var(--text); border-color: var(--glass-bdr); }
.page-btn.active { background: rgba(99,102,241,.2); color: var(--primary-h); border-color: rgba(99,102,241,.4); }
.page-btn:disabled { opacity: .3; pointer-events: none; }

/* ══════════════════════════════════════════════════════════════════════════
   FORMS
══════════════════════════════════════════════════════════════════════════ */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-size: .82rem; font-weight: 500; color: var(--text-2); }

.field input,
.field textarea {
  background: rgba(255,255,255,.06);
  border: 1px solid var(--glass-bdr);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text);
  font-size: .9rem;
  outline: none;
  transition: border-color var(--trans);
  width: 100%;
}
.field input:focus,
.field textarea:focus { border-color: var(--primary); }
.field textarea { resize: vertical; min-height: 72px; }

/* ══════════════════════════════════════════════════════════════════════════
   BUTTONS
══════════════════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--trans);
  position: relative;
  overflow: hidden;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--purple));
  color: #fff;
  box-shadow: 0 4px 16px rgba(99,102,241,.3);
}
.btn-primary:hover { opacity: .9; transform: translateY(-1px); box-shadow: 0 6px 20px rgba(99,102,241,.4); }
.btn-primary:active { transform: translateY(0); }

.btn-ghost {
  background: rgba(255,255,255,.06);
  color: var(--text-2);
  border-color: var(--glass-bdr);
}
.btn-ghost:hover { color: var(--text); background: rgba(255,255,255,.1); }

.btn-danger {
  background: rgba(239,68,68,.15);
  color: var(--red);
  border-color: rgba(239,68,68,.3);
}
.btn-danger:hover { background: rgba(239,68,68,.25); }

.btn.full { width: 100%; justify-content: center; }

/* ══════════════════════════════════════════════════════════════════════════
   MODALS
══════════════════════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
  animation: fadeIn .2s ease;
}
.modal-overlay.hidden { display: none; }

.modal {
  width: 100%;
  max-width: 480px;
  padding: 32px;
  box-shadow: var(--shadow);
  animation: scaleIn .25s ease;
}
.modal-sm { max-width: 360px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.modal-header h3 { font-size: 1.1rem; font-weight: 700; }

.modal-close {
  font-size: 1.4rem;
  color: var(--text-3);
  cursor: pointer;
  line-height: 1;
  transition: color var(--trans);
  background: none;
  border: none;
}
.modal-close:hover { color: var(--text); }

.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 24px;
}

/* Reveal modal */
.reveal-warning {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: rgba(245,158,11,.1);
  border: 1px solid rgba(245,158,11,.3);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 20px;
  font-size: .88rem;
  color: var(--text-2);
}
.reveal-warning svg { flex-shrink: 0; margin-top: 1px; }
.reveal-warning strong { color: var(--amber); }

.key-display {
  background: rgba(99,102,241,.08);
  border: 1px solid rgba(99,102,241,.25);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.key-display code {
  font-family: 'Courier New', monospace;
  font-size: 1rem;
  color: var(--primary-h);
  font-weight: 700;
  letter-spacing: .05em;
  word-break: break-all;
}

.copy-btn:hover { color: var(--primary-h) !important; }

.confirm-msg {
  color: var(--text-2);
  font-size: .9rem;
  line-height: 1.5;
}

/* ══════════════════════════════════════════════════════════════════════════
   TOASTS
══════════════════════════════════════════════════════════════════════════ */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 200;
}

.toast {
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: .88rem;
  font-weight: 500;
  box-shadow: var(--shadow);
  border: 1px solid transparent;
  animation: slideInRight .3s ease;
  max-width: 320px;
}
.toast-success { background: rgba(16,185,129,.15); border-color: rgba(16,185,129,.3); color: #34d399; }
.toast-error   { background: rgba(239,68,68,.15);  border-color: rgba(239,68,68,.3);  color: #f87171; }
.toast-info    { background: rgba(99,102,241,.15); border-color: rgba(99,102,241,.3); color: var(--primary-h); }

/* ══════════════════════════════════════════════════════════════════════════
   SPINNER
══════════════════════════════════════════════════════════════════════════ */
.spinner {
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.hidden { display: none !important; }

/* ══════════════════════════════════════════════════════════════════════════
   ERROR
══════════════════════════════════════════════════════════════════════════ */
.error-msg {
  background: rgba(239,68,68,.12);
  border: 1px solid rgba(239,68,68,.3);
  color: #f87171;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: .85rem;
  margin-bottom: 16px;
}

/* ══════════════════════════════════════════════════════════════════════════
   ANIMATIONS
══════════════════════════════════════════════════════════════════════════ */
@keyframes fadeIn    { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeInUp  { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes scaleIn   { from { opacity: 0; transform: scale(.95); } to { opacity: 1; transform: scale(1); } }
@keyframes slideInRight { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ══════════════════════════════════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .sidebar { width: 180px; }
  .main { margin-left: 180px; padding: 20px; }
  .topbar { flex-direction: column; align-items: flex-start; }
}
