/* ============================================================
   NURSHAUS UNIFIED DASHBOARD — Admin Styles
   ============================================================ */

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

:root {
    --sidebar-width: 240px;
    --topbar-height: 56px;
    --black: #111;
    --white: #fff;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --blue-500: #3b82f6;
    --blue-600: #2563eb;
    --green-500: #22c55e;
    --green-100: #dcfce7;
    --red-500: #ef4444;
    --red-100: #fee2e2;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

html { font-size: 15px; }
body {
    font-family: var(--font);
    background: var(--gray-50);
    color: var(--gray-900);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--blue-600); text-decoration: none; }
a:hover { text-decoration: underline; }

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

/* ── SIDEBAR ── */
.admin-sidebar {
    width: var(--sidebar-width);
    background: var(--gray-900);
    color: var(--gray-300);
    position: fixed;
    top: 0; left: 0; bottom: 0;
    overflow-y: auto;
    z-index: 10;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 1.25rem 1.25rem;
    border-bottom: 1px solid var(--gray-800);
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px; height: 32px;
    background: var(--white);
    color: var(--black);
    font-weight: 700;
    font-size: 0.75rem;
    border-radius: 6px;
}

.brand-text {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--white);
}

.sidebar-nav {
    list-style: none;
    padding: 0.75rem 0;
}

.sidebar-nav li a {
    display: block;
    padding: 0.55rem 1.25rem;
    font-size: 0.85rem;
    color: var(--gray-400);
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}

.sidebar-nav li a:hover {
    background: var(--gray-800);
    color: var(--white);
    text-decoration: none;
}

.sidebar-nav li a.active {
    background: var(--gray-800);
    color: var(--white);
    font-weight: 600;
}

.nav-section {
    padding: 1rem 1.25rem 0.35rem;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--gray-600);
}

/* ── MAIN ── */
.admin-main {
    flex: 1;
    margin-left: var(--sidebar-width);
}

.admin-topbar {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    position: sticky;
    top: 0;
    z-index: 5;
}

.admin-topbar h1 {
    font-size: 1.1rem;
    font-weight: 600;
}

.topbar-user {
    font-size: 0.8rem;
    color: var(--gray-500);
}

.admin-content {
    padding: 2rem;
}

/* ── STAT CARDS ── */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    padding: 1.25rem;
}

.stat-card .stat-label {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--gray-500);
    margin-bottom: 0.35rem;
}

.stat-card .stat-number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--gray-900);
    line-height: 1.1;
}

.stat-card .stat-sub {
    font-size: 0.75rem;
    color: var(--gray-400);
    margin-top: 0.25rem;
}

/* ── TABLES ── */
.data-table-wrapper {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    overflow: hidden;
}

.data-table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--gray-200);
}

.data-table-header h2 {
    font-size: 0.95rem;
    font-weight: 600;
}

table.data-table {
    width: 100%;
    border-collapse: collapse;
}

table.data-table th {
    text-align: left;
    padding: 0.65rem 1.25rem;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--gray-500);
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
}

table.data-table td {
    padding: 0.7rem 1.25rem;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-700);
}

table.data-table tr:last-child td { border-bottom: none; }
table.data-table tr:hover td { background: var(--gray-50); }

/* ── BADGES ── */
.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: 100px;
}
.badge--green { background: var(--green-100); color: #15803d; }
.badge--red { background: var(--red-100); color: #b91c1c; }
.badge--gray { background: var(--gray-100); color: var(--gray-600); }

/* ── BUTTONS ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    font-family: var(--font);
    font-size: 0.8rem;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    transition: opacity 0.15s;
}
.btn:hover { opacity: 0.85; text-decoration: none; }
.btn--primary { background: var(--gray-900); color: var(--white); }
.btn--outline { background: var(--white); color: var(--gray-700); border: 1px solid var(--gray-300); }
.btn--danger { background: var(--red-500); color: var(--white); }
.btn--sm { padding: 0.3rem 0.6rem; font-size: 0.7rem; }

/* ── EMPTY STATE ── */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--gray-400);
}
.empty-state p { font-size: 0.9rem; }

