/* 
 * Premium Residential Facility Management Design Style
 * Incorporates Dark Mode Variables, CSS Gradients, Glassmorphism, and responsive layouts.
 */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    --font-primary: 'Outfit', sans-serif;
    
    /* Light Mode Palette */
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-sidebar: #0f172a;
    --sidebar-text: #94a3b8;
    --sidebar-active: #38bdf8;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    
    /* System Accents */
    --primary: #0284c7;
    --primary-light: #e0f2fe;
    --secondary: #10b981;
    --secondary-light: #d1fae5;
    --danger: #ef4444;
    --warning: #f59e0b;
    --dark-glass: rgba(15, 23, 42, 0.03);
    --white-glass: rgba(255, 255, 255, 0.7);
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
}

/* Dark Mode Overrides */
[data-theme="dark"] {
    --bg-primary: #090d16;
    --bg-secondary: #111827;
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --border-color: #1f2937;
    --dark-glass: rgba(255, 255, 255, 0.03);
    --white-glass: rgba(17, 24, 39, 0.7);
    --primary-light: #0c4a6e;
    --secondary-light: #064e3b;
}

body {
    font-family: var(--font-primary);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
    overflow-x: hidden;
}

/* --- Layout Structure --- */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    color: var(--sidebar-text);
    flex-shrink: 0;
    transition: all 0.3s ease;
    z-index: 1030;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

/* Hide scrollbar for sidebar to keep it clean */
.sidebar::-webkit-scrollbar {
    width: 4px;
}
.sidebar::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.sidebar-header {
    height: 70px;
    display: flex;
    align-items: center;
    padding: 0 24px;
    border-bottom: 1px solid #1e293b;
    position: sticky;
    top: 0;
    background-color: var(--bg-sidebar);
    z-index: 10;
}

.sidebar-logo {
    font-size: 1.15rem;
    font-weight: 700;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-logo span {
    color: var(--sidebar-active);
}

.sidebar-menu {
    padding: 20px 0;
    list-style: none;
    margin: 0;
}

.sidebar-section-title {
    padding: 10px 24px;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 600;
    color: #475569;
}

.sidebar-menu-item a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.sidebar-menu-item a:hover {
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.05);
}

.sidebar-menu-item.active a {
    color: #ffffff;
    background-color: rgba(56, 189, 248, 0.08);
    border-left-color: var(--sidebar-active);
}

.sidebar-menu-item a i {
    width: 20px;
    font-size: 1.1rem;
}

.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.top-navbar {
    height: 70px;
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    transition: background-color 0.3s ease, border-color 0.3s ease;
    position: sticky;
    top: 0;
    z-index: 1020;
}

.content-body {
    padding: 30px;
    flex-grow: 1;
}

/* --- Premium Elements (Glassmorphism & Gradients) --- */
.glass-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

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

.kpi-card {
    position: relative;
    padding: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.kpi-card::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    opacity: 0.8;
}

.kpi-card.kpi-danger::after {
    background: var(--danger);
}

.kpi-card.kpi-warning::after {
    background: var(--warning);
}

.kpi-info h6 {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.kpi-info h3 {
    font-size: 1.8rem;
    font-weight: 700;
    margin: 0;
    color: var(--text-primary);
}

.kpi-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}

.kpi-icon.icon-primary {
    background-color: var(--primary-light);
    color: var(--primary);
}

.kpi-icon.icon-secondary {
    background-color: var(--secondary-light);
    color: var(--secondary);
}

.kpi-icon.icon-danger {
    background-color: rgba(239, 68, 68, 0.12);
    color: var(--danger);
}

.kpi-icon.icon-warning {
    background-color: rgba(245, 158, 11, 0.12);
    color: var(--warning);
}

/* --- Breadcrumbs --- */
.breadcrumb-wrapper {
    margin-bottom: 24px;
}

.breadcrumb-custom {
    display: flex;
    align-items: center;
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 0.85rem;
}

.breadcrumb-custom-item + .breadcrumb-custom-item::before {
    content: "\f105";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    padding: 0 10px;
    color: var(--text-secondary);
}

