/* ═══════════════════════════════════════════
   FlatCMS Admin Panel
═══════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --accent:    #4f46e5;
  --dark:      #1a1a2e;
  --sidebar-w: 220px;
  --text:      #2d2d2d;
  --muted:     #666;
  --border:    #e8e8e8;
  --bg:        #f5f5f7;
}

body { font-family: Inter, -apple-system, sans-serif; color: var(--text); background: var(--bg); font-size: 14px; line-height: 1.5; }
a { text-decoration: none; color: inherit; }

/* ─── SIDEBAR ─────────────────────────────── */
.admin-sidebar {
  position: fixed; top: 0; left: 0;
  width: var(--sidebar-w); height: 100vh;
  background: var(--dark);
  display: flex; flex-direction: column;
  z-index: 100; overflow-y: auto;
}
.sidebar-logo { padding: 24px 20px; color: #fff; font-size: 17px; font-weight: 700; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar-nav { display: flex; flex-direction: column; padding: 12px 0; flex: 1; }
.sidebar-nav a { display: block; padding: 11px 20px; color: rgba(255,255,255,.6); font-size: 14px; font-weight: 500; transition: color .15s,background .15s; border-left: 3px solid transparent; }
.sidebar-nav a:hover { color: #fff; background: rgba(255,255,255,.06); }
.sidebar-nav a.active { color: #fff; background: rgba(79,70,229,.18); border-left-color: var(--accent); }
.nav-logout { margin-top: auto; color: rgba(255,255,255,.35) !important; border-top: 1px solid rgba(255,255,255,.08); padding-top: 16px !important; }
.nav-logout:hover { color: #ff6b6b !important; background: rgba(255,0,0,.05) !important; }

/* ─── MAIN ────────────────────────────────── */
.admin-main { margin-left: var(--sidebar-w); padding: 32px 36px; min-height: 100vh; }
.admin-topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; flex-wrap: wrap; gap: 10px; }
.admin-topbar h2 { font-size: 22px; font-weight: 700; }

/* ─── BUTTONS ─────────────────────────────── */
.btn-primary { display: inline-flex; align-items: center; gap: 6px; background: var(--accent); color: #fff; padding: 9px 20px; border-radius: 8px; font-size: 13px; font-weight: 600; border: none; cursor: pointer; transition: opacity .15s; font-family: inherit; }
.btn-primary:hover { opacity: .88; }
.btn-outline { display: inline-flex; align-items: center; gap: 6px; background: transparent; color: var(--text); padding: 9px 20px; border-radius: 8px; font-size: 13px; font-weight: 500; border: 1.5px solid var(--border); cursor: pointer; transition: border-color .15s; font-family: inherit; }
.btn-outline:hover { border-color: #aaa; }
.btn-sm { padding: 6px 14px !important; font-size: 12px !important; }
.btn-danger { display: inline-flex; align-items: center; background: transparent; color: #c00; padding: 6px 12px; border-radius: 6px; font-size: 12px; font-weight: 500; border: 1.5px solid #f5c0c0; cursor: pointer; margin-left: 6px; transition: background .15s; font-family: inherit; }
.btn-danger:hover { background: #fff0f0; }
.btn-save { display: inline-flex; align-items: center; background: var(--accent); color: #fff; padding: 11px 28px; border-radius: 8px; font-size: 14px; font-weight: 600; border: none; cursor: pointer; font-family: inherit; transition: opacity .15s; }
.btn-save:hover { opacity: .88; }

/* ─── STATS ───────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; margin-bottom: 36px; }
.stat-card { background: #fff; border-radius: 14px; padding: 24px 20px; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.stat-num { font-size: 36px; font-weight: 700; color: var(--accent); margin-bottom: 4px; }
.stat-green .stat-num { color: #1a7a1a; }
.stat-red   .stat-num { color: #c0003c; }
.stat-label { font-size: 13px; color: var(--muted); }
.quick-actions h3 { font-size: 16px; margin-bottom: 16px; }
.qa-grid { display: flex; gap: 12px; flex-wrap: wrap; }
.qa-card { display: flex; align-items: center; gap: 10px; background: #fff; border: 1.5px solid var(--border); border-radius: 12px; padding: 14px 20px; font-size: 13px; font-weight: 500; transition: border-color .15s, box-shadow .15s; }
.qa-card:hover { border-color: var(--accent); box-shadow: 0 2px 12px rgba(79,70,229,.1); }
.qa-icon { font-size: 18px; color: var(--accent); font-weight: 700; }

/* ─── TABLE / CARD ────────────────────────── */
.card { background: #fff; border-radius: 16px; box-shadow: 0 1px 4px rgba(0,0,0,.06); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 12px 24px; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--border); background: #fafafa; }
td { padding: 14px 24px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafafa; }
.td-img { width: 52px; height: 52px; object-fit: cover; border-radius: 8px; display: block; }
.td-img-placeholder { width: 52px; height: 52px; background: #f0f0f0; border-radius: 8px; }
.admin-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.badge-new  { background: var(--accent); color: #fff; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-read { background: #e0e0e0; color: #666; padding: 2px 8px; border-radius: 20px; font-size: 11px; }
.msg-unread td { background: #f8f8ff; }
.empty-state { text-align: center; padding: 48px; color: var(--muted); }
.empty-state a { color: var(--accent); }

/* ─── FORM ────────────────────────────────── */
.form-card { background: #fff; border-radius: 16px; padding: 32px; box-shadow: 0 1px 4px rgba(0,0,0,.06); max-width: 800px; }
.form-section-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); margin: 32px 0 18px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.form-section-title:first-child { margin-top: 0; }
.form-group { margin-bottom: 22px; }
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 7px; }
.form-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
input[type=text], input[type=date], input[type=email], input[type=number], textarea, select { width: 100%; padding: 10px 14px; border: 1.5px solid var(--border); border-radius: 9px; font-size: 14px; color: var(--text); font-family: inherit; transition: border-color .15s; outline: none; background: #fff; }
input[type=text]:focus, input[type=date]:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { min-height: 100px; resize: vertical; }
.form-row   { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-actions { display: flex; gap: 12px; margin-top: 32px; padding-top: 24px; border-top: 1px solid var(--border); }

/* ─── UPLOAD ──────────────────────────────── */
.upload-area { border: 2px dashed var(--border); border-radius: 12px; padding: 28px; text-align: center; cursor: pointer; transition: border-color .2s; }
.upload-area:hover { border-color: var(--accent); }
.upload-area input[type=file] { display: none; }
.upload-preview { max-width: 200px; max-height: 160px; border-radius: 8px; margin: 12px auto 0; object-fit: cover; display: block; }
.upload-hint { font-size: 13px; color: var(--muted); margin-top: 8px; }
.current-img { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* ─── ALERTS ──────────────────────────────── */
.alert { padding: 12px 16px; border-radius: 9px; font-size: 13px; margin-bottom: 20px; }
.alert-success { background: #e8f8e8; color: #1a6b1a; border: 1px solid #b8e8b8; }
.alert-error   { background: #fde8ec; color: #b00030; border: 1px solid #f5b8c8; }

/* ─── LOGIN ───────────────────────────────── */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: #f0f0f8; }
.login-box { background: #fff; border-radius: 20px; padding: 48px 40px; width: 100%; max-width: 380px; box-shadow: 0 8px 40px rgba(0,0,0,.1); }
.login-logo { color: var(--accent); font-size: 20px; font-weight: 700; margin-bottom: 6px; }
.login-box h1 { font-size: 22px; margin-bottom: 6px; }
.login-sub { color: var(--muted); font-size: 13px; margin-bottom: 28px; }
.login-form input { margin-bottom: 16px; }
.login-form button { width: 100%; padding: 12px; background: var(--accent); color: #fff; border: none; border-radius: 9px; font-size: 15px; font-weight: 600; cursor: pointer; font-family: inherit; }
.login-form button:hover { opacity: .88; }

/* ─── TABS ────────────────────────────────── */
.tabs { display: flex; gap: 4px; margin-bottom: 24px; flex-wrap: wrap; }
.tab-btn { padding: 8px 16px; border: 1.5px solid var(--border); border-radius: 8px; background: none; cursor: pointer; font-size: 13px; font-weight: 500; color: var(--muted); font-family: inherit; transition: all .15s; }
.tab-btn:hover { border-color: var(--accent); color: var(--accent); }
.tab-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ─── SIDEBAR TOGGLE ──────────────────────── */
.sidebar-toggle { display: none; position: fixed; top: 12px; left: 12px; z-index: 600; width: 42px; height: 42px; background: var(--dark); color: #fff; border: none; border-radius: 9px; align-items: center; justify-content: center; cursor: pointer; box-shadow: 0 2px 10px rgba(0,0,0,.2); }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 400; }
.sidebar-overlay.visible { display: block; }

/* ─── RESPONSIVE ──────────────────────────── */
@media (max-width: 900px) {
  .sidebar-toggle { display: flex; }
  .admin-sidebar { transform: translateX(-100%); transition: transform .25s ease; z-index: 500; box-shadow: 4px 0 24px rgba(0,0,0,.2); }
  .admin-sidebar.open { transform: translateX(0); }
  .admin-main { margin-left: 0; padding: 68px 16px 32px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .form-row, .form-row-2 { grid-template-columns: 1fr; gap: 0; }
  .form-card { max-width: 100%; padding: 20px 16px; }
  .qa-grid { flex-direction: column; }
  .qa-card { width: 100%; }
  th, td { white-space: nowrap; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .admin-main { padding: 64px 12px 24px; }
  .login-box { padding: 32px 20px; }
}
