/* ========================================
   PHDC MIS - Bootstrap 5 Admin Layout
   ======================================== */

:root {
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 70px;
    --topbar-height: 60px;
    --primary: #0d6efd;
    --sidebar-bg: #1a1f36;
    --sidebar-hover: #2d3352;
    --sidebar-active: #0d6efd;
    --sidebar-text: #a4a6b3;
    --sidebar-text-active: #ffffff;
    --body-bg: #f4f6f9;
}

* { box-sizing: border-box; }

body {
    font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--body-bg);
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

/* ========== SIDEBAR ========== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    z-index: 1040;
    transition: transform 0.3s ease;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

.sidebar-inner {
    display: flex;
    flex-direction: column;
    min-height: 100%;
    padding-bottom: 20px;
}

.sidebar-brand {
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
}

.brand-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: #fff;
}

.brand-icon {
    font-size: 1.5rem;
    margin-right: 0.75rem;
    opacity: 0.9;
}

.brand-text {
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: 0.5px;
}

.sidebar-nav {
    list-style: none;
    padding: 0.5rem 0;
    margin: 0;
    flex: 1;
}

.sidebar-divider {
    border-color: rgba(255,255,255,0.08);
    margin: 0.5rem 1rem;
}

.sidebar-heading-text {
    padding: 0.5rem 1.25rem;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255,255,255,0.3);
}

.nav-item .nav-link {
    display: flex;
    align-items: center;
    padding: 0.65rem 1.25rem;
    color: var(--sidebar-text);
    text-decoration: none;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    font-size: 0.88rem;
    cursor: pointer;
}

.nav-item .nav-link i {
    width: 20px;
    margin-right: 0.75rem;
    text-align: center;
    font-size: 0.9rem;
    opacity: 0.8;
}

.nav-item .nav-link:hover {
    background: var(--sidebar-hover);
    color: #fff;
    border-left-color: rgba(255,255,255,0.15);
}

.nav-item.active > .nav-link {
    background: var(--sidebar-hover);
    color: var(--sidebar-text-active);
    border-left-color: var(--sidebar-active);
}

.nav-item.active > .nav-link i { opacity: 1; }

.nav-link .submenu-arrow {
    margin-left: auto;
    font-size: 0.7rem;
    transition: transform 0.2s;
}

.nav-item.open > .nav-link .submenu-arrow {
    transform: rotate(180deg);
}

.submenu {
    list-style: none;
    padding: 0;
    margin: 0;
    background: rgba(0,0,0,0.15);
}

.submenu-item {
    display: block;
    padding: 0.55rem 1.25rem 0.55rem 3.25rem;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.83rem;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.submenu-item:hover {
    background: rgba(255,255,255,0.05);
    color: #fff;
}

.submenu-item.active {
    color: var(--sidebar-text-active);
    background: rgba(13,110,253,0.15);
    border-left-color: var(--sidebar-active);
}

/* ========== SIDEBAR OVERLAY ========== */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1035;
}

.sidebar-overlay.show { display: block; }

/* ========== MAIN CONTENT ========== */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left 0.3s ease;
    display: flex;
    flex-direction: column;
}

/* ========== TOPBAR ========== */
.topbar {
    height: var(--topbar-height);
    border-bottom: 1px solid #e3e6f0;
    position: sticky;
    top: 0;
    z-index: 1030;
}

.sidebar-toggle {
    font-size: 1.2rem;
    color: #6c757d;
    text-decoration: none;
    padding: 0.5rem;
    border: none;
}

.sidebar-toggle:hover { color: #343a40; }

.avatar-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #e9ecef;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    color: #6c757d;
}

/* ========== CARDS ========== */
.app-card {
    background: #fff;
    border-radius: 0.5rem;
    box-shadow: 0 0.15rem 1.75rem 0 rgba(58,59,69,0.08);
    border: none;
}

.app-card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e3e6f0;
    font-weight: 700;
    color: #4e73df;
}

.app-card-body { padding: 1.25rem; }

.stat-card {
    background: #fff;
    border-radius: 0.5rem;
    box-shadow: 0 0.15rem 1.75rem 0 rgba(58,59,69,0.08);
    border: none;
    border-left: 4px solid;
    transition: transform 0.2s;
}

.stat-card:hover { transform: translateY(-2px); }
.stat-card.border-success { border-left-color: #1cc88a; }
.stat-card.border-warning { border-left-color: #f6c23e; }
.stat-card.border-danger { border-left-color: #e74a3b; }
.stat-card.border-primary { border-left-color: #4e73df; }
.stat-card.border-info { border-left-color: #36b9cc; }

.stat-card .stat-icon {
    font-size: 2rem;
    opacity: 0.3;
}

.stat-card .stat-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.25rem;
}

.stat-card .stat-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: #5a5c69;
}

/* ========== STATUS BADGES ========== */
.badge-available { background-color: #1cc88a; color: #fff; }
.badge-hold { background-color: #f6c23e; color: #856404; }
.badge-sold { background-color: #e74a3b; color: #fff; }
.badge-techhold { background-color: #36b9cc; color: #fff; }
.badge-prospect { background-color: #6c757d; color: #fff; }
.badge-qualified { background-color: #0dcaf0; color: #000; }
.badge-negotiating { background-color: #ffc107; color: #000; }
.badge-reserved { background-color: #0d6efd; color: #fff; }
.badge-cancelled { background-color: #dc3545; color: #fff; }

/* ========== PROGRESS ========== */
.progress { height: 0.75rem; border-radius: 0.5rem; }

/* ========== TABLES ========== */
.table thead th {
    border-top: none;
    border-bottom: 2px solid #e3e6f0;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    color: #5a5c69;
}

/* ========== FOOTER ========== */
.app-footer {
    padding: 1rem;
    background: #fff;
    border-top: 1px solid #e3e6f0;
    font-size: 0.8rem;
    color: #858796;
    margin-top: auto;
}

/* ========== SPINNER OVERLAY ========== */
.spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255,255,255,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.spinner-wrapper {
    text-align: center;
    padding: 2rem;
    background: #fff;
    border-radius: 0.5rem;
    box-shadow: 0 0.5rem 1rem rgba(0,0,0,0.1);
}

/* ========== LEAFLET MAP ========== */
.leaflet-container { z-index: 1; }
.custom-tooltip {
    background: white;
    border: 1px solid #ccc;
    border-radius: 6px;
    padding: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* ========== RESPONSIVE ========== */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.show {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
}

@media (max-width: 575.98px) {
    .stat-card .stat-value { font-size: 1.1rem; }
    .topbar .container-fluid { padding: 0 0.75rem; }
}

/* ========== DATATABLES OVERRIDE ========== */
.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--primary) !important;
    border-color: var(--primary) !important;
    color: #fff !important;
    border-radius: 0.25rem;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: #e9ecef !important;
    border-color: #dee2e6 !important;
}

/* ========== FORM STYLES ========== */
.form-control:focus, .form-select:focus {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.2rem rgba(13,110,253,0.25);
}
