/* MD3 Color Tokens & Mockup Styles */
:root {
    /* MD3 Color Tokens */
    --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-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: #FEF7FF;
    --md-sys-color-surface: #FEF7FF;
    --md-sys-color-surface-container: #F3EDF7;
    --md-sys-color-surface-container-low: #F7F2FA;
    --md-sys-color-surface-container-high: #ECE6F0;

    --md-sys-color-on-surface: #1D1B20;
    --md-sys-color-on-surface-variant: #49454F;
    --md-sys-color-outline: #79747E;
    --md-sys-color-outline-variant: #C4C7C5;

    --md-sys-color-success: #146c2e;

    --radius-l: 16px;
    --radius-m: 12px;
    --radius-full: 999px;
}

.dark-theme {
    --md-sys-color-primary: #D0BCFF;
    --md-sys-color-on-primary: #381E72;
    --md-sys-color-primary-container: #4F378B;
    --md-sys-color-on-primary-container: #EADDFF;
    --md-sys-color-secondary-container: #4A4458;
    --md-sys-color-on-secondary-container: #E8DEF8;
    --md-sys-color-tertiary-container: #633B48;
    --md-sys-color-on-tertiary-container: #FFD8E4;
    --md-sys-color-background: #141218;
    --md-sys-color-surface: #141218;
    --md-sys-color-surface-container: #1D1B20;
    --md-sys-color-surface-container-low: #1D1B20;
    --md-sys-color-surface-container-high: #2B2930;
    --md-sys-color-on-surface: #E6E1E5;
    --md-sys-color-on-surface-variant: #CAC4D0;
    --md-sys-color-outline: #938F99;
    --md-sys-color-outline-variant: #49454F;
    --md-sys-color-success: #81c995;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

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

.app-layout {
    display: flex;
    min-height: 100vh;
    width: 100vw;
}

/* --- SIDEBAR --- */
.sidebar {
    width: 280px;
    background-color: var(--md-sys-color-surface-container);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--md-sys-color-outline-variant);
    flex-shrink: 0;
    z-index: 2;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-header {
    padding: 24px 16px 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.brand {
    font-size: 20px;
    font-weight: 500;
    color: var(--md-sys-color-on-surface);
    padding-left: 8px;
}

.fab-extended {
    width: 100%;
    height: 56px;
    border-radius: 16px;
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: 0.2s;
}

.fab-extended:hover {
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.repo-list-container {
    flex: 1;
    overflow-y: auto;
    padding: 0 12px;
}

.section-label {
    padding: 0 16px 12px 16px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--md-sys-color-on-surface-variant);
    font-weight: 500;
}

.repo-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.repo-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 16px 0 16px;
    height: 48px;
    border-radius: var(--radius-full);
    cursor: pointer;
    color: var(--md-sys-color-on-surface-variant);
    font-weight: 500;
    transition: background 0.2s;
    font-size: 14px;
}

.repo-item:hover {
    background-color: rgba(29, 27, 32, 0.08);
}

.repo-item.active {
    background-color: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
}

.repo-item .path {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 16px 20px;
    background-color: rgba(0, 0, 0, 0.03);
    border-top: 1px solid var(--md-sys-color-outline-variant);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sys-stat {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
}

.sys-stat-label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--md-sys-color-on-surface-variant);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--md-sys-color-success);
}

/* --- MAIN CONTENT --- */
.main-content {
    flex: 1;
    padding: 24px 32px;
    margin-left: 280px;
    /* Offset for fixed sidebar */
    overflow-y: auto;
    /* Enable page scroll */
    display: flex;
    flex-direction: column;
    gap: 24px;
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.page-title {
    font-size: 28px;
    font-weight: 400;
    line-height: 1.2;
    margin-bottom: 4px;
}

.page-subtitle {
    font-family: monospace;
    color: var(--md-sys-color-on-surface-variant);
    font-size: 14px;
    background: var(--md-sys-color-surface-container-high);
    padding: 4px 8px;
    border-radius: 4px;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.stat-card {
    background-color: var(--md-sys-color-surface-container-low);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--radius-l);
    padding: 20px;
    position: relative;
}

.stat-card-icon {
    position: absolute;
    top: 20px;
    right: 20px;
    color: var(--md-sys-color-primary);
    background: var(--md-sys-color-secondary-container);
    padding: 8px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--md-sys-color-on-surface-variant);
    margin-bottom: 4px;
}

