/* ==========================================================================
   LUMORA - ADMIN PANEL
   ========================================================================== */

.admin-shell {
    display: none;
}

.admin-shell[data-mode="authenticated"] {
    /* Sidebar + main sit side by side in a flex row */
    display: flex;
}

/* ---- Auth gate ---- */
/* Gate is only shown while loading or when the user is not authorized.
   It must NOT appear once the admin panel is fully authenticated. */
.admin-gate {
    min-height: 70vh;
    display: none;
    align-items: center;
    justify-content: center;
}

.admin-shell[data-mode="loading"],
.admin-shell[data-mode="unauthorized"] {
    display: block;
}

.admin-shell[data-mode="loading"] .admin-gate,
.admin-shell[data-mode="unauthorized"] .admin-gate {
    display: flex;
}

.admin-shell[data-mode="authenticated"] .admin-gate {
    display: none;
}

/* While loading or unauthorized, only show the gate — hide the admin
   sidebar and main content so non-staff see just the access prompt. */
.admin-shell[data-mode="loading"] .admin-sidebar,
.admin-shell[data-mode="loading"] .admin-main,
.admin-shell[data-mode="unauthorized"] .admin-sidebar,
.admin-shell[data-mode="unauthorized"] .admin-main {
    display: none;
}

.admin-gate-card {
    background: var(--surface);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-xl);
    padding: 2.5rem 2rem;
    text-align: center;
    max-width: 380px;
    box-shadow: var(--shadow-card);
}

.admin-gate-lock {
    font-size: 2.4rem;
    display: block;
    margin-bottom: 1rem;
}

.admin-gate-card h2 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary-deep);
    margin-bottom: 0.5rem;
}

.admin-gate-card p {
    color: var(--muted);
    margin-bottom: 1.5rem;
}

.admin-gate-btn {
    display: inline-block;
    padding: 0.7rem 1.6rem;
    border-radius: 999px;
    background: var(--accent-gradient);
    color: #fff;
    font-weight: 700;
    box-shadow: 0 6px 16px rgba(194, 109, 132, 0.25);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.admin-gate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 22px rgba(194, 109, 132, 0.35);
}

/* ---- Layout shell ---- */
.admin-shell {
    display: flex;
    min-height: calc(100vh - 40px);
}

/* The base <main> wrapper centers content in a padded, width-constrained
   container. For the admin panel that wrapper must be full-width with no
   padding so the sidebar and content form a proper side-by-side layout
   (fixes the large empty gap above/beside the admin panel). */
main:has(> .admin-shell) {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
    display: block;
    flex: 1;
}

.admin-sidebar {
    width: 260px;
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    padding: 1.5rem 1rem;
    position: sticky;
    top: 0;
    height: 100vh;
}

.admin-brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0 0.5rem 1.5rem;
    border-bottom: 1px solid var(--line);
}

.admin-brand-logo {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    background: var(--accent-gradient);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.4rem;
    box-shadow: 0 6px 14px rgba(194, 109, 132, 0.25);
}

.admin-brand-text h1 {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--primary-deep);
    letter-spacing: -0.03em;
    line-height: 1.1;
}

.admin-brand-text span {
    font-size: 0.72rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.admin-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 1.25rem 0;
}

.admin-nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0.9rem;
    border: none;
    border-radius: 12px;
    background: transparent;
    color: var(--text);
    font-weight: 600;
    font-size: 0.95rem;
    font-family: inherit;
    width: 100%;
    text-align: left;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.admin-nav-item:hover {
    background: var(--surface-alt);
    transform: translateX(2px);
}

.admin-nav-item.is-active {
    background: var(--primary-soft);
    color: var(--accent-strong);
}

body.dark-mode .admin-nav-item.is-active {
    background: var(--primary-soft);
    color: #ffffff;
}

.admin-nav-icon {
    font-size: 1.1rem;
}

.admin-nav-badge {
    margin-left: auto;
    background: var(--accent);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    min-width: 22px;
    height: 22px;
    border-radius: 999px;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
}

