/* FCA-DFW | Scuderia High-End Design System */
:root {
    /* Ferrari Palette */
    --ferrari-red: #FF2800;
    --scuderia-red: #EF1A2D;
    --ferrari-yellow: #FFF200;
    --carbon-black: #080808;
    --carbon-dark: #121212;
    --carbon-light: #222222;
    --glass-bg: rgba(30, 30, 30, 0.6);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-main: #F4F4F4;
    --text-muted: #A0A0A0;
    
    /* Typography */
    --font-heading: 'Cinzel', serif;
    --font-ui: 'Inter', sans-serif;
    
    /* Animation */
    --transition-smooth: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    --transition-snappy: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body, html {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    background-color: var(--carbon-black);
    color: var(--text-main);
    font-family: var(--font-ui);
    overflow: hidden;
    /* Subtle carbon fiber pattern */
    background-image: 
        linear-gradient(45deg, #111 25%, transparent 25%, transparent 75%, #111 75%, #111), 
        linear-gradient(45deg, #111 25%, transparent 25%, transparent 75%, #111 75%, #111);
    background-size: 10px 10px;
    background-position: 0 0, 5px 5px;
}

h1, h2, h3, h4, .brand-text {
    font-family: var(--font-heading);
    letter-spacing: 1px;
}

a {
    color: var(--ferrari-yellow);
    text-decoration: none;
    transition: var(--transition-smooth);
}

/* Utilities */
.hidden { display: none !important; }
.flex-center { display: flex; align-items: center; justify-content: center; flex-direction: column; }
.text-red { color: var(--ferrari-red); }

/* Buttons */
.btn {
    font-family: var(--font-heading);
    font-weight: 600;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    padding: 14px 24px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    transition: var(--transition-smooth);
    font-size: 0.9rem;
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: linear-gradient(135deg, var(--ferrari-red), var(--scuderia-red));
    color: white;
    box-shadow: 0 4px 15px rgba(255, 40, 0, 0.4);
}

.btn-primary:active {
    transform: scale(0.96);
    box-shadow: 0 2px 8px rgba(255, 40, 0, 0.3);
}

.btn-block { width: 100%; }
.btn-icon { background: transparent; color: white; font-size: 1.2rem; }

/* Glass Panel / Pininfarina Aerodynamics */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

/* =========================================
   LOGIN SCREEN
   ========================================= */
#login-screen {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 1000;
    background: #000;
}

.login-bg {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: url('https://images.unsplash.com/photo-1592853625601-bb11b179013c?q=80&w=800&auto=format&fit=crop') center/cover no-repeat;
    opacity: 0.4;
    filter: grayscale(80%) sepia(20%) hue-rotate(330deg); /* High-end fashion filter */
}

.login-panel {
    position: relative;
    z-index: 2;
    padding: 40px 30px;
    width: 90%;
    max-width: 400px;
    max-height: 95%;
    overflow-y: auto;
    text-align: center;
}

.brand-header { margin-bottom: 30px; }
.brand-header .logo-icon {
    font-size: 3rem;
    color: var(--ferrari-yellow);
    margin-bottom: 15px;
    filter: drop-shadow(0 0 10px rgba(255, 242, 0, 0.5));
}
.brand-header h1 {
    font-size: 2.5rem;
    margin-bottom: 5px;
    background: linear-gradient(to right, #fff, #bbb);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.brand-header p {
    color: var(--text-muted);
    font-family: var(--font-ui);
    text-transform: uppercase;
    letter-spacing: 2px;
    font-size: 0.8rem;
}

.input-group {
    position: relative;
    margin-bottom: 20px;
}
.input-group i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}
.input-group input {
    width: 100%;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid var(--glass-border);
    padding: 15px 15px 15px 45px;
    border-radius: 6px;
    color: white;
    font-family: var(--font-ui);
    font-size: 1rem;
    transition: var(--transition-smooth);
}
.input-group input:focus {
    outline: none;
    border-color: var(--ferrari-red);
    box-shadow: 0 0 10px rgba(255, 40, 0, 0.2);
}

.auth-switch {
    margin-top: 20px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* =========================================
   MAIN APP SHELL
   ========================================= */
#app-shell {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    overflow: hidden;
}

/* TOP BAR */
.top-bar {
    height: 60px;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(10, 10, 10, 0.8);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--glass-border);
    z-index: 10;
}
.top-bar-left {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.2rem;
}
.user-avatar img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid var(--ferrari-red);
    object-fit: cover;
}

