/**
 * admin-style.css — Mobile-first responsive styles for QuantReflex Admin Panel
 *
 * Design philosophy mirrors the main app:
 *   background : #f8fafc
 *   card       : #ffffff
 *   accent     : #2563eb
 *   text       : #0f172a
 *   secondary  : #64748b
 */

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

html {
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
  scroll-behavior: smooth;
  overflow-x: hidden;
  scrollbar-width: none;
}
html::-webkit-scrollbar { display: none; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #f8fafc;
  color: #0f172a;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
input, textarea, select { font-family: inherit; }

/* ---- Login Screen ---- */
.login-screen {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 1.5rem;
  background: linear-gradient(135deg, #f8fafc 0%, #e0e7ff 100%);
}

.login-card {
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 2.5rem 2rem;
  border-radius: 1.25rem;
  box-shadow: 0 4px 24px rgba(0,0,0,.08);
  border: 1px solid rgba(226,232,240,.6);
  width: 100%;
  max-width: 380px;
  animation: fadeSlideUp .4s ease;
}

.login-header { text-align: center; margin-bottom: 2rem; }

.login-logo {
  width: 56px; height: 56px;
  margin: 0 auto 1rem;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  border-radius: .875rem;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; font-weight: 800;
  box-shadow: 0 4px 12px rgba(37,99,235,.3);
}

.login-title { font-size: 1.375rem; font-weight: 700; color: #0f172a; }
.login-subtitle { color: #64748b; font-size: .875rem; margin-top: .25rem; }

.login-field { margin-bottom: 1.25rem; }
.login-label { display: block; font-size: .8125rem; font-weight: 600; color: #334155; margin-bottom: .375rem; }

.login-input {
  width: 100%;
  padding: .75rem 1rem;
  border: 1.5px solid #e2e8f0;
  border-radius: .625rem;
  font-size: .9375rem;
  color: #0f172a;
  background: #fff;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.login-input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

.login-error {
  color: #dc2626;
  font-size: .8125rem;
  margin-bottom: 1rem;
  padding: .625rem .75rem;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: .5rem;
  text-align: center;
}

.login-footer {
  text-align: center; color: #94a3b8; font-size: .75rem; margin-top: 1.5rem;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 44px;
  padding: .75rem 1.25rem;
  border: none;
  border-radius: .625rem;
  font-size: .9375rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  background: #e2e8f0;
  color: #0f172a;
  transition: background .2s, transform .12s, box-shadow .2s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.96); }
.btn.accent {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  box-shadow: 0 2px 8px rgba(37,99,235,.25);
}
.btn.accent:hover { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.btn-sm {
  min-height: 36px;
  padding: .5rem 1rem;
  font-size: .8125rem;
  border-radius: .5rem;
  width: auto;
}
.btn-outline {
  background: transparent;
  border: 1.5px solid #e2e8f0;
  color: #334155;
}
.btn-outline:hover { background: #f1f5f9; }
.btn-danger {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
}
.btn-danger:hover { background: #fee2e2; }

/* ---- App Shell ---- */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

/* ---- Top Bar (mobile) ---- */
.top-bar {
  display: flex;
  align-items: center;
  padding: 0 1rem;
  height: 56px;
  background: rgba(255,255,255,.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(226,232,240,.6);
  position: sticky;
  top: 0;
  z-index: 100;
}

.menu-toggle {
  width: 36px; height: 36px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px;
  background: none; border: none; cursor: pointer; padding: 0;
  touch-action: manipulation;
}
.menu-toggle span {
  width: 20px; height: 2px;
  background: #334155; border-radius: 1px;
  transition: transform .2s, opacity .2s;
}

.top-bar-title {
  flex: 1;
  text-align: center;
  font-size: 1.0625rem;
  font-weight: 700;
  color: #0f172a;
}

.top-bar-action {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; cursor: pointer;
  color: #64748b;
  touch-action: manipulation;
}

/* ---- Sidebar ---- */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: 260px;
  background: rgba(255,255,255,.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-right: 1px solid rgba(226,232,240,.6);
  z-index: 200;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform .25s cubic-bezier(.25,.46,.45,.94);
}
.sidebar.open { transform: translateX(0); }

.sidebar-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.3);
  z-index: 199;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
}
.sidebar-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(226,232,240,.6);
  font-weight: 700;
  font-size: .9375rem;
  color: #0f172a;
}

.sidebar-logo {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  border-radius: .5rem;
  display: flex; align-items: center; justify-content: center;
  font-size: .875rem; font-weight: 800;
  flex-shrink: 0;
}

.sidebar-nav {
  flex: 1;
  padding: .75rem 0;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1.5rem;
  color: #64748b;
  font-weight: 500;
  font-size: .875rem;
  transition: all .15s ease;
  touch-action: manipulation;
}
.nav-item:hover,
.nav-item.active {
  color: #2563eb;
  background: rgba(37,99,235,.06);
}
.nav-item.active {
  font-weight: 600;
  border-right: 3px solid #2563eb;
}
.nav-item svg { flex-shrink: 0; }

.sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(226,232,240,.6);
}

.sidebar-logout {
  width: 100%;
  padding: .625rem 1rem;
  background: transparent;
  border: 1.5px solid #e2e8f0;
  border-radius: .5rem;
  font-size: .8125rem;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  transition: all .15s;
  touch-action: manipulation;
}
.sidebar-logout:hover { background: #f1f5f9; color: #334155; }

/* ---- Main Content ---- */
.main-content {
  flex: 1;
  padding: 1.25rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.view { display: none; max-width: 900px; margin: 0 auto; }
.view.active { display: block; animation: viewFadeIn .25s ease; }

@keyframes viewFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---- View Header ---- */
.view-header { margin-bottom: 1.5rem; }
.view-title { font-size: 1.5rem; font-weight: 700; color: #0f172a; }
.view-subtitle { color: #64748b; font-size: .875rem; margin-top: .125rem; }

/* ---- Cards ---- */
.card {
  background: rgba(255,255,255,.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 1rem;
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: 0 2px 8px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
  border: 1px solid rgba(226,232,240,.6);
  overflow: hidden;
  word-break: break-word;
}

/* ---- Stat Cards ---- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .75rem;
}

.stat-card {
  background: rgba(255,255,255,.88);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(226,232,240,.6);
  border-radius: 1rem;
  padding: 1.25rem 1rem;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,.04);
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: #2563eb;
  line-height: 1.1;
}
.stat-label {
  color: #64748b;
  font-size: .75rem;
  font-weight: 500;
  margin-top: .375rem;
  letter-spacing: .02em;
}

/* ---- Search ---- */
.search-bar {
  display: flex;
  gap: .5rem;
  margin-bottom: 1rem;
}
.search-input {
  flex: 1;
  padding: .75rem 1rem;
  border: 1.5px solid #e2e8f0;
  border-radius: .625rem;
  font-size: .875rem;
  color: #0f172a;
  background: #fff;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.search-input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

/* ---- Data Table ---- */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: .75rem;
  border: 1px solid rgba(226,232,240,.6);
  background: #fff;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 500px;
}
.data-table th,
.data-table td {
  padding: .75rem 1rem;
  text-align: left;
  border-bottom: 1px solid #f1f5f9;
  font-size: .8125rem;
}
.data-table th {
  background: #f8fafc;
  font-weight: 600;
  color: #64748b;
  font-size: .75rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  position: sticky;
  top: 0;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background .1s; }
.data-table tbody tr:active { background: #f8fafc; }

/* ---- Badges ---- */
.badge {
  display: inline-block;
  padding: .1875rem .625rem;
  border-radius: 9999px;
  font-size: .6875rem;
  font-weight: 700;
  letter-spacing: .02em;
}
.badge-premium { background: #dbeafe; color: #1e40af; }
.badge-premium-plus { background: #ede9fe; color: #5b21b6; }
.badge-free { background: #f1f5f9; color: #475569; }
.badge-active { background: #dcfce7; color: #15803d; }
.badge-draft { background: #fef9c3; color: #a16207; }
.badge-archived { background: #f1f5f9; color: #64748b; }

/* ---- Action Buttons (in tables) ---- */
.action-btn {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .375rem .75rem;
  font-size: .75rem;
  font-weight: 600;
  border: 1px solid #e2e8f0;
  border-radius: .375rem;
  background: #fff;
  color: #334155;
  cursor: pointer;
  transition: all .15s;
  touch-action: manipulation;
  white-space: nowrap;
}
.action-btn:hover { background: #f8fafc; border-color: #cbd5e1; }
.action-btn:active { transform: scale(.96); }

/* ---- Toast ---- */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
  pointer-events: none;
}

.toast {
  padding: .75rem 1.25rem;
  border-radius: .625rem;
  font-size: .8125rem;
  font-weight: 600;
  color: #fff;
  background: #0f172a;
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
  pointer-events: auto;
  animation: toastIn .3s ease;
  max-width: 90vw;
}
.toast.success { background: #059669; }
.toast.error { background: #dc2626; }
.toast.fadeout {
  animation: toastOut .25s ease forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateY(10px); }
}

/* ---- Modal ---- */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.4);
  z-index: 500;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: modalBgIn .2s ease;
}
.modal-content {
  background: #fff;
  border-radius: 1.25rem 1.25rem 0 0;
  padding: 1.5rem;
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  max-height: 85dvh;
  overflow-y: auto;
  animation: modalSlideUp .3s cubic-bezier(.25,.46,.45,.94);
}

@keyframes modalBgIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalSlideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}
.modal-title { font-size: 1.125rem; font-weight: 700; }
.modal-close {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: #f1f5f9; border: none; border-radius: 50%;
  font-size: 1rem; color: #64748b; cursor: pointer;
  touch-action: manipulation;
}
.modal-close:hover { background: #e2e8f0; }

.modal-field { margin-bottom: 1rem; }
.modal-label { display: block; font-size: .8125rem; font-weight: 600; color: #334155; margin-bottom: .375rem; }
.modal-input {
  width: 100%;
  padding: .75rem 1rem;
  border: 1.5px solid #e2e8f0;
  border-radius: .625rem;
  font-size: .875rem;
  color: #0f172a;
  background: #fff;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.modal-input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.modal-select {
  width: 100%;
  padding: .75rem 1rem;
  border: 1.5px solid #e2e8f0;
  border-radius: .625rem;
  font-size: .875rem;
  color: #0f172a;
  background: #fff;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%2364748b' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
}

.modal-actions {
  display: flex;
  gap: .75rem;
  margin-top: 1.5rem;
}
.modal-actions .btn { flex: 1; }

/* ---- User Detail Card ---- */
.user-detail { display: flex; flex-direction: column; gap: 1rem; }
.user-detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .5rem 0;
  border-bottom: 1px solid #f1f5f9;
  font-size: .875rem;
}
.user-detail-label { color: #64748b; font-weight: 500; }
.user-detail-value { color: #0f172a; font-weight: 600; }

/* ---- Empty State ---- */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: #94a3b8;
}
.empty-state-icon { font-size: 2.5rem; margin-bottom: .75rem; }
.empty-state-text { font-size: .875rem; }

/* ---- Loading ---- */
.loading { text-align: center; padding: 2rem; color: #94a3b8; font-size: .875rem; }

/* ---- Secondary Text ---- */
.text-secondary { color: #64748b; }
.text-sm { font-size: .8125rem; }

/* ==================== DESKTOP (768px+) ==================== */
@media (min-width: 768px) {
  .top-bar { display: none; }

  .sidebar {
    position: fixed;
    transform: translateX(0);
  }

  .sidebar-overlay { display: none; }

  .main-content {
    margin-left: 260px;
    padding: 2rem;
  }

  .stat-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .modal-content {
    border-radius: 1.25rem;
    margin-bottom: 0;
    align-self: center;
  }
  .modal-overlay {
    align-items: center;
  }

  .view { max-width: 1000px; }
}

/* ---- Very small screens ---- */
@media (max-width: 360px) {
  .stat-grid { grid-template-columns: 1fr; }
  .login-card { padding: 2rem 1.5rem; }
  .main-content { padding: 1rem; }
}
