/* =========================================================
   TOP NAVIGATION HEADER STYLING
   ========================================================= */

/* Header Left & Right Layout */
.top-header {
    height: 72px;
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 100;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 32px;
}

.header-brand {
    display: flex;
    align-items: center;
    border: none;
    background: transparent;
    padding: 0;
}

.header-brand-home {
    cursor: pointer;
}

.header-brand-home:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 4px;
    border-radius: 8px;
}

.header-mobile-nav-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-card);
    color: var(--text-main);
    cursor: pointer;
}

.header-mobile-nav-toggle i {
    font-size: 22px;
}

.logo-img-top {
    height: 46px;
    width: auto;
    max-width: 170px;
    object-fit: contain;
}

/* Header Right Area */
.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* Settings Dropdown */
.settings-dropdown {
    position: absolute;
    top: 50px;
    right: 0;
    width: 220px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    z-index: 1000;
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: dropdownFadeIn 0.15s ease-in-out;
}

.settings-dropdown.show {
    display: flex;
}

@keyframes dropdownFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.settings-menu-list {
    list-style: none;
    padding: 4px 0;
    margin: 0;
}

.dropdown-menu-item {
    width: 100%;
    background: transparent;
    border: none;
    padding: 12px 16px;
    text-align: left;
    font-family: inherit;
    font-size: 13.5px;
    color: var(--text-main);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: var(--transition);
}

.dropdown-menu-item:hover {
    background-color: var(--bg-color);
    color: var(--text-main);
}

.dropdown-menu-item i {
    font-size: 16px;
    color: var(--text-muted);
}

.settings-logout-btn {
    border-top: 1px solid var(--border);
    color: var(--danger);
    margin-top: 4px;
}

.settings-logout-btn i {
    color: var(--danger);
}

.settings-logout-btn:hover {
    background-color: var(--danger-light);
    color: var(--danger);
}

@media (min-width: 1025px) and (max-width: 1280px) {
    .top-header {
        padding-inline: 24px;
    }

    .header-left {
        gap: 20px;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .top-header {
        height: auto;
        min-height: 72px;
        flex-wrap: wrap;
        gap: 12px;
        padding-block: 12px;
        padding-inline: 24px;
    }

    .header-left {
        min-width: 0;
        gap: 20px;
    }

    .header-right {
        margin-left: auto;
    }

    .views-container {
        padding: 24px;
    }
}

@media (max-width: 768px) {
    .top-header {
        height: auto;
        min-height: 72px;
        align-items: stretch;
        flex-direction: column;
        gap: 12px;
        padding: 12px 16px;
    }

    .header-left,
    .header-right {
        width: 100%;
    }

    .header-left {
        align-items: center;
        justify-content: space-between;
        gap: 14px;
        flex-wrap: nowrap;
        position: relative;
    }

    .header-brand {
        flex-shrink: 0;
    }

    .logo-img-top {
        height: 38px;
        max-width: 132px;
    }

    .header-mobile-nav-toggle {
        display: inline-flex;
        margin-left: auto;
    }

    .header-page-identity {
        min-width: 0;
        flex: 1;
    }

    .header-page-identity h1 {
        font-size: 16px;
    }

    .header-right {
        justify-content: flex-end;
        gap: 10px;
    }

    .views-container {
        padding: 20px 16px;
    }

    .dashboard-widgets {
        grid-template-columns: minmax(0, 1fr);
    }

    .widget {
        min-width: 0;
        overflow-x: hidden;
    }

    .tables-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .table-container {
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .widget,
    .kpi-card {
        border-radius: 14px;
        padding: 18px;
    }

    .chart-widget .chart-container {
        height: 280px;
        min-height: 280px;
    }

    .dashboard-area-map {
        height: 340px;
    }

    .chart-scroll-frame {
        width: 100%;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
    }

    .chart-scroll-content {
        min-width: 620px;
    }

    .chart-scroll-content .chart-container {
        width: 100%;
    }

    .donut-legend {
        gap: 8px;
        padding: 12px 0 0;
    }
}

@media (max-width: 430px) {
    .top-header {
        padding-inline: 12px;
    }

    .views-container {
        padding: 16px 12px;
    }

    .widget,
    .kpi-card {
        padding: 16px;
    }

    .header-right {
        flex-wrap: wrap;
    }

    .notification-dropdown,
    .settings-dropdown,
    .user-dropdown {
        position: fixed;
        top: 126px;
        left: 12px;
        right: 12px;
        width: auto;
    }

    .chart-widget .chart-container {
        height: 250px;
        min-height: 250px;
    }

    .dashboard-area-map {
        height: 300px;
    }

    .chart-scroll-content {
        min-width: 560px;
    }

    .chart-controls,
    .widget-filters {
        width: 100%;
    }

    .chart-controls .compact-select,
    .widget-filters select,
    .widget-filters button {
        flex: 1 1 auto;
        min-width: 0;
    }
}
