/* ==========================================================================
   MATAKIN Portal - Kongmiao Design System (孔庙 - Confucian Temple Aesthetic)
   Scenic Temple Background, High-Contrast Frosted Glass, Imperial Crimson
   ========================================================================== */

/* ─── Design Tokens (Light High-Contrast) ────────────────────────────────── */
:root {
    /* Brand & Imperial Accents */
    --primary: #be123c;
    --primary-hover: #9f1239;
    --primary-light: rgba(190, 18, 60, 0.08);
    --primary-glow: rgba(190, 18, 60, 0.18);
    --primary-gradient: linear-gradient(135deg, #e11d48 0%, #be123c 100%);
    --gold: #d97706;
    --gold-light: #fef3c7;
    --gold-glow: rgba(217, 119, 6, 0.20);
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
    --purple: #8b5cf6;

    /* Light Surface Palette */
    --light-bg: #f8fafc;
    --card-bg: rgba(255, 255, 255, 0.94);
    --card-glass: rgba(255, 255, 255, 0.90);
    --sidebar-bg: rgba(255, 255, 255, 0.92);
    --sidebar-text: #1e293b;
    --sidebar-accent: #be123c;
    --topbar-bg: rgba(255, 255, 255, 0.90);

    /* Borders & Dividers */
    --border-color: rgba(226, 232, 240, 0.85);
    --border-strong: #cbd5e1;
    --card-border: rgba(255, 255, 255, 0.90);
    --divider: #f1f5f9;

    /* Radii */
    --card-radius: 16px;
    --card-radius-sm: 12px;
    --input-radius: 12px;
    --btn-radius: 50px;
    --img-radius: 14px;

    /* Shadows */
    --card-shadow: 0 4px 20px rgba(15, 23, 42, 0.05), 0 1px 3px rgba(15, 23, 42, 0.03);
    --card-shadow-hover: 0 12px 32px rgba(15, 23, 42, 0.09), 0 0 15px rgba(190, 18, 60, 0.08);
    --input-shadow-focus: 0 0 0 3px rgba(190, 18, 60, 0.15);
    --btn-shadow: 0 2px 10px rgba(190, 18, 60, 0.20);
    --btn-shadow-hover: 0 6px 18px rgba(190, 18, 60, 0.32);

    /* Sharp Typography */
    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;
    --text-faint: #94a3b8;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
}

/* ─── Themes ─────────────────────────────────────────────────────────────── */
[data-theme="ocean"] {
    --primary: #0891b2;
    --primary-hover: #0e7490;
    --primary-gradient: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
    --primary-glow: rgba(8, 145, 178, 0.20);
    --sidebar-accent: #0891b2;
}

[data-theme="sunset"] {
    --primary: #e11d48;
    --primary-hover: #be123c;
    --primary-gradient: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%);
    --primary-glow: rgba(225, 29, 72, 0.20);
    --sidebar-accent: #e11d48;
}

[data-theme="royal"] {
    --primary: #7c3aed;
    --primary-hover: #6d28d9;
    --primary-gradient: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    --primary-glow: rgba(124, 58, 237, 0.20);
    --sidebar-accent: #7c3aed;
}

[data-theme="slate"] {
    --primary: #475569;
    --primary-hover: #334155;
    --primary-gradient: linear-gradient(135deg, #64748b 0%, #475569 100%);
    --primary-glow: rgba(71, 85, 105, 0.20);
    --sidebar-accent: #475569;
}

/* ─── Base & Scenic Dacheng Temple Background ─────────────────────────────── */
body.portal-body {
    background-color: #f1f5f9;
    margin: 0;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    position: relative;
}

/* Full Dacheng Temple Image (Matching Login Page) */
.portal-scenic-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: url('/img/temple_bg.jpg') center center / cover no-repeat;
    z-index: 0;
    filter: saturate(1.05) brightness(0.95);
    pointer-events: none;
}

/* Soft luminous glass veil to keep background visible yet cards readable */
.portal-scenic-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, rgba(248, 250, 252, 0.55) 0%, rgba(241, 245, 249, 0.72) 100%);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 1;
    pointer-events: none;
}

.portal-nature-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
}

/* ─── Layout: Wrapper & Sidebar ──────────────────────────────────────────── */
.portal-wrapper {
    position: relative;
    display: flex;
    min-height: 100vh;
}

