/* ============================================================
   SEO Engine — Main Stylesheet
   Brand: #00A0E8
   ============================================================ */

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

:root {
  --brand:        #00A0E8;
  --brand-dark:   #0080BE;
  --brand-light:  #E5F5FD;
  --bg:           #F4F7FA;
  --surface:      #FFFFFF;
  --border:       #E2E8F0;
  --text:         #1A202C;
  --text-muted:   #718096;
  --sidebar-bg:   #0F172A;
  --sidebar-text: #CBD5E1;
  --sidebar-active-bg:   rgba(0,160,232,.15);
  --sidebar-active-text: #00A0E8;
  --success:      #22C55E;
  --info:         #3B82F6;
  --warning:      #F59E0B;
  --danger:       #EF4444;
  --neutral:      #94A3B8;
  --radius:       6px;
  --radius-lg:    10px;
  --shadow:       0 1px 3px rgba(0,0,0,.08);
  --shadow-lg:    0 4px 16px rgba(0,0,0,.12);
  --sidebar-w:    240px;
  --topbar-h:     56px;
}

html { font-size: 14px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

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

/* ─── Auth Layout ───────────────────────────────────────────── */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0F172A 0%, #1E293B 100%);
}

.auth-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 400px;
  padding: 2.5rem 2rem;
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin-bottom: 2rem;
}

.auth-logo svg { flex-shrink: 0; }

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

.auth-logo-sub {
  font-size: .7rem;
  font-weight: 400;
  color: var(--text-muted);
  display: block;
}

.auth-title { font-size: 1.4rem; font-weight: 700; margin-bottom: .3rem; }
.auth-sub   { color: var(--text-muted); margin-bottom: 1.8rem; font-size: .9rem; }

/* ─── Admin Shell ───────────────────────────────────────────── */
.shell { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform .25s;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: 1.1rem 1.2rem;
  border-bottom: 1px solid rgba(255,255,255,.06);
  text-decoration: none;
}

.sidebar-logo-text {
  font-size: .95rem;
  font-weight: 700;
  color: #FFF;
  line-height: 1.2;
}

.sidebar-logo-sub {
  font-size: .65rem;
  color: var(--sidebar-text);
  display: block;
  font-weight: 400;
}

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

.nav-section-label {
  font-size: .65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #475569;
  padding: .8rem 1.2rem .35rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .55rem 1.2rem;
  color: var(--sidebar-text);
  font-size: .85rem;
  text-decoration: none;
  border-radius: 0;
  transition: background .15s, color .15s;
  position: relative;
}

.nav-item:hover {
  background: rgba(255,255,255,.05);
  color: #FFF;
  text-decoration: none;
}

.nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--brand);
  border-radius: 0 2px 2px 0;
}

.nav-item svg { flex-shrink: 0; opacity: .7; }
.nav-item.active svg, .nav-item:hover svg { opacity: 1; }

.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,.06);
  padding: .8rem 1.2rem;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: .65rem;
}