.admin-nav-badge:not(:empty) {
    display: inline-flex;
}

.admin-sidebar-footer {
    border-top: 1px solid var(--line);
    padding-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.admin-back-link {
    padding: 0.6rem 0.9rem;
    border-radius: 10px;
    color: var(--muted);
    font-weight: 600;
    font-size: 0.9rem;
    transition: background 0.2s ease, color 0.2s ease;
}

.admin-back-link:hover {
    background: var(--surface-alt);
    color: var(--text);
}

.admin-logout-btn {
    padding: 0.6rem 0.9rem;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface-alt);
    color: #e5484d;
    font-weight: 700;
    font-size: 0.9rem;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s ease;
}

.admin-logout-btn:hover {
    background: rgba(229, 72, 77, 0.1);
}
/* ---- Main content area ---- */
.admin-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: 1.5rem;
}

.admin-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 0.5rem 1.5rem;
    border-bottom: 1px solid var(--line);
}

.admin-menu-toggle {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--surface-alt);
    color: var(--text);
    /* Hidden on desktop where the sidebar is always visible;
       shown only on mobile via the media query below. */
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    cursor: pointer;
    transition: background 0.2s ease;
}

.admin-menu-toggle:hover {
    background: var(--surface-alt);
}

.admin-topbar-title h2 {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary-deep);
    margin: 0;
}

.admin-topbar-title p {
    font-size: 0.85rem;
    color: var(--muted);
    margin: 0.25rem 0 0;
}

.admin-topbar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.admin-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--surface-alt);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
}

.admin-user-meta strong {
    display: block;
    font-size: 0.9rem;
    color: var(--text);
}

.admin-user-meta span {
    font-size: 0.75rem;
    color: var(--muted);
}

/* ---- View management ---- */
.admin-view {
    display: none;
}

.admin-view.is-active {
    display: block;
}

/* ---- Stats grid ---- */
.admin-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.admin-stat-card {
    background: var(--surface);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 1rem;
    text-align: center;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.admin-stat-card:hover {
    box-shadow: var(--shadow-card-hover);
    transform: translateY(-2px);
}

.admin-stat-icon {
    font-size: 1.6rem;
    display: block;
    margin-bottom: 0.4rem;
}

.admin-stat-info strong {
    display: block;
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--primary-deep);
    margin-bottom: 0.25rem;
}

.admin-stat-info span {
    font-size: 0.78rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* ---- Dashboard panels ---- */
.admin-dash-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.25rem;
}

.admin-panel-card {
    background: var(--surface);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    overflow: hidden;
}

.admin-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--line);
}

.admin-panel-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-deep);
    margin: 0;
}

.admin-link-btn {
    background: transparent;
    border: none;
    color: var(--accent-strong);
    font-weight: 600;
    font-size: 0.85rem;
    padding: 0;
    cursor: pointer;
}

.admin-link-btn:hover {
    color: var(--accent);
    text-decoration: underline;
}

/* ---- Recent blogs list ---- */
.admin-recent-list {
    padding: 1rem 1.25rem;
}

.admin-recent-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--surface-alt);
}

.admin-recent-item:last-child {
    border-bottom: none;
}

.admin-recent-item-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--primary-soft);
    color: var(--accent-strong);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.admin-recent-item-content {
    flex: 1;
}

.admin-recent-item-title {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text);
    margin-bottom: 0.25rem;
}

.admin-recent-item-meta {
    display: flex;
    gap: 0.75rem;
    font-size: 0.7rem;
    color: var(--muted);
}

/* ---- Authors list ---- */
.admin-authors-list {
    padding: 1rem 1.25rem;
}

.admin-author-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--surface-alt);
}

.admin-author-item:last-child {
    border-bottom: none;
}

.admin-author-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--surface-alt);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
}

.admin-author-info h4 {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 0.25rem;
}

.admin-author-info p {
    font-size: 0.7rem;
    color: var(--muted);
    margin: 0;
}

