/* Lap Timer Tracker - Main Stylesheet */

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Roboto', sans-serif;
    background-color: var(--theme-bg, #f5f5f5);
    color: var(--theme-text, #333);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Login Page */
#loginPage {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: var(--theme-login-gradient, linear-gradient(135deg, #667eea 0%, #764ba2 100%));
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.login-card {
    background: var(--theme-card-bg, white);
    border-radius: 8px;
    padding: 40px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.login-title {
    font-size: 28px;
    font-weight: 500;
    text-align: center;
    margin-bottom: 8px;
    color: var(--theme-text, #333);
}

.login-subtitle {
    text-align: center;
    color: var(--theme-text-muted, #666);
    margin-bottom: 30px;
}

/* Main Application Layout */
#mainApp {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* App Bar */
.app-bar {
    background-color: var(--theme-header, #64b5f6);
    color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-bar-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    max-width: 1400px;
    margin: 0 auto;
}

.app-title {
    font-size: 24px;
    font-weight: 500;
}

.app-bar-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-info {
    font-size: 14px;
}

/* Navigation Tabs */
.nav-tabs {
    background-color: var(--theme-card-bg, white);
    border-bottom: 1px solid var(--theme-border, #e0e0e0);
    display: flex;
    gap: 8px;
    padding: 0 24px;
    overflow-x: auto;
    position: sticky;
    top: 64px;
    z-index: 90;
}

.nav-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px 20px;
    border: none;
    background: none;
    color: var(--theme-text-muted, #666);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.3s;
    white-space: nowrap;
}

.nav-tab:hover {
    color: var(--theme-accent, #1976d2);
    background-color: var(--theme-hover, #f5f5f5);
}

.nav-tab.active {
    color: var(--theme-accent, #1976d2);
    border-bottom-color: var(--theme-accent, #1976d2);
}

.nav-tab .material-icons {
    font-size: 20px;
}

.nav-tab-right {
    margin-left: auto;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 24px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

.container {
    width: 100%;
}

.container-small {
    max-width: 800px;
    margin: 0 auto;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Cards */
.card {
    background: var(--theme-card-bg, white);
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--theme-border, transparent);
}

.card-title {
    font-size: 20px;
    font-weight: 500;
    margin-bottom: 16px;
    color: var(--theme-text, #333);
}

.card-subtitle {
    font-size: 14px;
    color: var(--theme-text-muted, #666);
    font-weight: 400;
    margin-left: 8px;
}

.section-title {
    font-size: 28px;
    font-weight: 400;
    margin-bottom: 24px;
    color: var(--theme-text, #333);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--theme-card-bg, white);
    border-radius: 8px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--theme-border, transparent);
}

.stat-icon {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon .material-icons {
    font-size: 32px;
    color: white;
}

.stat-content {
    flex: 1;
}

.stat-label {
    font-size: 14px;
    color: var(--theme-text-muted, #666);
    margin-bottom: 4px;
}

.stat-value {
    font-size: 32px;
    font-weight: 500;
    color: var(--theme-text, #333);
}

#statCircuits,
#statCars {
    font-size: 18px;
}

/* Forms */
.form-field {
    margin-bottom: 20px;
}

.form-field label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--theme-text, #333);
    margin-bottom: 8px;
}

.form-field input:not([type="checkbox"]),
.form-field select,
.form-field textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--theme-border, #ddd);
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    background-color: var(--theme-input-bg, #fff);
    color: var(--theme-text, #333);
    transition: border-color 0.3s;
    box-sizing: border-box;
}

/* Checkbox label inside form-field should use flex */
.form-field .checkbox-label {
    display: flex;
    margin-bottom: 0;
}

.form-field textarea {
    resize: vertical;
    min-height: 80px;
    max-height: 200px;
    line-height: 1.5;
}

/* Search input and filterable select styling */
.search-input {
    margin-bottom: 6px;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    margin-bottom: 6px;
}

.search-input-wrapper .search-input {
    flex: 1;
    margin-bottom: 0;
    padding-right: 32px;
}

.search-clear-btn {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--theme-border, #e0e0e0);
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 16px;
    line-height: 1;
    color: var(--theme-text-secondary, #666);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
}

.search-clear-btn:hover {
    background: #d32f2f;
    color: white;
}

.form-field select[size] {
    height: auto;
    min-height: 150px;
    max-height: 200px;
}

.form-field select[size] option,
.form-field select[size] optgroup {
    padding: 6px 10px;
}

.form-field select[size] option:checked {
    background: linear-gradient(0deg, #1976d2 0%, #1976d2 100%);
    color: white;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
    outline: none;
    border-color: var(--theme-accent, #1976d2);
}

.form-field input:disabled {
    background-color: var(--theme-hover, #f5f5f5);
    cursor: not-allowed;
}

.form-field small {
    display: block;
    font-size: 12px;
    color: var(--theme-text-muted, #666);
    margin-top: 4px;
}

/* Checkbox field styling */
.checkbox-field {
    margin-bottom: 20px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
    gap: 12px;
}

.checkbox-label input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkbox-custom {
    position: relative;
    height: 24px;
    width: 24px;
    min-width: 24px;
    background-color: var(--theme-input-bg, #fff);
    border: 2px solid var(--theme-text-muted, #999);
    border-radius: 4px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.checkbox-label:hover .checkbox-custom {
    border-color: var(--theme-accent, #1976d2);
}

.checkbox-label input[type="checkbox"]:checked ~ .checkbox-custom {
    background-color: var(--theme-accent, #1976d2);
    border-color: var(--theme-accent, #1976d2);
}

.checkbox-custom::after {
    content: "";
    position: absolute;
    display: none;
    left: 7px;
    top: 3px;
    width: 6px;
    height: 12px;
    border: solid white;
    border-width: 0 3px 3px 0;
    transform: rotate(45deg);
}

.checkbox-label input[type="checkbox"]:checked ~ .checkbox-custom::after {
    display: block;
}

.checkbox-text {
    font-size: 14px;
    color: var(--theme-text, #333);
    line-height: 1.4;
}

.checkbox-label input[type="checkbox"]:focus ~ .checkbox-custom {
    box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.2);
}

/* Remember Me checkbox - Login page */
.remember-me-field {
    margin-bottom: 20px;
}

.remember-me-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 14px;
    color: var(--theme-text, #333);
}

.remember-me-checkbox {
    width: 20px !important;
    height: 20px !important;
    min-width: 20px;
    min-height: 20px;
    cursor: pointer;
    accent-color: #1976d2;
    margin: 0;
    flex-shrink: 0;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.form-field-full {
    grid-column: 1 / -1;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: inherit;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background-color: var(--theme-accent, #1976d2);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background-color: #1565c0;
}

.btn-secondary {
    background-color: var(--theme-hover, #f5f5f5);
    color: var(--theme-text, #333);
}

.btn-secondary:hover:not(:disabled) {
    background-color: var(--theme-border, #e0e0e0);
}

.btn-success {
    background-color: #4caf50;
    color: white;
}

.btn-success:hover:not(:disabled) {
    background-color: #388e3c;
}

.btn-danger {
    background-color: var(--theme-danger, #f44336);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background-color: #d32f2f;
}

.btn-small {
    padding: 6px 10px;
    font-size: 12px;
    min-width: auto;
}

.btn-text {
    background: none;
    color: white;
}

.btn-text:hover:not(:disabled) {
    background-color: rgba(255, 255, 255, 0.1);
}

.btn-block {
    width: 100%;
    justify-content: center;
}

.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
}

/* Tables */
.table-container {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table thead {
    background-color: var(--theme-table-header, #f5f5f5);
}

.data-table th {
    padding: 12px;
    text-align: left;
    font-weight: 500;
    color: var(--theme-text-muted, #666);
    border-bottom: 2px solid var(--theme-border, #e0e0e0);
}

.data-table td {
    padding: 12px;
    border-bottom: 1px solid var(--theme-border-light, #f0f0f0);
    color: var(--theme-text, #333);
}

.data-table tbody tr:hover {
    background-color: var(--theme-table-hover, #fafafa);
}

.own-time-row {
    background-color: var(--theme-badge-bg, #e3f2fd) !important;
}

.time-cell {
    font-family: 'Courier New', monospace;
    font-weight: 600;
    color: var(--theme-accent, #1976d2);
}

.pb-time {
    color: var(--theme-success, #4caf50);
}

.actions-cell {
    white-space: nowrap;
    text-align: center;
}

.actions-cell .btn {
    margin: 0 2px;
}

.form-static-value {
    padding: 10px 12px;
    background-color: var(--theme-hover, #f5f5f5);
    border-radius: 4px;
    color: var(--theme-text-muted, #666);
    font-size: 14px;
}

.position-col {
    width: 60px;
    text-align: center !important;
    font-weight: 600;
}

.first-place {
    color: #ffd700;
    font-size: 20px;
}

.second-place {
    color: #c0c0c0;
    font-size: 20px;
}

.third-place {
    color: #cd7f32;
    font-size: 20px;
}

.gap-cell {
    font-family: 'Courier New', monospace;
    color: var(--theme-text-secondary, #666);
}

/* Badges */
.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    color: white;
    text-transform: uppercase;
}

.badge-small {
    padding: 2px 8px;
    font-size: 10px;
}

.fixed-setup-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    background: var(--theme-purple-bg, #ede7f6);
    color: var(--theme-purple-text, #4527a0);
    margin-left: 6px;
}

/* Messages */
.error-message {
    background-color: var(--theme-error-bg, #ffebee);
    color: var(--theme-error-text, #c62828);
    padding: 12px;
    border-radius: 4px;
    margin-bottom: 16px;
    font-size: 14px;
}

.success-message {
    background-color: var(--theme-success-bg, #e8f5e9);
    color: var(--theme-success-text, #2e7d32);
    padding: 12px;
    border-radius: 4px;
    margin-bottom: 16px;
    font-size: 14px;
}

.empty-message {
    text-align: center;
    color: var(--theme-text-muted, #999);
    padding: 40px 20px;
    font-size: 16px;
}

/* Filters */
.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

/* Dashboard side-by-side row */
.dashboard-row {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.dashboard-row-item {
    flex: 1;
    min-width: 0;
}

/* Pagination */
.pagination {
    padding: 20px 0;
}

.pagination-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 20px;
    padding: 16px;
    background: var(--theme-bg-tertiary, #f5f7fa);
    border-radius: 8px;
}

.pagination-controls .btn {
    min-width: 40px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pagination-controls .btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination-controls .btn .material-icons {
    font-size: 20px;
}

.pagination-info {
    font-size: 14px;
    color: var(--theme-text-secondary, #666);
    font-weight: 500;
    padding: 0 16px;
}

.pagination-buttons {
    display: flex;
    gap: 8px;
}

/* ============================================
   CAR-GAME MAPPING MATRIX
   ============================================ */
.mapping-game-col {
    text-align: center;
    white-space: nowrap;
    font-size: 0.82rem;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
}

#carMappingMatrix thead th,
#trackMappingMatrix thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--theme-bg-secondary, #f0f2f5);
}

#carMappingMatrix td.text-center {
    text-align: center;
    vertical-align: middle;
}

#carMappingMatrix input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--theme-primary, #667eea);
}

.mapping-row-dirty {
    background: rgba(102, 126, 234, 0.08) !important;
}

.car-edit-link {
    color: inherit;
    text-decoration: none;
}

.car-edit-link:hover {
    color: var(--theme-primary, #667eea);
    text-decoration: underline;
}

.btn-highlight {
    animation: pulse-btn 0.6s ease;
}

@keyframes pulse-btn {
    0% { box-shadow: 0 0 0 0 rgba(102, 126, 234, 0.5); }
    70% { box-shadow: 0 0 0 8px rgba(102, 126, 234, 0); }
    100% { box-shadow: 0 0 0 0 rgba(102, 126, 234, 0); }
}

/* Responsive Design */
@media (max-width: 768px) {
    .app-bar-content {
        padding: 12px 16px;
    }
    
    .app-title {
        font-size: 18px;
    }
    
    .nav-tabs {
        padding: 0 16px;
    }
    
    .nav-tab {
        padding: 12px 16px;
        font-size: 13px;
    }
    
    .main-content {
        padding: 16px;
    }
    
    .card {
        padding: 16px;
    }
    
    .form-grid,
    .filter-grid {
        grid-template-columns: 1fr;
    }
    
    .dashboard-row {
        flex-direction: column;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .data-table {
        font-size: 12px;
    }
    
    .data-table th,
    .data-table td {
        padding: 8px;
    }
    
    .form-actions {
        flex-direction: column-reverse;
    }
    
    .form-actions .btn {
        width: 100%;
    }
}

/* Profile and Admin Styles */
.profile-section,
.admin-section {
    margin-bottom: 32px;
}

.profile-section h3,
.admin-section h3 {
    font-size: 20px;
    font-weight: 500;
    margin-bottom: 16px;
    color: var(--theme-text, #333);
}

.info-card {
    background: var(--theme-card-bg, white);
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.info-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--theme-border, #e0e0e0);
}

.info-row:last-child {
    border-bottom: none;
}

.info-label {
    font-weight: 500;
    color: var(--theme-text-secondary, #666);
}

.info-value {
    color: var(--theme-text, #333);
}

.form-card {
    background: var(--theme-card-bg, white);
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.form-card .form-field {
    margin-bottom: 20px;
}

.form-card small {
    display: block;
    margin-top: 4px;
    color: var(--theme-text-secondary, #666);
    font-size: 12px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
    cursor: pointer;
}

.success-message {
    background-color: var(--theme-success-bg, #d4edda);
    color: var(--theme-success-text, #155724);
    padding: 12px 16px;
    border-radius: 4px;
    margin: 16px 0;
    border: 1px solid var(--theme-success, #c3e6cb);
}

.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.badge-admin {
    background-color: #f44336;
    color: white;
}

.badge-user {
    background-color: #4caf50;
    color: white;
}

.btn-small {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-danger {
    background-color: #f44336;
}

.btn-danger:hover {
    background-color: #d32f2f;
}

.text-center {
    text-align: center;
}

.text-muted {
    color: var(--theme-text-muted, #999);
}

#usersTableContainer {
    background: var(--theme-card-bg, white);
    border-radius: 8px;
    padding: 16px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    overflow-x: auto;
}

/* Teams Checkbox Container */
.teams-checkbox-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    padding: 12px;
    background: var(--theme-bg-tertiary, #f9f9f9);
    border: 1px solid var(--theme-border, #e0e0e0);
    border-radius: 4px;
    max-height: 300px;
    overflow-y: auto;
}

.team-checkbox {
    margin: 0 !important;
    padding: 8px 12px;
    background: var(--theme-card-bg, white);
    border: 1px solid var(--theme-border, #ddd);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.team-checkbox:hover {
    background: var(--theme-hover, #f0f0f0);
    border-color: var(--theme-accent, #667eea);
}

.team-checkbox input[type="checkbox"] {
    margin-right: 8px;
}

.team-checkbox input[type="checkbox"]:checked + span {
    font-weight: 500;
    color: var(--theme-accent, #667eea);
}

/* Game Checkbox (same as team-checkbox) */
.game-checkbox {
    display: flex;
    align-items: center;
    margin: 0 !important;
    padding: 10px 12px;
    background: var(--theme-card-bg, white);
    border: 1px solid var(--theme-border, #ddd);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.game-checkbox:hover {
    background: var(--theme-hover, #f0f0f0);
    border-color: var(--theme-accent, #667eea);
}

.game-checkbox input[type="checkbox"] {
    margin-right: 10px;
    width: 18px;
    height: 18px;
    cursor: pointer;
    flex-shrink: 0;
}

.game-checkbox span {
    flex: 1;
    user-select: none;
}

.game-checkbox input[type="checkbox"]:checked + span {
    font-weight: 600;
    color: var(--theme-accent, #667eea);
}

.game-checkbox:has(input[type="checkbox"]:checked) {
    background: var(--theme-accent-light, rgba(102, 126, 234, 0.1));
    border-color: var(--theme-accent, #667eea);
    box-shadow: 0 0 0 1px var(--theme-accent, #667eea);
}

/* Inline edit gamertag */
.info-row .pp-edit-gamertag-btn {
    margin-left: 8px;
    padding: 2px 6px;
    min-width: auto;
    line-height: 1;
}

.pp-gamertag-edit {
    flex-wrap: wrap;
}

/* Games Checkbox Container (profile) */
.games-checkbox-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 10px;
    padding: 12px;
    background: var(--theme-bg-tertiary, #f9f9f9);
    border: 1px solid var(--theme-border, #e0e0e0);
    border-radius: 4px;
    max-height: 350px;
    overflow-y: auto;
}

/* Profile games display (read-only list) */
.profile-games-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.profile-games-list .badge-game {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    border-radius: 16px;
    font-size: 13px;
    font-weight: 500;
    background: var(--theme-badge-bg, #e3f2fd);
    color: var(--theme-badge-text, #1976d2);
}

/* Mapped Items Grid */
.mapped-items-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.mapped-item {
    display: inline-flex;
    align-items: center;
    padding: 8px 14px;
    background: var(--theme-card-bg, white);
    border: 1px solid var(--theme-border, #ddd);
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.mapped-item:hover {
    background: #667eea;
    color: white;
    border-color: var(--theme-accent, #667eea);
}

.mapped-item .material-icons {
    font-size: 16px;
    margin-right: 6px;
}

/* Radio Label Styling */
.radio-label {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 4px;
    transition: background 0.2s;
}

.radio-label:hover {
    background: var(--theme-hover, #f0f0f0);
}

.radio-label input[type="radio"] {
    margin-right: 8px;
    width: 18px;
    height: 18px;
}

/* Admin Sub-Tabs */
.admin-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    padding: 8px;
    background: var(--theme-card-bg, white);
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    flex-wrap: wrap;
}

.admin-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    background: var(--theme-hover, #f5f5f5);
    color: var(--theme-text-secondary, #666);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
}

.admin-tab:hover {
    background: var(--theme-border, #e8e8e8);
    color: var(--theme-text, #333);
}

.admin-tab.active {
    background: #1976d2;
    color: white;
}

.admin-tab .material-icons {
    font-size: 20px;
}

.admin-sub-content {
    display: none;
}

.admin-sub-content.active {
    display: block;
}

/* Badge Styles */
.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.badge-success {
    background: #4caf50;
    color: white;
}

.badge-default {
    background: #9e9e9e;
    color: white;
}

.badge-team {
    background: #667eea;
    color: white;
    margin-right: 4px;
}

/* Delta Column Styling */
.delta-cell {
    font-weight: 500;
    font-family: 'Courier New', monospace;
}

.delta-fastest {
    color: #4caf50;
    font-weight: 600;
}

.delta-slower {
    color: #f44336;
}

.delta-faster {
    color: #4caf50;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: var(--theme-modal-bg, white);
    margin: auto;
    padding: 0;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--theme-border, #e0e0e0);
}

.modal-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 500;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    font-weight: bold;
    color: var(--theme-text-muted, #999);
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.modal-close:hover {
    color: var(--theme-text, #333);
}

.modal-content form {
    padding: 20px;
}

.modal-content .form-field {
    margin-bottom: 16px;
}

.modal-content .form-actions {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--theme-border, #e0e0e0);
}

/* Teams Checkbox Container */
.teams-checkbox-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--theme-border, #ddd);
    border-radius: 4px;
    background-color: var(--theme-bg-tertiary, #f9f9f9);
    max-height: 200px;
    overflow-y: auto;
}

.team-checkbox {
    display: flex !important;
    align-items: center;
    padding: 8px;
    background: var(--theme-card-bg, white);
    border: 1px solid var(--theme-border, #e0e0e0);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.team-checkbox:hover {
    background-color: var(--theme-hover, #f5f5f5);
    border-color: var(--theme-accent, #667eea);
}

.team-checkbox input[type="checkbox"] {
    margin-right: 8px;
}

/* Snackbar Styles */
.snackbar {
    visibility: hidden;
    min-width: 300px;
    background-color: #4caf50;
    color: white;
    text-align: center;
    border-radius: 8px;
    padding: 16px 24px;
    position: fixed;
    z-index: 10000;
    top: 24px;
    right: 24px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 12px;
}

.snackbar.show {
    visibility: visible;
    animation: snackbarIn 0.3s ease-out, snackbarOut 0.3s ease-in 2.7s;
}

.snackbar.error {
    background-color: #f44336;
}

.snackbar .snackbar-icon {
    font-size: 20px;
}

@keyframes snackbarIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes snackbarOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

/* Team Logo Styles */
.team-logo-thumb {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.logo-cell {
    width: 60px;
    text-align: center;
}

.no-logo {
    color: var(--text-muted);
    font-size: 12px;
}

.logo-preview-container {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    padding: 12px;
    background: var(--card-bg);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.team-logo-preview {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.file-upload-wrapper {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.file-upload-wrapper input[type="file"] {
    padding: 8px;
    border: 1px dashed var(--border-color);
    border-radius: 6px;
    background: var(--bg-color);
    cursor: pointer;
}

.file-upload-wrapper input[type="file"]:hover {
    border-color: var(--primary-color);
}

.help-text {
    color: var(--text-muted);
    font-size: 12px;
}

.team-description-text {
    display: inline-block;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-sm {
    padding: 4px 8px;
    font-size: 12px;
}

/* ============================================
   TEAM CHALLENGES STYLES
   ============================================ */

/* Challenge Section Titles */
.challenge-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 18px;
    font-weight: 500;
    margin: 24px 0 16px 0;
    color: var(--theme-text, #333);
}

.challenge-section-title .material-icons {
    font-size: 24px;
    color: var(--theme-accent, #1976d2);
}

/* Challenges Grid */
.challenges-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

/* Challenge Card */
.challenge-card {
    background: var(--theme-card-bg, white);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--theme-border, #e0e0e0);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.challenge-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.challenge-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: var(--theme-header-light, #f8f9fa);
    border-bottom: 1px solid var(--theme-border, #e0e0e0);
}

.challenge-name {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    color: var(--theme-text, #333);
}

.challenge-status {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.challenge-status.status-active {
    background-color: var(--theme-success-bg, #e8f5e9);
    color: var(--theme-success-text, #2e7d32);
}

.challenge-status.status-upcoming {
    background-color: var(--theme-info-bg, #e3f2fd);
    color: var(--theme-info-text, #1565c0);
}

.challenge-status.status-completed {
    background-color: var(--theme-hover, #f5f5f5);
    color: var(--theme-text-muted, #757575);
}

.challenge-card-body {
    padding: 16px;
}

.challenge-info-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    font-size: 14px;
    color: var(--theme-text-muted, #666);
}

.challenge-info-row .material-icons {
    font-size: 18px;
    color: var(--theme-accent, #1976d2);
    opacity: 0.7;
}

.challenge-card-footer {
    display: flex;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--theme-bg, #f5f5f5);
    border-top: 1px solid var(--theme-border, #e0e0e0);
}

.challenge-stat {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: var(--theme-text-muted, #666);
}

.challenge-stat .material-icons {
    font-size: 16px;
}

/* Challenge Detail Modal */
.modal-xlarge {
    max-width: 900px;
}

.modal-xlarge .modal-body {
    padding: 24px;
}

.modal-xlarge .modal-header {
    padding: 20px 24px;
}

.challenge-detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    padding: 16px;
    background: var(--theme-bg, #f5f5f5);
    border-radius: 8px;
    margin-bottom: 16px;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.detail-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--theme-text-muted, #666);
    text-transform: uppercase;
}

.detail-value {
    font-size: 14px;
    font-weight: 500;
    color: var(--theme-text, #333);
}

.challenge-description {
    padding: 12px;
    background: var(--theme-card-bg, white);
    border-left: 3px solid var(--theme-accent, #1976d2);
    margin-top: 12px;
    font-style: italic;
    color: var(--theme-text-muted, #666);
}

.challenge-detail-info h4 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.challenge-detail-info h4 .material-icons {
    color: var(--theme-accent, #1976d2);
}

/* Challenge Leaderboard */
.position-cell {
    text-align: center;
    font-weight: 600;
}

.position-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 14px;
    font-weight: 700;
}

.position-1 {
    background: linear-gradient(135deg, #ffd700, #ffb300);
    color: #333;
}

.position-2 {
    background: linear-gradient(135deg, #c0c0c0, #a0a0a0);
    color: #333;
}

.position-3 {
    background: linear-gradient(135deg, #cd7f32, #a0522d);
    color: white;
}

.laptime-cell {
    font-family: 'Roboto Mono', monospace;
    font-weight: 600;
    color: var(--theme-accent, #1976d2);
}

.gap-cell {
    font-family: 'Roboto Mono', monospace;
    color: var(--theme-text-muted, #666);
}

.highlight-row {
    background-color: rgba(25, 118, 210, 0.1) !important;
}

.user-stats-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--theme-accent, #1976d2);
    color: white;
    border-radius: 8px;
    margin-top: 16px;
    font-size: 14px;
}

.user-stats-bar .material-icons {
    font-size: 20px;
}

/* Form Section in Modal */
.form-section h4 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--theme-border, #e0e0e0);
    color: var(--theme-text, #333);
}

.form-section h4 .material-icons {
    color: var(--theme-accent, #1976d2);
}

/* Print Styles */
@media print {
    .app-bar,
    .nav-tabs,
    .form-actions,
    .btn {
        display: none !important;
    }
}

/* ── Personal Profile Tab ─────────────────────────── */

.pp-avatar-section {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    flex-wrap: wrap;
}

.pp-avatar-preview {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--theme-bg-alt, #e8eaf6);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 3px solid var(--theme-border, #e0e0e0);
}

.pp-avatar-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.pp-avatar-placeholder {
    font-size: 80px;
    color: var(--theme-text-muted, #999);
}

.pp-avatar-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
}

.pp-avatar-upload-label {
    cursor: pointer;
}

.pp-rating-row {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
}

.pp-rating-field {
    flex: 1;
    min-width: 220px;
}

.pp-rating-dropdowns {
    display: flex;
    gap: 10px;
}

.pp-rating-dropdowns select {
    flex: 1;
    min-width: 100px;
}

/* ── Profile 2-column layout ─────────────────────────── */
.profile-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
}

.profile-col .profile-section {
    margin-bottom: 20px;
}

.profile-col .profile-section:last-child {
    margin-bottom: 0;
}

.profile-col .info-card,
.profile-col .form-card {
    padding: 16px;
}

.profile-col .info-row {
    padding: 7px 0;
}

.profile-col .form-card .form-field {
    margin-bottom: 14px;
}

@media (max-width: 900px) {
    .profile-columns {
        grid-template-columns: 1fr;
    }
}