.sidebar-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--brand);
  display: flex; align-items: center; justify-content: center;
  color: #FFF;
  font-size: .75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name {
  color: #E2E8F0;
  font-size: .8rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-role { color: #64748B; font-size: .7rem; }

/* Main content */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Topbar */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title { font-size: 1rem; font-weight: 600; }

.topbar-actions { display: flex; align-items: center; gap: .75rem; }

/* Page content */
.page-body {
  padding: 1.5rem;
  flex: 1;
}

/* ─── Page Header ───────────────────────────────────────────── */
.page-header {
  margin-bottom: 1.5rem;
}

.page-header h1 {
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.3;
}

.page-header p {
  color: var(--text-muted);
  font-size: .85rem;
  margin-top: .2rem;
}

.page-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

/* ─── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}

.card-title { font-size: .95rem; font-weight: 600; }

.card-body { padding: 1.25rem; }

/* ─── Stats Grid ─────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow);
}

.stat-label { font-size: .75rem; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: .05em; }
.stat-value { font-size: 1.8rem; font-weight: 700; line-height: 1.2; margin-top: .2rem; }
.stat-sub   { font-size: .75rem; color: var(--text-muted); margin-top: .15rem; }

/* ─── Tables ─────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
}

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

thead tr { background: #F8FAFC; }

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

td {
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

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

.table-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 2.5rem 1rem !important;
}

/* ─── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: .2rem .55rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

.badge--neutral  { background: #F1F5F9; color: #64748B; }
.badge--success  { background: #DCFCE7; color: #16A34A; }
.badge--info     { background: #DBEAFE; color: #1D4ED8; }
.badge--warning  { background: #FEF3C7; color: #D97706; }
.badge--danger   { background: #FEE2E2; color: #DC2626; }
.badge--brand    { background: var(--brand-light); color: var(--brand-dark); }

/* ─── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .45rem 1rem;
  border-radius: var(--radius);
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: background .15s, border-color .15s, color .15s;
  line-height: 1.4;
}

.btn:hover { text-decoration: none; }

.btn-primary {
  background: var(--brand);
  color: #FFF;
  border-color: var(--brand);
}
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #FFF; }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--bg); color: var(--text); }

.btn-danger {
  background: var(--danger);
  color: #FFF;
  border-color: var(--danger);
}
.btn-danger:hover { background: #DC2626; color: #FFF; }

.btn-sm {
  padding: .3rem .7rem;
  font-size: .8rem;
}

.btn-icon {
  padding: .4rem;
  border-radius: var(--radius);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  color: var(--text-muted);
  transition: background .15s, color .15s;
  display: inline-flex; align-items: center;
}
.btn-icon:hover { background: var(--bg); color: var(--text); }

/* ─── Forms ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.1rem; }

label {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  margin-bottom: .35rem;
  color: var(--text);
}

.form-control {
  display: block;
  width: 100%;
  padding: .55rem .8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .875rem;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
}

.form-control:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(0,160,232,.15);
}

.form-control::placeholder { color: #A0AEC0; }

select.form-control { cursor: pointer; }

textarea.form-control { resize: vertical; min-height: 90px; }

.form-hint { font-size: .78rem; color: var(--text-muted); margin-top: .3rem; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* ─── Alerts ─────────────────────────────────────────────────── */
.alert {
  padding: .8rem 1rem;
  border-radius: var(--radius);
  font-size: .875rem;
  margin-bottom: 1rem;
  border: 1px solid transparent;
}
.alert-danger  { background: #FEF2F2; border-color: #FECACA; color: #991B1B; }
.alert-success { background: #F0FDF4; border-color: #BBF7D0; color: #166534; }
.alert-info    { background: #EFF6FF; border-color: #BFDBFE; color: #1E40AF; }
.alert-warning { background: #FFFBEB; border-color: #FDE68A; color: #92400E; }

/* ─── Modal ──────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
  align-items: center;
  justify-content: center;
}

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

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.5rem;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.2rem;
}

.modal-title { font-size: 1.05rem; font-weight: 700; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: .6rem;
  margin-top: 1.4rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

/* ─── Pagination ─────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: .3rem;
  margin-top: 1.2rem;
  flex-wrap: wrap;
}

.page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 .5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .82rem;
  color: var(--text);
  background: var(--surface);
  text-decoration: none;
  transition: background .15s, color .15s;
}
.page-link:hover { background: var(--bg); text-decoration: none; }
.page-link.active { background: var(--brand); border-color: var(--brand); color: #FFF; }
.page-link.disabled { opacity: .4; pointer-events: none; }

/* ─── Progress Bar ───────────────────────────────────────────── */
.progress { background: #E2E8F0; border-radius: 999px; height: 6px; overflow: hidden; }
.progress-bar {
  height: 100%;
  background: var(--brand);
  border-radius: 999px;
  transition: width .3s;
}

/* ─── Misc utilities ─────────────────────────────────────────── */
.text-muted { color: var(--text-muted); }
.text-sm    { font-size: .8rem; }
.text-xs    { font-size: .73rem; }
.font-bold  { font-weight: 700; }
.flex       { display: flex; }
.items-center { align-items: center; }
.gap-2      { gap: .5rem; }
.gap-3      { gap: .75rem; }
.mt-1       { margin-top: .25rem; }
.mt-3       { margin-top: .75rem; }
.mb-4       { margin-bottom: 1rem; }
.w-full     { width: 100%; }
.truncate   { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ─── Search / filter bar ────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
  margin-bottom: 1.2rem;
}

.search-input {
  position: relative;
  flex: 1;
  min-width: 180px;
  max-width: 320px;
}

.search-input svg {
  position: absolute;
  left: .7rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-input input {
  padding-left: 2.1rem;
}

/* ─── Code / JSON viewer ─────────────────────────────────────── */
pre.json-view {
  background: #0F172A;
  color: #E2E8F0;
  border-radius: var(--radius);
  padding: 1rem;
  font-size: .78rem;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 400px;
  overflow-y: auto;
}

/* ─── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .form-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
