/* ═══════════════════════════════════════════════════════════════
   Giáo Phận Nha Trang — Admin Panel Stylesheet
   ═══════════════════════════════════════════════════════════════ */

:root {
  --sidebar-w: 260px;
  --topbar-h: 60px;
  --blue-600: #02c99b;
  --blue-700: #018864;
  --blue-800: #016d50;
  --blue-900: #015840;
  --gray-50:  #F9FAFB;
  --gray-100: #F3F4F6;
  --gray-200: #E5E7EB;
  --gray-400: #9CA3AF;
  --gray-600: #4B5563;
  --gray-700: #374151;
  --gray-800: #1F2937;
  --green-600: #16A34A;
  --amber-600: #D97706;
  --red-600:   #DC2626;
  --radius: 10px;
  --shadow: 0 1px 4px rgba(2,201,155,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 4px 16px rgba(2,201,155,.10), 0 2px 6px rgba(0,0,0,.05);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Be Vietnam Pro', 'Segoe UI', sans-serif;
  font-size: 14px;
  background: var(--gray-50);
  color: var(--gray-800);
}
a { text-decoration: none; color: var(--blue-600); }

/* ── LAYOUT ─────────────────────────────────────────────────── */
.admin-layout { display: flex; min-height: 100vh; }

/* ── SIDEBAR ─────────────────────────────────────────────────── */
.admin-sidebar {
  width: var(--sidebar-w);
  background: var(--blue-900);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 100;
  overflow-y: auto;
  transition: transform .3s;
}
.sidebar-brand {
  padding: 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.1);
  display: flex;
  align-items: center;
  gap: .75rem;
}
.sidebar-brand .icon { font-size: 1.5rem; color: #fff; }
.sidebar-brand .name { font-size: .95rem; font-weight: 800; color: #fff; line-height: 1.2; }
.sidebar-brand .sub  { font-size: .7rem; color: rgba(255,255,255,.5); }
.sidebar-nav { padding: .75rem 0; flex: 1; }
.nav-section { padding: .4rem 1rem .2rem; font-size: .65rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: rgba(255,255,255,.35); }
.nav-item { display: flex; align-items: center; gap: .6rem; padding: .6rem 1rem; color: rgba(255,255,255,.75); font-size: .875rem; font-weight: 500; border-left: 3px solid transparent; transition: all .2s; }
.nav-item i { width: 18px; text-align: center; font-size: .85rem; }
.nav-item:hover { color: #fff; background: rgba(255,255,255,.08); }
.nav-item.active { color: #fff; background: rgba(255,255,255,.12); border-left-color: #60A5FA; }
.sidebar-footer { padding: .75rem 1rem; border-top: 1px solid rgba(255,255,255,.1); }
.sidebar-user { display: flex; align-items: center; gap: .6rem; }
.sidebar-user .avatar { width: 32px; height: 32px; border-radius: 50%; background: rgba(255,255,255,.15); display: flex; align-items: center; justify-content: center; color: #fff; font-size: .8rem; overflow: hidden; }
.sidebar-user .avatar img { width: 100%; height: 100%; object-fit: cover; }
.sidebar-user .info .name { font-size: .8rem; font-weight: 700; color: #fff; }
.sidebar-user .info .role { font-size: .68rem; color: rgba(255,255,255,.4); }
.sidebar-user .logout { margin-left: auto; color: rgba(255,255,255,.4); font-size: .8rem; }
.sidebar-user .logout:hover { color: #fff; }

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

/* ── TOPBAR ──────────────────────────────────────────────────── */
.admin-topbar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow);
}
.topbar-left { display: flex; align-items: center; gap: 1rem; }
.page-title { font-size: 1rem; font-weight: 700; color: var(--gray-800); }
.topbar-right { display: flex; align-items: center; gap: 1rem; }
.topbar-right a { font-size: .8rem; color: var(--gray-600); display: flex; align-items: center; gap: .35rem; }
.topbar-right a:hover { color: var(--blue-600); }
.menu-toggle { display: none; background: none; border: none; cursor: pointer; color: var(--gray-600); font-size: 1.2rem; }

/* ── PAGE CONTENT ────────────────────────────────────────────── */
.page-content { padding: 1.5rem; flex: 1; }

/* ── FLASH MESSAGES ─────────────────────────────────────────── */
.flash-msg {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .875rem;
  font-weight: 500;
  position: relative;
}
.flash-success { background: #D1FAE5; color: #065F46; border: 1px solid #A7F3D0; }
.flash-error   { background: #FEE2E2; color: #991B1B; border: 1px solid #FCA5A5; }
.flash-msg .close-btn { margin-left: auto; background: none; border: none; cursor: pointer; color: inherit; opacity: .6; font-size: 1rem; }

/* ── CARDS / STATS ───────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 1rem;
}
.stat-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}
.stat-icon.blue   { background: #DBEAFE; color: var(--blue-700); }
.stat-icon.green  { background: #D1FAE5; color: var(--green-600); }
.stat-icon.amber  { background: #FEF3C7; color: var(--amber-600); }
.stat-icon.red    { background: #FEE2E2; color: var(--red-600); }
.stat-info .num   { font-size: 1.75rem; font-weight: 800; line-height: 1; }
.stat-info .label { font-size: .75rem; color: var(--gray-400); margin-top: .2rem; }

/* ── PANEL ───────────────────────────────────────────────────── */
.panel { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; margin-bottom: 1.5rem; }
.panel-header { padding: .85rem 1.25rem; border-bottom: 1px solid var(--gray-200); display: flex; align-items: center; justify-content: space-between; }
.panel-title { font-size: .9rem; font-weight: 700; color: var(--gray-800); display: flex; align-items: center; gap: .5rem; }
.panel-title i { color: var(--blue-600); }
.panel-body { padding: 1.25rem; }

/* ── TABLE ───────────────────────────────────────────────────── */
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th { background: var(--gray-50); font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--gray-500); padding: .65rem 1rem; text-align: left; border-bottom: 1px solid var(--gray-200); }
.admin-table td { padding: .65rem 1rem; border-bottom: 1px solid var(--gray-100); font-size: .875rem; vertical-align: middle; }
.admin-table tr:hover td { background: var(--gray-50); }
.admin-table tr:last-child td { border-bottom: none; }

/* ── BADGES ──────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: .3rem; font-size: .7rem; font-weight: 700; padding: .2rem .6rem; border-radius: 20px; text-transform: uppercase; letter-spacing: .04em; }
.badge-published { background: #D1FAE5; color: #065F46; }
.badge-draft     { background: #FEF3C7; color: #92400E; }
.badge-archived  { background: var(--gray-100); color: var(--gray-500); }
.badge-admin     { background: #EDE9FE; color: #5B21B6; }
.badge-editor    { background: #DBEAFE; color: var(--blue-700); }

/* ── BUTTONS ─────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .45rem 1rem; border-radius: var(--radius); font-size: .8rem; font-weight: 600; cursor: pointer; border: 1px solid transparent; transition: all .2s; text-decoration: none; }
.btn-sm { padding: .3rem .65rem; font-size: .75rem; }
.btn-primary { background: var(--blue-700); color: #fff; }
.btn-primary:hover { background: var(--blue-800); color: #fff; }
.btn-secondary { background: var(--gray-100); color: var(--gray-700); border-color: var(--gray-200); }
.btn-secondary:hover { background: var(--gray-200); }
.btn-success { background: var(--green-600); color: #fff; }
.btn-danger  { background: var(--red-600); color: #fff; }
.btn-danger:hover { background: #B91C1C; color: #fff; }
.btn-outline { background: #fff; color: var(--blue-700); border-color: var(--blue-200); }
.btn-outline:hover { background: var(--blue-700); color: #fff; }
.btn-group { display: flex; gap: .35rem; flex-wrap: wrap; }

/* ── FORMS ───────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.25rem; }
.form-label { display: block; font-size: .8rem; font-weight: 700; color: var(--gray-700); margin-bottom: .4rem; }
.form-label .required { color: var(--red-600); }
.form-control {
  width: 100%;
  padding: .5rem .75rem;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: .875rem;
  font-family: inherit;
  color: var(--gray-800);
  background: #fff;
  transition: border-color .2s, box-shadow .2s;
  outline: none;
}
.form-control:focus { border-color: var(--blue-400, #60A5FA); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
select.form-control { cursor: pointer; }
textarea.form-control { min-height: 120px; resize: vertical; }
.form-hint { font-size: .75rem; color: var(--gray-400); margin-top: .3rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }

/* Image preview */
.img-preview { margin-top: .5rem; }
.img-preview img { max-width: 200px; max-height: 130px; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--gray-200); }

/* Toggle switch */
.toggle-wrap { display: flex; align-items: center; gap: .5rem; }
.toggle { position: relative; width: 40px; height: 22px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; inset: 0; background: var(--gray-200); border-radius: 22px; cursor: pointer; transition: .2s; }
.toggle-slider::before { content: ''; position: absolute; height: 16px; width: 16px; left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: .2s; }
input:checked + .toggle-slider { background: var(--blue-600); }
input:checked + .toggle-slider::before { transform: translateX(18px); }

/* ── RICH TEXT EDITOR ────────────────────────────────────────── */
.editor-toolbar { background: var(--gray-50); border: 1px solid var(--gray-200); border-radius: var(--radius) var(--radius) 0 0; padding: .5rem; display: flex; flex-wrap: wrap; gap: .35rem; }
.editor-toolbar button { padding: .3rem .55rem; border: 1px solid var(--gray-200); border-radius: 4px; background: #fff; cursor: pointer; font-size: .8rem; color: var(--gray-700); }
.editor-toolbar button:hover { background: var(--gray-100); }
.editor-toolbar button.active { background: var(--blue-700); color: #fff; border-color: var(--blue-700); }
.editor-area { border: 1px solid var(--gray-200); border-top: none; border-radius: 0 0 var(--radius) var(--radius); min-height: 350px; padding: 1rem; outline: none; font-size: .9rem; line-height: 1.8; }
.editor-area:focus { box-shadow: 0 0 0 3px rgba(37,99,235,.1); border-color: #60A5FA; }

/* ── LOGIN PAGE ──────────────────────────────────────────────── */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--blue-900) 0%, var(--blue-700) 100%); padding: 1rem; }
.login-box { background: #fff; border-radius: 12px; padding: 2.5rem; width: 100%; max-width: 400px; box-shadow: 0 20px 40px rgba(0,0,0,.2); }
.login-logo { text-align: center; margin-bottom: 1.5rem; }
.login-logo .cross { font-size: 2.5rem; color: var(--blue-700); display: block; }
.login-logo h1 { font-size: 1.2rem; color: var(--gray-800); margin-top: .5rem; }
.login-logo p { font-size: .8rem; color: var(--gray-400); }

/* ── PAGINATION ──────────────────────────────────────────────── */
.pagination { display: flex; gap: .35rem; align-items: center; flex-wrap: wrap; }
.pagination a, .pagination span { display: inline-flex; align-items: center; justify-content: center; min-width: 32px; height: 32px; padding: 0 .4rem; border: 1px solid var(--gray-200); border-radius: 6px; font-size: .8rem; color: var(--gray-600); }
.pagination a:hover { background: var(--gray-50); color: var(--blue-600); }
.pagination .active { background: var(--blue-700); border-color: var(--blue-700); color: #fff; font-weight: 700; }

/* ── RESPONSIVE ──────────────────────────────────────────────── */
@media (max-width: 1024px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 768px) {
  .admin-sidebar { transform: translateX(-100%); }
  .admin-sidebar.open { transform: translateX(0); }
  .admin-main { margin-left: 0; }
  .menu-toggle { display: block; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
}
@media (max-width: 480px) { .stats-grid { grid-template-columns: 1fr; } }