.stat-value {
    font-size: 28px;
    font-weight: 400;
    color: var(--md-sys-color-on-surface);
    line-height: 1.2;
}

.stat-sub {
    font-size: 12px;
    color: var(--md-sys-color-on-surface-variant);
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Repo Panel & Table */
.repo-panel {
    background-color: var(--md-sys-color-surface);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--radius-l);
    pointer-events: auto;
    /* No flex or overflow restrictions - expands naturally */
}

.repo-toolbar {
    padding: 16px 24px;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--md-sys-color-surface-container-low);
}

.table-wrapper {
    /* Table expands with content - no height restrictions */
    width: 100%;
}

table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

thead {
    position: sticky;
    top: 0;
    background: var(--md-sys-color-surface-container-low);
    z-index: 1;
    /* Reduced from 1000 to test click blocking */
}

th {
    text-align: left;
    padding: 16px 24px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--md-sys-color-on-surface-variant);
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

/* Interactive Rows */
tbody.snapshot-group {
    border-bottom: 1px solid #E0E0E0;
}

tr.summary-row {
    cursor: pointer;
    transition: background 0.1s;
}

tr.summary-row:hover {
    background-color: rgba(0, 0, 0, 0.02);
}

td {
    padding: 14px 24px;
    color: var(--md-sys-color-on-surface);
    font-size: 14px;
    vertical-align: middle;
}

.expand-icon {
    transition: transform 0.3s ease;
    color: var(--md-sys-color-on-surface-variant);
}

.snapshot-group.expanded .expand-icon {
    transform: rotate(90deg);
}

/* Detail Row (File Browser) */
tr.details-row {
    display: none;
    background-color: #fafafa;
}

.snapshot-group.expanded tr.details-row {
    display: table-row;
}

.file-browser-container {
    padding: 16px 0 16px 40px;
    /* Indent for visual hierarchy */
    max-height: 300px;
    overflow-y: auto;
}

/* File Tree Styling */
.tree-list {
    list-style: none;
    padding-left: 20px;
    border-left: 1px solid #ddd;
}

.tree-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    font-family: 'Roboto Mono', monospace;
    font-size: 13px;
    color: #444;
}

.tree-icon {
    font-size: 18px;
    color: var(--md-sys-color-on-surface-variant);
}

.folder-icon {
    color: #FBC02D;
    /* Classic folder color hint */
}

.icon-success {
    color: var(--md-sys-color-success) !important;
}

/* Restore Button */
.btn-restore {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-restore:hover {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.badge {
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 6px;
    font-weight: 500;
}

.badge-hourly {
    background-color: var(--md-sys-color-tertiary-container);
    color: var(--md-sys-color-on-tertiary-container);
}

.badge-daily {
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
}

/* Icon Button */
.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--md-sys-color-on-surface-variant);
    transition: background 0.2s, color 0.2s;
}

.btn-icon:hover {
    background-color: var(--md-sys-color-surface-container-high);
    color: var(--md-sys-color-primary);
}

.btn-browse {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background-color: var(--md-sys-color-secondary-container);
    /* Changed to secondary container */
    color: var(--md-sys-color-on-secondary-container);
    /* ensure contrast */
    border: none;
    padding: 0 16px;
    height: 32px;
    border-radius: 16px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: box-shadow 0.2s;
}

.btn-browse:hover {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Modal Content */
.modal-content {
    background: var(--md-sys-color-surface);
    border-radius: 16px;
    width: 90%;
    max-width: 1200px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
    animation: slideUp 0.2s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Loader */
#app-wasm-loader {
    background-color: var(--md-sys-color-background) !important;
    background-image: none !important;
}

/* Hide default elements (Logo and Label) */
#app-wasm-loader>* {
    display: none !important;
}

