/* =========================================
   WESTERN ROOTS — BLOG ADMIN PANEL STYLES
   ========================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
    --bg-primary: #0f1117;
    --bg-secondary: #1a1d27;
    --bg-card: #21253a;
    --accent: #004834;
    --accent-light: #006b4f;
    --accent-glow: rgba(0, 72, 52, 0.3);
    --gold: #c9a84c;
    --danger: #e05252;
    --danger-light: #ff6b6b;
    --success: #3ab885;
    --warning: #f0a500;
    --text-primary: #f0f2ff;
    --text-secondary: #8a9bb5;
    --text-muted: #5a6a80;
    --border: rgba(255, 255, 255, 0.07);
    --border-hover: rgba(0, 72, 52, 0.5);
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    --radius: 14px;
    --radius-sm: 8px;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

/* ── LOGIN PAGE ── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at 30% 20%, rgba(0, 72, 52, 0.25) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 80%, rgba(201, 168, 76, 0.08) 0%, transparent 50%),
        var(--bg-primary);
    padding: 20px;
}

.login-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 48px 44px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow), 0 0 60px rgba(0, 72, 52, 0.12);
    animation: fadeSlideUp 0.5s ease;
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo .wr-badge {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    color: #fff;
    border-radius: 50px;
    padding: 8px 20px;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 12px;
}

.login-logo h1 {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text-primary);
}

.login-logo p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.login-error {
    background: rgba(224, 82, 82, 0.15);
    border: 1px solid rgba(224, 82, 82, 0.3);
    color: var(--danger-light);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    margin-bottom: 20px;
    display: none;
}

.login-error.show {
    display: block;
}

/* ── FORM ELEMENTS ── */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    transition: var(--transition);
    outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--accent-light);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-group textarea {
    resize: vertical;
    min-height: 140px;
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-muted);
}

.form-group select option {
    background: var(--bg-card);
}

/* ── BUTTONS ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    border: none;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    color: #fff;
    box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px var(--accent-glow);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    border-color: var(--accent-light);
    color: var(--text-primary);
}

.btn-danger {
    background: rgba(224, 82, 82, 0.15);
    color: var(--danger-light);
    border: 1px solid rgba(224, 82, 82, 0.25);
}

.btn-danger:hover {
    background: rgba(224, 82, 82, 0.28);
    transform: translateY(-1px);
}

.btn-edit {
    background: rgba(0, 107, 79, 0.18);
    color: var(--success);
    border: 1px solid rgba(58, 184, 133, 0.25);
}

.btn-edit:hover {
    background: rgba(0, 107, 79, 0.3);
    transform: translateY(-1px);
}

.btn-sm {
    padding: 7px 14px;
    font-size: 0.82rem;
}

.btn-full {
    width: 100%;
    justify-content: center;
}

/* ── ADMIN LAYOUT ── */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
}

.sidebar-logo {
    padding: 28px 24px;
    border-bottom: 1px solid var(--border);
}

.sidebar-logo .brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}

.sidebar-logo .brand-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.sidebar-logo .brand-name {
    font-weight: 800;
    font-size: 1rem;
    color: var(--text-primary);
    line-height: 1.2;
}

.sidebar-logo .brand-sub {
    font-size: 0.72rem;
    color: var(--accent-light);
    font-weight: 500;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.sidebar-nav {
    padding: 24px 16px;
    flex: 1;
}

.nav-section-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 1.5px;
    text-transform: uppercase;
    padding: 0 8px;
    margin-bottom: 8px;
    margin-top: 20px;
}

.nav-section-label:first-child {
    margin-top: 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 4px;
    text-decoration: none;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.nav-item.active {
    background: linear-gradient(135deg, var(--accent-glow), rgba(0, 72, 52, 0.15));
    color: #fff;
    border: 1px solid rgba(0, 107, 79, 0.3);
}

.nav-item .nav-icon {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 20px 16px;
    border-top: 1px solid var(--border);
}

.admin-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    margin-bottom: 12px;
}

.admin-avatar {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--accent), var(--gold));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
}

.admin-name {
    font-size: 0.875rem;
    font-weight: 600;
}

.admin-role {
    font-size: 0.75rem;
    color: var(--accent-light);
    font-weight: 500;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 260px;
    min-height: 100vh;
    background: var(--bg-primary);
}

/* Top Bar */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 32px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-title h2 {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--text-primary);
}

.topbar-title p {
    font-size: 0.82rem;
    color: var(--text-secondary);
}

/* Stats Row */
.stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    padding: 28px 32px 0;
}

.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: var(--transition);
}

.stat-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.stat-icon.green {
    background: rgba(0, 72, 52, 0.25);
}

.stat-icon.gold {
    background: rgba(201, 168, 76, 0.18);
}

.stat-icon.blue {
    background: rgba(90, 130, 200, 0.18);
}

