/* web/static/css/dashboard.css */
/* No font import needed - using system native fonts for Apple feel */

:root {
    --bg-color: #ffffff;
    --card-bg: #f2f2f5;
    --text-primary: #000000;
    --text-secondary: #929292;
    --accent: #d5001c;
    --success: #34c759;
    --danger: #ff3b30;
    --warning: #ff9f0a;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", system-ui, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    padding-bottom: 110px;
    letter-spacing: -0.2px;
}

.container {
    max-width: 500px;
    margin: 0 auto;
    padding: 20px;
}

header {
    margin-top: 30px;
    /* Pushed down to avoid iPhone notch */
    padding-top: env(safe-area-inset-top);
    /* Extra safety for notched devices */
    margin-bottom: 5px;
    /* Minimal gap to tighten layout */
}

.refresh-hint {
    font-size: 9px;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    opacity: 0.6;
    margin-bottom: 2px;
}

.car-title {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.8px;
    margin: 0 0 12px 0;
}

.status-badges {
    display: flex;
    align-items: center;
    gap: 12px;
}

.prominent-stats {
    display: none;
}

.badge {
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 6px;
    letter-spacing: 0.5px;
}

.badge i,
.badge svg {
    width: 12px;
    height: 12px;
}

.badge-online {
    background: #fff;
    color: var(--success);
    border: 1px solid rgba(52, 199, 89, 0.2);
}

.badge-sleep {
    background: rgba(93, 93, 255, 0.1);
    color: #5d5dff;
    border: none;
    /* Cleaner look */
}

.badge-sleep i {
    stroke-width: 2.5px;
}

@keyframes badge-pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(14, 165, 233, 0.4);
    }

    50% {
        transform: scale(1.05);
        box-shadow: 0 0 15px 0 rgba(14, 165, 233, 0.6);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(14, 165, 233, 0.4);
    }
}

.badge-charging {
    background: #0ea5e9;
    color: #fff;
    animation: badge-pulse 3s infinite ease-in-out;
    font-weight: 600;
}

.meeting-alert {
    background: #1c1c1e;
    border-radius: 20px;
    padding: 8px 14px;
    color: white;
    display: flex;
    gap: 12px;
    margin-bottom: 5px;
    /* Minimal gap to car */
    /* Centers the alert between top and car */
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.meeting-icon {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--warning);
    font-size: 18px;
}

.meeting-info {
    flex: 1;
    min-width: 0;
}

.meeting-label {
    font-size: 8px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.4);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 2px;
}

.meeting-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 2px;
}

.meeting-location {
    font-size: 11px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.5);
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
}

.meeting-location i {
    color: #5d5dff;
}

.meeting-dist {
    color: #5d5dff;
    font-weight: 600;
}

.meeting-arrival-pill {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    background: rgba(255, 159, 10, 0.1);
    border: 1px solid rgba(255, 159, 10, 0.2);
    padding: 1px 5px;
    /* Extremely compact */
    border-radius: 100px;
    margin-top: 4px;
}

.meeting-arrival-pill i {
    color: #ff9f0a !important;
    width: 4px;
    /* Ultra micro as requested */
    height: 4px;
    display: block;
    stroke-width: 4px;
}

.meeting-arrival-text {
    font-size: 9px;
    /* Smaller */
    font-weight: 700;
    color: #ff9f0a;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}



.meeting-time {
    text-align: right;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
}

.meeting-time-val {
    font-size: 17px;
    font-weight: 700;
}

.meeting-date-val {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.4);
}

.hero {
    display: flex;
    justify-content: center;
    margin-bottom: -15px;
    /* Hero stays close to metrics */
}

.car-image {
    width: 110%;
    max-width: 450px;
}

/* Main Metrics Row (Below Car) */
.main-metrics-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 35px;
    /* Increased to push icon-grid down */
    padding: 12px 5px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.metrics-left {
    display: flex;
    align-items: baseline;
    gap: 12px;
}

.metric-soc {
    font-size: 42px;
    font-weight: 800;
    letter-spacing: -2px;
    color: #000;
    line-height: 1;
}

.metric-range {
    font-size: 18px;
    font-weight: 600;
    color: #8e8e93;
    letter-spacing: -0.5px;
}