/* Crisp Frosted Glass Sidebar */
.portal-sidebar {
    background: var(--sidebar-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid rgba(226, 232, 240, 0.90);
    box-shadow: 4px 0 25px rgba(15, 23, 42, 0.05);
    display: flex;
    flex-direction: column;
}

/* Bootstrap Offcanvas Mobile Sidebar & Modal Stacking Context Fix */
.offcanvas-backdrop {
    z-index: 1040 !important;
}

@media (max-width: 767.98px) {
    .portal-sidebar,
    .portal-sidebar.offcanvas-md {
        z-index: 1050 !important;
        width: 285px;
    }
}

.modal {
    z-index: 1065 !important;
}
.modal-backdrop {
    z-index: 1060 !important;
}
.modal-dialog {
    z-index: 1070 !important;
}

@media (min-width: 768px) {
    .portal-sidebar {
        width: 275px;
        height: 100vh;
        position: sticky;
        top: 0;
        z-index: 100;
    }
}

@media (max-width: 767.98px) {
    .portal-sidebar {
        width: 285px;
    }
}

.sidebar-header {
    padding: 1.5rem 1.25rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.70);
}

.sidebar-brand-logo {
    width: 64px;
    height: auto;
    filter: drop-shadow(0 4px 12px rgba(217, 119, 6, 0.35));
    transition: transform var(--transition-normal);
}

.sidebar-brand-logo:hover {
    transform: scale(1.05);
}

.sidebar-brand-title {
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: 0.10em;
    color: #0f172a;
    margin-top: 0.4rem;
}

.sidebar-brand-badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 0.2rem 0.6rem;
    background: rgba(190, 18, 60, 0.08);
    border: 1px solid rgba(190, 18, 60, 0.25);
    color: #be123c;
    border-radius: 20px;
    margin-top: 0.25rem;
}

.sidebar-nav {
    list-style: none;
    padding: 1rem 0.85rem;
    margin: 0;
    flex: 1;
    overflow-y: auto;
}

.sidebar-nav .nav-item {
    margin-bottom: 0.3rem;
}

.portal-sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.7rem 1rem;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: var(--input-radius);
    font-weight: 600;
    font-size: 0.90rem;
    border: 1px solid transparent;
    transition: all var(--transition-fast);
}

.portal-sidebar .nav-link i {
    font-size: 1.15rem;
    color: #64748b;
    transition: all var(--transition-fast);
}

.portal-sidebar .nav-link:hover {
    background: rgba(241, 245, 249, 0.90);
    color: var(--primary);
    border-color: rgba(226, 232, 240, 0.8);
    transform: translateX(2px);
}

.portal-sidebar .nav-link:hover i {
    color: var(--primary);
    transform: scale(1.1);
}

.portal-sidebar .nav-link.active {
    background: var(--primary-gradient);
    color: #ffffff !important;
    font-weight: 700;
    box-shadow: 0 4px 15px var(--primary-glow);
}

.portal-sidebar .nav-link.active i {
    color: #ffffff !important;
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.6);
}

/* ─── Layout: Topbar ─────────────────────────────────────────────────────── */
.portal-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    position: relative;
    z-index: 10;
}

.portal-topbar {
    height: 72px;
    background: var(--topbar-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(226, 232, 240, 0.90);
    box-shadow: 0 2px 15px rgba(15, 23, 42, 0.03);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 90;
}

.search-box {
    display: flex;
    align-items: center;
    background: #ffffff;
    border: 1px solid var(--border-strong);
    border-radius: 30px;
    padding: 0.45rem 1.1rem;
    width: 280px;
    transition: all var(--transition-normal);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.search-box i {
    color: #64748b;
    margin-right: 0.5rem;
    font-size: 1.1rem;
}

.search-box input {
    background: transparent;
    border: none;
    outline: none;
    color: #0f172a;
    font-size: 0.88rem;
    font-weight: 500;
    width: 100%;
}

.search-box input::placeholder {
    color: #94a3b8;
}

.search-box:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
    width: 320px;
}

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

/* User Profile Chip (Light) */
.portal-topbar .user-profile {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 30px;
    padding: 0.35rem 0.85rem 0.35rem 0.4rem;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
    transition: all var(--transition-normal);
}

.portal-topbar .user-profile:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(190, 18, 60, 0.12);
}

.portal-topbar .user-name {
    color: #0f172a !important;
    font-weight: 700;
}

.portal-topbar .user-role {
    color: #64748b !important;
    font-weight: 500;
}

/* ─── Portal Main Content & Cards ────────────────────────────────────────── */
.portal-content {
    flex: 1;
    padding: 2rem;
    position: relative;
    z-index: 10;
}

/* High-Contrast Frosted Glass Cards */
.glass-card,
.portal-body .card {
    background: var(--card-bg) !important;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(226, 232, 240, 0.95) !important;
    border-radius: var(--card-radius) !important;
    box-shadow: var(--card-shadow) !important;
    color: var(--text-primary) !important;
    transition: all var(--transition-normal);
}

