/* Material 3 Design System */
:root {
    /* Color Roles */
    --md-sys-color-primary: #15803d;
    --md-sys-color-on-primary: #ffffff;
    --md-sys-color-primary-container: #d1e8d1;
    --md-sys-color-on-primary-container: #00210b;

    --md-sys-color-secondary: #516350;
    --md-sys-color-on-secondary: #ffffff;
    --md-sys-color-secondary-container: #d4e8d0;

    --md-sys-color-surface: #fefdfb;
    --md-sys-color-on-surface: #191c19;
    --md-sys-color-surface-variant: #f0f2ee;
    --md-sys-color-on-surface-variant: #424940;

    --md-sys-color-outline: #72796f;
    --md-sys-color-outline-variant: #c1c9be;

    --md-sys-color-error: #ba1a1a;
    --md-sys-color-on-error: #ffffff;

    /* Spacing Scale (8dp grid) */
    --md-sys-spacing-micro: 4px;
    --md-sys-spacing-base: 8px;
    --md-sys-spacing-section: 16px;
    --md-sys-spacing-vertical: 24px;
    --md-sys-spacing-large: 32px;

    /* Shape Scale */
    --md-sys-shape-corner-small: 8px;
    --md-sys-shape-corner-medium: 12px;
    --md-sys-shape-corner-large: 16px;
    --md-sys-shape-corner-full: 1000px;

    /* Typography Scale */
    --md-sys-typescale-headline-small-font: 'Roboto', sans-serif;
    --md-sys-typescale-headline-small-size: 24px;
    --md-sys-typescale-headline-small-weight: 400;

    --md-sys-typescale-label-large-font: 'Roboto', sans-serif;
    --md-sys-typescale-label-large-size: 14px;
    --md-sys-typescale-label-large-weight: 500;

    --md-sys-typescale-body-large-font: 'Roboto', sans-serif;
    --md-sys-typescale-body-large-size: 16px;
    --md-sys-typescale-body-large-weight: 400;

    --md-sys-typescale-body-medium-font: 'Roboto', sans-serif;
    --md-sys-typescale-body-medium-size: 14px;
    --md-sys-typescale-body-medium-weight: 400;
}

/* Reset & Base */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background-color: var(--md-sys-color-surface);
    color: var(--md-sys-color-on-surface);
    line-height: 1.5;
    overflow-x: hidden;
}

/* Layout Containers */
.app-container {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    background-color: var(--md-sys-color-surface);
}

.page {
    flex: 1;
    display: none;
    flex-direction: column;
    padding: var(--md-sys-spacing-section);
    padding-bottom: 80px;
    /* Space for bottom nav */
    animation: pageFadeIn 0.3s ease-out;
}

.page.active {
    display: flex;
}

@keyframes pageFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header */
.header-row {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: var(--md-sys-spacing-base) var(--md-sys-spacing-section);
    margin-bottom: var(--md-sys-spacing-vertical);
}

.header-row .logo-infotv {
    justify-self: start;
}

.header-row .logo-ags {
    justify-self: center;
}

.header-row #user-badge {
    justify-self: end;
}