/* Custom Spinner using pseudo-element */
#app-wasm-loader::after {
    content: "";
    width: 48px;
    height: 48px;
    border: 5px solid var(--md-sys-color-surface-container-high);
    border-bottom-color: var(--md-sys-color-primary);
    border-radius: 50%;
    display: inline-block;
    box-sizing: border-box;
    animation: rotation 1s linear infinite;
}

@keyframes rotation {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Modal Header */
/* Table Styles */
.table-header,
.table-row {
    display: grid;
    grid-template-columns: 90px 140px 1fr 80px 100px 60px;
    /* ID | Time | Hostname | Size | Files | Actions */
    padding: 12px 24px;
    align-items: center;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    gap: 16px;
}

.table-row:hover {
    background-color: var(--md-sys-color-surface-variant);
    /* Hover effect */
}

.table-header .header {
    font-size: 14px;
    font-weight: 500;
    color: var(--md-sys-color-on-surface-variant);
}

.table-row .cell {
    font-size: 14px;
    color: var(--md-sys-color-on-surface);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.table-row .cell:last-child {
    overflow: visible;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--md-sys-color-on-surface);
    transition: background 0.2s;
}

.modal-close:hover {
    background: var(--md-sys-color-surface-container-high);
}

/* Modal Body */
.modal-body {
    padding: 16px 24px;
    overflow-y: auto;
    flex: 1;
}

/* Action Menu */
.action-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: var(--md-sys-color-surface);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    min-width: 180px;
    overflow: hidden;
    animation: fadeIn 0.1s ease;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    font-size: 14px;
    color: var(--md-sys-color-on-surface);
    transition: background 0.2s;
}

.menu-item:hover {
    background: var(--md-sys-color-surface-container-high);
}

.menu-item .material-symbols-rounded {
    font-size: 20px;
    color: var(--md-sys-color-on-surface-variant);
}

/* New Div-based Snapshot List */
.snapshot-list {
    display: flex;
    flex-direction: column;
    pointer-events: auto;
}

.snapshot-header {
    display: flex;
    padding: 16px 24px;
    background: var(--md-sys-color-surface-container-low);
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--md-sys-color-on-surface-variant);
}

.snapshot-row {
    display: flex;
    padding: 14px 24px;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    align-items: center;
    transition: background 0.1s;
    pointer-events: auto;
}

.snapshot-row:hover {
    background-color: rgba(0, 0, 0, 0.02);
}

.col-id {
    width: 120px;
    flex-shrink: 0;
}

.col-time {
    flex: 1;
}

.col-tags {
    width: 100px;
    flex-shrink: 0;
}

.col-size {
    width: 150px;
    flex-shrink: 0;
}

.col-actions {
    width: 80px;
    flex-shrink: 0;
    display: flex;
    justify-content: flex-end;
}

.action-btn-container {
    position: relative;
}

.snapshot-empty {
    padding: 32px;
    text-align: center;
    color: var(--md-sys-color-on-surface-variant);
}

/* Tree View */
.tree-container {
    display: flex;
    flex-direction: column;
}

