/* ============================================
   ADMIN PANEL — BASE SETTINGS
   ============================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

body {
    margin: 0;
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #0f0f14;
    color: #e8e8ed;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* Subtle animated gradient mesh background */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse at 20% 20%, rgba(77, 120, 255, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(140, 80, 255, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(60, 200, 220, 0.04) 0%, transparent 60%);
    z-index: -1;
    pointer-events: none;
}

.overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: transparent;
    z-index: -2;
}

/* ============================================
   UTILITIES
   ============================================ */
.container { max-width: 1360px; margin: 32px auto; padding: 0 24px; }
.login-container { max-width: 420px; margin-top: 140px; }
.text-center { text-align: center; }
.hidden { display: none !important; }
.opacity-50 { opacity: 0.5; }
.helper-text { font-size: 0.85rem; opacity: 0.6; margin-bottom: 18px; line-height: 1.5; }

body.no-scroll {
    overflow: hidden;
}

/* ============================================
   GLASS PANEL
   ============================================ */
.glass-panel {
    background: rgba(255, 255, 255, 0.035);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 16px;
    padding: 28px;
    box-shadow:
        0 4px 24px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* ============================================
   TWO-COLUMN ADMIN LAYOUT (Desktop)
   ============================================ */
.admin-main-grid {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 24px;
    align-items: start;
}

.admin-left,
.admin-right {
    min-width: 0;
}

/* ============================================
   HEADER & TABS
   ============================================ */
.header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.header-row h2 {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #fff;
    margin: 0;
}

.header-row h2 i {
    margin-right: 10px;
    color: rgba(100, 160, 255, 0.8);
}

.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
}

.tab-btn {
    flex: 1;
    padding: 14px 18px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);
    color: rgba(255, 255, 255, 0.45);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    border-radius: 10px;
    transition: all 0.25s ease;
    text-transform: uppercase;
    letter-spacing: 1.2px;
}

.tab-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.7);
}

.tab-btn.active {
    background: rgba(100, 160, 255, 0.12);
    color: #6da8ff;
    border-color: rgba(100, 160, 255, 0.3);
    box-shadow: 0 0 20px rgba(100, 160, 255, 0.08);
}

/* ============================================
   FORMS — Inputs, Selects, Textareas
   ============================================ */
.form-row { display: flex; gap: 10px; }