/* ── LOGIN ── */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--gray-50);
}

.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    padding: 2.5rem;
}

.login-card h1 {
    font-size: 1.25rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 0.5rem;
}

.login-card .login-sub {
    text-align: center;
    font-size: 0.85rem;
    color: var(--gray-500);
    margin-bottom: 2rem;
}

.login-card .form-group {
    margin-bottom: 1rem;
}

.login-card label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--gray-600);
    margin-bottom: 0.3rem;
}

.login-card input {
    width: 100%;
    padding: 0.6rem 0.8rem;
    font-family: var(--font);
    font-size: 0.9rem;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    outline: none;
}

.login-card input:focus { border-color: var(--gray-900); }

.login-card .btn { width: 100%; justify-content: center; margin-top: 0.5rem; }

.login-error {
    background: var(--red-100);
    color: #b91c1c;
    font-size: 0.8rem;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    text-align: center;
}

/* ── FLASH ── */
.flash {
    padding: 0.65rem 1rem;
    border-radius: 6px;
    font-size: 0.85rem;
    margin-bottom: 1.5rem;
}
.flash--success { background: var(--green-100); color: #15803d; }
.flash--error { background: var(--red-100); color: #b91c1c; }

/* ── PAGINATION ── */
.pagination {
    display: flex;
    gap: 0.25rem;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--gray-200);
}
.pagination a, .pagination span {
    padding: 0.35rem 0.7rem;
    font-size: 0.8rem;
    border-radius: 4px;
}
.pagination a { color: var(--gray-600); }
.pagination a:hover { background: var(--gray-100); text-decoration: none; }
.pagination .current { background: var(--gray-900); color: var(--white); }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
    .admin-sidebar { display: none; }
    .admin-main { margin-left: 0; }
    .stat-grid { grid-template-columns: 1fr 1fr; }
}

/* ============================================================
   CMS / BLOG EDITOR STYLES
   ============================================================ */

/* ── PAGE HEADER ── */
.admin-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}
.admin-page-header h2 { font-size: 1.5rem; font-weight: 700; line-height: 1.3; }
.admin-page-header h2 small { font-weight: 400; color: var(--gray-500); font-size: 0.85rem; }

/* ── FORMS (general) ── */
.form-group { margin-bottom: 1rem; }
.form-group label {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 0.3rem;
    color: var(--gray-900);
}
.form-group label small { font-weight: 400; color: var(--gray-500); }

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="url"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group input[type="date"],
.form-group input[type="time"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-family: var(--font);
    font-size: 0.9rem;
    color: var(--gray-900);
    background: var(--white);
    transition: border-color 0.15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--gray-900);
    box-shadow: 0 0 0 2px rgba(17,24,39,0.08);
}
.form-group textarea { resize: vertical; }

.input-large { font-size: 1.25rem !important; font-weight: 700; padding: 0.75rem !important; }

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 0 1.25rem;
}
.form-row { display: flex; gap: 1rem; align-items: flex-end; }
.form-actions { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--gray-200); }
.help-text { font-size: 0.8rem; color: var(--gray-500); margin-top: 0.25rem; }

/* ── ALERTS ── */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}
.alert-success { background: var(--green-100); color: #15803d; border: 1px solid #bbf7d0; }
.alert-error   { background: var(--red-100); color: #b91c1c; border: 1px solid #fecaca; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.alert-info    { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

/* ── ADMIN TABLE (CMS) ── */
.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    background: var(--white);
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--gray-200);
}
.admin-table th {
    text-align: left;
    padding: 0.65rem 0.75rem;
    border-bottom: 2px solid var(--gray-200);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--gray-500);
    white-space: nowrap;
    background: var(--gray-50);
}
.admin-table td {
    padding: 0.65rem 0.75rem;
    border-bottom: 1px solid var(--gray-100);
    vertical-align: middle;
}
.admin-table tbody tr:hover { background: var(--gray-50); }
.admin-table-compact th,
.admin-table-compact td { padding: 0.4rem 0.5rem; font-size: 0.85rem; }
.col-check { width: 36px; }
.actions-cell { white-space: nowrap; }