.tree-header,
.tree-row {
    display: grid;
    grid-template-columns: 1fr 100px 100px 140px;
    /* Name | Size | Mode | Modified */
    padding: 10px 16px;
    align-items: center;
    gap: 16px;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

.tree-header {
    background-color: var(--md-sys-color-surface-container-low);
    font-weight: 500;
    font-size: 13px;
    color: var(--md-sys-color-on-surface-variant);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-top-left-radius: 16px;
    /* Matches modal content logic if needed */
    border-top-right-radius: 16px;
}

.tree-row {
    font-size: 14px;
    color: var(--md-sys-color-on-surface);
    transition: background-color 0.1s;
}

.tree-row:hover {
    background-color: var(--md-sys-color-surface-variant);
}

.tree-col-name {
    display: flex;
    align-items: center;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* Mobile Sidebar Overlay */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1001;
    /* Above Top Bar (if needed) but Sidebar is z-2 so sidebar needs z-index bump */
    animation: fadeIn 0.2s;
}

/* Mobile Menu Button - Hidden on Desktop */
.mobile-menu-btn {
    display: none !important;
}

/* Media Query for Mobile/Tablet */
@media (max-width: 768px) {

    /* Main Layout */
    .app-layout {
        display: block;
        /* Stack sidebar and main content */
    }

    /* Sidebar - Mobile Drawer */
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 1002;
        /* Above overlay */
        background-color: var(--md-sys-color-surface);
        /* Ensure background is opaque */
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
        width: 280px;
        /* Fixed width drawer */
    }

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

    /* Main Content */
    .main-content {
        margin-left: 0;
        /* Reset margin since sidebar is fixed/hidden */
        width: 100%;
    }

    /* Show Menu Button */
    .mobile-menu-btn {
        display: flex !important;
    }

    /* Top Bar adjustments */
    .top-bar {
        padding: 12px 16px;
    }

    /* Stats Grid - Single Column on Mobile */
    .stats-grid {
        grid-template-columns: 1fr;
    }

    /* Snapshot Table - Card View */
    .table-header {
        display: none;
        /* Hide header row */
    }

    .table-row {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        padding: 16px;
        gap: 8px;
        border: 1px solid var(--md-sys-color-outline-variant);
        border-radius: 12px;
        margin-bottom: 12px;
        background-color: var(--md-sys-color-surface);
    }

    .table-row .cell {
        width: 100%;
        overflow: visible;
        display: flex;
        justify-content: space-between;
        align-items: center;
        font-size: 14px;
    }

    .table-row .cell::before {
        content: attr(data-label);
        font-weight: 500;
        color: var(--md-sys-color-on-surface-variant);
        text-transform: uppercase;
        font-size: 12px;
    }

    /* Inject labels via CSS content (Simplified approach - manual labels are better but CSS content works if fixed order) */
    /* Note: data-label attribute is best best, but for now we rely on order or just display content cleanly */

    /* Specifically style the Actions cell to be at top right or bottom right */
    .table-row .cell:last-child {
        justify-content: flex-end;
        width: 100%;
        margin-top: 8px;
        border-top: 1px solid var(--md-sys-color-outline-variant);
        padding-top: 8px;
    }

    /* Modal - Full Screen */
    .modal-content {
        width: 100%;
        height: 100%;
        max-height: 100%;
        max-width: 100%;
        border-radius: 0;
    }

    /* File Browser Tree - Simplified */
    .tree-header {
        display: none;
    }

    .tree-row {
        grid-template-columns: 1fr auto;
        /* Name | Size */
        gap: 8px;
        padding: 12px 16px;
    }

    /* Hide Mode and Modified on Mobile */
    .tree-col-mode,
    .tree-col-mtime {
        display: none;
    }
}

.tree-col-size,
.tree-col-mode,
.tree-col-mtime {
    font-family: 'Roboto Mono', monospace;
    font-size: 13px;
    color: var(--md-sys-color-on-surface-variant);
}

/* Modal Search Input */
.modal-search-input {
    background-color: var(--md-sys-color-surface-container-high);
    border: none;
    border-radius: 20px;
    padding: 10px 16px;
    color: var(--md-sys-color-on-surface);
    font-size: 14px;
    outline: none;
    width: 250px;
    transition: box-shadow 0.2s;
}

.modal-search-input:focus {
    box-shadow: 0 0 0 2px var(--md-sys-color-primary);
}

.modal-search-input::placeholder {
    color: var(--md-sys-color-on-surface-variant);
}

/* Wizard Styles */
.wizard-step {
    animation: fadeIn 0.3s ease-out;
}

.wizard-card {
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: 12px;
    padding: 24px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    text-align: center;
    background-color: var(--md-sys-color-surface-container-low);
}

.wizard-card:hover {
    background-color: var(--md-sys-color-surface-container-high);
    border-color: var(--md-sys-color-primary);
    transform: translateY(-2px);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- AUTHENTICATION (M3 REDESIGN) --- */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: var(--md-sys-color-background);
    padding: 24px;
}