.metrics-right {
    text-align: right;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.metric-label {
    font-size: 9px;
    font-weight: 800;
    color: #b0b0b5;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.metric-odo {
    font-size: 19px;
    font-weight: 700;
    color: #1c1c1e;
    letter-spacing: -0.3px;
}

.stat-label {
    font-size: 9px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 8px;
    display: block;
    opacity: 0.5;
}

.stat-value {
    font-size: 20px;
    font-weight: 500;
    color: var(--text-primary);
    letter-spacing: -0.4px;
}

.stat-sub-value {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 400;
    margin-left: 4px;
}

/* Charging Card Liquid Animation */
@keyframes wave {
    0% {
        transform: translate(-50%, -75%) rotate(0deg);
    }

    100% {
        transform: translate(-50%, -75%) rotate(360deg);
    }
}

.charging-card {
    background: #0ea5e9;
    background: linear-gradient(135deg, #38bdf8 0%, #0284c7 100%);
    border-radius: 30px;
    padding: 24px;
    margin-bottom: 30px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 15px 35px rgba(14, 165, 233, 0.15);
}

.charging-card::before,
.charging-card::after {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    bottom: -460px;
    left: 50%;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 40%;
    animation: wave 10s infinite linear;
    z-index: 1;
}

.charging-card::after {
    bottom: -450px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 35%;
    animation: wave 15s infinite linear;
}

.charging-card-content {
    position: relative;
    z-index: 2;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.charging-icon-wrapper {
    width: 52px;
    height: 52px;
    background: #fff;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #0284c7;
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.05);
}

.charging-main-info {
    display: flex;
    align-items: center;
    gap: 18px;
}

.charging-text-label {
    font-size: 12px;
    font-weight: 800;
    color: rgba(255, 255, 255, 0.7);
    display: block;
    margin-bottom: 2px;
}

.charging-text-value {
    font-size: 22px;
    font-weight: 600;
    display: flex;
    align-items: baseline;
    gap: 4px;
    color: #fff;
}

.charging-text-value small {
    font-size: 14px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.8);
}

.charging-eta {
    text-align: right;
}

.charging-eta-label {
    font-size: 11px;
    font-weight: 800;
    color: rgba(255, 255, 255, 0.7);
    display: block;
}

.charging-eta-time {
    font-size: 18px;
    font-weight: 800;
    color: #fff;
}

.charging-progress-bar-container {
    position: relative;
    z-index: 2;
    height: 8px;
    background: rgba(0, 0, 0, 0.08);
    border-radius: 4px;
    margin-bottom: 20px;
}

.charging-progress-bar-fill {
    height: 100%;
    background: #0ea5e9;
    border-radius: 4px;
}

.charging-footer {
    position: relative;
    z-index: 2;
    display: flex;
    justify-content: space-between;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.charging-update-tag {
    font-size: 11px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.6);
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Grid & Rest */
.btn-details {
    width: 100%;
    background: #f2f2f7;
    border: none;
    padding: 18px;
    border-radius: 14px;
    font-size: 15px;
    font-weight: 500;
    margin-bottom: 15px;
    cursor: pointer;
    color: #1c1c1e;
    transition: all 0.2s ease;
}

.btn-details:active {
    background: #e5e5ea;
    transform: scale(0.98);
}

.icon-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    background: #f2f2f5;
    border-radius: 16px;
    margin-bottom: 10px;
    /* Puxa para junto da barra inferior */
    overflow: hidden;
}

.grid-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 0;
    gap: 10px;
    position: relative;
    cursor: pointer;
}

.grid-item:not(:last-child)::after {
    content: "";
    position: absolute;
    right: 0;
    height: 40%;
    width: 1.5px;
    background: rgba(0, 0, 0, 0.08);
}

.grid-item i,
.grid-item svg {
    width: 22px;
    height: 22px;
    color: #3a3a3c;
    margin-bottom: 6px;
    display: block;
}

.grid-item span {
    font-size: 10px;
    font-weight: 500;
    color: #8e8e93;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.grid-item.ok i,
.grid-item.ok svg {
    color: #0ea5e9;
}

.grid-item.active i,
.grid-item.active svg {
    color: #ff3b30;
}

.grid-item.active span,
.grid-item.ok span {
    color: #3a3a3c;
    font-weight: 600;
}

/* Disabled State for Grid Items */
.grid-item.disabled-icon i,
.grid-item.disabled-icon svg {
    color: #c7c7cc !important;
}

.grid-item.disabled-icon span {
    color: #d1d1d6 !important;
}

/* SOC Charging Animation */
@keyframes text-glow-pulse {
    0% {
        text-shadow: 0 0 5px rgba(14, 165, 233, 0.2);
        color: #000;
    }

    50% {
        text-shadow: 0 0 20px rgba(14, 165, 233, 0.6);
        color: #0284c7;
    }

    100% {
        text-shadow: 0 0 5px rgba(14, 165, 233, 0.2);
        color: #000;
    }
}

.metric-soc.charging-active {
    animation: text-glow-pulse 2s infinite ease-in-out;
}

/* Location Card */
.location-card {
    background: #fff;
    border-radius: 28px;
    padding: 28px;
    border: 1.5px solid #f2f2f5;
}

.location-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.location-title {
    font-size: 12px;
    font-weight: 800;
    color: #b0b0b5;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.address-street {
    font-size: 18px;
    font-weight: 600;
    color: #1c1c1e;
    margin-bottom: 4px;
}

.address-city {
    font-size: 15px;
    color: #8e8e93;
    font-weight: 600;
}

.location-coords {
    margin-top: 25px;
    padding-top: 15px;
    border-top: 1.5px solid #f9f9fb;
    font-size: 12px;
    color: #c7c7cc;
    font-family: monospace;
    display: flex;
    justify-content: space-between;
}

/* Bottom Nav */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.7);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 12px 10px 25px 10px;
    border-top: 0.5px solid rgba(0, 0, 0, 0.1);
    z-index: 1500;
    backdrop-filter: blur(40px) saturate(180%);
    -webkit-backdrop-filter: blur(40px) saturate(180%);
}

