/* =====================================================================
   admin.css — Nikka Roldan Portfolio Admin Panel
   Color scheme: purple/violet matching the public site
   ===================================================================== */

:root {
  --primary:     #6a6af0;
  --primary-dark:#5757db;
  --primary-soft:#8d8df5;
  --sidebar-bg:  #1a1530;
  --sidebar-w:   240px;
  --page-bg:     #f5f4fc;
  --card-bg:     #ffffff;
  --text:        #1f1f2e;
  --text-muted:  #6d6d80;
  --border:      #ececf4;
  --shadow:      0 4px 20px rgba(0,0,0,0.07);
  --radius:      14px;
  --success:     #16a34a;
  --danger:      #dc2626;
  --warn:        #d97706;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: 'DM Sans', sans-serif;
  background: var(--page-bg);
  display: flex; min-height: 100vh;
  color: var(--text);
}

/* ── SIDEBAR ─────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w); background: var(--sidebar-bg);
  min-height: 100vh; display: flex; flex-direction: column;
  position: fixed; left: 0; top: 0; bottom: 0; z-index: 50;
  overflow-y: auto;
}
.sidebar-logo {
  padding: 22px 18px 16px; border-bottom: 1px solid rgba(255,255,255,0.06);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-logo img { width: 36px; height: 36px; object-fit: contain; filter: brightness(0) invert(1); }
.sidebar-logo-text { font-family: 'Volkhov', serif; font-size: .85rem; color: rgba(255,255,255,0.9); line-height: 1.3; }
.sidebar-logo-text small { display: block; font-family: 'DM Sans', sans-serif; font-size: .6rem; color: rgba(255,255,255,0.3); font-weight: 300; letter-spacing: .06em; }

.user-badge { padding: 14px 18px; border-bottom: 1px solid rgba(255,255,255,0.05); }
.user-badge .role { font-size: .6rem; text-transform: uppercase; letter-spacing: .1em; color: rgba(255,255,255,0.3); }
.user-badge .name { font-size: .82rem; color: rgba(255,255,255,0.75); margin-top: 2px; font-weight: 500; }

.sidebar nav { flex: 1; padding: 12px 0; }
.nav-section {
  font-size: .58rem; letter-spacing: .12em; text-transform: uppercase;
  color: rgba(255,255,255,0.2); padding: 14px 18px 5px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 18px;
  font-size: .82rem; color: rgba(255,255,255,0.45);
  text-decoration: none; border-left: 3px solid transparent;
  transition: all .2s; position: relative;
}
.nav-item:hover { color: rgba(255,255,255,.85); background: rgba(255,255,255,.04); }
.nav-item.active { color: #a8a8ff; border-left-color: var(--primary-soft); background: rgba(106,106,240,.1); }
.nav-item i { width: 16px; text-align: center; flex-shrink: 0; }
.nav-badge {
  margin-left: auto; background: #ef4444; color: white;
  font-size: .6rem; font-weight: 700; padding: 2px 7px;
  border-radius: 999px; line-height: 1.4;
}
.btn-logout {
  margin: 14px; padding: 9px; background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08); border-radius: 8px;
  color: rgba(255,255,255,.4); font-family: 'DM Sans', sans-serif;
  font-size: .76rem; cursor: pointer; transition: all .2s;
  text-align: center; text-decoration: none; display: block;
}
.btn-logout:hover { background: rgba(239,68,68,.1); color: #fca5a5; border-color: rgba(239,68,68,.2); }

/* ── MAIN ─────────────────────────────────────────────────────────────── */
.main { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; }
.topbar {
  background: white; padding: 14px 28px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
  box-shadow: 0 1px 8px rgba(0,0,0,0.05);
}
.topbar h2 { font-family: 'Volkhov', serif; font-size: 1.15rem; color: var(--text); }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.date-badge {
  font-size: .74rem; color: var(--text-muted); background: var(--page-bg);
  padding: 4px 12px; border-radius: 20px; border: 1px solid var(--border);
}
.page-body { padding: 24px 28px; flex: 1; }