.stat-num {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
    color: var(--text-primary);
}

.stat-label {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Content Area */
.content-area {
    padding: 28px 32px;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.section-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* Blog Table */
.table-wrapper {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.blog-table {
    width: 100%;
    border-collapse: collapse;
}

.blog-table thead th {
    padding: 14px 20px;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.02);
}

.blog-table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: var(--transition);
}

.blog-table tbody tr:last-child {
    border-bottom: none;
}

.blog-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.025);
}

.blog-table td {
    padding: 16px 20px;
    vertical-align: middle;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.blog-table td.title-cell {
    color: var(--text-primary);
    font-weight: 600;
    max-width: 280px;
}

.blog-table td.title-cell .blog-thumbnail {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    object-fit: cover;
    margin-right: 12px;
    vertical-align: middle;
    border: 1px solid var(--border);
}

.blog-table td.title-cell .title-text {
    display: inline-block;
    vertical-align: middle;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.category-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
    background: rgba(0, 72, 52, 0.2);
    color: var(--success);
    border: 1px solid rgba(58, 184, 133, 0.2);
}

.empty-state {
    padding: 60px 20px;
    text-align: center;
}

.empty-state .empty-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* ── MODAL ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(6px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: all;
}

.modal-box {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%;
    max-width: 900px; /* Wider for block editor */
    max-height: 95vh;
    overflow-y: auto;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
    transform: translateY(24px) scale(0.97);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.open .modal-box {
    transform: translateY(0) scale(1);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 28px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
}

.modal-close {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
    transition: var(--transition);
}

.modal-close:hover {
    background: rgba(224, 82, 82, 0.2);
    border-color: rgba(224, 82, 82, 0.3);
    color: var(--danger-light);
}

.modal-body {
    padding: 28px;
}

.modal-footer {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    padding: 20px 28px;
    border-top: 1px solid var(--border);
}

/* Delete Confirm Modal */
.confirm-modal .modal-box {
    max-width: 420px;
}

.confirm-icon {
    font-size: 3rem;
    text-align: center;
    margin-bottom: 16px;
}

.confirm-modal .modal-body {
    text-align: center;
}

.confirm-modal .modal-body h4 {
    font-size: 1.1rem;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.confirm-modal .modal-body p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ── BLOCK-BASED EDITOR STYLES ── */
.main-form-group {
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.blocks-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.blocks-header h4 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.blocks-container {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.content-block-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    position: relative;
    transition: var(--transition);
}

.content-block-item:hover {
    border-color: var(--border-hover);
    background: rgba(255, 255, 255, 0.035);
}

.block-ctrl {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.block-num {
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--gold);
    background: rgba(201, 168, 76, 0.1);
    padding: 2px 10px;
    border-radius: 50px;
}

.btn-remove-block {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(224, 82, 82, 0.1);
    color: var(--danger-light);
    border: 1px solid rgba(224, 82, 82, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    cursor: pointer;
    transition: var(--transition);
}

.btn-remove-block:hover {
    background: var(--danger);
    color: #fff;
    transform: rotate(90deg);
}

.block-grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1.5fr; /* Heading, Image, Content */
    gap: 20px;
}

.block-col label {
    display: block;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.block-col input, 
.block-col textarea {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    color: var(--text-primary);
    font-size: 0.88rem;
}

.block-image-picker {
    display: flex;
    gap: 8px;
}

.file-mini-btn {
    position: relative;
    width: 40px;
    height: 40px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

.file-mini-btn input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.block-preview-mini {
    margin-top: 10px;
    width: 100%;
    height: 80px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    display: none;
    border: 1px solid var(--border);
}

.block-preview-mini.show {
    display: block;
}

.block-preview-mini img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

@media (max-width: 800px) {
    .block-grid-3 {
        grid-template-columns: 1fr;
    }
}

/* Toast */
.toast {
    position: fixed;
    bottom: 28px;
    right: 28px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 3px solid var(--success);
    border-radius: var(--radius-sm);
    padding: 14px 20px;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-primary);
    box-shadow: var(--shadow);
    z-index: 999;
    display: flex;
    align-items: center;
    gap: 10px;
    transform: translateY(80px);
    opacity: 0;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast.error {
    border-left-color: var(--danger);
}

/* Animations */
@keyframes fadeSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Responsive */
@media (max-width: 900px) {
    .sidebar {
        width: 220px;
    }

    .main-content {
        margin-left: 220px;
    }

    .stats-row {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 700px) {
    .admin-layout {
        flex-direction: column;
    }

    .sidebar {
        position: relative;
        width: 100%;
        height: auto;
    }

    .main-content {
        margin-left: 0;
    }

    .stats-row {
        grid-template-columns: 1fr;
        padding: 16px;
    }

    .content-area {
        padding: 16px;
    }

    .topbar {
        padding: 16px;
    }
}