/* ==========================================================================
   APPLICATION LAYOUT
   ========================================================================== */

.dashboard {
    min-height: 100vh;

    display: grid;

    grid-template-columns:
        220px
        minmax(0, 1fr);

    grid-template-rows:
        auto
        1fr
        auto;
}


/* ==========================================================================
   HEADER
   ========================================================================== */

.dashboard-header {
    grid-column: 1 / -1;

    display: flex;

    align-items: center;
    justify-content: space-between;

    gap: 1rem;

    padding: 0.875rem 2rem;

    border-bottom: 1px solid var(--border-color);

    background: var(--bg-primary);
}

.logo-container {
    display: flex;

    align-items: center;

    gap: 0.75rem;

    min-width: 0;
}

.logo {
    display: block;

    height: 48px;

    width: auto;

    flex-shrink: 0;
}

.subtitle {
    min-width: 0;

    color: var(--text-secondary);

    font-size: 0.9rem;

    line-height: 1.3;

    overflow-wrap: anywhere;
}

.mobile-menu-btn {
    display: none;

    width: 42px;
    height: 42px;

    padding: 0;

    align-items: center;
    justify-content: center;

    flex-shrink: 0;

    background: transparent;

    color: var(--text-primary);

    border: 1px solid var(--border-color);

    border-radius: var(--radius-sm);

    cursor: pointer;
}

.mobile-menu-btn:hover {
    background: var(--bg-secondary);

    opacity: 1;
}

.mobile-menu-icon {
    position: relative;

    display: block;

    width: 20px;
    height: 14px;
}

.mobile-menu-icon::before,
.mobile-menu-icon::after,
.mobile-menu-icon span {
    position: absolute;

    left: 0;

    width: 20px;
    height: 2px;

    background: currentColor;

    border-radius: 999px;

    content: "";
}

.mobile-menu-icon::before {
    top: 0;
}

.mobile-menu-icon span {
    top: 6px;
}

.mobile-menu-icon::after {
    top: 12px;
}


/* ==========================================================================
   Theme Switcher
   ========================================================================== */
.theme-toggle {
    display: inline-flex;

    align-items: center;
    justify-content: center;

    width: 42px;
    height: 42px;

    padding: 0;

    flex-shrink: 0;

    background: transparent;

    color: var(--text-primary);

    border: 1px solid var(--border-color);

    border-radius: var(--radius-sm);

    cursor: pointer;

    font-size: 1.15rem;
}

.theme-toggle:hover {
    background: var(--bg-secondary);

    opacity: 1;
}

/* ==========================================================================
   SIDEBAR
   ========================================================================== */

.sidebar {
    background: var(--bg-secondary);

    border-right: 1px solid var(--border-color);

    overflow-y: auto;

    padding: 0.75rem 0;
}

.sidebar-link,
.submenu-toggle {
    display: flex;

    justify-content: space-between;
    align-items: center;

    width: 100%;

    padding: 0.8rem 1.25rem;

    text-decoration: none;

    color: var(--text-primary);

    background: transparent;

    border: none;
    border-left: 3px solid transparent;

    cursor: pointer;

    text-align: left;
}

.sidebar-link:hover,
.submenu-toggle:hover {
    background: var(--accent-color);

    color: #ffffff;
}

.sidebar-link.active {
    background: var(--accent-color);

    color: #ffffff;

    border-left-color: #ffffff;
}


/* ==========================================================================
   SUB MENUS
   ========================================================================== */

.submenu {
    display: none;

    background: rgba(255, 255, 255, 0.03);
}

.submenu.open {
    display: block;
}

.submenu .sidebar-link {
    padding-left: 2rem;

    font-size: 0.9rem;
}

.submenu-arrow {
    transition: transform 0.2s;
}

.submenu-toggle.open .submenu-arrow {
    transform: rotate(90deg);
}


/* ==========================================================================
   MAIN
   ========================================================================== */

.main-content {
    max-width: 1400px;

    width: 100%;

    min-width: 0;

    margin: 0 auto;

    padding: 2rem;

    overflow-x: hidden;
}


/* ==========================================================================
   FOOTER
   ========================================================================== */

.dashboard-footer {
    grid-column: 1 / -1;

    padding: 1rem;

    text-align: center;

    border-top: 1px solid var(--border-color);

    color: var(--text-secondary);

    background: var(--bg-secondary);
}


/* ==========================================================================
   TABLET / COMPACT DESKTOP
   ========================================================================== */

@media (max-width: 75em) {

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

    .mobile-menu-btn {
        display: inline-flex;
    }

    .sidebar {
        position: fixed;

        left: 0;
        top: 0;
        bottom: 0;

        width: min(280px, 85vw);

        transform: translateX(-100%);

        transition: transform 0.2s ease;

        z-index: 999;

        box-shadow:
            8px 0 24px
            rgba(0, 0, 0, 0.25);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        padding: 1.25rem;
    }
}


/* ==========================================================================
   MOBILE
   ========================================================================== */

@media (max-width: 40em) {

    .dashboard-header {
        align-items: flex-start;

        gap: 0.75rem;

        padding:
            0.75rem
            1rem;
    }

    .logo-container {
        flex-direction: column;

        align-items: flex-start;

        gap: 0.25rem;

        flex: 1;
    }

    .logo {
        height: 36px;
    }

    .subtitle {
        display: block;

        max-width: 100%;

        font-size: 0.8rem;

        line-height: 1.25;
    }

    .dashboard-header > div:last-child {
        margin-left: auto !important;

        display: flex !important;

        align-items: center !important;

        gap: 0.5rem !important;

        flex-shrink: 0;
    }

    .dashboard-header > div:last-child > div {
        display: none;
    }

    .dashboard-header > div:last-child > a {
        display: none;
    }

    .mobile-menu-btn {
        display: inline-flex;

        width: 40px;
        height: 40px;
    }

    .main-content {
        width: 100%;

        min-width: 0;

        padding: 1rem;
    }

    .dashboard-footer {
        padding: 0.75rem 1rem;

        font-size: 0.85rem;
    }
}