/* ── STATUS BADGES ── */
.status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.status-published { background: #d1fae5; color: #065f46; }
.status-draft     { background: var(--gray-100); color: var(--gray-600); }
.status-scheduled { background: #dbeafe; color: #1e40af; }
.status-archived  { background: var(--red-100); color: #b91c1c; }

/* ── FILTERS ── */
.admin-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
    align-items: center;
}
.filter-form {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}
.filter-form select,
.filter-form input[type="text"] {
    padding: 0.4rem 0.65rem;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-family: var(--font);
    font-size: 0.85rem;
}
.bulk-actions {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    align-items: center;
}
.bulk-actions select {
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 0.85rem;
}

/* ── ADMIN PAGINATION ── */
.admin-pagination {
    display: flex;
    gap: 4px;
    margin-top: 1rem;
    justify-content: center;
}
.admin-pagination a {
    padding: 0.35rem 0.7rem;
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    font-size: 0.85rem;
    color: var(--gray-700);
    text-decoration: none;
}
.admin-pagination a:hover { background: var(--gray-50); text-decoration: none; }
.admin-pagination a.active { background: var(--gray-900); color: var(--white); border-color: var(--gray-900); }

/* ── TWO-COLUMN LAYOUT ── */
.admin-two-col {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 1.5rem;
    align-items: start;
}

/* ── EDITOR LAYOUT ── */
.editor-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 1.5rem;
    align-items: start;
}
.editor-box {
    background: var(--white);
    border-radius: 6px;
    padding: 1.25rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    margin-bottom: 1rem;
    border: 1px solid var(--gray-200);
}
.editor-box h3 {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-500);
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--gray-200);
}
.editor-fieldset {
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    padding: 1.25rem;
    margin-top: 1.5rem;
}
.editor-fieldset legend {
    font-weight: 700;
    font-size: 0.9rem;
    padding: 0 0.5rem;
    color: var(--gray-500);
}
.editor-body-wrap { margin-bottom: 1.5rem; }
.editor-toolbar-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.3rem;
}
.editor-status { display: flex; align-items: center; gap: 1rem; font-size: 0.8rem; }
.editor-word-count { color: var(--gray-500); }
.editor-autosave-status { color: var(--green-500); transition: opacity 0.3s; }
.editor-autosave-status.saving { color: #f59e0b; }
.editor-autosave-status.error { color: var(--red-500); }

/* ── TAG SELECTOR ── */
.tag-selector { max-height: 300px; overflow-y: auto; }
.tag-group { margin-bottom: 0.75rem; }
.tag-group h4 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-500);
    margin-bottom: 0.4rem;
}
.tag-checkbox {
    display: inline-block;
    font-size: 0.82rem;
    font-weight: 400;
    margin-right: 0.5rem;
    margin-bottom: 0.3rem;
    white-space: nowrap;
}
.tag-checkbox input { margin-right: 3px; }

/* ── IMAGE PREVIEW ── */
.current-image { margin-bottom: 0.75rem; }
.current-image img {
    max-width: 100%;
    max-height: 150px;
    border-radius: 6px;
    border: 1px solid var(--gray-200);
}