/* APP CONTENT / VIEWPORTS */
.app-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    padding-top: 70px; /* Space for fixed top tabs */
    height: 100%;
}

.tab-view {
    padding: 20px;
    min-height: 100%;
}
#view-map.tab-view { padding: 0; height: 100%; }

/* Dashboard UI */
.dashboard-layout {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

@media (min-width: 1024px) {
    .dashboard-layout {
        display: grid;
        grid-template-columns: 3fr 2fr;
        gap: 30px;
        align-items: start;
    }
}

.hero-card {
    background: linear-gradient(135deg, var(--carbon-dark), var(--carbon-light));
    border-left: 4px solid var(--ferrari-red);
    padding: 25px;
    border-radius: 12px;
    margin-bottom: 30px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.4);
}
.hero-card h2 { margin-bottom: 10px; }
.hero-card p { color: var(--text-muted); font-size: 0.95rem; }

.section-title {
    margin-bottom: 15px;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 10px;
}

.event-card {
    background: var(--carbon-dark);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 20px;
    border: 1px solid var(--glass-border);
    box-shadow: 0 8px 16px rgba(0,0,0,0.3);
}
.event-img {
    height: 160px;
    background-size: cover;
    background-position: center;
    position: relative;
}
.event-date-badge {
    position: absolute;
    top: 10px; left: 10px;
    background: rgba(0,0,0,0.8);
    color: var(--ferrari-yellow);
    padding: 5px 12px;
    border-radius: 4px;
    font-family: var(--font-heading);
    font-weight: bold;
    border: 1px solid rgba(255, 242, 0, 0.3);
}
.event-info { padding: 20px; }
.event-info h3 { margin-bottom: 5px; font-size: 1.3rem; }
.event-meta {
    display: flex; gap: 15px;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 15px;
}
.rsvp-actions {
    display: flex; gap: 10px;
}
.btn-rsvp {
    flex: 1;
    padding: 10px;
    background: var(--carbon-light);
    color: white;
    border: 1px solid var(--glass-border);
    border-radius: 6px;
}
.btn-rsvp.active-yes { background: var(--ferrari-red); border-color: var(--ferrari-red); }
.btn-rsvp.active-maybe { background: var(--ferrari-yellow); color: black; border-color: var(--ferrari-yellow); }
.btn-rsvp.active-no { background: #333; opacity: 0.6; }

/* CALENDAR WIDGET */
.calendar-month {
    background: var(--carbon-dark);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 20px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.3);
}
.calendar-month h4 {
    text-align: center;
    margin-bottom: 10px;
    font-family: var(--font-heading);
    color: var(--ferrari-yellow);
    font-size: 1.2rem;
}
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 5px;
    text-align: center;
}
.cal-day-header {
    font-size: 0.75rem;
    color: var(--text-muted);
    padding-bottom: 5px;
}
.cal-day {
    font-size: 0.85rem;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    border-radius: 50%;
    color: var(--text-main);
}
.cal-day.empty {
    background: transparent;
}
.cal-day.current-day {
    border: 2px solid var(--success-green, #10b981);
    border-radius: 4px;
}
.cal-day.has-event {
    background: var(--ferrari-red);
    color: white;
    font-weight: bold;
    box-shadow: 0 0 10px rgba(255, 40, 0, 0.6);
    cursor: pointer;
    position: relative;
}

.cal-tooltip {
    position: absolute;
    bottom: 130%;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background: var(--carbon-black);
    color: var(--text-main);
    padding: 10px 15px;
    border-radius: 8px;
    border: 1px solid var(--ferrari-red);
    font-size: 0.8rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition-snappy);
    z-index: 100;
    pointer-events: none;
    box-shadow: 0 5px 15px rgba(0,0,0,0.8);
    font-family: var(--font-ui);
    font-weight: normal;
    text-align: center;
    line-height: 1.4;
}

.cal-tooltip strong {
    color: var(--ferrari-yellow);
    font-size: 0.9rem;
}

.cal-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -6px;
    border-width: 6px;
    border-style: solid;
    border-color: var(--ferrari-red) transparent transparent transparent;
}

