@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap');

:root {
    /* MD3 Color Palette (Indigo/Violet base - SAME AS ORIGINAL) */
    --md-sys-color-primary: #3f51b5;
    --md-sys-color-on-primary: #ffffff;
    --md-sys-color-primary-container: #e8eaf6;
    --md-sys-color-on-primary-container: #1a237e;

    --md-sys-color-secondary: #009688;
    --md-sys-color-on-secondary: #ffffff;
    --md-sys-color-secondary-container: #e0f2f1;
    --md-sys-color-on-secondary-container: #004d40;

    --md-sys-color-tertiary: #ef5350;

    --md-sys-color-background: #fdfbff;
    --md-sys-color-on-background: #1b1b1f;

    --md-sys-color-surface: #fdfbff;
    --md-sys-color-on-surface: #1b1b1f;
    --md-sys-color-surface-variant: #e1e2ec;
    --md-sys-color-on-surface-variant: #44474f;
    --md-sys-color-outline: #74777f;
    --md-sys-color-outline-variant: #c4c6d0;

    --md-sys-color-success: #4caf50;
    --md-sys-color-error: #ba1a1a;
    --md-sys-color-on-error: #ffffff;

    /* MD3 Elevations */
    --md-sys-elevation-0: none;
    --md-sys-elevation-1: 0px 1px 2px rgba(0, 0, 0, 0.3), 0px 1px 3px 1px rgba(0, 0, 0, 0.15);
    --md-sys-elevation-2: 0px 1px 2px rgba(0, 0, 0, 0.3), 0px 2px 6px 2px rgba(0, 0, 0, 0.15);
    --md-sys-elevation-3: 0px 1px 3px rgba(0, 0, 0, 0.3), 0px 4px 8px 3px rgba(0, 0, 0, 0.15);

    /* Layout & Shape */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 28px;

    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;

    --font-heading: 'Roboto', sans-serif;
    --font-body: 'Roboto', sans-serif;
}

/* Dark Mode Variables */
body.dark-mode {
    --md-sys-color-primary: #9fa8da;
    --md-sys-color-on-primary: #1a237e;
    --md-sys-color-primary-container: #283593;
    --md-sys-color-on-primary-container: #e8eaf6;

    --md-sys-color-secondary: #80cbc4;
    --md-sys-color-on-secondary: #004d40;
    --md-sys-color-secondary-container: #00695c;
    --md-sys-color-on-secondary-container: #e0f2f1;

    --md-sys-color-background: #1b1b1f;
    --md-sys-color-on-background: #e3e2e6;

    --md-sys-color-surface: #1b1b1f;
    --md-sys-color-on-surface: #e3e2e6;
    --md-sys-color-surface-variant: #44474f;
    --md-sys-color-on-surface-variant: #c4c6d0;
    --md-sys-color-outline: #8e9099;
    --md-sys-color-outline-variant: #44474f;

    --md-sys-color-error: #ffb4ab;
    --md-sys-color-on-error: #690005;
}

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

body {
    font-family: var(--font-body);
    background-color: var(--md-sys-color-background);
    color: var(--md-sys-color-on-background);
    line-height: 1.5;
    height: 100vh;
    overflow: hidden;
    transition: background-color 0.3s, color 0.3s;
}

/* === Material Symbols === */
.material-symbols-outlined {
    font-family: 'Material Symbols Outlined';
    font-weight: normal;
    font-style: normal;
    font-size: 24px;
    display: inline-block;
    line-height: 1;
    text-transform: none;
    letter-spacing: normal;
    word-wrap: normal;
    white-space: nowrap;
    direction: ltr;
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

/* === Layout === */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 600px;
    /* Mobile first constrained */
    margin: 0 auto;
    position: relative;
    background-color: var(--md-sys-color-background);
}