.logo-ags {
    height: 48px;
    width: 120px;
    background-image: url('assets/logo-ags.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.logo-infotv {
    height: 16px;
    width: 80px;
    background-image: url('assets/logo-infotv.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: left center;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--md-sys-shape-corner-full);
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
}

/* Navigation Bar (Bottom) */
.nav-bar {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    height: 80px;
    background-color: var(--md-sys-color-surface-variant);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 0 var(--md-sys-spacing-base);
    z-index: 100;
}

.nav-destination {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    flex: 1;
    color: var(--md-sys-color-on-surface-variant);
    transition: color 0.2s;
}

.nav-destination .icon-container {
    width: 64px;
    height: 32px;
    border-radius: var(--md-sys-shape-corner-large);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.nav-destination.active {
    color: var(--md-sys-color-on-surface);
}

.nav-destination.active .icon-container {
    background-color: var(--md-sys-color-primary-container);
}

.nav-destination .label {
    font-size: 12px;
    font-weight: 500;
}

/* Typography */
.headline-small {
    font-family: var(--md-sys-typescale-headline-small-font);
    font-size: 28px;
    font-weight: 700;
    color: var(--md-sys-color-on-surface);
    margin-bottom: 32px;
}

.date-label {
    font-size: 14px;
    color: #757575;
    letter-spacing: 0.2px;
    margin-bottom: 4px;
}

.label-large {
    font-family: var(--md-sys-typescale-label-large-font);
    font-size: var(--md-sys-typescale-label-large-size);
    font-weight: var(--md-sys-typescale-label-large-weight);
    color: var(--md-sys-color-on-surface-variant);
    margin-bottom: var(--md-sys-spacing-base);
}

/* Components */

/* Segmented Button */
.segmented-button {
    display: flex;
    width: 100%;
    height: 48px;
    border: 1px solid var(--md-sys-color-outline);
    border-radius: var(--md-sys-shape-corner-medium);
    overflow: hidden;
    margin-bottom: var(--md-sys-spacing-vertical);
}

.segmented-button .segment {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
    cursor: pointer;
    border-right: 1px solid var(--md-sys-color-outline);
}

.segmented-button .segment:last-child {
    border-right: none;
}

.segmented-button .segment.selected {
    background-color: #d1e8d1;
    color: #00210b;
}

/* Chips */
.chip-group {
    display: flex;
    flex-wrap: wrap;
    gap: var(--md-sys-spacing-base);
    margin-bottom: var(--md-sys-spacing-vertical);
}

.filter-chip {
    height: 32px;
    padding: 0 12px;
    border-radius: var(--md-sys-shape-corner-small);
    border: 1px solid var(--md-sys-color-outline);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-chip.selected {
    background-color: var(--md-sys-color-primary-container);
    border: none;
    color: var(--md-sys-color-on-primary-container);
}

/* List Items */
.list-item {
    display: flex;
    align-items: center;
    min-height: 56px;
    padding: 0 var(--md-sys-spacing-section);
    cursor: pointer;
    transition: background-color 0.2s;
}

.in-list-item {
    margin-bottom: 16px;
}

/* Home Tabs */
.home-tabs {
    display: flex;
    gap: 32px;
    margin-bottom: 24px;
}

.home-tab {
    font-size: 16px;
    font-weight: 500;
    color: #666;
    padding-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 3px solid transparent;
}

.home-tab.active {
    color: #2E7D32;
    border-bottom: 3px solid #2E7D32;
}

.list-item .content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.list-item .title {
    font-size: var(--md-sys-typescale-body-large-size);
    color: var(--md-sys-color-on-surface);
}

.list-item .supporting-text {
    font-size: var(--md-sys-typescale-body-medium-size);
    color: var(--md-sys-color-on-surface-variant);
}

.list-item .trailing {
    margin-left: var(--md-sys-spacing-section);
    color: var(--md-sys-color-on-surface-variant);
}

/* Checkbox List Item */
.checkbox-list-item {
    display: flex;
    align-items: center;
    min-height: 56px;
    padding: 0 var(--md-sys-spacing-section);
    cursor: pointer;
}

.checkbox-list-item .checkbox-container {
    margin-right: var(--md-sys-spacing-section);
    width: 18px;
    height: 18px;
    border: 2px solid var(--md-sys-color-outline);
    border-radius: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.checkbox-list-item.selected .checkbox-container {
    background-color: var(--md-sys-color-primary);
    border-color: var(--md-sys-color-primary);
}

.checkbox-list-item.selected .checkbox-container::after {
    content: '✓';
    color: white;
    font-size: 12px;
}

.checkbox-list-item .label {
    font-size: var(--md-sys-typescale-body-large-size);
    color: var(--md-sys-color-on-surface);
}

/* Buttons */
.filled-button {
    height: 40px;
    padding: 0 24px;
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    border-radius: var(--md-sys-shape-corner-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
    cursor: pointer;
    border: none;
    width: 100%;
    margin-top: var(--md-sys-spacing-vertical);
}

/* Helpers */
.hidden {
    display: none !important;
}

/* Modal Bottom Sheet */
.bottom-sheet-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    display: none;
    justify-content: center;
    align-items: flex-end;
    z-index: 200;
}

.bottom-sheet-overlay.active {
    display: flex;
}

.bottom-sheet {
    width: 100%;
    max-width: 480px;
    background-color: var(--md-sys-color-surface);
    border-radius: var(--md-sys-shape-corner-large) var(--md-sys-shape-corner-large) 0 0;
    padding: var(--md-sys-spacing-section);
    padding-bottom: 40px;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    animation: sheetSlideUp 0.3s ease-out;
}

@keyframes sheetSlideUp {
    from {
        transform: translateY(100%);
    }

    to {
        transform: translateY(0);
    }
}

/* Top Sheet Variant */
.top-sheet-overlay {
    align-items: flex-start !important;
}

.top-sheet {
    width: 100%;
    max-width: 480px;
    background-color: var(--md-sys-color-surface);
    border-radius: 0 0 var(--md-sys-shape-corner-large) var(--md-sys-shape-corner-large);
    padding: var(--md-sys-spacing-section);
    padding-bottom: 24px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    animation: sheetSlideDown 0.3s ease-out;
}

@keyframes sheetSlideDown {
    from {
        transform: translateY(-100%);
    }

    to {
        transform: translateY(0);
    }
}

.sheet-handle {
    width: 32px;
    height: 4px;
    background-color: var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-shape-corner-full);
    margin: 0 auto var(--md-sys-spacing-section);
}

/* Status Message (Toast) */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #313131;
    color: white;
    padding: 12px 24px;
    border-radius: 4px;
    font-size: 14px;
    z-index: 300;
    display: none;
}

.toast.active {
    display: block;
}

/* Login PIN Input */
.pin-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 16px;
    width: 240px;
    /* Reduced width to ensure square buttons fit on height */
}

.pin-btn {
    aspect-ratio: 1;
    /* Forces square shape */
    border-radius: var(--md-sys-shape-corner-small);
    border: 1px solid var(--md-sys-color-outline);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 500;
    cursor: pointer;
    background-color: var(--md-sys-color-surface);
}

.pin-btn:active {
    background-color: var(--md-sys-color-surface-variant);
}