.nav-item {
    display: flex;
    justify-content: center;
    align-items: center;
    flex: 1;
    height: 44px;
    cursor: pointer;
}

.nav-item i,
.nav-item svg {
    width: 26px;
    height: 26px;
    color: #8e8e93;
    stroke-width: 2px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-item.active i,
.nav-item.active svg {
    color: #007aff;
    transform: translateY(-2px);
}

/* User Modal Fix */
#userModal .modal-content {
    border-radius: 32px;
    background: #111;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

#userModal .modal-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

/* Pull to Refresh */
.pull-to-refresh {
    height: 0;
    opacity: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ptr-icon {
    width: 34px;
    height: 34px;
    background: #f2f2f7;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* History Modal Improvements */
.history-current-card {
    background: linear-gradient(135deg, #ffffff 0%, #f9f9fb 100%);
    border-radius: 32px;
    padding: 35px 24px;
    color: #1c1c1e;
    text-align: center;
    margin-bottom: 35px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.04), 0 1px 3px rgba(0, 0, 0, 0.02);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.history-current-img {
    width: 100%;
    max-width: 320px;
    height: auto;
    margin-bottom: 25px;
    filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.05));
    mix-blend-mode: multiply;
    /* Blends white background into the card's light gray if not pure white */
}

.history-status-badge {
    display: inline-flex;
    align-items: center;
    padding: 8px 16px;
    border-radius: 12px;
    font-size: 18px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: -0.5px;
    margin-bottom: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.history-status-badge.positive {
    background: rgba(52, 199, 89, 0.1);
    color: var(--success);
}

.history-status-badge.negative {
    background: rgba(255, 59, 48, 0.1);
    color: var(--danger);
}

.state-ok-icon {
    color: var(--success);
}

.state-alert-icon {
    color: var(--danger);
}

.history-state-text {
    font-size: 24px;
    font-weight: 800;
    display: block;
    letter-spacing: -1px;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.history-since-text {
    font-size: 13px;
    color: #8e8e93;
    font-weight: 600;
    display: block;
}

.history-list-title {
    font-size: 11px;
    font-weight: 800;
    color: #b0b0b5;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    margin-bottom: 20px;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px solid #f2f2f7;
}

.history-item:last-child {
    border-bottom: none;
}

.history-date {
    font-size: 13px;
    color: #8e8e93;
    font-weight: 500;
}

.history-item::after {
    content: "";
    position: absolute;
    left: 4px;
    top: 24px;
    bottom: -24px;
    width: 1.5px;
    background: #f2f2f7;
}

.history-item:last-child::after {
    display: none;
}

.history-item::before {
    content: "";
    position: absolute;
    left: 0;
    top: 5px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid #d1d1d6;
    z-index: 2;
    transition: all 0.3s ease;
}

.history-item.active-state::before {
    background: var(--success);
    border-color: var(--success);
    box-shadow: 0 0 0 4px rgba(52, 199, 89, 0.15);
}

.history-item.inactive-state::before {
    background: var(--danger);
    border-color: var(--danger);
    box-shadow: 0 0 0 4px rgba(255, 59, 48, 0.15);
}

.history-item-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f9f9fb;
    padding: 14px 18px;
    border-radius: 16px;
    border: 1px solid rgba(0, 0, 0, 0.02);
}

.history-item-label {
    font-size: 15px;
    font-weight: 700;
    color: #1c1c1e;
}

.history-item-time {
    color: #8e8e93;
    font-size: 12px;
    font-weight: 600;
}

.modal-close {
    background: #f2f2f7;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: #e5e5ea;
    transform: rotate(90deg);
}

/* Car Charging Glow Bar */
.car-charging-glow-bar {
    width: 90%;
    max-width: 350px;
    height: 3px;
    background: rgba(14, 165, 233, 0.1);
    border-radius: 2px;
    margin: -10px auto 25px auto;
    /* Pull up closer to car */
    position: relative;
    overflow: visible;
    /* Allow glow to spill out */
    z-index: 5;
}

.car-charging-glow-fill {
    height: 100%;
    background: #0ea5e9;
    border-radius: 2px;
    box-shadow: 0 0 10px 2px rgba(14, 165, 233, 0.8), 0 0 20px 5px rgba(14, 165, 233, 0.4);
    transition: width 0.5s ease-out;
    animation: glow-bar-pulse 2s infinite ease-in-out;
}

@keyframes glow-bar-pulse {
    0% {
        opacity: 0.8;
        box-shadow: 0 0 10px 2px rgba(14, 165, 233, 0.6);
    }

    50% {
        opacity: 1;
        box-shadow: 0 0 15px 4px rgba(14, 165, 233, 0.9);
    }

    100% {
        opacity: 0.8;
        box-shadow: 0 0 10px 2px rgba(14, 165, 233, 0.6);
    }
}