/* Layout Grid Principal */
.app-container {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    grid-template-rows: var(--header-h) 1fr;
    height: 100vh;
    overflow: hidden;
}

/* Header */
.app-header {
    grid-column: 1 / -1;
    background-color: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    padding: 0 var(--space-lg);
    justify-content: space-between;
    z-index: 10;
}

.app-brand {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--color-primary);
    cursor: pointer;
}

.app-brand:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 4px;
    border-radius: var(--radius-sm);
}

/* Sidebar toggle — visível apenas em mobile (T6) */
.sidebar-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    color: var(--color-text);
    flex-shrink: 0;
}

.sidebar-toggle:hover {
    background-color: var(--color-bg);
}

.sidebar-toggle:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.sidebar-backdrop {
    display: none;
}

/* Sidebar */
.app-sidebar {
    background-color: var(--color-surface);
    border-right: 1px solid var(--color-border);
    padding: var(--space-md);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.history-title {
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-muted);
    margin-bottom: var(--space-md);
    font-weight: 600;
}

.history-list {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

/* Main Content */
.app-main {
    background-color: var(--color-bg);
    padding: var(--space-xl);
    overflow-y: auto;
    position: relative;
}

.upload-view,
.report-view {
    max-width: 960px;
    margin: 0 auto;
}

.report-view {
    background-color: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: var(--space-xl);
    min-height: 80vh;
}

/* Mobile drawer (T6) */
@media (max-width: 767px) {
    .app-container {
        grid-template-columns: 1fr;
    }

    .sidebar-toggle {
        display: inline-flex;
    }

    .app-sidebar {
        position: fixed;
        top: var(--header-h);
        left: 0;
        bottom: 0;
        width: min(var(--sidebar-w), 85vw);
        z-index: 100;
        transform: translateX(-100%);
        transition: transform 0.25s var(--ease-out);
        box-shadow: var(--shadow-md);
    }

    .sidebar-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        top: var(--header-h);
        background: rgba(2, 44, 34, 0.4);
        z-index: 90;
    }

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

    .app-container.sidebar-open .sidebar-backdrop {
        display: block;
    }

    .app-container.sidebar-open .sidebar-backdrop[hidden] {
        display: block;
    }

    .app-main {
        padding: var(--space-md);
    }
}