/* ---- Toolbar ---- */
.admin-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    padding: 0 0.5rem 1rem;
    border-bottom: 1px solid var(--line);
}

.admin-search {
    flex: 1 1 220px;
    min-width: 180px;
    padding: 0.7rem 0.9rem;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: 0.9rem;
}

.admin-search:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(194, 109, 132, 0.2);
}

.admin-search::placeholder {
    color: var(--muted);
}

.admin-select {
    padding: 0.7rem 0.9rem;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: 0.9rem;
    min-width: 140px;
}

.admin-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(194, 109, 132, 0.2);
}

/* ---- Tables ---- */
.admin-table-wrap {
    flex: 1;
    overflow: auto;
}

.admin-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.admin-table th,
.admin-table td {
    padding: 0.85rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--surface-alt);
    font-size: 0.88rem;
}

.admin-table th {
    background: var(--surface-alt);
    font-weight: 700;
    color: var(--text);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.04em;
}

.admin-table tr:hover td {
    background: var(--surface-alt);
}

.admin-table td {
    color: var(--text);
}

.admin-table-actions {
    min-width: 100px;
    text-align: center;
}

/* ---- Owner row & badge ---- */
.admin-row-owner td {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.06) 0%, rgba(255, 215, 0, 0.02) 100%);
}

.admin-row-owner:hover td {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.10) 0%, rgba(255, 215, 0, 0.05) 100%);
}

body.dark-mode .admin-row-owner td {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.08) 0%, rgba(255, 215, 0, 0.03) 100%);
}

body.dark-mode .admin-row-owner:hover td {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.14) 0%, rgba(255, 215, 0, 0.07) 100%);
}

.admin-owner-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: linear-gradient(135deg, #f5a623 0%, #f7c948 100%);
    color: #4a3200;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    line-height: 1;
    vertical-align: middle;
    margin-left: 0.35rem;
    white-space: nowrap;
}

body.dark-mode .admin-owner-badge {
    background: linear-gradient(135deg, #f5a623 0%, #f7c948 100%);
    color: #3a2800;
}

/* Locked icon styling */
.admin-locked {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    font-size: 1rem;
    opacity: 0.5;
    cursor: not-allowed;
}

/* Disabled action buttons for locked rows */
.admin-btn-icon:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
}

/* ---- Empty state ---- */
.admin-empty {
    text-align: center;
    color: var(--muted);
    font-style: italic;
    padding: 2rem;
}

/* ---- Loading row ---- */
.admin-loading-row {
    text-align: center;
    color: var(--muted);
    font-style: italic;
    padding: 2rem;
}

/* ---- Responsive ---- */
@media (max-width: 992px) {
    .admin-sidebar {
        width: 220px;
    }
}

.admin-sidebar-overlay {
    display: none;
}

@media (max-width: 768px) {
    .admin-sidebar {
        width: 260px;
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        z-index: 1001;
        /* Start fully off-screen and slide in when .open is applied. */
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: 4px 0 12px rgba(0,0,0,0.15);
    }

    .admin-sidebar.open {
        transform: translateX(0);
    }

    /* Dimmed backdrop behind the open drawer; click to close. */
    .admin-sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        z-index: 1000;
        background: rgba(0, 0, 0, 0.45);
    }

    .admin-sidebar.open ~ .admin-sidebar-overlay {
        display: block;
    }

    .admin-main {
        margin-left: 0;
        padding-top: 4rem;
    }

    .admin-menu-toggle {
        display: flex;
    }
}

/* Header wraps to 2 rows at ≤600 px — match the global main padding. */
@media (max-width: 600px) {
    .admin-main {
        padding-top: 7.5rem;
    }
}

@media (max-width: 480px) {
    /* Sidebar already uses the transform slide-over from the 768px block;
       just make it a bit narrower on very small screens. */
    .admin-sidebar {
        width: 220px;
    }

    .admin-panel-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .admin-link-btn {
        align-self: flex-start;
    }
}
