/* ============================================
   SI-ABANG | Custom Styles (Extracted from index.html)
   Fase 2 Optimization: Cacheable External CSS
   ============================================ */

/* --- Draggable Dashboard Cards --- */
.pro-card.dragging { opacity: 0.5; border: 2px dashed #3b82f6; cursor: grabbing !important; }
.pro-card.cursor-grab { cursor: grab; }
.pro-card.cursor-grab:active { cursor: grabbing; }

/* Dashboard Sidebar & Navigation */
.dash-nav-btn {
    color: #94a3b8;
    border: 1px solid transparent;
}
.dash-nav-btn:hover {
    color: #f1f5f9;
}
.dash-nav-btn.active {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
    color: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
.dash-nav-btn.active div {
    background: var(--primary) !important;
    color: white !important;
    box-shadow: 0 0 15px rgba(225, 29, 72, 0.3);
}

.dash-section {
    animation: fadeIn 0.4s ease-out;
}
.dash-section.hidden {
    display: none !important;
}

/* --- Root Variables & Typography Scale --- */
:root {
    --primary: #E11D48;
    /* Rose 600 */
    --primary-hover: #BE123C;
    /* Rose 700 */
    --primary-soft: rgba(225, 29, 72, 0.1);
    --slate-50: #F8FAFC;
    --slate-100: #F1F5F9;
    --slate-200: #E2E8F0;
    --slate-300: #CBD5E1;
    --slate-400: #94A3B8;
    --slate-500: #64748B;
    --slate-600: #475569;
    --slate-700: #334155;
    --slate-800: #1E293B;
    --slate-900: #0F172A;

    /* JDS Typography Scale (-20% Adjusted) */
    --jds-h1: 60px;
    --jds-h2: 48px;
    --jds-h3: 38px;
    --jds-h4: 29px;
    --jds-h5: 24px;
    --jds-h6: 19px;
    --jds-body: 16px;
    --jds-small: 13px;
}

/* Mobile Optimization: Global Typography Scaling */
@media (max-width: 640px) {
    :root {
        --jds-h1: 40px;
        --jds-h2: 32px;
        --jds-h3: 24px;
        --jds-h4: 20px;
        --jds-h5: 18px;
        --jds-h6: 16px;
        --jds-body: 14px;
        --jds-small: 12px;
    }
    
    .heading-1 {
        font-size: 24px !important;
    }
    
    .pro-card {
        padding: 1rem !important;
        border-radius: 1rem !important;
    }

    .recap-tab-btn {
        padding: 6px 12px !important;
        font-size: 11px !important;
    }

    #sys-ready {
        bottom: 20px !important;
        left: 10px !important;
        font-size: 10px !important;
    }
}

/* --- [PHASE 4] Performance Enhancements --- */
.animate-fadeIn { animation: fadeIn 0.4s ease-out forwards; }

/* --- Skeleton Pulse Animation --- */
.pulse { animation: pulse 1.5s cubic-bezier(0.4, 0, 0.6, 1) infinite; }
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .5; }
}

@keyframes popIn {
    0% { opacity: 0; transform: translate(-50%, 20px) scale(0.9); }
    100% { opacity: 1; transform: translate(-50%, 0) scale(1); }
}

