/* --- Base & Theme Variables --- */
:root {
    --md-sys-color-primary: #6750A4;
    --md-sys-color-on-primary: #FFFFFF;
    --md-sys-color-primary-container: #EADDFF;
    --md-sys-color-on-primary-container: #21005D;
    --md-sys-color-secondary: #625B71;
    --md-sys-color-on-secondary: #FFFFFF;
    --md-sys-color-secondary-container: #E8DEF8;
    --md-sys-color-on-secondary-container: #1D192B;
    --md-sys-color-tertiary-container: #FFD8E4;
    --md-sys-color-on-tertiary-container: #31111D;
    --md-sys-color-background: #FFFBFE;
    --md-sys-color-on-background: #1C1B1F;
    --md-sys-color-surface: #FFFBFE;
    --md-sys-color-on-surface: #1C1B1F;
    --md-sys-color-surface-variant: #E7E0EC;
    --md-sys-color-on-surface-variant: #49454F;
    --md-sys-color-surface-bright: #FEF7FF;
    --md-sys-color-surface-container-high: #ECE6F0;
    --md-sys-color-surface-container-highest: #E6E0E9;
    --md-sys-color-surface-container-low: #F7F2FA;
    --md-sys-color-surface-container: #F3EDF7;
    --md-sys-color-outline: #79747E;
    --md-sys-color-outline-variant: #CAC4D0;
    --md-sys-color-inverse-surface: #313033;
    --md-sys-color-inverse-on-surface: '#F4EFF4';
    --md-sys-color-error: #B3261E;

    --drawer-width: 280px;
}

body {
    font-family: 'Roboto', sans-serif;
    margin: 0;
    background-color: var(--md-sys-color-background);
    color: var(--md-sys-color-on-background);
}

/* --- Main Layout using CSS Grid --- */
.app-container {
    display: grid;
    grid-template-columns: var(--drawer-width) 1fr;
    min-height: 100vh;
}

/* --- Navigation Drawer (Sidebar) --- */
.navigation-drawer {
    background-color: var(--md-sys-color-surface);
    border-right: 1px solid var(--md-sys-color-outline-variant);
    padding: 12px;
    /* Make it sticky to the top within its grid cell */
    position: sticky;
    top: 0;
    height: 100vh;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    z-index: 2000 !important; /* Always on top of everything */
}

.nav-header {
    display: flex;
    align-items: center;
    padding: 16px 16px 24px 16px;
}

.logo-icon {
    font-size: 24px;
    margin-right: 12px;
    color: var(--md-sys-color-primary);
}

.app-name {
    font-size: 1.5rem;
    font-weight: 500;
    color: var(--md-sys-color-on-surface);
}

.nav-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-menu li {
    margin-bottom: 4px;
}

.nav-menu a {
    display: flex;
    align-items: center;
    height: 56px;
    padding: 0 24px;
    border-radius: 28px;
    text-decoration: none;
    color: var(--md-sys-color-on-surface-variant);
    font-size: 0.875rem;
    font-weight: 500;
    transition: background-color 0.2s, color 0.2s;
}

.nav-menu a:hover {
    background-color: rgba(29, 25, 43, 0.08);
    color: var(--md-sys-color-on-surface);
}

.nav-menu a.active {
    background-color: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
}

.nav-menu a .material-symbols-rounded {
    margin-right: 12px;
    font-size: 24px;
}

.divider {
    height: 1px;
    background-color: var(--md-sys-color-outline);
    margin: 12px 16px;
    opacity: 0.2;
}

/* --- Main Content Area --- */
.content-area {
    display: flex;
    flex-direction: column;
    /* This area will scroll naturally if content overflows */
}

.top-app-bar {
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    background-color: var(--md-sys-color-surface);
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    /* Make the top bar sticky */
    position: sticky;
    top: 0;
    z-index: 1500 !important; /* High enough to be above page content and sub-navs */
}

.page-title {
    font-size: 1.375rem;
    font-weight: 400;
    margin: 0;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    font-weight: 500;
}

.content-wrapper {
    padding: 24px;
    background-color: var(--md-sys-color-background);
}

/* --- Form Elements --- */
.form-input,
.form-textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--md-sys-color-outline);
    border-radius: 4px;
    background-color: var(--md-sys-color-surface);
    color: var(--md-sys-color-on-surface);
    font-family: inherit;
    font-size: 1rem;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--md-sys-color-primary);
    box-shadow: 0 0 0 2px var(--md-sys-color-primary-container);
}

.form-textarea {
    resize: vertical;
}

/* --- Toast Notifications --- */
#toast-container {
    position: fixed;
    bottom: 1.25rem;
    right: 1.25rem;
    z-index: 50;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.toast-message {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    animation: fadeIn 0.5s ease-out forwards, fadeOut 0.5s ease-in 4.5s forwards;
}
.toast-message.success { background-color: #4CAF50; color: white; }
.toast-message.error { background-color: #B3261E; color: white; }
.toast-message.warning { background-color: #FFC107; color: black; }
.toast-message.info { background-color: #2196F3; color: white; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateX(100%); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes fadeOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(100%); }
}