/* ── DETAILS / SUMMARY ── */
details { margin-bottom: 0.5rem; }
details summary {
    cursor: pointer;
    padding: 0.5rem 0;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
details summary:hover { color: var(--blue-600); }
details[open] summary {
    margin-bottom: 0.75rem;
    border-bottom: 1px solid var(--gray-200);
    padding-bottom: 0.75rem;
}
.inline-edit-form { margin-bottom: 1rem; }

/* ── MODAL ── */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal-content {
    background: var(--white);
    border-radius: 6px;
    padding: 2rem;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.modal-content h3 { margin-bottom: 1rem; }

/* ── BUTTON ALIASES (blog-admin style) ── */
.btn-primary { background: var(--gray-900); color: var(--white); }
.btn-muted   { background: var(--gray-200); color: var(--gray-700); }
.btn-danger  { background: var(--red-500); color: var(--white); }
.btn-sm      { padding: 0.3rem 0.6rem; font-size: 0.7rem; }
.btn-block   { display: block; width: 100%; text-align: center; }

/* ── CKEditor 5 Integration ── */
.ck.ck-editor { width: 100% !important; }
.ck.ck-editor__top .ck-sticky-panel .ck-toolbar {
    border-color: var(--gray-300) !important;
    background: var(--gray-50) !important;
    border-radius: 6px 6px 0 0 !important;
}
.ck.ck-editor__main > .ck-editor__editable {
    border-color: var(--gray-300) !important;
    border-radius: 0 0 6px 6px !important;
    min-height: 500px;
    max-height: 80vh;
    overflow-y: auto;
}
.ck.ck-editor__main > .ck-editor__editable:focus {
    border-color: var(--gray-900) !important;
    box-shadow: 0 0 0 2px rgba(17,24,39,0.08) !important;
}
.ck-content {
    font-family: 'Source Sans Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 1rem;
    line-height: 1.75;
    color: #565656;
    padding: 1.5rem !important;
}
.ck-content h2 {
    font-family: 'Open Sans Condensed', Impact, sans-serif;
    font-size: 1.5em; font-weight: 700; line-height: 1.25; color: #232323;
    margin-top: 2rem; margin-bottom: 0.75rem;
}
.ck-content h3 {
    font-family: 'Open Sans Condensed', Impact, sans-serif;
    font-size: 1.25em; font-weight: 700; line-height: 1.25; color: #232323;
    margin-top: 1.5rem; margin-bottom: 0.5rem;
}
.ck-content h4 {
    font-family: 'Open Sans Condensed', Impact, sans-serif;
    font-size: 1.125em; font-weight: 700; color: #232323;
    margin-top: 1.25rem; margin-bottom: 0.5rem;
}
.ck-content p { margin-bottom: 1rem; }
.ck-content blockquote {
    border-left: 3px solid #232323;
    padding: 0.75rem 1.25rem; margin: 1.5rem 0;
    font-style: italic; color: #565656;
}
.ck-content ul, .ck-content ol { margin: 0 0 1rem 1.5rem; }
.ck-content li { margin-bottom: 0.35rem; }
.ck-content a { color: #232323; text-decoration: underline; text-underline-offset: 2px; }
.ck-content img { max-width: 100%; height: auto; }
.ck-content figure.image { margin: 1.5rem 0; }
.ck-content figure.image figcaption {
    font-size: 0.85rem; color: #999; text-align: center; padding: 0.5rem 0;
}
.ck-content pre {
    background: #f7f7f7; border: 1px solid #ddd; padding: 1rem;
    font-family: 'SF Mono', 'Fira Code', monospace; font-size: 0.9rem;
    overflow-x: auto; margin-bottom: 1rem;
}
.ck-content code {
    font-family: 'SF Mono', 'Fira Code', monospace; font-size: 0.9em;
    background: #f7f7f7; padding: 0.15em 0.4em; border-radius: 3px;
}
.ck-content pre code { background: none; padding: 0; }
.ck-content hr { border: none; border-top: 1px solid #ddd; margin: 2rem 0; }
.ck-content table { border-collapse: collapse; width: 100%; }
.ck-content table td, .ck-content table th {
    border: 1px solid #ddd; padding: 0.5rem 0.75rem; font-size: 0.9rem;
}
.ck-content table th { background: #f7f7f7; font-weight: 700; color: #232323; }

.ck.ck-balloon-panel { z-index: 10000 !important; }
.ck.ck-notification-warning, .ck-powered-by, .ck-body .ck-notification { display: none !important; }

/* ── CMS RESPONSIVE ── */
@media (max-width: 1024px) {
    .editor-layout { grid-template-columns: 1fr; }
    .admin-two-col { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
    .admin-page-header { flex-direction: column; align-items: flex-start; }
    .form-grid { grid-template-columns: 1fr; }
}
