/* ============================================================
   Divine Mercy Foundation — Admin Panel Stylesheet
   ============================================================ */

:root {
  --red:       #C8102E;
  --red-dark:  #9a0c22;
  --red-light: #fef2f4;
  --navy:      #0D1F35;
  --navy-mid:  #1a3557;
  --sidebar-w: 260px;
  --topbar-h:  60px;
  --white:     #FFFFFF;
  --bg:        #F3F4F6;
  --border:    #E5E7EB;
  --text:      #111827;
  --muted:     #6B7280;
  --success:   #059669;
  --danger:    #DC2626;
  --radius:    10px;
  --font: 'Inter', system-ui, sans-serif;
  --transition: 0.2s ease;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body { font-family: var(--font); color: var(--text); background: var(--bg); }
a { color: var(--red); text-decoration: none; }
a:hover { color: var(--red-dark); }
img { max-width: 100%; height: auto; display: block; }
input, select, textarea, button { font-family: var(--font); }

/* ── Layout ── */
.admin-layout { display: flex; min-height: 100vh; }
.admin-sidebar {
  width: var(--sidebar-w);
  background: var(--navy);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 200;
  overflow-y: auto;
  transition: transform var(--transition);
}
.admin-main {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.admin-content {
  flex: 1;
  padding: 2rem;
  max-width: 1200px;
}

/* ── Sidebar ── */
.sidebar-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-logo { width: 40px; height: 40px; object-fit: contain; }
.sidebar-brand strong { color: #fff; font-size: .95rem; display: block; }
.sidebar-brand span   { color: rgba(255,255,255,.45); font-size: .72rem; }
.sidebar-close {
  margin-left: auto;
  background: none;
  border: none;
  color: rgba(255,255,255,.5);
  font-size: 1rem;
  cursor: pointer;
  display: none;
}

.sidebar-nav {
  padding: 1rem 0;
  flex: 1;
}
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .7rem 1.25rem;
  color: rgba(255,255,255,.65);
  font-size: .88rem;
  font-weight: 500;
  transition: all var(--transition);
}
.sidebar-nav a:hover,
.sidebar-nav a.active {
  background: rgba(255,255,255,.08);
  color: #fff;
}
.sidebar-nav a.active { border-left: 3px solid var(--red); }
.sidebar-nav a svg { flex-shrink: 0; }
.sidebar-divider { border-top: 1px solid rgba(255,255,255,.08); margin: .5rem 0; }
.nav-logout { color: rgba(255,100,100,.7) !important; }
.nav-logout:hover { color: #ff8888 !important; }

.sidebar-user {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,.08);
}
.sidebar-user-avatar {
  width: 36px; height: 36px;
  background: var(--red);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  font-size: .85rem;
  flex-shrink: 0;
}
.sidebar-user strong { color: #fff; font-size: .85rem; display: block; }
.sidebar-user span   { color: rgba(255,255,255,.4); font-size: .72rem; }

/* ── Top bar ── */
.admin-topbar {
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
}
.admin-page-title { font-size: 1.1rem; font-weight: 600; flex: 1; }
.admin-topbar-right { display: flex; align-items: center; gap: 1rem; }
.admin-topbar-user  { font-size: .85rem; color: var(--muted); }
.admin-logout-btn {
  font-size: .82rem;
  background: var(--red-light);
  color: var(--red);
  padding: .35rem .9rem;
  border-radius: 50px;
  font-weight: 600;
}
.admin-logout-btn:hover { background: var(--red); color: #fff; }

.sidebar-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: .4rem;
}
.sidebar-toggle span {
  display: block; width: 22px; height: 2px;
  background: var(--navy); border-radius: 2px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .6rem 1.3rem; border-radius: 8px;
  font-size: .875rem; font-weight: 600; cursor: pointer;
  border: none; transition: all var(--transition); text-decoration: none;
  white-space: nowrap;
}
.btn-lg { padding: .8rem 1.8rem; font-size: .95rem; }
.btn-sm { padding: .35rem .85rem; font-size: .8rem; }
.btn-full { width: 100%; justify-content: center; }

.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); color: #fff; }
.btn-secondary { background: var(--navy); color: #fff; }
.btn-secondary:hover { background: var(--navy-mid); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; color: #fff; }

/* ── Dashboard ── */
.dash-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}
.dash-stat {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}
.dash-stat--red  { border-left: 4px solid var(--red); }
.dash-stat--alert { border-left: 4px solid #f59e0b; }
.dash-stat-value { font-size: 2rem; font-weight: 700; line-height: 1.1; margin-bottom: .25rem; }
.dash-stat-label { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.dash-stat-link  { display: inline-block; margin-top: .75rem; font-size: .82rem; font-weight: 600; color: var(--red); }

.dash-actions { display: flex; gap: 1rem; margin-bottom: 2rem; flex-wrap: wrap; }

.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

/* ── Cards ── */
.admin-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  margin-bottom: 1.5rem;
}
.dash-card { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.dash-card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.1rem 1.25rem; border-bottom: 1px solid var(--border);
}
.dash-card-header h2 { font-size: .95rem; font-weight: 600; }
.dash-card-header a  { font-size: .82rem; color: var(--red); font-weight: 500; }

/* ── Tables ── */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
.admin-table--full { /* inside admin-card */ }
.dash-card .admin-table { /* inside dash-card */ }

.admin-table th {
  background: var(--bg);
  padding: .7rem 1rem;
  text-align: left;
  font-size: .75rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  border-bottom: 1px solid var(--border);
}
.admin-table td {
  padding: .9rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: #f9fafb; }
.row-unread td { font-weight: 600; background: #fffbeb; }
.table-empty { text-align: center; color: var(--muted); padding: 2rem !important; }
.table-title-link { font-weight: 500; color: var(--text); }
.table-title-link:hover { color: var(--red); }
.td-title .has-image { margin-left: .4rem; font-size: .8rem; }
.td-actions { display: flex; align-items: center; gap: .75rem; }

.table-action { font-size: .82rem; font-weight: 500; color: var(--red); }
.table-action--danger { color: var(--danger); }
.table-action:hover { opacity: .8; }

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: .2rem .65rem;
  border-radius: 50px;
  font-size: .72rem;
  font-weight: 600;
  text-transform: capitalize;
}
.badge-published    { background: #dcfce7; color: #166534; }
.badge-draft        { background: #f3f4f6; color: #4b5563; }
.badge-news         { background: #eff6ff; color: #1d4ed8; }
.badge-activity     { background: #fef3c7; color: #92400e; }
.badge-announcement { background: #f5f3ff; color: #6d28d9; }

/* ── Toolbar ── */
.admin-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.admin-filter-tabs { display: flex; gap: .5rem; flex-wrap: wrap; }
.admin-filter-tabs a {
  padding: .4rem 1rem;
  border-radius: 50px;
  font-size: .82rem;
  font-weight: 500;
  color: var(--muted);
  border: 1.5px solid var(--border);
  background: var(--white);
  transition: all var(--transition);
}
.admin-filter-tabs a:hover,
.admin-filter-tabs a.active {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

/* ── Forms ── */
.form-group { margin-bottom: 1.1rem; }
.form-group label {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: .4rem;
}
.form-group small { font-size: .75rem; color: var(--muted); font-weight: 400; }
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: .65rem .9rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: .88rem;
  color: var(--text);
  background: #fff;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(200,16,46,.12);
}
.form-group textarea { resize: vertical; }
.form-group input[type="file"] { padding: .4rem .6rem; }
.input-large { font-size: 1.05rem !important; padding: .8rem 1rem !important; }
.required { color: var(--red); }

.form-actions { margin-top: 1rem; }
.inline-form { display: inline; }

/* ── Rich editor ── */
.editor-toolbar {
  display: flex;
  gap: .25rem;
  flex-wrap: wrap;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  padding: .5rem;
}
.editor-toolbar button {
  padding: .3rem .7rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--white);
  font-size: .82rem;
  cursor: pointer;
  transition: all var(--transition);
}
.editor-toolbar button:hover { background: var(--red); color: #fff; border-color: var(--red); }

.rich-editor {
  min-height: 320px;
  padding: 1rem;
  border: 1.5px solid var(--border);
  border-radius: 0 0 8px 8px;
  font-size: .93rem;
  line-height: 1.8;
  background: var(--white);
  overflow-y: auto;
}
.rich-editor:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 3px rgba(200,16,46,.12); }
.rich-editor p { margin-bottom: 1em; }
.hidden-textarea { display: none; }

/* ── Edit layout ── */
.edit-layout { display: grid; grid-template-columns: 1fr 300px; gap: 1.5rem; align-items: start; }
.edit-main   {}
.edit-sidebar { position: sticky; top: 76px; }
.edit-sidebar-box {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.edit-sidebar-box h3 {
  font-size: .82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  margin-bottom: .85rem;
  padding-bottom: .65rem;
  border-bottom: 1px solid var(--border);
}
.current-image { margin-bottom: .75rem; }
.current-image img { width: 100%; border-radius: 6px; max-height: 160px; object-fit: cover; }
.img-note { font-size: .78rem; color: var(--muted); margin-top: .35rem; }

/* ── Pages grid ── */
.pages-grid     { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.25rem; }
.page-section-title { font-size: .95rem; margin-bottom: 1rem; padding-bottom: .65rem; border-bottom: 1px solid var(--border); }

/* ── Settings ── */
.settings-grid    { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.25rem; }
.settings-section-title { font-size: .95rem; margin-bottom: 1rem; padding-bottom: .65rem; border-bottom: 1px solid var(--border); }
.admin-subtitle   { color: var(--muted); font-size: .9rem; margin-bottom: 1.5rem; }

/* ── Messages ── */
.message-view { }
.message-view-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.message-view-header h2 { font-size: 1.2rem; }
.message-meta { display: flex; flex-wrap: wrap; gap: 1.5rem; font-size: .88rem; color: var(--muted); margin-bottom: 1.25rem; padding-bottom: 1.25rem; border-bottom: 1px solid var(--border); }
.message-meta strong { color: var(--text); }
.message-body { font-size: .95rem; line-height: 1.7; margin-bottom: 1.5rem; }
.message-actions { display: flex; gap: 1rem; flex-wrap: wrap; }
.unread-dot { color: var(--red); font-size: .7rem; }

/* ── Pagination ── */
.pagination { display: flex; gap: .4rem; margin-top: 1.25rem; justify-content: center; }
.page-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 8px;
  border: 1.5px solid var(--border); font-size: .85rem; color: var(--text);
  transition: all var(--transition);
}
.page-btn.active,
.page-btn:hover { background: var(--red); border-color: var(--red); color: #fff; }

/* ── Alerts ── */
.alert { padding: .85rem 1.1rem; border-radius: 8px; margin-bottom: 1.25rem; font-size: .88rem; }
.alert-success { background: #ecfdf5; border: 1px solid #6ee7b7; color: #065f46; }
.alert-error   { background: #fef2f2; border: 1px solid #fca5a5; color: #991b1b; }

/* ── Login page ── */
.admin-login-page { background: var(--navy); min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-wrap {
  background: var(--white);
  border-radius: 16px;
  padding: 2.5rem 2.25rem;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 24px 60px rgba(0,0,0,.3);
}
.login-brand { display: flex; align-items: center; gap: .75rem; margin-bottom: 1.75rem; }
.login-brand img { width: 52px; height: 52px; object-fit: contain; }
.login-brand strong { display: block; font-size: 1rem; color: var(--navy); }
.login-brand span   { font-size: .8rem; color: var(--muted); }
.login-title    { font-size: 1.5rem; margin-bottom: .4rem; }
.login-subtitle { color: var(--muted); font-size: .88rem; margin-bottom: 1.5rem; }
.login-form .btn { margin-top: .25rem; }
.login-back { text-align: center; margin-top: 1.5rem; font-size: .85rem; color: var(--muted); }

/* ── Responsive ── */
@media (max-width: 1024px) {
  .dash-stats { grid-template-columns: repeat(2, 1fr); }
  .dash-grid  { grid-template-columns: 1fr; }
  .edit-layout { grid-template-columns: 1fr; }
  .edit-sidebar { position: static; }
  .pages-grid  { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .admin-sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-w);
  }
  .admin-sidebar.open { transform: translateX(0); }
  .admin-main { margin-left: 0; }
  .sidebar-toggle { display: flex; }
  .sidebar-close  { display: block; }
  .dash-stats     { grid-template-columns: 1fr 1fr; }
  .admin-content  { padding: 1.25rem; }
}