.breadcrumb-custom-item a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.breadcrumb-custom-item.active {
    color: var(--text-secondary);
}

/* --- Forms & Cascading Dropdowns --- */
.form-control-custom {
    border-radius: 10px;
    border: 1px solid var(--border-color);
    padding: 11px 16px;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    transition: all 0.2s ease;
    font-size: 0.9rem;
}

.form-control-custom:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(2, 132, 199, 0.12);
    outline: none;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

.form-label-custom {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

/* --- Tables & Data Grids --- */
.table-custom {
    width: 100%;
    margin-bottom: 0;
    color: var(--text-primary);
    border-collapse: collapse;
}

.table-custom th {
    background-color: var(--dark-glass);
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.85rem;
    padding: 16px 20px;
    border-bottom: 2px solid var(--border-color);
}

.table-custom td {
    padding: 16px 20px;
    font-size: 0.88rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.table-custom tbody tr {
    transition: background-color 0.2s ease;
}

.table-custom tbody tr:hover {
    background-color: var(--dark-glass);
}

/* --- Badge Components --- */
.badge-custom {
    padding: 6px 12px;
    font-weight: 600;
    font-size: 0.75rem;
    border-radius: 30px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.badge-active {
    background-color: var(--secondary-light);
    color: var(--secondary);
}

.badge-inactive {
    background-color: rgba(100, 116, 139, 0.12);
    color: var(--text-secondary);
}

.badge-danger {
    background-color: rgba(239, 68, 68, 0.12);
    color: var(--danger);
}

.badge-warning {
    background-color: rgba(245, 158, 11, 0.12);
    color: var(--warning);
}

/* --- Theme Toggle & Icons --- */
.theme-toggle-btn {
    border: none;
    background: none;
    font-size: 1.25rem;
    color: var(--text-secondary);
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.theme-toggle-btn:hover {
    background-color: var(--dark-glass);
    color: var(--text-primary);
}

/* --- Notice Board Widget --- */
.notice-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.notice-item {
    border-left: 4px solid var(--primary);
    background-color: var(--dark-glass);
    padding: 16px;
    border-radius: 0 12px 12px 0;
}

.notice-title {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 4px;
}

.notice-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    display: flex;
    gap: 12px;
}

.notice-body {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* --- Custom Scrollbar --- */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* --- Responsive Adjustments --- */
@media (min-width: 992px) {
    .sidebar.collapsed {
        margin-left: -260px;
    }
}

@media (max-width: 991px) {
    .sidebar {
        margin-left: -260px;
    }
    
    .sidebar.show {
        margin-left: 0;
    }
}

/* ═══════════════════════════════════════════════════
   MICRO KPI CARDS  (Dashboard compact tiles)
═══════════════════════════════════════════════════ */
.micro-kpi-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s ease, transform 0.15s ease;
    cursor: default;
    height: 100%;
    min-height: 58px;
}

.micro-kpi-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.micro-kpi-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    flex-shrink: 0;
}

.micro-kpi-body {
    min-width: 0;
    flex: 1;
}

.micro-kpi-label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.micro-kpi-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
}

/* ═══════════════════════════════════════════════════
   DASHBOARD CHART TITLE
═══════════════════════════════════════════════════ */
.dash-chart-title {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 8px;
}

/* ═══════════════════════════════════════════════════
   COMPACT NOTICE BOARD
═══════════════════════════════════════════════════ */
.notice-item-compact {
    border-left: 3px solid var(--primary);
    background-color: var(--dark-glass);
    padding: 8px 12px;
    border-radius: 0 8px 8px 0;
    margin-bottom: 8px;
}

.notice-title-compact {
    font-weight: 600;
    font-size: 0.78rem;
    color: var(--primary);
    margin-bottom: 2px;
}

.notice-meta-compact {
    font-size: 0.68rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.notice-body-compact {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* ═══════════════════════════════════════════════════
   EXCEL-LIKE GRID TABLE  (table-xls)
   Dense, bordered, small font — for all master lists
   and data panels
═══════════════════════════════════════════════════ */
.table-xls {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.75rem;
    color: var(--text-primary);
    font-family: var(--font-primary);
}

.table-xls th {
    background-color: #1E3A5F;
    color: #ffffff;
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 5px 10px;
    border: 1px solid rgba(255,255,255,0.15);
    white-space: nowrap;
    vertical-align: middle;
}

.table-xls td {
    padding: 4px 10px;
    font-size: 0.74rem;
    border: 1px solid var(--border-color);
    vertical-align: middle;
    background-color: var(--bg-secondary);
}

.table-xls tbody tr:nth-child(even) td {
    background-color: #f0f5fb;
}

[data-theme="dark"] .table-xls tbody tr:nth-child(even) td {
    background-color: rgba(255,255,255,0.03);
}

.table-xls tbody tr:hover td {
    background-color: #e8f0fe !important;
    transition: background-color 0.1s ease;
}

[data-theme="dark"] .table-xls tbody tr:hover td {
    background-color: rgba(56,189,248,0.07) !important;
}

.table-xls tfoot td {
    background-color: #e8f0fe;
    font-weight: 700;
    font-size: 0.72rem;
    border-top: 2px solid var(--primary);
}

/* Override table-custom with tighter padding for grid density */
.table-custom th {
    background-color: #1E3A5F;
    color: #ffffff;
    font-weight: 600;
    font-size: 0.7rem;
    padding: 7px 10px;
    border-bottom: 2px solid var(--primary);
    white-space: nowrap;
}

.table-custom td {
    padding: 5px 10px;
    font-size: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.table-custom tbody tr:nth-child(even) {
    background-color: #f8faff;
}

[data-theme="dark"] .table-custom tbody tr:nth-child(even) {
    background-color: rgba(255,255,255,0.02);
}

.table-custom tbody tr:hover {
    background-color: #e8f0fe !important;
}

[data-theme="dark"] .table-custom tbody tr:hover {
    background-color: rgba(56,189,248,0.06) !important;
}

/* ═══════════════════════════════════════════════════
   COMPACT FORM GRID
   For entry forms — tighter controls, smaller labels
═══════════════════════════════════════════════════ */
.form-compact .form-label-custom {
    font-size: 0.72rem;
    font-weight: 600;
    margin-bottom: 3px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.form-compact .form-control-custom,
.form-compact .form-select {
    font-size: 0.78rem;
    padding: 6px 10px;
    border-radius: 6px;
    border-color: var(--border-color);
}

.form-compact .mb-3 {
    margin-bottom: 0.6rem !important;
}

.form-compact .form-section-title {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--primary);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 4px;
    margin-bottom: 8px;
    margin-top: 4px;
}

/* Compact glass card for forms */
.glass-card.form-card .card-body {
    padding: 16px 20px !important;
}

/* Reduce content-body padding for grid density */
.content-body {
    padding: 18px 22px;
    flex-grow: 1;
}


/* --- Radium Glow Animation --- */
@keyframes radiumPulse {
    0%, 100% {
        text-shadow: 0 0 2px rgba(186, 230, 253, 0.5),
                     0 0 6px rgba(186, 230, 253, 0.6);
    }
    33% {
        text-shadow: 0 0 2px rgba(125, 211, 252, 0.6),
                     0 0 8px rgba(125, 211, 252, 0.7);
    }
    66% {
        text-shadow: 0 0 3px rgba(56, 189, 248, 0.7),
                     0 0 10px rgba(56, 189, 248, 0.8);
    }
}

.radium-glow {
    animation: radiumPulse 5s infinite linear;
    -webkit-text-stroke: 0.5px rgba(15, 23, 42, 0.5);
    color: #1e3a8a; /* Dark Blue */
}

/* ═══════════════════════════════════════════════════
   SIDEBAR ACCORDION — GROUP HEADERS & SUBMENUS
═══════════════════════════════════════════════════ */

/* Group container — just a list item */
.sidebar-group {
    list-style: none;
}

/* Clickable group header (replaces old .sidebar-section-title) */
.sidebar-group-hdr {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 20px 11px 24px;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s ease, color 0.2s ease;
    position: relative;
    border-left: 3px solid transparent;
}

.sidebar-group-hdr:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* Icon in group header */
.sidebar-grp-icon {
    font-size: 0.9rem;
    width: 18px;
    text-align: center;
    color: #475569;
    transition: color 0.2s;
    flex-shrink: 0;
}

/* Label text */
.sidebar-grp-label {
    flex: 1;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #64748b;
    transition: color 0.2s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Chevron arrow — rotates 90° when open */
.sidebar-grp-arrow {
    font-size: 0.6rem;
    color: #475569;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), color 0.2s;
    flex-shrink: 0;
}

/* Expanded state for the group header */
.sidebar-group-hdr.expanded .sidebar-grp-icon,
.sidebar-group-hdr.expanded .sidebar-grp-arrow {
    color: var(--sidebar-active);
}

.sidebar-group-hdr.expanded .sidebar-grp-label {
    color: #cbd5e1;
}

.sidebar-group-hdr.expanded .sidebar-grp-arrow {
    transform: rotate(90deg);
}

/* Active group — header border highlight */
.sidebar-group-hdr.has-active {
    border-left-color: var(--sidebar-active);
}

.sidebar-group-hdr.has-active .sidebar-grp-icon,
.sidebar-group-hdr.has-active .sidebar-grp-label {
    color: #e2e8f0;
}

/* ── SUBMENU SLIDE CONTAINER ── */
.sidebar-submenu {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: rgba(0, 0, 0, 0.15);
}

.sidebar-submenu.open {
    max-height: 600px; /* tall enough for any menu */
}

/* ── SUBMENU ITEM ── */
.sidebar-sub-item {
    list-style: none;
}

.sidebar-sub-item a {
    display: flex;
    align-items: center;
    gap: 9px;
    /* Indented right vs group header */
    padding: 9px 20px 9px 42px;
    font-size: 0.855rem;
    font-weight: 500;
    color: #64748b;
    text-decoration: none;
    transition: all 0.18s ease;
    border-left: 3px solid transparent;
    position: relative;
}

.sidebar-sub-item a .sub-bullet {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #334155;
    flex-shrink: 0;
    transition: background 0.2s, transform 0.2s;
}

.sidebar-sub-item a i {
    width: 16px;
    font-size: 0.85rem;
    text-align: center;
    color: #475569;
    transition: color 0.2s;
    flex-shrink: 0;
}

.sidebar-sub-item a:hover {
    color: #cbd5e1;
    background: rgba(255, 255, 255, 0.04);
    border-left-color: rgba(56, 189, 248, 0.35);
}

.sidebar-sub-item a:hover .sub-bullet {
    background: var(--sidebar-active);
    transform: scale(1.4);
}

.sidebar-sub-item a:hover i {
    color: var(--sidebar-active);
}

/* Active submenu item */
.sidebar-sub-item.active a {
    color: #ffffff;
    background: rgba(56, 189, 248, 0.1);
    border-left-color: var(--sidebar-active);
    font-weight: 600;
}

.sidebar-sub-item.active a .sub-bullet {
    background: var(--sidebar-active);
    box-shadow: 0 0 6px rgba(56, 189, 248, 0.6);
    transform: scale(1.3);
}

.sidebar-sub-item.active a i {
    color: var(--sidebar-active);
}

/* Divider between last submenu item and next group */
.sidebar-group + .sidebar-group {
    border-top: 1px solid rgba(255, 255, 255, 0.04);
}

/* Dashboard item consistent styling */
.sidebar-menu > .sidebar-menu-item {
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    margin-bottom: 4px;
}

/* PWA Install Button Noticeable Pulsing & Glow Animation */
@keyframes pwa-pulse-glow {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(2, 132, 199, 0.4);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 14px 4px rgba(2, 132, 199, 0.7);
        border-color: rgba(2, 132, 199, 0.9) !important;
    }
}

.pwa-pulse-btn {
    animation: pwa-pulse-glow 2.5s infinite ease-in-out !important;
    transition: transform 0.2s ease-in-out;
}


