/* MargaCharge Mobile - Theme-aware, green accent */

:root {
    --brand-green: #4CAF50;
    --brand-green-dim: #388E3C;
    --tab-bar-height: 60px;
}

[data-bs-theme="dark"] {
    --bg-primary: #1a1a2e;
    --bg-card: #16213e;
    --bg-surface: #0f3460;
    --text-primary: #e0e0e0;
    --text-muted: #8a8a9a;
    --border-subtle: rgba(255,255,255,0.08);
}

[data-bs-theme="light"] {
    --bg-primary: #f8f9fa;
    --bg-card: #ffffff;
    --bg-surface: #e9ecef;
    --text-primary: #212529;
    --text-muted: #6c757d;
    --border-subtle: rgba(0,0,0,0.1);
}

html, body {
    height: 100%;
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior: none;
}

/* Loading screen */
.loading-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
}

/* Blazor error UI */
#blazor-error-ui {
    background: #6e0101;
    color: white;
    padding: 0.6rem 1.25rem;
    display: none;
    position: fixed;
    bottom: var(--tab-bar-height);
    left: 0;
    right: 0;
    z-index: 1000;
    text-align: center;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    margin-left: 1rem;
}

/* Status badges */
.badge-available { background-color: #6c757d; }
.badge-preparing { background-color: #ffc107; color: #000; }
.badge-charging { background-color: var(--brand-green); }
.badge-suspended { background-color: #fd7e14; }
.badge-finishing { background-color: #0dcaf0; color: #000; }
.badge-faulted { background-color: #dc3545; }
.badge-unavailable { background-color: #6c757d; }
.badge-unknown { background-color: #6c757d; }

/* Status card */
.status-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 16px;
    padding: 1.5rem;
}

/* Stat items */
.stat-item {
    text-align: center;
    padding: 0.75rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--brand-green);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Session list */
.session-item {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 0.6rem 0.75rem;
    margin-bottom: 0.5rem;
}

.session-item.invoiced {
    opacity: 0.6;
}

.session-item .session-date {
    color: var(--text-muted);
    font-size: 0.78rem;
}

.session-item .session-energy {
    font-size: 1rem;
    font-weight: 600;
    color: var(--brand-green);
}

/* Filter tabs */
.filter-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.filter-tab {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 20px;
    color: var(--text-muted);
    font-size: 0.78rem;
    padding: 0.4rem 0.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s;
}

.filter-tab.active {
    background: var(--brand-green);
    color: #fff;
    border-color: var(--brand-green);
}

/* Invoice bar */
.invoice-bar {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

/* Pull-to-refresh indicator */
.refresh-indicator {
    text-align: center;
    padding: 0.5rem;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Top bar */
.top-bar {
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-subtle);
    padding: 0.75rem 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.top-bar h1 {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
    color: var(--brand-green);
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.btn-logout, .btn-theme {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    transition: color 0.15s;
}

.btn-logout:hover, .btn-theme:hover {
    color: var(--text-primary);
}

.charger-select {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
    border-radius: 0.5rem;
    padding: 0.2rem 0.5rem;
    font-size: 0.8rem;
    max-width: 140px;
    cursor: pointer;
}

/* Content area */
.page-content {
    padding: 1rem;
    padding-bottom: calc(var(--tab-bar-height) + env(safe-area-inset-bottom, 0px) + 1.5rem);
    min-height: calc(100vh - 52px - var(--tab-bar-height));
}

/* Tab bar */
.tab-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--tab-bar-height);
    background: var(--bg-card);
    border-top: 1px solid var(--border-subtle);
    display: flex;
    z-index: 200;
    padding-bottom: env(safe-area-inset-bottom);
}

.tab-bar a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.7rem;
    gap: 0.2rem;
    transition: color 0.15s;
}

.tab-bar a i {
    font-size: 1.4rem;
}

.tab-bar a.active {
    color: var(--brand-green);
}

/* Solar indicator */
.solar-badge {
    background: linear-gradient(135deg, #ff9800, #ffc107);
    color: #000;
    font-weight: 600;
}

/* Profile page */
.profile-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--bg-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--brand-green);
    flex-shrink: 0;
}

.preference-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    gap: 1rem;
}

.preference-toggle + .preference-toggle {
    border-top: 1px solid var(--border-subtle);
}

.preference-toggle .form-check-input {
    width: 3rem;
    height: 1.5rem;
    cursor: pointer;
    flex-shrink: 0;
}

.preference-toggle .form-check-input:checked {
    background-color: var(--brand-green);
    border-color: var(--brand-green);
}

.preference-toggle .form-check-input:focus {
    box-shadow: 0 0 0 0.2rem rgba(76, 175, 80, 0.25);
    border-color: var(--brand-green);
}

.btn-info-toggle {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 0 0.3rem;
    cursor: pointer;
    vertical-align: middle;
    transition: color 0.15s;
}

.btn-info-toggle:hover {
    color: var(--text-primary);
}

.info-box {
    background: var(--bg-surface);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--text-muted);
}

.info-box p:last-child {
    margin-bottom: 0;
}

/* Energy mix pie chart */
.energy-pie-container {
    position: relative;
    width: 100px;
    height: 100px;
    flex-shrink: 0;
}

.energy-pie {
    width: 100%;
    height: 100%;
}

.energy-pie-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.energy-legend {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
}

.energy-legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.78rem;
}

.energy-legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Car picker */
.car-selected {
    position: relative;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 0.75rem 2.5rem 0.75rem 0.75rem;
    cursor: pointer;
    transition: border-color 0.15s;
}

.car-selected:hover {
    border-color: var(--brand-green);
}

.car-edit-icon {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.85rem;
}

.car-picker-list {
    max-height: 250px;
    overflow-y: auto;
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    margin-top: 0.25rem;
    background: var(--bg-card);
}

.car-picker-brand {
    padding: 0.4rem 0.75rem 0.2rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    position: sticky;
    top: 0;
    background: var(--bg-card);
}

.car-picker-item {
    padding: 0.6rem 0.75rem;
    cursor: pointer;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border-subtle);
    transition: background 0.1s;
}

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

.car-picker-item:active,
.car-picker-item.selected {
    background: var(--bg-surface);
    color: var(--brand-green);
}

.car-picker-empty {
    padding: 1.5rem;
    text-align: center;
    font-size: 0.85rem;
}

/* Utility: green text */
.text-brand { color: var(--brand-green) !important; }
