/* =========================================
   1. VARIABLES & RESET
   ========================================= */
:root {
    /* Farbpalette: Blau/Schwarz Modern */
    --bg-body: #090a0c;          /* Sehr dunkler Hintergrund */
    --bg-sidebar: #0f1115;       /* Sidebar etwas heller */
    --bg-card: #161b22;          /* Karten Hintergrund */
    --bg-input: #0d1117;         /* Input Felder */
    
    --primary: #2f81f7;          /* Haupt-Blau */
    --primary-hover: #58a6ff;    /* Helleres Blau für Hover */
    --primary-glow: rgba(56, 139, 253, 0.4);
    
    --accent-red: #da3633;       /* Für Fehler oder F1-Rot */
    --accent-green: #2ea043;     /* Für Erfolge */
    
    --text-main: #f0f6fc;        /* Fast Weiß */
    --text-muted: #8b949e;       /* Ausgegrauter Text */
    
    --border-color: #30363d;     /* Subtile Rahmen */
    --radius: 8px;               /* Abrundung */
    --shadow: 0 4px 12px rgba(0,0,0,0.5);
    
    --sidebar-width: 260px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Titillium Web', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    display: flex;
    height: 100vh;
    overflow: hidden; /* Scrollen nur im Main-Bereich */
}

/* Scrollbar Styling (Webkit) */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-body); 
}
::-webkit-scrollbar-thumb {
    background: var(--border-color); 
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--primary); 
}

/* =========================================
   2. SIDEBAR NAVIGATION
   ========================================= */
#sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 20px;
    flex-shrink: 0;
    z-index: 100;
}

.sidebar-header {
    margin-bottom: 40px;
    text-align: center;
}

.logo {
    font-weight: 900;
    font-size: 2rem;
    letter-spacing: 2px;
    color: #fff;
    margin-bottom: 10px;
}

.logo span {
    color: var(--primary);
}

.user-status-card {
    background: rgba(255,255,255,0.05);
    padding: 10px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    color: var(--text-muted);
}

.nav-group {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.nav-label {
    text-transform: uppercase;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin: 20px 0 10px 10px;
    font-weight: 700;
    letter-spacing: 1px;
}

.nav-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 12px 15px;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
    font-size: 1rem;
    border-radius: var(--radius);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
}

.nav-btn:hover {
    background: rgba(255,255,255,0.05);
    color: var(--text-main);
}

.nav-btn.active {
    background: rgba(47, 129, 247, 0.15);
    color: var(--primary);
    border-left: 3px solid var(--primary);
    font-weight: 600;
    box-shadow: 0 0 15px rgba(47, 129, 247, 0.1);
}

/* Rollen-spezifische Buttons */
.staff-btn { border-left-color: var(--accent-green) !important; }
.admin-btn { border-left-color: var(--accent-red) !important; }

