/* =========================================
   MAIN TAB NAVIGATION STYLES
   ========================================= */

.main-tab-section {
    grid-column: 1 / -1;
}

/* Main Tab Buttons */
.main-tabs {
    display: flex;
    gap: 0;
    background: #050a14;
    border-bottom: 2px solid var(--neon-blue);
    padding: 0;
    margin-bottom: 20px;
    border-radius: 8px 8px 0 0;
    overflow-x: auto;
    scrollbar-width: thin;
    min-height: var(--main-tabs-height);
    position: sticky;
    top: calc(var(--topbar-height) + var(--ticker-height));
    z-index: 85;
    box-shadow: 0 -18px 0 18px #050a14, 0 12px 18px rgba(0, 0, 0, 0.35);
}

.main-tab-btn {
    background: transparent;
    border: none;
    color: var(--text-dim);
    padding: 15px 25px;
    cursor: pointer;
    font-family: var(--font-ui), var(--font-cn-sans);
    font-size: 0.95rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    position: relative;
}

.main-tab-btn svg {
    opacity: 0.6;
    transition: opacity 0.3s ease;
}

.main-tab-btn:hover {
    background: rgba(0, 243, 255, 0.05);
    color: var(--neon-cyan);
}

.main-tab-btn:hover svg {
    opacity: 1;
}

.main-tab-btn.active {
    color: var(--neon-cyan);
    border-bottom-color: var(--neon-cyan);
    background: rgba(0, 243, 255, 0.08);
    text-shadow: 0 0 8px rgba(0, 243, 255, 0.6);
}

.main-tab-btn.active svg {
    opacity: 1;
    filter: drop-shadow(0 0 4px var(--neon-cyan));
}

.main-tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg,
        transparent,
        var(--neon-cyan),
        transparent
    );
    animation: tabGlow 2s ease-in-out infinite;
}

@keyframes tabGlow {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* Main Tab Content */
.main-tab-content {
    position: relative;
}

.main-tab-pane {
    display: none;
    position: relative;
    min-height: 180px;
    animation: fadeIn 0.3s ease;
}

.main-tab-pane.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Dashboard Grid Layout */
.dashboard-grid {
    display: grid;
    grid-template-columns: 3fr 1fr;
    gap: 20px;
}

.dashboard-main {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.dashboard-sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-sidebar {
        order: -1; /* Move sidebar to top on mobile */
    }
}

@media (max-width: 768px) {
    :root {
        --main-tabs-height: 52px;
    }

    .main-tabs {
        border-radius: 0;
        gap: 0;
    }

    .main-tab-btn {
        padding: 12px 15px;
        font-size: 0.85rem;
    }

    .main-tab-btn span {
        display: none; /* Hide text on mobile, show only icons */
    }

    .main-tab-btn svg {
        margin: 0;
    }

    #tab-config .config-panel-header {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding-bottom: 10px;
        margin-bottom: 10px;
    }

    #tab-config .config-panel-header .panel-title {
        min-height: 24px;
    }

    #tab-config .cfg-actions {
        display: flex;
        align-items: center;
        gap: 8px;
        width: 100%;
        margin-top: 0;
    }

    #tab-config .cfg-actions .cyber-btn {
        width: 100%;
        min-height: 38px;
        padding: 7px 8px;
        line-height: 1.2;
        font-size: 0.78rem;
        white-space: normal;
    }

    #tab-config .config-primary-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        flex: 1 1 auto;
        min-width: 0;
    }

    #tab-config .config-maintenance-menu {
        flex: 0 0 118px;
    }

    #tab-config .tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 6px;
        padding-bottom: 4px;
        margin-bottom: 8px;
        -webkit-overflow-scrolling: touch;
    }

    #tab-config .tab-btn {
        flex: 0 0 auto;
        padding: 8px 14px;
        white-space: nowrap;
    }
}

