/* =========================================================
   Frank Admin Portal — complete stylesheet
   ========================================================= */

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

:root {
  --bg:           #080a12;
  --surface:      #111520;
  --panel:        #171b28;
  --panel-hover:  #1d2235;
  --border:       rgba(255,255,255,.07);
  --border-focus: rgba(99,102,241,.5);
  --text:         #e2e4f0;
  --muted:        #6b7280;
  --accent:       #6366f1;
  --accent-hover: #4f46e5;
  --success:      #10b981;
  --warning:      #f59e0b;
  --danger:       #ef4444;
  --danger-hover: #dc2626;
  --radius:       10px;
  --radius-sm:    6px;
  --font:         'Inter', system-ui, -apple-system, sans-serif;
  --shadow:       0 4px 24px rgba(0,0,0,.4);
  --shadow-lg:    0 8px 48px rgba(0,0,0,.6);
}

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

html { font-size: 16px; }

body {
  font-family: var(--font);
  background:  var(--bg);
  color:        var(--text);
  min-height:   100vh;
  line-height:  1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

/* =========================================================
   Layout helpers
   ========================================================= */

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.w-full { width: 100%; }
.text-center { text-align: center; }
.text-sm { font-size: .875rem; }
.text-xs { font-size: .75rem; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }

/* =========================================================
   Auth card (login / enroll)
   ========================================================= */

.auth-page {
  display:         flex;
  flex-direction:  column;
  align-items:     center;
  justify-content: center;
  min-height:      100vh;
  padding:         24px;
  background:      radial-gradient(ellipse at 50% 0%, rgba(99,102,241,.12) 0%, transparent 70%);
}

.auth-card {
  background:   var(--surface);
  border:       1px solid var(--border);
  border-radius: calc(var(--radius) * 1.5);
  box-shadow:   var(--shadow-lg);
  padding:      48px 40px;
  width:        100%;
  max-width:    420px;
}

.auth-logo {
  display:         flex;
  align-items:     center;
  justify-content: center;
  margin-bottom:   32px;
}

.auth-logo .logo-mark {
  width:           44px;
  height:          44px;
  background:      linear-gradient(135deg, var(--accent) 0%, #818cf8 100%);
  border-radius:   12px;
  display:         flex;
  align-items:     center;
  justify-content: center;
  font-size:       20px;
  font-weight:     700;
  color:           #fff;
  margin-right:    12px;
  flex-shrink:     0;
}

.auth-logo .logo-text {
  font-size:   1.25rem;
  font-weight: 600;
  color:       var(--text);
  line-height: 1.2;
}

.auth-logo .logo-sub {
  font-size:  .75rem;
  color:      var(--muted);
  font-weight: 400;
}

.auth-title {
  font-size:     1.5rem;
  font-weight:   700;
  text-align:    center;
  margin-bottom: 8px;
  background:    linear-gradient(135deg, #e2e4f0 0%, #a5b4fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.auth-subtitle {
  text-align:    center;
  color:         var(--muted);
  font-size:     .9rem;
  margin-bottom: 36px;
}

/* =========================================================
   Buttons
   ========================================================= */

.btn {
  display:         inline-flex;
  align-items:     center;
  justify-content: center;
  gap:             8px;
  padding:         10px 20px;
  border-radius:   var(--radius-sm);
  border:          1px solid transparent;
  font-family:     var(--font);
  font-size:       .875rem;
  font-weight:     500;
  cursor:          pointer;
  transition:      background .15s, border-color .15s, opacity .15s, box-shadow .15s;
  text-decoration: none;
  white-space:     nowrap;
  user-select:     none;
}

.btn:disabled {
  opacity: .5;
  cursor:  not-allowed;
}

.btn-primary {
  background: var(--accent);
  color:      #fff;
  border-color: var(--accent);
}
.btn-primary:hover:not(:disabled) {
  background:   var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow:   0 0 0 3px rgba(99,102,241,.3);
}

.btn-secondary {
  background:   transparent;
  color:        var(--text);
  border-color: var(--border);
}
.btn-secondary:hover:not(:disabled) {
  background:   var(--panel-hover);
  border-color: rgba(255,255,255,.15);
}

.btn-danger {
  background:   transparent;
  color:        var(--danger);
  border-color: rgba(239,68,68,.3);
}
.btn-danger:hover:not(:disabled) {
  background:   rgba(239,68,68,.1);
  border-color: var(--danger);
}

.btn-danger-solid {
  background:   var(--danger);
  color:        #fff;
  border-color: var(--danger);
}
.btn-danger-solid:hover:not(:disabled) {
  background:   var(--danger-hover);
  border-color: var(--danger-hover);
}

.btn-lg {
  padding:     14px 28px;
  font-size:   1rem;
  border-radius: var(--radius);
}

.btn-sm {
  padding:   6px 12px;
  font-size: .8rem;
}

.btn-passkey {
  width:      100%;
  padding:    16px;
  background: linear-gradient(135deg, var(--accent) 0%, #818cf8 100%);
  color:      #fff;
  border:     none;
  border-radius: var(--radius);
  font-size:  1rem;
  font-weight: 600;
  cursor:     pointer;
  transition: opacity .2s, box-shadow .2s;
  box-shadow: 0 4px 16px rgba(99,102,241,.4);
}
.btn-passkey:hover:not(:disabled) {
  opacity:    .92;
  box-shadow: 0 6px 24px rgba(99,102,241,.55);
}
.btn-passkey:disabled {
  opacity: .5;
  cursor:  not-allowed;
}

.btn-passkey svg, .btn svg { flex-shrink: 0; }

/* =========================================================
   Forms
   ========================================================= */

.form-group {
  margin-bottom: 20px;
}

label {
  display:       block;
  font-size:     .875rem;
  font-weight:   500;
  color:         var(--text);
  margin-bottom: 6px;
}

input[type="text"],
input[type="password"],
input[type="email"],
select,
textarea {
  width:         100%;
  padding:       10px 14px;
  background:    var(--bg);
  border:        1px solid var(--border);
  border-radius: var(--radius-sm);
  color:         var(--text);
  font-family:   var(--font);
  font-size:     .875rem;
  transition:    border-color .15s, box-shadow .15s;
  outline:       none;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow:   0 0 0 3px rgba(99,102,241,.2);
}

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

select {
  appearance:      none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236b7280' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat:   no-repeat;
  background-position: right 14px center;
  padding-right:       38px;
  cursor:              pointer;
}

select option { background: var(--surface); }

.form-hint {
  font-size:  .8rem;
  color:      var(--muted);
  margin-top: 4px;
}

.checkbox-row {
  display:     flex;
  align-items: center;
  gap:         8px;
  font-size:   .875rem;
}

.checkbox-row input[type="checkbox"] {
  width:         16px;
  height:        16px;
  accent-color:  var(--accent);
  cursor:        pointer;
}

/* =========================================================
   Dashboard layout
   ========================================================= */

.dashboard {
  display:    flex;
  min-height: 100vh;
  flex-direction: column;
}

.topbar {
  background:    var(--surface);
  border-bottom: 1px solid var(--border);
  padding:       0 32px;
  height:        60px;
  display:       flex;
  align-items:   center;
  justify-content: space-between;
  position:      sticky;
  top:           0;
  z-index:       100;
}

.topbar-brand {
  display:     flex;
  align-items: center;
  gap:         12px;
  font-weight: 600;
  font-size:   1rem;
  color:       var(--text);
}

.topbar-brand .mark {
  width:           34px;
  height:          34px;
  background:      linear-gradient(135deg, var(--accent) 0%, #818cf8 100%);
  border-radius:   8px;
  display:         flex;
  align-items:     center;
  justify-content: center;
  font-size:       15px;
  font-weight:     700;
  color:           #fff;
}

.topbar-actions {
  display:     flex;
  align-items: center;
  gap:         12px;
}

.topbar-time {
  font-size: .8rem;
  color:     var(--muted);
}

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

/* =========================================================
   Tabs
   ========================================================= */

.tabs {
  display:       flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 32px;
  gap:           4px;
}

.tab-btn {
  padding:      10px 20px;
  background:   transparent;
  border:       none;
  border-bottom: 2px solid transparent;
  color:        var(--muted);
  font-family:  var(--font);
  font-size:    .9rem;
  font-weight:  500;
  cursor:       pointer;
  transition:   color .15s, border-color .15s;
  margin-bottom: -1px;
}

.tab-btn:hover { color: var(--text); }

.tab-btn.active {
  color:         var(--accent);
  border-bottom-color: var(--accent);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* =========================================================
   Site cards grid
   ========================================================= */

.sites-grid {
  display:               grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap:                   20px;
}

.site-card {
  background:    var(--panel);
  border:        1px solid var(--border);
  border-radius: var(--radius);
  padding:       24px;
  display:       flex;
  flex-direction: column;
  gap:            12px;
  transition:    border-color .15s, box-shadow .15s;
}

.site-card:hover {
  border-color: rgba(99,102,241,.3);
  box-shadow:   0 4px 20px rgba(0,0,0,.3);
}

.site-card-icon {
  width:           40px;
  height:          40px;
  border-radius:   10px;
  background:      rgba(99,102,241,.15);
  display:         flex;
  align-items:     center;
  justify-content: center;
  font-size:       18px;
}

.site-card-name {
  font-weight: 600;
  font-size:   1rem;
}

.site-card-url {
  font-size: .8rem;
  color:     var(--muted);
  word-break: break-all;
}

/* =========================================================
   Section headers
   ========================================================= */

.section-header {
  display:       flex;
  align-items:   center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.section-title {
  font-size:   1.2rem;
  font-weight: 600;
}

/* =========================================================
   Tables
   ========================================================= */

.table-wrap {
  background:    var(--panel);
  border:        1px solid var(--border);
  border-radius: var(--radius);
  overflow:      hidden;
  overflow-x:    auto;
}

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

thead {
  background: var(--surface);
}

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

td {
  padding:     12px 16px;
  border-bottom: 1px solid var(--border);
  color:       var(--text);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }

tbody tr { transition: background .1s; }
tbody tr:hover { background: rgba(255,255,255,.025); }

.td-actions {
  display:     flex;
  align-items: center;
  gap:         8px;
  flex-wrap:   wrap;
}

/* =========================================================
   Modal
   ========================================================= */

.modal-overlay {
  display:          none;
  position:         fixed;
  inset:            0;
  background:       rgba(0,0,0,.65);
  backdrop-filter:  blur(4px);
  z-index:          500;
  align-items:      center;
  justify-content:  center;
  padding:          24px;
}

.modal-overlay.open {
  display: flex;
}

.modal-dialog {
  background:    var(--surface);
  border:        1px solid var(--border);
  border-radius: calc(var(--radius) * 1.5);
  box-shadow:    var(--shadow-lg);
  padding:       32px;
  width:         100%;
  max-width:     440px;
  animation:     modalIn .18s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(.95) translateY(8px); }
  to   { opacity: 1; transform: scale(1)  translateY(0); }
}

.modal-title {
  font-size:     1.1rem;
  font-weight:   600;
  margin-bottom: 20px;
}

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

/* =========================================================
   Alerts / Toasts
   ========================================================= */

.alert {
  padding:       12px 16px;
  border-radius: var(--radius-sm);
  font-size:     .875rem;
  margin-bottom: 16px;
  border:        1px solid transparent;
  display:       flex;
  align-items:   flex-start;
  gap:           10px;
}

.alert-success { background: rgba(16,185,129,.1); border-color: rgba(16,185,129,.3); color: #34d399; }
.alert-error   { background: rgba(239,68,68,.1);  border-color: rgba(239,68,68,.3);  color: #f87171; }
.alert-warning { background: rgba(245,158,11,.1); border-color: rgba(245,158,11,.3); color: #fbbf24; }
.alert-info    { background: rgba(99,102,241,.1); border-color: rgba(99,102,241,.3); color: #a5b4fc; }

.toast-container {
  position:  fixed;
  bottom:    24px;
  right:     24px;
  z-index:   1000;
  display:   flex;
  flex-direction: column;
  gap:       10px;
  max-width: 360px;
}

.toast {
  background:    var(--surface);
  border:        1px solid var(--border);
  border-radius: var(--radius);
  padding:       14px 16px;
  box-shadow:    var(--shadow);
  font-size:     .875rem;
  display:       flex;
  align-items:   flex-start;
  gap:           10px;
  animation:     toastIn .2s ease;
  border-left-width: 3px;
}

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

.toast.toast-success { border-left-color: var(--success); }
.toast.toast-error   { border-left-color: var(--danger);  }
.toast.toast-warning { border-left-color: var(--warning); }

.toast-icon { font-size: 1rem; flex-shrink: 0; margin-top: 1px; }
.toast-msg  { flex: 1; line-height: 1.4; }
.toast-close {
  background: none;
  border:     none;
  color:      var(--muted);
  cursor:     pointer;
  font-size:  1rem;
  line-height: 1;
  padding:    0;
  margin-left: auto;
}
.toast-close:hover { color: var(--text); }

/* =========================================================
   Loading spinner
   ========================================================= */

.spinner {
  display:        inline-block;
  width:          18px;
  height:         18px;
  border:         2px solid rgba(255,255,255,.2);
  border-top-color: currentColor;
  border-radius:  50%;
  animation:      spin .6s linear infinite;
  flex-shrink:    0;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  display:         flex;
  align-items:     center;
  justify-content: center;
  padding:         48px;
  color:           var(--muted);
  gap:             12px;
  font-size:       .875rem;
}

/* =========================================================
   Admin page specifics
   ========================================================= */

.admin-header {
  margin-bottom: 32px;
  padding-bottom: 20px;
  border-bottom:  1px solid var(--border);
}

.admin-header h1 {
  font-size:  1.75rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.admin-header p { color: var(--muted); font-size: .9rem; }

.admin-section {
  background:    var(--surface);
  border:        1px solid var(--border);
  border-radius: var(--radius);
  padding:       28px;
  margin-bottom: 24px;
}

.admin-section h2 {
  font-size:     1.05rem;
  font-weight:   600;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom:  1px solid var(--border);
}

.invite-url-box {
  background:    var(--bg);
  border:        1px solid var(--border);
  border-radius: var(--radius-sm);
  padding:       12px 16px;
  font-family:   monospace;
  font-size:     .85rem;
  word-break:    break-all;
  color:         var(--accent);
  margin-top:    12px;
}

/* =========================================================
   Enroll page
   ========================================================= */

.enroll-step {
  display:       flex;
  align-items:   flex-start;
  gap:           16px;
  margin-bottom: 20px;
}

.step-num {
  width:           28px;
  height:          28px;
  border-radius:   50%;
  background:      rgba(99,102,241,.2);
  border:          1px solid rgba(99,102,241,.4);
  color:           var(--accent);
  font-size:       .8rem;
  font-weight:     600;
  display:         flex;
  align-items:     center;
  justify-content: center;
  flex-shrink:     0;
  margin-top:      2px;
}

.step-text { font-size: .875rem; color: var(--muted); }
.step-text strong { color: var(--text); }

/* =========================================================
   Badges / tags
   ========================================================= */

.badge {
  display:       inline-flex;
  align-items:   center;
  padding:       2px 8px;
  border-radius: 999px;
  font-size:     .75rem;
  font-weight:   500;
}

.badge-blue    { background: rgba(99,102,241,.15); color: #a5b4fc; }
.badge-green   { background: rgba(16,185,129,.15); color: #34d399; }
.badge-yellow  { background: rgba(245,158,11,.15); color: #fbbf24; }
.badge-red     { background: rgba(239,68,68,.15);  color: #f87171; }
.badge-muted   { background: rgba(107,114,128,.15); color: #9ca3af; }

/* =========================================================
   Empty states
   ========================================================= */

.empty-state {
  text-align: center;
  padding:    48px 24px;
  color:      var(--muted);
}

.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: 12px; }
.empty-state p { font-size: .9rem; }

/* =========================================================
   Responsive
   ========================================================= */

@media (max-width: 768px) {
  .topbar { padding: 0 16px; }
  .dashboard-body { padding: 20px 16px; }
  .auth-card { padding: 32px 24px; }
  .sites-grid { grid-template-columns: 1fr; }
  .modal-dialog { padding: 24px 20px; }
  .tabs { overflow-x: auto; }
}
