/* ============================================================
   Screen CMS — Admin stylesheet
   ============================================================ */

:root {
  --bg:        #0f172a;
  --surface:   #1e293b;
  --surface2:  #263248;
  --border:    rgba(255,255,255,.08);
  --text:      #f1f5f9;
  --muted:     #94a3b8;
  --accent:    #6366f1;
  --accent-h:  #818cf8;
  --success:   #10b981;
  --warning:   #f59e0b;
  --danger:    #ef4444;
  --radius:    10px;
  --sidebar-w: 220px;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
}

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

html, body { height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

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

/* ---- Layout ---- */
.admin-shell {
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 20px 16px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}

.logo-circle {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 13px; letter-spacing: .5px;
  flex-shrink: 0;
}

.sidebar-logo span { font-weight: 700; font-size: 15px; }

.sidebar-nav { flex: 1; padding: 12px 8px; }

.nav-section { margin-bottom: 20px; }

.nav-section-title {
  font-size: 10px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 8px 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  transition: background .15s, color .15s;
  white-space: nowrap;
}

.nav-link:hover { background: var(--surface2); color: var(--text); text-decoration: none; }
.nav-link.active { background: rgba(99,102,241,.15); color: var(--accent-h); }
.nav-link .icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-foot {
  padding: 12px 8px;
  border-top: 1px solid var(--border);
}

.user-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px;
}
.user-chip .avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 11px;
}
.user-chip .info { min-width: 0; }
.user-chip .email { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip .role { font-size: 11px; color: var(--muted); }

/* ---- Main content ---- */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  height: 56px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 12px;
  flex-shrink: 0;
}

.topbar h1 { font-size: 18px; font-weight: 700; }
.topbar .spacer { flex: 1; }

.page-body { padding: 24px; flex: 1; }

/* ---- Cards ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.card + .card { margin-top: 16px; }

.card-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: opacity .15s, background .15s;
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { opacity: .85; text-decoration: none; }
.btn:active { opacity: .7; }

.btn-primary  { background: var(--accent); color: #fff; }
.btn-success  { background: var(--success); color: #fff; }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-ghost    { background: transparent; border-color: var(--border); color: var(--text); }
.btn-sm       { padding: 5px 12px; font-size: 12px; }
.btn-full     { width: 100%; justify-content: center; }
.btn-icon     { padding: 7px 10px; }

/* ---- Forms ---- */
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 5px;
  font-weight: 500;
}

input[type=text], input[type=email], input[type=password],
input[type=number], input[type=color], input[type=datetime-local],
select, textarea {
  width: 100%;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,.2);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}
textarea { min-height: 80px; resize: vertical; }
select option { background: var(--surface); }

input[type=color] { padding: 4px 6px; height: 38px; cursor: pointer; }