.glass-card:hover,
.portal-body .card:hover {
    box-shadow: var(--card-shadow-hover) !important;
    border-color: rgba(190, 18, 60, 0.30) !important;
}

.portal-body .card-header {
    background: rgba(248, 250, 252, 0.90) !important;
    border-bottom: 1px solid var(--border-color) !important;
    padding: 1.25rem 1.5rem;
    color: #0f172a !important;
    font-weight: 700;
}

.portal-body .card-footer {
    background: rgba(248, 250, 252, 0.80) !important;
    border-top: 1px solid var(--border-color) !important;
    padding: 1rem 1.5rem;
}

/* ─── Responsive Feed Card Media & Image Proportions ──────────────────────── */
.feed-card-media {
    position: relative;
    width: 100%;
    height: 220px;
    overflow: hidden;
    background-color: #0f172a;
}

@media (max-width: 767.98px) {
    .feed-card-media {
        height: 260px !important; /* Enhanced proportional height on mobile */
    }
}

@media (min-width: 768px) and (max-width: 991.98px) {
    .feed-card-media {
        height: 220px;
    }
}

@media (min-width: 992px) {
    .feed-card-media {
        height: 210px;
    }
}

.feed-card-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.35s ease;
}

.feed-card:hover .feed-card-media img {
    transform: scale(1.04);
}

/* ─── Global Feed Badge Styles ────────────────────────────────────────────── */
.feed-badge-galeri {
    background-color: #16a34a !important;
    color: #ffffff !important;
    border: 1px solid #16a34a !important;
    box-shadow: 0 4px 10px rgba(22, 163, 74, 0.25) !important;
}

.feed-badge-event {
    background-color: #dc2626 !important;
    color: #ffffff !important;
    border: 1px solid #dc2626 !important;
    box-shadow: 0 4px 10px rgba(220, 38, 38, 0.25) !important;
}

.feed-badge-berita {
    background-color: #d97706 !important;
    color: #ffffff !important;
    border: 1px solid #d97706 !important;
    box-shadow: 0 4px 10px rgba(217, 119, 6, 0.25) !important;
}

.feed-badge-dokumen {
    background-color: #2563eb !important;
    color: #ffffff !important;
    border: 1px solid #2563eb !important;
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.25) !important;
}

.feed-badge-lagu {
    background-color: #7c3aed !important;
    color: #ffffff !important;
    border: 1px solid #7c3aed !important;
    box-shadow: 0 4px 10px rgba(124, 58, 237, 0.25) !important;
}

/* ─── Global Feed Filter Button Styles ────────────────────────────────────── */
.feed-filter-btn {
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid transparent;
}

.feed-filter-btn[data-filter="all"] {
    background-color: #f1f5f9;
    color: #475569;
    border-color: #cbd5e1;
}

.feed-filter-btn[data-filter="all"].active {
    background-color: #475569;
    color: #ffffff;
    border-color: #475569;
    box-shadow: 0 4px 10px rgba(71, 85, 105, 0.2);
}

.feed-filter-btn[data-filter="galeri"] {
    background-color: #f0fdf4;
    color: #16a34a;
    border-color: #bbf7d0;
}

.feed-filter-btn[data-filter="galeri"].active {
    background-color: #16a34a;
    color: #ffffff;
    border-color: #16a34a;
    box-shadow: 0 4px 10px rgba(22, 163, 74, 0.25);
}

.feed-filter-btn[data-filter="event"] {
    background-color: #fef2f2;
    color: #dc2626;
    border-color: #fecaca;
}

.feed-filter-btn[data-filter="event"].active {
    background-color: #dc2626;
    color: #ffffff;
    border-color: #dc2626;
    box-shadow: 0 4px 10px rgba(220, 38, 38, 0.25);
}

.feed-filter-btn[data-filter="berita"] {
    background-color: #fffbeb;
    color: #d97706;
    border-color: #fde68a;
}

.feed-filter-btn[data-filter="berita"].active {
    background-color: #d97706;
    color: #ffffff;
    border-color: #d97706;
    box-shadow: 0 4px 10px rgba(217, 119, 6, 0.25);
}

.feed-filter-btn[data-filter="dokumen"] {
    background-color: #eff6ff;
    color: #2563eb;
    border-color: #bfdbfe;
}

.feed-filter-btn[data-filter="dokumen"].active {
    background-color: #2563eb;
    color: #ffffff;
    border-color: #2563eb;
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.25);
}

.feed-filter-btn[data-filter="lagu"] {
    background-color: #f5f3ff;
    color: #7c3aed;
    border-color: #ddd6fe;
}

.feed-filter-btn[data-filter="lagu"].active {
    background-color: #7c3aed;
    color: #ffffff;
    border-color: #7c3aed;
    box-shadow: 0 4px 10px rgba(124, 58, 237, 0.25);
}