.auth-card {
    background-color: var(--md-sys-color-surface-container-high);
    padding: 40px;
    border-radius: 28px;
    /* M3 XL Corner Radius */
    width: 100%;
    max-width: 440px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    /* Subtle elevation */
}

/* Header */
.auth-header {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    margin-bottom: 8px;
}

.auth-icon {
    width: 48px;
    height: 48px;
    background-color: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
    border-radius: 16px;
    /* M3 M Corner Radius */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.auth-title {
    font-size: 24px;
    font-weight: 400;
    /* M3 Headline Small */
    color: var(--md-sys-color-on-surface);
}

.auth-subtitle {
    font-size: 14px;
    color: var(--md-sys-color-on-surface-variant);
    font-weight: 500;
}

/* Filled Text Fields (M3) */
.md3-field {
    position: relative;
    background-color: var(--md-sys-color-surface-container-highest);
    border-top-left-radius: 4px;
    /* M3 Extra Small */
    border-top-right-radius: 4px;
    height: 56px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 0 16px;
    transition: background-color 0.2s;
    border-bottom: 1px solid var(--md-sys-color-on-surface-variant);
}

.md3-field:focus-within {
    border-bottom: 2px solid var(--md-sys-color-primary);
}

.md3-field label {
    font-family: 'Roboto', sans-serif;
    font-size: 12px;
    color: var(--md-sys-color-on-surface-variant);
    pointer-events: none;
    transition: 0.2s ease all;
    position: absolute;
    top: 8px;
    left: 16px;
}

.md3-field input {
    background: none;
    border: none;
    outline: none;
    font-size: 16px;
    font-family: 'Roboto', sans-serif;
    color: var(--md-sys-color-on-surface);
    width: 100%;
    margin-top: 16px;
    /* Space for labels */
    padding: 0;
    height: 24px;
}

/* Active floating label style handled by HTML structure/placeholder hack or JS state usually, 
   but for simplicity we fix the label to top. Ideally we can use :placeholder-shown for float animation. */

.md3-field:hover {
    background-color: rgba(29, 27, 32, 0.08);
    /* Overlay for state layer */
}

/* Buttons */
.btn-m3-primary {
    height: 40px;
    border-radius: 20px;
    /* Stadium */
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    border: none;
    font-family: 'Roboto', sans-serif;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.1px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 24px;
    transition: 0.2s;
    width: 100%;
}

.btn-m3-primary:hover {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    /* Elevation 1 */
    opacity: 0.92;
}

.btn-m3-primary:disabled {
    background-color: rgba(29, 27, 32, 0.12);
    color: rgba(29, 27, 32, 0.38);
    box-shadow: none;
    cursor: not-allowed;
}

/* Links */
.auth-footer {
    text-align: center;
    margin-top: 16px;
    font-size: 14px;
    color: var(--md-sys-color-on-surface-variant);
}

.link-primary {
    color: var(--md-sys-color-primary);
    text-decoration: none;
    font-weight: 500;
    cursor: pointer;
}

.link-primary:hover {
    text-decoration: underline;
}

/* Error Message */
.auth-error {
    color: var(--md-sys-color-error);
    background-color: rgba(186, 26, 26, 0.1);
    padding: 12px;
    border-radius: 8px;
    font-size: 14px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
/* Loading Overlay */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: var(--radius-l);
    gap: 16px;
    animation: fadeIn 0.3s ease;
}

.dark-theme .loading-overlay {
    background: rgba(20, 18, 24, 0.8);
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--md-sys-color-surface-container-high);
    border-bottom-color: var(--md-sys-color-primary);
    border-radius: 50%;
    display: inline-block;
    box-sizing: border-box;
    animation: rotation 1s linear infinite;
}

.loading-text {
    font-size: 16px;
    font-weight: 500;
    color: var(--md-sys-color-on-surface);
}

.loading-subtext {
    font-size: 14px;
    color: var(--md-sys-color-on-surface-variant);
}
