﻿html {
    font-size: 14px;
}

/* ===========================
   THEME — Modern Light
=========================== */
:root {
    --nav-bg: #f8fafc;
    --nav-bg-light: #f1f5f9;
    --accent: #0ea5e9;
    --accent-light: #0284c7;
    --accent-glow: rgba(14,165,233,.10);
    --topbar-bg: #ffffff;
    --topbar-border: #e5e7eb;
    --nav-text: #64748b;
    --nav-text-hover: #1e293b;
    --nav-border: #f1f5f9;
}

/* ===========================
   SIDEBAR
=========================== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 200px;
    height: 100vh;
    background: var(--nav-bg);
    border-right: 1px solid var(--nav-border);
    box-shadow: 2px 0 12px rgba(0,0,0,0.06);
    color: var(--nav-text);
    padding-top: 10px;
    z-index: 1200;
    transition: width 0.25s ease;
    overflow-x: hidden;
    overflow-y: auto;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 14px 10px;
    border-bottom: 1px solid var(--nav-border);
    min-height: 43px;
}

.sidebar-logo img {
    height: 32px;
    flex-shrink: 0;
}

.sidebar-logo span {
    font-weight: 700;
    font-size: 0.9rem;
    letter-spacing: .3px;
    color: var(--accent-light);
    white-space: nowrap;
    overflow: hidden;
}

/* Collapse toggle button */
.btn-collapse-sidebar {
    margin-left: auto;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1px solid var(--nav-border);
    background: var(--nav-bg-light);
    color: var(--nav-text);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background .15s, color .15s, transform .25s;
    flex-shrink: 0;
    padding: 0;
}

.btn-collapse-sidebar:hover {
    background: var(--accent-glow);
    color: var(--accent);
}

.sidebar.collapsed .btn-collapse-sidebar {
    margin: 0 auto;
    transform: rotate(180deg);
}

.sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-menu > li > a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    font-size: 13px;
    color: var(--nav-text);
    text-decoration: none;
    transition: color .15s, background .15s;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-menu > li > a > i {
    flex-shrink: 0;
    width: 18px;
    text-align: center;
    font-size: 15px;
}

.sidebar-menu > li > a:hover {
    color: var(--nav-text-hover);
    background: var(--nav-bg-light);
}

.sidebar-menu li.active > a {
    background: var(--accent-glow);
    color: var(--accent);
    font-weight: 600;
    border-right: 3px solid var(--accent);
}

.menu-group > a {
    cursor: pointer;
}

.menu-group > a > .bi-chevron-down {
    margin-left: auto;
    flex-shrink: 0;
    font-size: 11px;
    transition: transform .2s;
}

.menu-group.open > a > .bi-chevron-down {
    transform: rotate(180deg);
}

.submenu {
    display: none;
    list-style: none;
    padding-left: 0;
}

.menu-group.open > .submenu {
    display: block;
}

.submenu li a {
    padding: 6px 14px 6px 34px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    color: var(--nav-text);
    text-decoration: none;
    transition: color .15s, background .15s;
    white-space: nowrap;
    overflow: hidden;
}

.submenu li a > i {
    flex-shrink: 0;
    width: 16px;
    text-align: center;
}

.submenu li a:hover {
    color: var(--nav-text-hover);
    background: var(--nav-bg-light);
}

.submenu li.active a {
    color: var(--accent);
    background: var(--accent-glow);
    font-weight: 600;
}

/* ===========================
   SIDEBAR COLLAPSED STATE
=========================== */
.sidebar.collapsed {
    width: 56px;
}

.sidebar.collapsed .sidebar-logo span,
.sidebar.collapsed .sidebar-logo img {
    display: none;
}

.sidebar.collapsed .sidebar-logo {
    justify-content: center;
    padding: 0 0 10px;
}

.sidebar.collapsed .sidebar-menu > li > a > i {
    color: var(--nav-text);
}

.sidebar.collapsed .sidebar-menu > li > a > span,
.sidebar.collapsed .menu-group > a > .bi-chevron-down {
    display: none;
}