/* ─── Global Toast Container Positioning ─────────────────────────────────── */
.toast-container {
    position: fixed !important;
    top: 90px !important; /* Di bawah navbar 72px yang sticky */
    right: 24px !important;
    z-index: 100000 !important; /* Di atas modal backdrop (1050), modal dialog (1055), dan navbar (1000) */
    pointer-events: none !important;
}

.toast-container > * {
    pointer-events: auto !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25) !important;
    border-radius: 12px !important;
}

/* Typography Clarity */
.portal-body h1, .portal-body h2, .portal-body h3, .portal-body h4, .portal-body h5, .portal-body h6 {
    color: #0f172a;
    font-weight: 700;
}

.portal-body p, .portal-body span, .portal-body td, .portal-body th {
    color: var(--text-primary);
}

.portal-body .text-muted {
    color: #64748b !important;
}

/* Primary Button */
.btn-primary {
    background: var(--primary-gradient) !important;
    border: none !important;
    box-shadow: var(--btn-shadow) !important;
    color: #ffffff !important;
    font-weight: 600;
    transition: all var(--transition-normal);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%) !important;
    box-shadow: var(--btn-shadow-hover) !important;
    transform: translateY(-1px);
}

/* Form Controls */
.portal-body .form-control,
.portal-body .form-select {
    background-color: #ffffff;
    border: 1px solid var(--border-strong);
    color: #0f172a;
    border-radius: var(--input-radius);
    padding: 0.6rem 1rem;
    font-size: 0.92rem;
}

.portal-body .form-control:focus,
.portal-body .form-select:focus {
    border-color: var(--primary);
    box-shadow: var(--input-shadow-focus);
}

/* Tables */
.portal-body .table {
    color: #0f172a !important;
}

.portal-body .table th {
    background: #f8fafc !important;
    color: #334155 !important;
    font-weight: 700;
    border-bottom: 2px solid var(--border-color);
}

.portal-body .table td {
    color: #1e293b !important;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

/* Interactive Ruby Butterfly on Portal (Bottom-Right) - Natural Ambient Watermark */
.portal-butterfly-badge {
    position: fixed;
    bottom: 18px;
    right: 22px;
    z-index: 999;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.35rem 0.6rem;
    background: transparent;
    border: none;
    box-shadow: none;
    color: rgba(190, 18, 60, 0.75);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    opacity: 0.65;
    transition: all var(--transition-normal);
    user-select: none;
}

.portal-butterfly-badge:hover {
    opacity: 1;
    color: #be123c;
    transform: scale(1.05);
}

.portal-butterfly-badge i.ti-butterfly {
    color: #e11d48;
    font-size: 1.25rem;
    animation: butterflyFlutter 1.8s ease-in-out infinite alternate;
    filter: drop-shadow(0 2px 6px rgba(225, 29, 72, 0.35));
}

@keyframes butterflyFlutter {
    0% { transform: scale(1) rotate(-5deg); }
    100% { transform: scale(1.15) rotate(5deg); }
}

/* Theme picker */
.theme-picker {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border-color);
}

.theme-swatches {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.theme-swatch {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
}

.theme-swatch:hover {
    transform: scale(1.15);
}

.theme-swatch.active {
    border-color: #0f172a;
    box-shadow: 0 0 0 2px var(--primary);
}

.theme-swatch[data-theme="default"] { background: #be123c; }
.theme-swatch[data-theme="ocean"] { background: #0891b2; }
.theme-swatch[data-theme="sunset"] { background: #e11d48; }
.theme-swatch[data-theme="royal"] { background: #7c3aed; }
.theme-swatch[data-theme="slate"] { background: #475569; }

/* ─── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .portal-topbar {
        padding: 0 1rem;
    }

    .portal-content {
        padding: 1rem;
    }

    .search-box {
        display: none;
    }

    .portal-butterfly-badge {
        bottom: 15px;
        right: 15px;
        padding: 0.4rem 0.75rem;
        font-size: 0.72rem;
    }
}

/* ─── SweetAlert2 & Toast Modal/Navbar Stacking Fix ───────────────────────── */
.swal2-container {
    z-index: 99999 !important;
}

.toast-container,
.position-fixed.top-0.end-0,
div[class*="toast-container"] {
    position: fixed !important;
    top: calc(72px + 1.25rem) !important;
    right: 1.5rem !important;
    z-index: 99999 !important;
    pointer-events: none;
}

.toast-container .toast,
.toast-container .alert,
.toast-container > *,
.position-fixed.top-0.end-0 .toast {
    pointer-events: auto;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.18) !important;
    border-radius: 12px !important;
}