.cal-day.has-event:hover .cal-tooltip,
.cal-day.has-event.active-tooltip .cal-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* MAP VIEW */
#mapbox-container {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0; left: 0;
}
.map-overlay {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    height: 100%;
}
.map-sheet {
    background: var(--glass-bg);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-top: 1px solid var(--glass-border);
    border-radius: 24px 24px 0 0;
    padding: 30px 20px;
    pointer-events: auto;
    transform: translateY(70%); /* peek state */
    transition: var(--transition-smooth);
}
.map-sheet.expanded { transform: translateY(0); }
.sheet-handle {
    width: 40px; height: 5px;
    background: rgba(255,255,255,0.3);
    border-radius: 3px;
    margin: -15px auto 20px auto;
}
.map-sheet h3 { margin-bottom: 10px; }
.map-sheet p { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 20px; }

/* GARAGE VIEW */
.garage-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 30px;
}
.user-flair-section {
    display: flex; align-items: center; gap: 20px;
    background: var(--glass-bg);
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 30px;
}
.flair-preview { position: relative; }
.flair-preview img {
    width: 80px; height: 80px; border-radius: 50%;
    border: 3px solid var(--ferrari-red);
}
.btn-edit-flair {
    position: absolute; bottom: 0; right: 0;
    background: var(--ferrari-red); color: white;
    border: none; border-radius: 50%;
    width: 30px; height: 30px;
    cursor: pointer;
}
.flair-info h3 { font-size: 1.5rem; margin-bottom: 5px; }
.flair-badge {
    display: inline-block;
    background: rgba(255, 242, 0, 0.1);
    color: var(--ferrari-yellow);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: bold;
    text-transform: uppercase;
}

.car-card {
    background: var(--carbon-dark);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 20px;
    border: 1px solid var(--glass-border);
}
.car-img {
    width: 100%;
    aspect-ratio: 16 / 9;
    background-size: cover;
    background-position: center;
}

.garage-backdrop {
    width: 100%;
    aspect-ratio: 16 / 9;
    background-size: cover;
    background-position: center;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.car-img-inner {
    width: 75%;
    height: 65%;
    background-size: cover;
    background-position: center;
    border-radius: 8px;
    box-shadow: 0 15px 40px rgba(0,0,0,0.9);
    position: relative;
    top: 5%; /* Grounds the car in the garage */
}

.car-placeholder-inner {
    width: 75%;
    height: 65%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    border-radius: 8px;
    border: 1px dashed var(--ferrari-yellow);
    color: var(--ferrari-yellow);
    position: relative;
    top: 5%;
}
.car-details { padding: 15px; }
.car-name { font-family: var(--font-heading); font-size: 1.2rem; margin-bottom: 5px; }
.car-specs { color: var(--text-muted); font-size: 0.9rem; }

/* TOP NAV TABS */
.top-nav-tabs {
    height: 70px;
    background: rgba(15, 15, 15, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-around;
    align-items: center;
    position: fixed;
    top: 60px; left: 0; right: 0;
    z-index: 1000;
}
.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    font-family: var(--font-ui);
    font-size: 0.75rem;
    cursor: pointer;
    transition: var(--transition-snappy);
    width: 60px;
}
.tab-btn i { font-size: 1.4rem; }
.tab-btn.active { color: var(--ferrari-red); transform: translateY(-3px); }
.tab-btn.active i { filter: drop-shadow(0 0 8px rgba(255, 40, 0, 0.5)); }

/* MODALS */
.modal {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.8);
    z-index: 2000;
    display: flex; justify-content: center; align-items: center;
}
.modal-content {
    width: 90%; max-width: 400px;
    padding: 30px;
}
.modal-header { display: flex; justify-content: space-between; margin-bottom: 20px; }
.btn-close { background: transparent; border: none; color: white; font-size: 1.5rem; cursor: pointer; }
.form-group { margin-bottom: 15px; }
.form-group label { display: block; margin-bottom: 8px; color: var(--text-muted); font-size: 0.85rem; }
.form-group input {
    width: 100%;
    background: rgba(0,0,0,0.5);
    border: 1px solid var(--glass-border);
    padding: 12px;
    border-radius: 6px;
    color: white;
    font-family: var(--font-ui);
}
.form-group input:focus { outline: none; border-color: var(--ferrari-red); }

/* Animations */
.fade-in { animation: fadeIn 0.4s ease forwards; }
.fade-in-up { animation: fadeInUp 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) forwards; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Mapbox Customizations */
.mapboxgl-popup-content {
    background: var(--carbon-dark) !important;
    color: white !important;
    border: 1px solid var(--ferrari-red);
    border-radius: 8px !important;
    font-family: var(--font-ui);
}
.mapboxgl-popup-anchor-bottom .mapboxgl-popup-tip {
    border-top-color: var(--ferrari-red) !important;
}