.sidebar-footer {
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.logout-link {
    display: block;
    text-align: center;
    background: #1f242c;
    color: var(--text-main);
    text-decoration: none;
    padding: 12px;
    border-radius: var(--radius);
    font-weight: 700;
    transition: 0.3s;
}

.logout-link:hover {
    background: var(--primary);
    box-shadow: 0 0 15px var(--primary-glow);
}

/* =========================================
   3. MAIN CONTENT AREA
   ========================================= */
#main {
    flex: 1;
    padding: 30px 40px;
    overflow-y: auto;
    background: radial-gradient(circle at top right, #13171f 0%, var(--bg-body) 60%);
}

.view-section {
    display: none; /* Standardmäßig ausgeblendet, JS steuert dies */
    animation: fadeIn 0.4s ease-out;
}

.view-section.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.page-title {
    font-size: 2rem;
    font-weight: 300;
    margin-bottom: 30px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
    display: inline-block;
}

/* =========================================
   4. CARDS & GRID SYSTEM
   ========================================= */
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.card h2, .card h3 {
    margin-bottom: 20px;
    color: var(--text-main);
    font-weight: 600;
}

/* Grid Layouts */
.grid-2-1 {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

.grid-1-2 {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 20px;
}

.grid-1-1 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.dashboard-standings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* Split View für Mail/Chat */
.split-view {
    display: flex;
    gap: 20px;
    height: calc(100vh - 150px);
}

.list-pane {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.content-pane {
    flex: 2;
    overflow-y: auto;
    background: #0d1117; /* Etwas dunkler für Kontrast */
}

/* =========================================
   5. FORMS & INPUTS
   ========================================= */
.form-row {
    display: flex;
    gap: 20px;
}

.form-group {
    margin-bottom: 15px;
    flex: 1;
}

label, .input-label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 600;
}

input, select, textarea {
    width: 100%;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 12px;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(47, 129, 247, 0.2);
}

/* Buttons */
.action-btn {
    background: linear-gradient(135deg, var(--primary) 0%, #1f6feb 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: transform 0.1s, box-shadow 0.2s;
    margin-top: 10px;
    display: inline-block;
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px var(--primary-glow);
    background: var(--primary-hover);
}

.action-btn:active {
    transform: translateY(0);
}

.compose-btn {
    width: 100%;
    margin-bottom: 15px;
    margin-top: 0;
}

/* =========================================
   6. COMPONENT SPECIFICS
   ========================================= */

/* Stat Cards */
.stat-card {
    text-align: center;
    border-top: 3px solid var(--primary);
}

.stat-label {
    display: block;
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 1px;
}

.stat-value {
    display: block;
    font-size: 2.5rem;
    font-weight: 700;
    color: #fff;
    margin-top: 5px;
}

/* Tabellen/Listen Elemente */
.item-list div, .standings-list div {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.2s;
}

.item-list div:hover {
    background: rgba(255,255,255,0.03);
}

/* Chat Styling */
.chat-container {
    height: calc(100vh - 180px);
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}

.chat-header {
    padding: 15px;
    background: rgba(0,0,0,0.2);
    border-bottom: 1px solid var(--border-color);
}

.chat-window {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-input-area {
    padding: 20px;
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 10px;
}

/* Chat Messages */
.chat-msg {
    padding: 10px 15px;
    border-radius: 12px;
    max-width: 80%;
    line-height: 1.4;
    font-size: 0.95rem;
}

.chat-msg strong {
    color: var(--primary);
    display: block;
    font-size: 0.75rem;
    margin-bottom: 2px;
}

.chat-msg-content {
    color: #ddd;
}

/* Unterscheidung User vs. Andere (muss durch JS Klassen gesetzt werden, hier vorbreitet) */
.msg-own {
    align-self: flex-end;
    background: rgba(47, 129, 247, 0.2);
    border: 1px solid rgba(47, 129, 247, 0.3);
}

.msg-other {
    align-self: flex-start;
    background: #21262d;
    border: 1px solid var(--border-color);
}

/* Registration Specifics */
.f1-red-text {
    color: var(--accent-red);
}

/* Modal Overlay */
.overlay-modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(5px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    width: 600px;
    max-width: 90%;
    background: #1c2128;
    border: 1px solid #444c56;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

/* Race Control Header */
.rc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}
.rc-header .page-title { border: none; margin: 0; }

/* Empty States */
.empty-state {
    display: flex;
    height: 100%;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-style: italic;
}

/* Principal Role Styling */
.principal-label {
    color: #f59e0b; /* Amber/Gold */
    opacity: 0.9;
}

.principal-btn.active {
    background: rgba(245, 158, 11, 0.15) !important;
    color: #f59e0b !important;
    border-left-color: #f59e0b !important;
    box-shadow: 0 0 15px rgba(245, 158, 11, 0.1) !important;
}

.principal-stat {
    border-bottom-color: #f59e0b !important;
}

/* Anpassung für die Fahrer-Liste im HQ */
.driver-contract-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
}
.driver-info h4 { margin: 0; color: #fff; }
.driver-info small { color: var(--text-muted); }

.contract-status {
    font-size: 0.85rem;
    padding: 4px 8px;
    background: rgba(46, 160, 67, 0.2);
    color: #2ea043;
    border-radius: 4px;
    margin-right: 10px;
}

/* =========================================
   7. RESPONSIVE DESIGN
   ========================================= */
@media (max-width: 900px) {
    body { flex-direction: column; height: auto; overflow: auto; }
    #sidebar { width: 100%; height: auto; padding: 10px; }
    .nav-group { flex-direction: row; overflow-x: auto; margin: 10px 0; padding-bottom: 10px; }
    .nav-label { display: none; }
    .nav-btn { font-size: 0.9rem; padding: 8px 12px; white-space: nowrap; }
    
    #main { padding: 20px; height: auto; }
    .grid-2-1, .grid-1-2, .dashboard-standings-grid, .split-view { 
        grid-template-columns: 1fr; 
        flex-direction: column;
        height: auto;
    }
    
    .chat-container { height: 500px; }
}