.app-bar {
    background-color: var(--md-sys-color-surface);
    color: var(--md-sys-color-on-surface);
    padding: var(--spacing-sm) var(--spacing-md);
    padding-top: max(var(--spacing-sm), env(safe-area-inset-top));
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    z-index: 10;
    transition: background-color 0.3s;
}

.app-bar-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 56px;
}

.app-title-wrapper {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.app-logo {
    color: var(--md-sys-color-primary);
    font-size: 28px;
}

.app-title {
    font-size: 1.375rem;
    font-weight: 400;
    color: var(--md-sys-color-on-surface);
}

.app-actions {
    display: flex;
    gap: var(--spacing-xs);
    align-items: center;
}

/* Vehicle Selector in Header */
.vehicle-selector {
    background: var(--md-sys-color-surface-variant);
    color: var(--md-sys-color-on-surface-variant);
    border: none;
    padding: 6px 12px;
    border-radius: 16px;
    font-family: inherit;
    font-size: 0.875rem;
    outline: none;
    cursor: pointer;
    max-width: 150px;
}

/* === Main Content === */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-md);
    padding-bottom: 88px;
    scrollbar-width: thin;
}

/* === Tabs === */
.tabs-container {
    background-color: var(--md-sys-color-surface);
    border-top: 1px solid var(--md-sys-color-outline-variant);
    order: 3;
}

.tabs-scroll {
    display: flex;
    overflow-x: auto;
    padding: 0 var(--spacing-sm);
}

.tab {
    flex: 1;
    padding: 12px 0;
    background: none;
    border: none;
    color: var(--md-sys-color-on-surface-variant);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 64px;
}

.tab .material-symbols-outlined {
    padding: 4px 20px;
    border-radius: 16px;
    transition: background-color 0.2s;
}

.tab.active {
    color: var(--md-sys-color-on-surface);
}

.tab.active .material-symbols-outlined {
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

.tab-label {
    font-size: 0.75rem;
    font-weight: 500;
}

/* === Cards === */
.card {
    background-color: var(--md-sys-color-surface);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    transition: background-color 0.3s, border-color 0.3s;
}

.card-elevated {
    background-color: var(--md-sys-color-surface);
    box-shadow: var(--md-sys-elevation-1);
    border: none;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
}

.card-title {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--md-sys-color-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* === Stats Grid === */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

.stat-card {
    background-color: var(--md-sys-color-secondary-container);
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    text-align: center;
    color: var(--md-sys-color-on-secondary-container);
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
}

.stat-label {
    font-size: 0.75rem;
    opacity: 0.9;
}

/* === Forms === */
.form-group {
    margin-bottom: var(--spacing-md);
}

.form-label {
    display: block;
    margin-bottom: var(--spacing-xs);
    font-size: 0.875rem;
    color: var(--md-sys-color-on-surface-variant);
}

.text-field {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--md-sys-color-outline);
    border-radius: 4px;
    font-family: inherit;
    font-size: 1rem;
    background-color: transparent;
    color: var(--md-sys-color-on-surface);
    transition: border-color 0.2s;
}

.text-field:focus {
    outline: none;
    border-color: var(--md-sys-color-primary);
    border-width: 2px;
    padding: 11px 15px;
}

select.text-field {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23000000%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right .7em top 50%;
    background-size: .65em auto;
}

body.dark-mode select.text-field {
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23FFFFFF%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
}

/* Checkbox Style */
.checkbox-container {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-size: 1rem;
    user-select: none;
}

.checkbox-container input {
    width: 20px;
    height: 20px;
    accent-color: var(--md-sys-color-primary);
}

/* Buttons */
.button {
    padding: 10px 24px;
    border: none;
    border-radius: 20px;
    font-weight: 500;
    font-size: 0.875rem;
    letter-spacing: 0.1px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.filled-button {
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    box-shadow: var(--md-sys-elevation-1);
}

.filled-button:active {
    box-shadow: none;
}

.text-button {
    background: transparent;
    color: var(--md-sys-color-primary);
    padding: 10px 12px;
}

.text-button:hover {
    background-color: rgba(63, 81, 181, 0.08);
}

.button.full {
    width: 100%;
}

.button.danger {
    background-color: var(--md-sys-color-error);
    color: var(--md-sys-color-on-error);
}

/* FAB */
.fab-container {
    position: fixed;
    bottom: 100px;
    right: 24px;
    z-index: 100;
}

.fab-main {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    border: none;
    box-shadow: var(--md-sys-elevation-3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.fab-main:active {
    transform: scale(0.95);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-md);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s;
    backdrop-filter: blur(2px);
}

.modal.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background-color: var(--md-sys-color-surface);
    color: var(--md-sys-color-on-surface);
    width: 100%;
    max-width: 400px;
    border-radius: 28px;
    padding: 24px;
    box-shadow: var(--md-sys-elevation-3);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.2, 0.0, 0, 1.0);
    max-height: 85vh;
    overflow-y: auto;
}

.modal.active .modal-content {
    transform: scale(1);
}

.modal-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: 24px;
}