.animate-popIn {
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.skeleton {
    background-color: var(--slate-100);
    border-radius: 0.5rem;
    position: relative;
    overflow: hidden;
}

.skeleton::after {
    content: "";
    position: absolute;
    top: 0; right: 0; bottom: 0; left: 0;
    transform: translateX(-100%);
    background-image: linear-gradient(90deg, rgba(255,255,255,0) 0, rgba(255,255,255,0.2) 20%, rgba(255,255,255,0.5) 60%, rgba(255,255,255,0));
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    100% { transform: translateX(100%); }
}

/* --- Custom Slim Scrollbar --- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--slate-300); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--slate-400); }

/* --- Input Glow Effect --- */
input:focus, select:focus, textarea:focus {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 4px var(--primary-soft) !important;
    outline: none !important;
}

[id*="map-"][id$="-container"] {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
[id*="map-"][id$="-container"]:hover {
    border-color: #cbd5e1;
}

/* --- Global Font --- */
body, h1, h2, h3, h4, h5, h6, p, span, div, button, input, select {
    font-family: 'Lato', sans-serif !important;
}

body {
    font-size: var(--jds-body);
    line-height: 1.6;
    background-color: #fff;
    background-image: url('../assets/orange_wave_bg.webp');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    min-height: 100vh;
    color: #1E293B;
}

/* --- Heading Hierarchy --- */
h1 { font-size: var(--jds-h1); font-weight: 800; line-height: 1.2; }
h2 { font-size: var(--jds-h2); font-weight: 800; line-height: 1.2; }
h3 { font-size: var(--jds-h3); font-weight: 700; line-height: 1.2; }
h4 { font-size: var(--jds-h4); font-weight: 700; line-height: 1.2; }
h5 { font-size: var(--jds-h5); font-weight: 600; line-height: 1.2; }
h6 { font-size: var(--jds-h6); font-weight: 600; line-height: 1.2; }

/* --- Card Component --- */
.pro-card {
    background: white;
    border-radius: 1.5rem;
    border: 1px solid var(--slate-100);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

.pro-card:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

/* --- Button Component --- */
.btn-rose {
    background: var(--primary);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    font-size: var(--jds-small);
}

.btn-rose:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(225, 29, 72, 0.25);
}

/* --- Modern Dialog Styling --- */
dialog {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
    transform: translate(-50%, -45%) scale(0.95);
}

dialog[open] {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

dialog::backdrop {
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    transition: all 0.3s;
}

/* --- Text Label --- */
.text-label {
    font-size: var(--jds-small);
    font-weight: 700;
    color: var(--slate-400);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* --- Heading --- */
.heading-1 {
    font-size: var(--jds-h2) !important;
    font-weight: 800;
    color: var(--slate-900);
    letter-spacing: -0.025em;
    line-height: 1.2;
}

/* --- Table --- */
.pro-table thead th {
    background: var(--slate-50);
    color: var(--slate-800);
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    padding: 0.5rem 0.75rem;
    border-bottom: 2px solid var(--slate-100);
    text-align: left;
    letter-spacing: 0.05em;
}

.pro-table tbody td {
    padding: 0.1rem 1rem;
    border-bottom: 1px solid var(--slate-50);
    font-size: 13px;
    font-weight: 500;
    color: var(--slate-900);
    line-height: 1.0;
}

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

.view.active {
    display: block !important;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Error Overlay --- */
#err-overlay {
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 9999;
    background: #fee2e2;
    border: 2px solid #e11d48;
    color: #7f1d1d;
    padding: 16px 20px;
    border-radius: 12px;
    font-family: monospace;
    font-size: 13px;
    max-width: 90vw;
    display: none;
    box-shadow: 0 8px 24px rgba(225, 29, 72, 0.2);
}

/* --- Recap Tab Buttons --- */
.recap-tab-btn {
    padding: 10px 20px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    background: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    transition: all 0.2s;
    color: #0f172a;
    border: 1px solid #f1f5f9;
}
.recap-tab-btn.active {
    background: #2563eb;
    color: white;
    box-shadow: 0 10px 20px rgba(37,99,235,0.2);
    border-color: #2563eb;
}

/* --- Query Summary Tile --- */
.query-summary-tile {
    background: white;
    padding: 1.5rem;
    border-radius: 1.5rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.02);
    border: 1px solid #f1f5f9;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* --- Admin Sidebar Buttons --- */
.admin-side-btn {
    color: #64748b;
    transition: all 0.2s;
}

.admin-side-btn:hover {
    background: #fff1f2;
    color: #e11d48;
}

.admin-side-btn.bg-emerald-600 {
    color: white !important;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
}

/* [FIXED] Added role-specific button colors for consolidated showAdminSection */
.admin-side-btn.bg-blue-600 {
    color: white !important;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.admin-side-btn.bg-orange-600 {
    color: white !important;
    box-shadow: 0 4px 12px rgba(234, 88, 12, 0.2);
}

/* --- Sub-Admin Tab Buttons --- */
.sub-tab-btn {
    color: #64748b;
    text-align: left;
}

.sub-tab-btn:hover {
    background: #fff1f2;
    color: #e11d48;
}

.sub-tab-btn.active {
    background: #e11d48;
    color: white;
    box-shadow: 0 4px 12px rgba(225, 29, 72, 0.2);
}

/* [PHASE 2] Minimum touch target for accessibility */
.btn-admin-action {
    min-width: 36px;
    min-height: 36px;
}

/* --- Hide Datalist Arrow --- */
input.no-dropdown::-webkit-calendar-picker-indicator {
    display: none !important;
    -webkit-appearance: none;
}
/* --- Chart Panels --- */
.chart-square-panel {
    aspect-ratio: 1 / 1 !important;
    height: auto !important;
    width: 100% !important;
    max-width: 500px !important; /* Expanded for 101 units visibility */
    display: flex !important;
    flex-direction: column !important;
    min-height: 0 !important; /* Reset any min-height */
}

/* Ensure the chart container takes all available space within the square panel */
.chart-square-panel > .flex-1 {
    min-height: 0;
    position: relative;
}
/* --- Dropdown Select & Option Colors --- */
select, option {
    color: #000000 !important;
}
/* --- Mobile Optimization: Tables & Touch Targets --- */
@media (max-width: 768px) {
    /* Ensure scroll containers are visible and smooth */
    .overflow-x-auto {
        border: 1px solid var(--slate-100);
        border-radius: 1rem;
        background: white;
        margin-bottom: 1rem;
        box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
    }

    /* Prevent table collapse and set readable scale */
    .pro-table {
        min-width: 650px !important;
    }

    .pro-table thead th {
        font-size: 9px !important;
        padding: 10px 8px !important;
        white-space: nowrap;
    }

    .pro-table tbody td {
        font-size: 11px !important;
        padding: 8px !important;
        height: auto !important;
    }

    /* Expand touch targets for action buttons in tables */
    .pro-table td button, 
    .pro-table td .btn-action {
        min-width: 34px;
        min-height: 34px;
        margin: 2px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        background: var(--slate-50);
        border-radius: 8px;
    }

    /* Optimization for pro-card on small screens */
    .pro-card {
        padding: 1rem !important;
    }
}

/* Fix for horizontal scroll indicator on mobile */
.overflow-x-auto::-webkit-scrollbar {
    height: 4px;
}
.overflow-x-auto::-webkit-scrollbar-thumb {
    background: var(--slate-200);
    border-radius: 10px;
}

/* --- [SARPRAS SIDEBAR STYLES] --- */
#sarpras-sidebar {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.sarpras-side-btn {
    transition: all 0.2s ease;
}
.sarpras-side-btn.active {
    transform: translateX(4px);
}
.sidebar-text.hidden {
    display: none !important;
}
#sarpras-sidebar.w-20 .sidebar-text {
    display: none;
}
#sarpras-sidebar.w-20 {
    width: 80px !important;
}
#sarpras-sidebar.w-20 .sarpras-side-btn {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
}
#sarpras-sidebar.w-20 .sarpras-side-btn i {
    margin: 0;
}

/* Tailwind Dynamic Classes for app.js */
.bg-rose-600 { background-color: #E11D48 !important; }
.bg-emerald-600 { background-color: #059669 !important; }