input, select, textarea {
    width: 100%;
    padding: 11px 14px;
    margin-bottom: 12px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #e0e0e8;
    border-radius: 8px;
    box-sizing: border-box;
    font-family: inherit;
    font-size: 0.88rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input[type="file"] {
    padding: 9px 12px;
    font-size: 0.82rem;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: rgba(100, 160, 255, 0.5);
    box-shadow: 0 0 0 3px rgba(100, 160, 255, 0.08);
}

input::placeholder, textarea::placeholder {
    color: rgba(255, 255, 255, 0.28);
}

summary { cursor: pointer; margin-bottom: 15px; color: #6da8ff; font-weight: 600; }
hr { border-color: rgba(255, 255, 255, 0.06); margin: 20px 0; }

/* ============================================
   BUTTONS
   ============================================ */
.btn-primary {
    width: 100%;
    padding: 12px 18px;
    background: linear-gradient(135deg, #4d8eff 0%, #6da8ff 100%);
    color: #fff;
    border: none;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s ease;
    letter-spacing: 0.5px;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #5e9aff 0%, #82baff 100%);
    box-shadow: 0 4px 16px rgba(77, 142, 255, 0.25);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
}

.logout-btn {
    background: none;
    border: 1px solid rgba(255, 80, 80, 0.4);
    color: rgba(255, 100, 100, 0.9);
    padding: 7px 18px;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.logout-btn:hover {
    background: rgba(255, 80, 80, 0.1);
    border-color: rgba(255, 80, 80, 0.6);
}

.cancel-btn {
    width: 100%;
    margin-top: 8px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
    padding: 10px;
    cursor: pointer;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.84rem;
    transition: all 0.2s ease;
}

.cancel-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* ============================================
   SEARCH BAR & LIST TOOLBAR
   ============================================ */
.search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 18px;
}

#filterSelect { width: 200px; }

.list-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    gap: 12px;
}

.list-toolbar h3 {
    margin: 0;
    font-size: 0.92rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    color: rgba(255, 255, 255, 0.7);
    text-transform: uppercase;
}

.btn-add {
    width: auto;
    padding: 9px 16px;
    white-space: nowrap;
    font-size: 0.82rem;
}

/* ============================================
   EDITOR PANEL  (Right Column — Desktop)
   ============================================ */
.editor-panel,
.editor-placeholder {
    background: rgba(255, 255, 255, 0.04);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 20px;
}

.editor-panel {
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 20px;
    transition: opacity 0.2s ease;
}

.editor-backdrop {
    display: none;
}

.editor-body {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.editor-header h3 {
    margin: 0;
    color: #fff;
    font-size: 0.95rem;
    font-weight: 600;
}

.panel-close {
    width: 28px;
    height: 28px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 50%;
    background: transparent;
    color: rgba(255, 255, 255, 0.6);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.panel-close:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.editor-placeholder {
    color: rgba(255, 255, 255, 0.4);
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 0.88rem;
    line-height: 1.6;
}

/* ============================================
   LIST ITEMS
   ============================================ */
.list-scroll {
    max-height: 560px;
    overflow-y: auto;
    padding-right: 6px;
}

/* Custom scrollbar */
.list-scroll::-webkit-scrollbar {
    width: 5px;
}

.list-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.list-scroll::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 10px;
}

.list-scroll::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

.load-more-admin {
    margin-top: 12px;
}

.item-card {
    background: rgba(255, 255, 255, 0.025);
    border-left: 3px solid rgba(100, 160, 255, 0.5);
    padding: 14px 16px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.item-card:hover {
    background: rgba(255, 255, 255, 0.05);
    border-left-color: #6da8ff;
}

.item-tag {
    display: inline-block;
    background: linear-gradient(135deg, rgba(100, 160, 255, 0.2), rgba(100, 160, 255, 0.1));
    color: #8ac0ff;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.65rem;
    margin-right: 8px;
    font-weight: 700;
    letter-spacing: 0.5px;
    border: 1px solid rgba(100, 160, 255, 0.15);
}

.item-actions button {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.4);
    cursor: pointer;
    font-size: 1rem;
    margin-left: 8px;
    padding: 4px;
    transition: all 0.2s ease;
    border-radius: 4px;
}

.item-actions button:hover {
    transform: scale(1.15);
}

.edit-btn:hover { color: #ffd166; background: rgba(255, 209, 102, 0.1); }
.delete-btn:hover { color: #ff6b6b; background: rgba(255, 107, 107, 0.1); }


/* ============================================
   MOBILE POPUP OVERLAY  (≤ 980px)
   ============================================ */
@media (max-width: 980px) {
    .container {
        margin: 20px auto;
        padding: 0 14px;
    }

    .glass-panel {
        padding: 18px;
        border-radius: 14px;
    }

    /* Stack to single column on mobile */
    .admin-main-grid {
        display: flex;
        flex-direction: column;
        gap: 0;
    }

    .admin-left {
        width: 100%;
    }

    /* The right column becomes a fixed overlay container on mobile */
    .admin-right {
        position: fixed;
        inset: 0;
        z-index: 1000;
        pointer-events: none;
        display: flex;
        align-items: flex-start; /* Changed from flex-end to flex-start */
        justify-content: center;
    }

    /* Backdrop overlay for mobile popup */
    .admin-right::before {
        content: '';
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.6);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        opacity: 0;
        transition: opacity 0.3s ease;
        pointer-events: none;
        z-index: -1;
    }

    .admin-right.popup-active {
        pointer-events: auto;
    }

    .admin-right.popup-active::before {
        opacity: 1;
        pointer-events: auto;
    }

    /* Hide placeholder entirely on mobile */
    .editor-placeholder {
        display: none !important;
    }

    /* The editor panel becomes a top-sheet popup */
    .editor-panel {
        position: relative !important;
        top: auto !important;
        width: 100%;
        max-width: 520px;
        max-height: 85vh;
        overflow-y: auto;
        overscroll-behavior: contain;
        background: rgba(22, 22, 30, 0.97);
        backdrop-filter: blur(30px);
        -webkit-backdrop-filter: blur(30px);
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 0 0 20px 20px; /* Rounded bottom corners */
        padding: 0;
        box-shadow:
            0 8px 40px rgba(0, 0, 0, 0.5),
            inset 0 -1px 0 rgba(255, 255, 255, 0.08); /* Adjusted inner shadow */
        transform: translateY(-100%); /* Slide down from top */
        transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
        pointer-events: auto;
    }

    .editor-panel.mobile-open {
        transform: translateY(0);
    }

    /* Visual handle indicator at the bottom now */
    .editor-panel.mobile-open::after {
        content: '';
        display: block;
        width: 36px;
        height: 4px;
        background: rgba(255, 255, 255, 0.2);
        border-radius: 4px;
        margin: 0 auto 12px;
    }

    .editor-panel .editor-header {
        position: sticky;
        top: 0;
        z-index: 2;
        padding: 16px 20px 12px;
        margin-bottom: 0;
        background: rgba(22, 22, 30, 0.98);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border-bottom: 1px solid rgba(255, 255, 255, 0.06);
        border-radius: 0; /* Header doesn't need top rounding if at top */
    }

    .editor-panel .editor-body {
        padding: 16px 20px 28px;
    }

    .editor-panel input,
    .editor-panel select,
    .editor-panel textarea {
        margin-bottom: 12px;
        font-size: 16px; /* Prevents iOS zoom on focus */
    }

    /* Custom scrollbar for the popup */
    .editor-panel::-webkit-scrollbar {
        width: 4px;
    }

    .editor-panel::-webkit-scrollbar-track {
        background: transparent;
    }

    .editor-panel::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.15);
        border-radius: 10px;
    }

    .list-scroll {
        max-height: none;
        padding-right: 0;
    }

    .search-bar {
        flex-direction: column;
        gap: 8px;
        margin-bottom: 14px;
    }

    #searchInput,
    #filterSelect {
        width: 100%;
    }

    .list-toolbar {
        flex-direction: row;
        align-items: center;
        gap: 10px;
    }

    .btn-add {
        width: auto;
        flex-shrink: 0;
    }

    .item-card {
        padding: 12px 14px;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .item-actions {
        width: 100%;
        display: flex;
        justify-content: flex-end;
    }
}

@media (max-width: 560px) {
    .tabs {
        flex-direction: column;
        gap: 6px;
    }

    .tab-btn {
        padding: 12px;
        font-size: 0.84rem;
    }

    .header-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .list-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .btn-add {
        width: 100%;
    }
}

/* ============================================
   LOGIN SCREEN POLISH
   ============================================ */
.login-container .glass-panel {
    padding: 40px 32px;
}

.login-container h2 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.login-container .btn-primary {
    margin-top: 6px;
    padding: 14px;
    font-size: 0.9rem;
    letter-spacing: 1px;
}