/*
 * Layout Styles
 * Grid system for Sidebar + Main Content (Responsive)
 */

.app-container {
    display: grid;
    grid-template-columns: 260px 1fr;
    /* Sidebar fixed width, Content fills rest */
    min-height: 100vh;
}

.hidden-desktop {
    display: none !important;
}

/* Sidebar Styling */
.sidebar {
    background-color: var(--color-primary);
    color: white;
    padding: var(--spacing-md);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    margin-bottom: var(--spacing-lg);
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--color-primary-light);
    padding-bottom: var(--spacing-sm);
}

.nav-link {
    display: block;
    padding: var(--spacing-sm);
    color: #94a3b8;
    /* Slate 400 */
    border-radius: var(--radius-sm);
    margin-bottom: var(--spacing-xs);
    transition: all 0.2s;
}

.nav-link:hover,
.nav-link.active {
    background-color: var(--color-primary-light);
    color: white;
    text-decoration: none;
}

/* Main Content Area */
.main-content {
    padding: var(--spacing-lg);
    overflow-y: auto;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-lg);
    flex-wrap: wrap;
    gap: var(--spacing-sm);
}

.top-bar h1 {
    flex: 1;
    min-width: 0;
}

.actions {
    display: flex;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
}

/* ---- RESPONSIVE BREAKPOINTS ---- */

/* Tablet: 768px and below */
@media (max-width: 768px) {
    .hidden-desktop {
        display: flex !important;
    }

    .app-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }

    .mobile-header {
        align-items: center;
        justify-content: space-between;
        padding: var(--spacing-sm) var(--spacing-md);
        background-color: var(--color-primary);
        color: white;
        margin-bottom: var(--spacing-md);
        border-radius: var(--radius-md);
        box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    }

    .mobile-brand {
        font-weight: 700;
        letter-spacing: 0.05em;
    }

    #mobile-menu-toggle {
        background: transparent;
        color: white;
        border: none;
        font-size: 1.5rem;
        cursor: pointer;
        padding: 0.5rem;
        border-radius: var(--radius-sm);
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: background-color 0.2s;
    }

    #mobile-menu-toggle:hover {
        background-color: var(--color-primary-light);
    }

    /* Off-Canvas Sidebar */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 250px;
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        flex-direction: column;
        align-items: stretch;
        padding: var(--spacing-md);
        box-shadow: 4px 0 10px rgba(0, 0, 0, 0.1);
    }

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

    .sidebar-header {
        margin-bottom: var(--spacing-lg);
        font-size: 1.25rem;
        border-bottom: 1px solid var(--color-primary-light);
        padding-bottom: var(--spacing-sm);
        border-right: none;
    }

    .nav-link {
        padding: var(--spacing-sm);
        margin-bottom: var(--spacing-xs);
        font-size: 1rem;
        min-height: 44px;
        /* WCAG touch target */
        display: flex;
        align-items: center;
    }

    .main-content {
        order: 2;
        padding: var(--spacing-sm);
    }

    .top-bar {
        position: sticky;
        top: 0;
        z-index: 10;
        background: var(--bg-body, #f8fafc);
        padding-bottom: 1rem;
        margin-bottom: 1rem;
        border-bottom: 1px solid var(--border-color);
        /* Layout */
        flex-direction: column;
        align-items: stretch;
    }

    .actions {
        width: 100%;
        display: flex;
        flex-direction: row;
        /* Try to keep them side-by-side if they fit */
        flex-wrap: wrap;
        /* Allow stacking if needed */
        gap: var(--spacing-sm);
    }

    .actions button {
        flex: 1;
        /* Stretch buttons evenly */
        min-width: 44px;
        /* WCAG touch target */
        white-space: nowrap;
        /* Keep text on one line */
    }
}

/* Mobile: 480px and below */
@media (max-width: 480px) {
    .sidebar {
        width: 80%;
        /* Takes up more space on very small screens */
    }

    .actions {
        flex-direction: column;
    }

    .actions button {
        width: 100%;
        margin-left: 0 !important;
    }
}