/* Notification */
.notification {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--md-sys-color-on-surface);
    color: var(--md-sys-color-surface);
    padding: 14px 16px;
    border-radius: 4px;
    z-index: 3000;
    box-shadow: var(--md-sys-elevation-2);
    font-size: 0.875rem;
    align-items: center;
    gap: 12px;
    min-width: 300px;
}

/* List Items (Refuel Logs) */
.log-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

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

.log-main {
    font-weight: 500;
    color: var(--md-sys-color-on-surface);
}

.log-sub {
    font-size: 0.85rem;
    color: var(--md-sys-color-on-surface-variant);
}

.log-value {
    font-weight: 700;
    color: var(--md-sys-color-primary);
    text-align: right;
}

/* Car List Item */
.car-item {
    background-color: var(--md-sys-color-surface);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.car-item.active-car {
    border: 2px solid var(--md-sys-color-primary);
    background-color: var(--md-sys-color-surface-variant);
}

/* Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 32px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--md-sys-color-surface-variant);
    border: 2px solid var(--md-sys-color-outline);
    transition: .4s;
    border-radius: 16px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 6px;
    bottom: 6px;
    background-color: var(--md-sys-color-outline);
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--md-sys-color-primary);
    border-color: var(--md-sys-color-primary);
}

input:checked+.slider:before {
    transform: translateX(20px);
    background-color: var(--md-sys-color-on-primary);
    left: 2px;
    bottom: 2px;
    height: 24px;
    width: 24px;
}

/* Settings Item */
.settings-group {
    margin-bottom: var(--spacing-lg);
}

.settings-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    cursor: pointer;
}

/* Swipeable Items */
.swipe-container {
    position: relative;
    overflow: hidden;
    margin-bottom: 2px;
    /* separator */
}

.swipe-content {
    background-color: var(--md-sys-color-surface);
    position: relative;
    z-index: 2;
    transition: transform 0.2s ease-out;
    padding: 12px 16px;
    /* Match typical list item padding */
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    cursor: grab;
    user-select: none;
}

.swipe-content:active {
    cursor: grabbing;
}

.swipe-actions-left {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 50%;
    background-color: #FBC02D;
    display: flex;
    align-items: center;
    padding-left: 20px;
    color: #1d1b20;
    z-index: 1;
}

.swipe-actions-right {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 50%;
    background-color: var(--md-sys-color-error);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 20px;
    color: white;
    z-index: 1;
}


.swipe-actions-left span,
.swipe-actions-right span {
    font-size: 24px;
    pointer-events: none;
}

/* === Update Banner === */
.update-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--md-sys-elevation-2);
    z-index: 10000;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
    }
    to {
        transform: translateY(0);
    }
}

.update-content {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 500;
}

.update-content .material-symbols-outlined {
    font-size: 24px;
}

.update-banner .button {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 8px 16px;
    font-weight: 500;
}

.update-banner .button:hover {
    background: rgba(255, 255, 255, 0.3);
}