/* ── BUTTONS ──────────────────────────────────────────────────────────── */
.btn-primary {
  padding: 8px 18px; background: var(--primary); color: white;
  border: none; border-radius: 8px; font-family: 'DM Sans', sans-serif;
  font-size: .82rem; font-weight: 600; cursor: pointer;
  text-decoration: none; display: inline-flex; align-items: center; gap: 7px;
  transition: background .2s;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary {
  padding: 7px 16px; background: white; color: var(--text);
  border: 1.5px solid var(--border); border-radius: 8px;
  font-family: 'DM Sans', sans-serif; font-size: .82rem; font-weight: 500;
  cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 7px;
  transition: border-color .2s, background .2s;
}
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }
.btn-ghost {
  padding: 7px 16px; color: var(--text-muted); border-radius: 8px;
  font-size: .82rem; text-decoration: none; display: inline-block; transition: color .2s;
}
.btn-ghost:hover { color: var(--primary); }
.btn-sm {
  padding: 5px 12px; font-size: .75rem; background: var(--page-bg);
  border: 1px solid var(--border); border-radius: 6px; color: var(--text);
  text-decoration: none; display: inline-block; transition: all .2s;
}
.btn-sm:hover { background: var(--primary); color: white; border-color: var(--primary); }

/* ── CARDS ────────────────────────────────────────────────────────────── */
.card {
  background: var(--card-bg); border-radius: var(--radius);
  padding: 24px; box-shadow: var(--shadow); margin-bottom: 20px;
}

/* ── KPI GRID ──────────────────────────────────────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-bottom: 24px; }
.kpi-card {
  background: white; border-radius: var(--radius); padding: 22px 24px;
  box-shadow: var(--shadow); display: flex; align-items: center; gap: 18px;
  border-left: 4px solid transparent;
}
.kpi-card--primary { border-left-color: var(--primary); }
.kpi-card--green   { border-left-color: #22c55e; }
.kpi-card--purple  { border-left-color: #a855f7; }

.kpi-icon {
  width: 52px; height: 52px; border-radius: 14px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
}
.kpi-card--primary .kpi-icon { background: rgba(106,106,240,.12); color: var(--primary); }
.kpi-card--green   .kpi-icon { background: rgba(34,197,94,.12);   color: #16a34a; }
.kpi-card--purple  .kpi-icon { background: rgba(168,85,247,.12);  color: #9333ea; }

.kpi-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: var(--text-muted); margin-bottom: 4px; }
.kpi-val   { font-size: 2rem; font-weight: 700; color: var(--text); line-height: 1; margin-bottom: 4px; }
.kpi-sub   { font-size: .75rem; color: var(--text-muted); }
.kpi-sub strong { color: var(--text); }

/* ── CHARTS ───────────────────────────────────────────────────────────── */
.charts-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 24px; }
.chart-card { background: white; border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.chart-card-header h3 { font-size: .9rem; font-weight: 600; color: var(--text); margin-bottom: 16px; }

/* ── TABLE ────────────────────────────────────────────────────────────── */
.table-card { background: white; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; margin-bottom: 20px; }
.table-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.table-header h3 { font-size: .95rem; font-weight: 600; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .82rem; }
th {
  text-align: left; padding: 10px 16px; font-size: .68rem;
  text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted);
  background: var(--page-bg); border-bottom: 1px solid var(--border);
}
td { padding: 11px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(106,106,240,.03); }
tr.row-unread td { background: rgba(106,106,240,.04); }
tr.row-unread td:first-child { border-left: 3px solid var(--primary); }