@media (max-width: 480px) {
    .main-tab-btn {
        padding: 10px 12px;
        flex: 1; /* Equal width buttons */
    }

    #tab-config .cfg-actions {
        flex-wrap: wrap;
    }

    #tab-config .config-primary-actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        flex-basis: 100%;
    }

    #tab-config .config-maintenance-menu {
        flex: 1 1 100%;
    }

    #tab-config .cfg-actions .cyber-btn {
        font-size: 0.74rem;
    }
}

/* =========================================
   CONFIG SUB-TAB STYLES (existing)
   ========================================= */

/* Keep existing .tabs and .tab-btn styles for config panel */
.tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.tab-btn {
    padding: 8px 16px;
    background: transparent;
    border: 1px solid var(--text-dim);
    color: var(--text-dim);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.3s ease;
    border-radius: 4px;
    font-family: var(--font-cn-sans);
}

.tab-btn:hover {
    border-color: var(--neon-cyan);
    color: var(--neon-cyan);
    background: rgba(0, 243, 255, 0.05);
}

.tab-btn.active {
    background: var(--neon-cyan);
    color: var(--bg-deep);
    border-color: var(--neon-cyan);
    font-weight: 500;
}

.tab-panes {
    position: relative;
}

.tab-pane {
    display: none;
    position: relative;
    min-height: 180px;
}

.tab-pane.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

/* =========================================
   GRID LAYOUT OVERRIDE
   ========================================= */

/* Override app-container for full-width tabs */
.app-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
    display: block; /* Change from grid to block */
    position: relative;
    z-index: 2;
}

/* =========================================
   BADGE & INDICATOR STYLES
   ========================================= */

.main-tab-btn .badge {
    background: var(--neon-red);
    color: #fff;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: bold;
    margin-left: auto;
}

/* =========================================
   LOADING STATE
   ========================================= */

.main-tab-pane.loading::before {
    content: '';
    position: fixed;
    left: 50%;
    top: 50%;
    width: min(260px, calc(100vw - 120px));
    height: 2px;
    z-index: 10001;
    background: linear-gradient(90deg,
        transparent,
        var(--neon-cyan),
        transparent
    );
    background-size: 180% 100%;
    animation: loadingBar 1.5s ease-in-out infinite;
    transform: translate(-50%, 38px);
    pointer-events: none;
}

.tab-loading-mask {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(3, 7, 13, 0.62);
    backdrop-filter: blur(3px);
    cursor: progress;
    user-select: none;
    overflow: hidden;
}

.main-tab-pane.tab-loading-active > .tab-loading-mask,
.tab-pane.tab-loading-active > .tab-loading-mask {
    display: flex;
    pointer-events: auto;
}

.tab-loading-card {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    width: fit-content;
    max-width: min(360px, calc(100vw - 48px));
    padding: 14px 16px;
    border: 1px solid rgba(0, 243, 255, 0.34);
    background: rgba(5, 10, 20, 0.86);
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.42), 0 0 18px rgba(0, 243, 255, 0.12);
    color: var(--text-main);
}

.tab-loading-spinner {
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    border: 3px solid rgba(0, 243, 255, 0.22);
    border-top-color: var(--neon-cyan);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

.tab-loading-text {
    min-width: 0;
    color: var(--text-main);
    font-family: var(--font-cn-sans);
    font-size: 0.9rem;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

@keyframes loadingBar {
    0% { background-position: 180% 0; opacity: 0.25; }
    50% { opacity: 0.9; }
    100% { background-position: -80% 0; opacity: 0.25; }
}

@media (max-width: 480px) {
    .main-tab-pane.loading::before {
        width: min(180px, calc(100vw - 96px));
        transform: translate(-50%, 34px);
    }

    .tab-loading-card {
        max-width: min(300px, calc(100vw - 40px));
        padding: 13px 14px;
    }

    .tab-loading-spinner {
        width: 26px;
        height: 26px;
    }

    .tab-loading-text {
        font-size: 0.84rem;
    }
}