.field-row   { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* ---- Alerts ---- */
.alert {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 14px;
  display: flex; align-items: center; gap: 8px;
}
.alert-error   { background: rgba(239,68,68,.15);  border: 1px solid rgba(239,68,68,.3);  color: #fca5a5; }
.alert-success { background: rgba(16,185,129,.12); border: 1px solid rgba(16,185,129,.3); color: #6ee7b7; }
.alert-warning { background: rgba(245,158,11,.12); border: 1px solid rgba(245,158,11,.3); color: #fcd34d; }
.alert-info    { background: rgba(99,102,241,.12); border: 1px solid rgba(99,102,241,.3); color: #a5b4fc; }

/* ---- Badges ---- */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.badge-admin   { background: rgba(99,102,241,.2);  color: #a5b4fc; }
.badge-editor  { background: rgba(16,185,129,.15); color: #6ee7b7; }
.badge-warning { background: rgba(245,158,11,.15); color: #fcd34d; }
.badge-danger  { background: rgba(239,68,68,.15);  color: #fca5a5; }
.badge-info    { background: rgba(99,102,241,.1);  color: #c7d2fe; }
.badge-success { background: rgba(16,185,129,.1);  color: #a7f3d0; }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
}
th {
  text-align: left;
  font-size: 11px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
tr:last-child td { border-bottom: 0; }
tr:hover td { background: rgba(255,255,255,.03); }

/* ---- Login page ---- */
.login-page { background: var(--bg); display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-wrap { width: 100%; max-width: 400px; padding: 16px; }
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .logo-circle { width: 56px; height: 56px; font-size: 20px; border-radius: 16px; margin: 0 auto 12px; }
.login-logo h1 { font-size: 22px; font-weight: 800; }
.login-logo p { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* ---- Tabs (screen editor) ---- */
.tabs-bar {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.tab-btn {
  padding: 8px 14px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .15s;
}
.tab-btn.active { color: var(--accent-h); border-bottom-color: var(--accent); }
.tab-btn:hover  { color: var(--text); }

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

/* ---- Screen editor 2-col ---- */
.editor-shell {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 20px;
  min-height: calc(100vh - 100px);
}
.editor-form  { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.editor-preview {
  position: sticky;
  top: 16px;
  height: calc(100vh - 100px);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.preview-bar {
  display: flex; align-items: center; gap: 8px;
  flex-shrink: 0;
}
.preview-iframe {
  flex: 1;
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #000;
}

/* ---- Repeating items ---- */
.item-list { display: flex; flex-direction: column; gap: 10px; }
.item-row {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}
.item-row-header {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 10px;
}
.item-row-header .item-title { font-weight: 600; font-size: 13px; flex: 1; }
.move-btn {
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
}
.move-btn:hover { background: var(--surface); color: var(--text); }

/* ---- Dashboard stats ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.stat-label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.stat-value { font-size: 26px; font-weight: 800; }
.stat-note  { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---- Emergency badge (dashboard) ---- */
.em-info     { color: #93c5fd; }
.em-warning  { color: #fcd34d; }
.em-critical { color: #fca5a5; }
.em-evac     { color: #ff4444; font-weight: 800; }

/* ---- Screen cards (list) ---- */
.screen-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.screen-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.screen-card-name { font-weight: 700; font-size: 16px; }
.screen-card-slug { font-size: 12px; color: var(--muted); font-family: monospace; }
.screen-card-foot { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---- Upload gallery ---- */
.upload-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 16px;
}
.upload-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.upload-item img {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  display: block;
}
.upload-item-info {
  padding: 8px;
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
}
.upload-item-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upload-item-foot { padding: 6px 8px; display: flex; gap: 6px; }

/* ---- Pagination ---- */
.pagination { display: flex; gap: 6px; margin-top: 16px; align-items: center; }
.page-btn {
  padding: 5px 11px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  text-decoration: none;
  display: inline-block;
}
.page-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.page-btn:hover  { background: var(--surface2); color: var(--text); text-decoration: none; }

/* ---- Utilities ---- */
.text-muted  { color: var(--muted); }
.text-danger { color: var(--danger); }
.text-sm     { font-size: 12px; }
.mt-4        { margin-top: 4px; }
.mt-8        { margin-top: 8px; }
.mt-12       { margin-top: 12px; }
.mt-16       { margin-top: 16px; }
.mb-8        { margin-bottom: 8px; }
.mb-16       { margin-bottom: 16px; }
.flex        { display: flex; }
.flex-wrap   { flex-wrap: wrap; }
.gap-8       { gap: 8px; }
.gap-12      { gap: 12px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

.divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}

.mono { font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace; }
.truncate { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* ---- Lucide icons ---- */
[data-lucide] {
  width: 15px;
  height: 15px;
  stroke-width: 1.8;
  vertical-align: -2px;
  display: inline-block;
  flex-shrink: 0;
}
.nav-link [data-lucide] { width: 16px; height: 16px; }
.btn [data-lucide]      { width: 14px; height: 14px; vertical-align: -1px; }
.card-title [data-lucide] { width: 16px; height: 16px; }
.stat-label [data-lucide] { width: 13px; height: 13px; }
.badge [data-lucide]    { width: 11px; height: 11px; vertical-align: -1px; }