/* ── STATUS PILLS ─────────────────────────────────────────────────────── */
.status-pill {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: .7rem; font-weight: 600; text-transform: capitalize;
}
.status-unread  { background: #fef3c7; color: #92400e; }
.status-read    { background: #dbeafe; color: #1e40af; }
.status-replied { background: #d1fae5; color: #065f46; }

/* ── ALERTS ──────────────────────────────────────────────────────────── */
.alert { padding: 12px 18px; border-radius: 10px; margin-bottom: 18px; font-size: .88rem; display: flex; align-items: center; gap: 10px; }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.alert-danger  { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

/* ── MESSAGE VIEW ─────────────────────────────────────────────────────── */
.msg-thread-grid { display: grid; grid-template-columns: 3fr 2fr; gap: 24px; }
.msg-detail { margin-bottom: 0; }
.msg-detail-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.msg-name  { font-size: 1.1rem; font-weight: 700; color: var(--text); }
.msg-email { font-size: .84rem; color: var(--text-muted); margin-top: 3px; }
.msg-meta  { font-size: .8rem; color: var(--text-muted); margin-bottom: 18px; }
.msg-body  {
  background: var(--page-bg); border-radius: 12px; padding: 18px;
  line-height: 1.8; color: var(--text); white-space: pre-wrap;
  margin-bottom: 24px;
}
.reply-thread { border-top: 1px solid var(--border); padding-top: 20px; }
.thread-title { font-size: .88rem; font-weight: 600; color: var(--text-muted); margin-bottom: 14px; }
.no-replies   { font-size: .84rem; color: var(--text-muted); font-style: italic; }
.reply-bubble { background: linear-gradient(135deg, var(--primary), var(--primary-soft)); border-radius: 14px; padding: 14px 18px; margin-bottom: 14px; }
.reply-bubble-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.reply-admin { font-size: .78rem; font-weight: 600; color: rgba(255,255,255,.9); }
.reply-time  { font-size: .72rem; color: rgba(255,255,255,.6); }
.reply-text  { font-size: .88rem; color: white; line-height: 1.7; }

.reply-form-card h3 { font-size: 1rem; margin-bottom: 8px; }
.reply-note { font-size: .78rem; color: var(--text-muted); margin-bottom: 20px; }
.reply-note a { color: var(--primary); }

.form-group { display: flex; flex-direction: column; margin-bottom: 16px; }
.form-group label { font-size: .8rem; font-weight: 600; margin-bottom: 7px; color: var(--text); text-transform: uppercase; letter-spacing: .05em; }
.form-group input, .form-group textarea, .form-group select {
  width: 100%; padding: 10px 13px; border: 1.5px solid var(--border);
  border-radius: 8px; font-family: 'DM Sans', sans-serif; font-size: .88rem;
  background: white; outline: none; transition: border-color .2s;
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
  border-color: var(--primary);
}

/* ── FILTER BAR ──────────────────────────────────────────────────────── */
.filter-bar { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 18px; }
.filter-group { display: flex; flex-direction: column; gap: 4px; }
.filter-group label { font-size: .65rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); }
.filter-group select { padding: 8px 11px; border: 1.5px solid var(--border); border-radius: 7px; font-family: 'DM Sans', sans-serif; font-size: .82rem; background: white; outline: none; }

/* ── PAGINATION ──────────────────────────────────────────────────────── */
.pagination { display: flex; gap: 6px; justify-content: center; padding: 20px 0; }
.pagination a {
  padding: 6px 12px; border-radius: 7px; border: 1px solid var(--border);
  color: var(--text); font-size: .82rem; text-decoration: none; transition: all .2s;
}
.pagination a:hover { border-color: var(--primary); color: var(--primary); }
.pagination a.active { background: var(--primary); color: white; border-color: var(--primary); }

/* ══════════════════════════════════════════════════════════════════════
   ADMIN RESPONSIVE — Mobile & Tablet
══════════════════════════════════════════════════════════════════════ */

/* ── Tablet: sidebar collapses ──────────────────────────────────────── */
@media (max-width: 900px) {
  :root { --sidebar-w: 0px; }

  .sidebar {
    transform: translateX(-100%);
    transition: transform .3s ease;
    width: 260px;
    z-index: 200;
  }
  .sidebar.open { transform: translateX(0); }

  /* Overlay behind open sidebar */
  .sidebar-overlay {
    display: none;
    position: fixed; inset: 0; z-index: 199;
    background: rgba(0,0,0,.45);
  }
  .sidebar-overlay.open { display: block; }

  .main { margin-left: 0; }

  /* Mobile topbar — add hamburger */
  .topbar {
    padding: 12px 16px; gap: 10px;
  }
  .topbar h2 { font-size: .95rem; }

  .topbar-mobile-menu {
    display: flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; border-radius: 8px;
    background: var(--page-bg); border: 1px solid var(--border);
    cursor: pointer; flex-shrink: 0;
    flex-direction: column; gap: 4px;
  }
  .topbar-mobile-menu span {
    display: block; width: 18px; height: 2px;
    background: var(--text); border-radius: 2px;
    transition: all .25s;
  }

  .page-body { padding: 16px; }

  /* KPI grid — 2 columns */
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .kpi-card { padding: 16px; gap: 12px; }
  .kpi-icon { width: 42px; height: 42px; font-size: 1.1rem; }
  .kpi-val  { font-size: 1.6rem; }

  /* Charts — stack */
  .charts-row { grid-template-columns: 1fr; }
  .msg-thread-grid { grid-template-columns: 1fr; }

  /* Portfolio editor */
  .pe-layout { grid-template-columns: 1fr; }
  .pe-tabs { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; }
  .pe-tab { white-space: nowrap; }

  /* Table horizontal scroll already handled by .table-wrap */
  table { font-size: .76rem; }
  th, td { padding: 8px 10px; }

  /* Filter bar — wrap */
  .filter-bar { flex-wrap: wrap; gap: 8px; }
}

/* ── Small mobile ───────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .topbar { padding: 10px 14px; }
  .topbar h2 { font-size: .88rem; }
  .date-badge { display: none; }
  .page-body { padding: 12px; }
  .card { padding: 16px; }
  .table-header { padding: 12px 14px; }
  .table-header h3 { font-size: .84rem; }
}
