/* ─────────────────────────────────────────────────────────────────
   EDURE Admin — app.css
   Theme: navy #1B3A6B  accent #2563EB  bg #F1F5F9
   ───────────────────────────────────────────────────────────────── */

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

:root {
  --navy:    #1B3A6B;
  --navy2:   #152d54;
  --accent:  #2563EB;
  --accent2: #1d4ed8;
  --bg:      #F1F5F9;
  --surface: #ffffff;
  --border:  #e2e8f0;
  --text:    #1e293b;
  --text2:   #64748b;
  --danger:  #dc2626;
  --success: #16a34a;
  --warn:    #d97706;
  --radius:  8px;
  --shadow:  0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow2: 0 4px 16px rgba(0,0,0,.12);
  --sidebar-w: 220px;
  --navbar-h:  56px;
}

html, body { height: 100%; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 14px; color: var(--text); background: var(--bg); }

.hidden { display: none !important; }

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 0 16px; height: 38px; border-radius: var(--radius);
  border: none; cursor: pointer; font-size: 14px; font-weight: 500;
  text-decoration: none; white-space: nowrap; transition: background .15s, opacity .15s;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-full { width: 100%; justify-content: center; }
.btn-primary   { background: var(--accent);  color: #fff; }
.btn-primary:hover:not(:disabled)   { background: var(--accent2); }
.btn-secondary { background: var(--border);  color: var(--text); }
.btn-secondary:hover:not(:disabled) { background: #cbd5e1; }
.btn-ghost     { background: transparent;    color: #fff; }
.btn-ghost:hover:not(:disabled) { background: rgba(255,255,255,.15); }
.btn-danger    { background: var(--danger);  color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }
.btn-passkey   { background: var(--navy); color: #fff; }
.btn-passkey:hover:not(:disabled) { background: var(--navy2); }

/* ── Alerts ──────────────────────────────────────────────────────── */
.alert { padding: 10px 14px; border-radius: var(--radius); font-size: 13px; margin-bottom: 12px; }
.alert-erro    { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.alert-info    { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }

/* ── Badges ──────────────────────────────────────────────────────── */
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; }
.badge-admin   { background: #ede9fe; color: #5b21b6; }
.badge-user    { background: #e0f2fe; color: #0369a1; }
.badge-active  { background: #dcfce7; color: #166534; }
.badge-inactive{ background: #fee2e2; color: #991b1b; }
.badge-app     { background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }

/* ── Forms ───────────────────────────────────────────────────────── */
label { display: block; font-size: 13px; font-weight: 500; color: var(--text2); margin-bottom: 4px; }
input[type="text"], input[type="email"], input[type="password"], select, textarea {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 14px; background: var(--surface); color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.form-group { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ── Password toggle ─────────────────────────────────────────────── */
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 42px; }
.pw-toggle {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; color: var(--text2); padding: 4px;
}
.pw-toggle:hover { color: var(--text); }

/* ── Login Screen ────────────────────────────────────────────────── */
.screen-login {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--navy) 0%, #1e4080 60%, #2563EB 100%);
}
.login-card {
  background: var(--surface); border-radius: 16px; padding: 40px 36px;
  width: 100%; max-width: 380px; box-shadow: var(--shadow2);
}
.login-brand { text-align: center; margin-bottom: 28px; }
.login-logo {
  width: 64px; height: 64px; border-radius: 16px;
  background: var(--navy); color: #fff;
  font-size: 28px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 14px;
}
.login-brand h1 { font-size: 22px; font-weight: 700; color: var(--text); }
.login-brand p  { color: var(--text2); font-size: 13px; margin-top: 4px; }
.login-divider  { display: flex; align-items: center; gap: 10px; margin: 16px 0; color: var(--text2); font-size: 12px; }
.login-divider::before, .login-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.login-version  { text-align: center; margin-top: 20px; font-size: 12px; color: #94a3b8; }

/* ── Navbar ──────────────────────────────────────────────────────── */
.navbar {
  height: var(--navbar-h); background: var(--navy);
  display: flex; align-items: center; gap: 12px; padding: 0 16px;
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.nav-toggle { background: none; border: none; color: #fff; font-size: 20px; cursor: pointer; padding: 6px; }
.nav-brand  { color: #fff; font-weight: 700; font-size: 16px; text-decoration: none; }
.nav-user   { flex: 1; color: rgba(255,255,255,.7); font-size: 13px; text-align: right; }

/* ── App layout ──────────────────────────────────────────────────── */
#screen-app { height: 100vh; display: flex; flex-direction: column; }
.app-layout { display: flex; flex: 1; overflow: hidden; margin-top: var(--navbar-h); }

/* ── Sidebar ─────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w); background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow-y: auto; flex-shrink: 0;
  transition: width .2s, transform .2s;
}
.sidebar-nav { padding: 12px 8px; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.sidebar-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--radius);
  color: var(--text2); text-decoration: none; font-size: 13.5px; font-weight: 500;
  transition: background .15s, color .15s;
}
.sidebar-link:hover { background: var(--bg); color: var(--text); }
.sidebar-link.active { background: #dbeafe; color: var(--accent); }
.sidebar-link.active svg { stroke: var(--accent); }
.sidebar-divider { height: 1px; background: var(--border); margin: 8px 12px; }
.sidebar-version { padding: 10px 16px; font-size: 11px; color: #94a3b8; }

/* ── Main content ────────────────────────────────────────────────── */
.main-content { flex: 1; overflow-y: auto; padding: 24px; }

/* ── Page header ─────────────────────────────────────────────────── */
.page-title { font-size: 20px; font-weight: 700; margin-bottom: 20px; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.page-header .page-title { margin-bottom: 0; }

/* ── Cards ───────────────────────────────────────────────────────── */
.card { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card-title { font-size: 14px; font-weight: 600; color: var(--text2); margin-bottom: 14px; text-transform: uppercase; letter-spacing: .04em; }

/* ── Stats grid ──────────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); padding: 18px 20px; box-shadow: var(--shadow); }
.stat-label { font-size: 12px; color: var(--text2); font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--navy); margin-top: 4px; }

/* ── Tables ──────────────────────────────────────────────────────── */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; padding: 8px 12px; font-size: 12px; font-weight: 600; color: var(--text2); border-bottom: 2px solid var(--border); background: var(--bg); text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; }
.tbl-actions { display: flex; gap: 6px; }
.tbl-empty { text-align: center; color: var(--text2); padding: 32px; font-size: 13px; }

/* ── Filters row ─────────────────────────────────────────────────── */
.filters-row { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.filters-row select { width: auto; min-width: 160px; }

/* ── Account grid ────────────────────────────────────────────────── */
.account-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; max-width: 760px; }

/* ── Passkeys list ───────────────────────────────────────────────── */
.passkey-item { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.passkey-item:last-child { border-bottom: none; }
.passkey-name { font-weight: 500; }
.passkey-date { color: var(--text2); font-size: 12px; margin-top: 2px; }
.passkeys-empty { color: var(--text2); font-size: 13px; padding: 12px 0; }

/* ── Modal ───────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 16px;
}
.modal-card {
  background: var(--surface); border-radius: 12px;
  width: 100%; max-width: 560px; box-shadow: var(--shadow2);
  display: flex; flex-direction: column; max-height: 90vh;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px; border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 16px; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text2); line-height: 1; padding: 0 4px; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px; overflow-y: auto; }

/* ── Perms grid ──────────────────────────────────────────────────── */
.perms-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 6px; }
.perm-check { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; font-weight: normal; color: var(--text); }
.perm-check input { width: auto; }

/* ── Recent audit ────────────────────────────────────────────────── */
.audit-row { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 12.5px; align-items: baseline; }
.audit-row:last-child { border-bottom: none; }
.audit-action { font-weight: 600; color: var(--text); min-width: 130px; }
.audit-user   { color: var(--text2); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.audit-time   { color: #94a3b8; white-space: nowrap; }

/* ── Loading spinner ─────────────────────────────────────────────── */
.spinner {
  width: 32px; height: 32px; border: 3px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin .7s linear infinite; margin: 24px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast ───────────────────────────────────────────────────────── */
#toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 300;
  background: var(--text); color: #fff; padding: 12px 20px;
  border-radius: var(--radius); font-size: 13px; box-shadow: var(--shadow2);
  opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s;
  pointer-events: none;
}
#toast.show { opacity: 1; transform: translateY(0); }
#toast.toast-err  { background: var(--danger); }
#toast.toast-ok   { background: var(--success); }

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    position: fixed; top: var(--navbar-h); left: 0; bottom: 0;
    z-index: 90; transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }
  .main-content { padding: 16px; }
  .form-row { grid-template-columns: 1fr; }
  .account-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .perms-grid { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 10px; }
}

@media (max-width: 480px) {
  .login-card { padding: 28px 20px; }
  .stats-grid { grid-template-columns: 1fr; }
  .modal-card { max-height: 100vh; border-radius: 12px 12px 0 0; margin-top: auto; }
}

/* ── Sidebar overlay (mobile) ────────────────────────────────────── */
#sidebar-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.3);
  z-index: 89;
}
#sidebar-overlay.show { display: block; }