.sidebar.collapsed .sidebar-menu > li > a {
    justify-content: center;
    padding: 10px 0;
}

.sidebar.collapsed .sidebar-menu > li > a > i {
    font-size: 17px;
}

.sidebar.collapsed .submenu {
    display: none !important;
}

.sidebar.collapsed ~ .topbar {
    left: 56px;
}

.sidebar.collapsed ~ .main-content {
    margin-left: 56px;
}

.sidebar.collapsed ~ .footer-content {
    margin-left: 56px;
}

/* Tooltip on hover when collapsed */
.sidebar.collapsed .sidebar-menu > li {
    position: relative;
}

.sidebar.collapsed .sidebar-menu > li > a::after {
    content: attr(data-title);
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    background: #1e293b;
    color: #f1f5f9;
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity .15s;
    z-index: 9999;
    box-shadow: 0 4px 12px rgba(0,0,0,.15);
    margin-left: 8px;
}

.sidebar.collapsed .sidebar-menu > li > a:hover::after {
    opacity: 1;
}

/* ===========================
   SIDEBAR BACKDROP (mobile)
=========================== */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1150;
}

.sidebar-backdrop.show {
    display: block;
}

/* ===========================
   RIGHT PANEL LAYOUT
   Use .has-right-panel on container-fluid
   to reserve space for notification panel
=========================== */
.has-right-panel {
    padding-right: 340px;
    transition: padding-right 0.3s ease;
}

/* Toggle button for notification panel (mobile/tablet) */
.btn-noti-toggle {
    display: none;
}

/* ===========================
   COMMON UTILITIES
=========================== */
.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

html {
    position: relative;
    min-height: 100%;
}

body {
    margin-bottom: 60px;
}

.form-floating > .form-control-plaintext::placeholder,
.form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder,
.form-floating > .form-control:focus::placeholder {
    text-align: start;
}

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.7);
    z-index: 20000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

label.required::after {
    content: " *";
    color: red;
    font-weight: bold;
}

input:required {
    border-left: 3px solid red;
}

/* ===========================
   RESPONSIVE: TABLET (≤992px)
=========================== */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .topbar {
        left: 0 !important;
    }

    .main-content {
        margin-left: 0 !important;
        padding: 70px 16px 16px !important;
    }

    .footer-content {
        margin-left: 0 !important;
    }

    /* Right panel becomes overlay drawer on tablet */
    .has-right-panel {
        padding-right: 15px !important;
    }

    .history-panel-right,
    .history-panel-left {
        position: fixed !important;
        right: 0 !important;
        left: auto !important;
        top: 56px !important;
        width: 300px !important;
        height: calc(100vh - 56px) !important;
        max-height: none !important;
        transform: translateX(100%);
        transition: transform 0.3s ease;
        z-index: 2500;
    }

    .history-panel-right.open,
    .history-panel-left.open {
        transform: translateX(0);
    }

    /* Show the notification toggle button */
    .btn-noti-toggle {
        display: inline-flex !important;
    }

    .chart-card {
        width: 100% !important;
    }

    .chart-card.active {
        width: 95vw !important;
        top: 60px !important;
    }
}

/* ===========================
   RESPONSIVE: MOBILE (≤576px)
=========================== */
@media (max-width: 575.98px) {
    .main-content {
        padding: 64px 10px 10px !important;
    }

    .chart-wrapper {
        height: 250px;
    }

    .dashboard-card {
        margin-bottom: 10px;
    }

    .table-responsive-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .modal-dialog {
        margin: 0;
        max-width: 100%;
    }

    .modal-content {
        border-radius: 0;
        min-height: 100vh;
    }

    .history-panel-right,
    .history-panel-left {
        width: 100% !important;
    }
}

/* ===========================
   RESPONSIVE: DESKTOP (≥992px)
=========================== */
@media (min-width: 992px) {
    .btn-sidebar-toggle {
        display: none !important;
    }
}