/* DeductFlow Mobile PWA — Ocean Flow Dark Theme */

:root {
    --bg-primary: #09090b;
    --bg-secondary: #18181b;
    --bg-tertiary: #1f1f23;
    --bg-surface: #27272a;
    --text-primary: #fafafa;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    --teal-primary: #00A8B5;
    --teal-bright: #00D4E4;
    --teal-dark: #006B73;
    --teal-glow: #00E5EE;
    --coral: #FF6B6B;
    --coral-soft: #FF8A8A;
    --amber: #F59E0B;
    --success: #10B981;
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-default: rgba(255, 255, 255, 0.1);
    --border-ocean: rgba(0, 168, 181, 0.3);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --radius-full: 9999px;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4), 0 2px 4px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5), 0 4px 8px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 30px rgba(0, 168, 181, 0.2);
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    overscroll-behavior: none;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

/* ── Header ────────────────────────────────────────── */

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    padding-top: calc(12px + env(safe-area-inset-top, 0));
    background: linear-gradient(180deg, #0B2B3C 0%, var(--bg-primary) 100%);
    border-bottom: 1px solid var(--border-ocean);
    position: sticky;
    top: 0;
    z-index: 50;
}

.app-header .logo img {
    height: 32px;
    width: auto;
}

.header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.property-select {
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    color: var(--text-primary);
    font-size: 0.8rem;
    font-weight: 500;
    padding: 6px 28px 6px 10px;
    border-radius: var(--radius-sm);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a1a1aa' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    max-width: 160px;
}

.btn-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}
.btn-icon:active { background: var(--bg-tertiary); }
.btn-icon svg { width: 18px; height: 18px; }

/* ── Tab Bar ───────────────────────────────────────── */

.tab-bar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-subtle);
    padding-bottom: env(safe-area-inset-bottom, 0);
    z-index: 50;
}

.tab-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 0 8px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-family: 'Inter', sans-serif;
    font-size: 0.65rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: color var(--transition-fast);
    position: relative;
}
.tab-btn svg { width: 22px; height: 22px; }
.tab-btn.active { color: var(--teal-bright); }
.tab-btn.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 32px;
    height: 2px;
    background: var(--teal-primary);
    border-radius: 0 0 2px 2px;
}

/* ── Main Content ──────────────────────────────────── */

.tab-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px;
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0));
}

.tab-page { display: none; }
.tab-page.active { display: block; }

/* ── Cards ─────────────────────────────────────────── */

.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 12px;
}

.card-header {
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-subtle);
}

.card-title {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
}

.card-body { padding: 16px; }

/* ── Stat Row ──────────────────────────────────────── */

.stat-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
}

.stat-box {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 14px;
    text-align: center;
}

.stat-value {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 1.3rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1;
    margin-bottom: 4px;
}
.stat-value.teal { color: var(--teal-bright); }
.stat-value.coral { color: var(--coral-soft); }
.stat-value.amber { color: var(--amber); }
.stat-value.success { color: var(--success); }

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

/* ── Forms ─────────────────────────────────────────── */

.form-group {
    margin-bottom: 14px;
}

.form-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-default);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 16px; /* prevents iOS zoom */
    padding: 12px 14px;
    border-radius: var(--radius-md);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    -webkit-appearance: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--teal-primary);
    box-shadow: 0 0 0 3px rgba(0, 168, 181, 0.2);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--text-muted);
}

.form-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23a1a1aa' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.form-textarea {
    resize: vertical;
    min-height: 72px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

/* ── Buttons ───────────────────────────────────────── */

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px 20px;
    border: none;
    border-radius: var(--radius-md);
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    -webkit-appearance: none;
}
.btn svg { width: 18px; height: 18px; }

.btn-primary {
    background: linear-gradient(135deg, #0B2B3C 0%, var(--teal-primary) 100%);
    color: white;
    box-shadow: var(--shadow-sm), var(--shadow-glow);
}
.btn-primary:active {
    transform: scale(0.98);
    box-shadow: var(--shadow-sm);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-default);
}
.btn-secondary:active { background: var(--bg-surface); }

.btn-danger {
    background: linear-gradient(135deg, #EF4444, #DC2626);
    color: white;
}

.btn-success {
    background: linear-gradient(135deg, var(--teal-primary), var(--teal-bright));
    color: white;
    box-shadow: var(--shadow-sm), var(--shadow-glow);
}

.btn-sm {
    padding: 8px 14px;
    font-size: 0.8rem;
}

.btn-outline {
    background: transparent;
    color: var(--teal-bright);
    border: 1px solid var(--border-ocean);
}

/* ── Receipt Photo ─────────────────────────────────── */

.receipt-capture {
    position: relative;
    border: 2px dashed var(--border-ocean);
    border-radius: var(--radius-md);
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-fast);
}
.receipt-capture:active {
    background: rgba(0, 168, 181, 0.05);
}

.receipt-capture input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.receipt-capture svg {
    width: 28px;
    height: 28px;
    color: var(--teal-primary);
    margin-bottom: 6px;
}

.receipt-capture-text {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.receipt-preview {
    position: relative;
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: 14px;
}
.receipt-preview img {
    width: 100%;
    max-height: 200px;
    object-fit: cover;
    border-radius: var(--radius-md);
}
.receipt-preview .remove-receipt {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    background: rgba(0, 0, 0, 0.7);
    border: none;
    border-radius: var(--radius-full);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.receipt-preview .remove-receipt svg { width: 14px; height: 14px; }

/* ── Active Hours Timer ────────────────────────────── */

.timer-display {
    text-align: center;
    padding: 24px 0;
}

.timer-time {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 3.5rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 8px;
    font-variant-numeric: tabular-nums;
}

.timer-time.running { color: var(--teal-bright); }

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

.timer-controls {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}
.timer-controls .btn { flex: 1; }

.activity-select-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    margin-bottom: 16px;
}

.activity-group-label {
    grid-column: 1 / -1;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 6px 0 2px;
}
.activity-group-label:first-child { padding-top: 0; }

.activity-chip {
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-family: 'Inter', sans-serif;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: center;
}
.activity-chip.active {
    background: rgba(0, 168, 181, 0.12);
    border-color: var(--teal-primary);
    color: var(--teal-bright);
}

/* ── Mileage ───────────────────────────────────────── */

.location-inputs {
    position: relative;
    margin-bottom: 14px;
}

.location-dot {
    position: absolute;
    left: 14px;
    width: 10px;
    height: 10px;
    border-radius: var(--radius-full);
    z-index: 2;
}
.location-dot.start { top: 17px; background: var(--teal-primary); }
.location-dot.end { bottom: 17px; background: var(--coral); }

.location-line {
    position: absolute;
    left: 18px;
    top: 32px;
    bottom: 32px;
    width: 2px;
    background: var(--border-default);
    z-index: 1;
}

.location-inputs .form-input {
    padding-left: 36px;
}
.location-inputs .form-input + .form-input {
    margin-top: 8px;
}

/* Calculate Distance Button & Status */
.btn-calc {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 4px;
    margin-bottom: 4px;
}
.btn-calc svg { flex-shrink: 0; }

.distance-status {
    font-size: 0.8rem;
    padding: 0;
    max-height: 0;
    overflow: hidden;
    transition: all 0.2s ease;
    border-radius: var(--radius-sm);
    text-align: center;
}
.distance-status.show {
    padding: 8px 12px;
    max-height: 60px;
    margin-bottom: 8px;
}
.distance-status.loading { color: var(--text-muted); }
.distance-status.success { color: var(--success); background: rgba(16, 185, 129, 0.1); }
.distance-status.error { color: var(--coral); background: rgba(255, 107, 107, 0.1); }

/* Google Places Autocomplete Dark Theme */
.pac-container {
    background: var(--bg-secondary) !important;
    border: 1px solid var(--border-ocean) !important;
    border-radius: var(--radius-md) !important;
    box-shadow: var(--shadow-lg) !important;
    font-family: 'Inter', sans-serif !important;
    margin-top: 4px;
    z-index: 9999 !important;
}
.pac-item {
    background: transparent !important;
    border-top: 1px solid var(--border-subtle) !important;
    color: var(--text-primary) !important;
    padding: 10px 14px !important;
    font-size: 0.85rem !important;
    line-height: 1.4 !important;
    cursor: pointer;
}
.pac-item:first-child { border-top: none !important; }
.pac-item:hover, .pac-item-selected {
    background: rgba(0, 168, 181, 0.1) !important;
}
.pac-item-query {
    color: var(--text-primary) !important;
    font-weight: 500 !important;
    font-size: 0.85rem !important;
}
.pac-item .pac-item-query + span {
    color: var(--text-muted) !important;
    font-size: 0.8rem !important;
}
.pac-icon { display: none !important; }
.pac-matched { color: var(--teal-bright) !important; }

.round-trip-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}
.toggle-switch input { display: none; }
.toggle-track {
    position: absolute;
    inset: 0;
    background: var(--bg-surface);
    border-radius: var(--radius-full);
    border: 1px solid var(--border-default);
    transition: all var(--transition-fast);
    cursor: pointer;
}
.toggle-track::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background: var(--text-muted);
    border-radius: var(--radius-full);
    transition: all var(--transition-fast);
}
.toggle-switch input:checked + .toggle-track {
    background: rgba(0, 168, 181, 0.2);
    border-color: var(--teal-primary);
}
.toggle-switch input:checked + .toggle-track::after {
    transform: translateX(20px);
    background: var(--teal-bright);
}

/* ── Entry List ────────────────────────────────────── */

.entry-list {
    list-style: none;
}

.entry-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-subtle);
}
.entry-item:last-child { border-bottom: none; }

.entry-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    flex-shrink: 0;
}
.entry-icon.expense {
    background: rgba(255, 107, 107, 0.1);
    color: var(--coral-soft);
}
.entry-icon.mileage {
    background: rgba(0, 168, 181, 0.1);
    color: var(--teal-bright);
}
.entry-icon.hours {
    background: rgba(245, 158, 11, 0.1);
    color: var(--amber);
}
.entry-icon svg { width: 16px; height: 16px; }

.entry-details {
    flex: 1;
    min-width: 0;
}

.entry-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.entry-meta {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.entry-amount {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 0.9rem;
    font-weight: 700;
    flex-shrink: 0;
}
.entry-amount.expense { color: var(--coral-soft); }
.entry-amount.mileage { color: var(--teal-bright); }
.entry-amount.hours { color: var(--amber); }

/* ── Empty State ───────────────────────────────────── */

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}
.empty-state svg {
    width: 40px;
    height: 40px;
    color: var(--teal-primary);
    opacity: 0.4;
    margin-bottom: 12px;
}
.empty-state p {
    font-size: 0.85rem;
    line-height: 1.5;
}

/* ── Toast ─────────────────────────────────────────── */

.toast-container {
    position: fixed;
    top: calc(16px + env(safe-area-inset-top, 0));
    left: 16px;
    right: 16px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    font-size: 0.85rem;
    color: var(--text-primary);
    box-shadow: var(--shadow-lg);
    pointer-events: auto;
    animation: toastIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--coral); }

@keyframes toastIn {
    from { opacity: 0; transform: translateY(-12px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Section Header ────────────────────────────────── */

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

.section-title {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--teal-bright);
}

/* ── Progress Bar (Active Hours) ───────────────────── */

.progress-wrap {
    margin-bottom: 16px;
}

.progress-bar-bg {
    height: 8px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-top: 8px;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #0B2B3C, var(--teal-primary), var(--teal-bright));
    border-radius: var(--radius-full);
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* ── Utilities ─────────────────────────────────────── */

.hidden { display: none !important; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.8rem; }

/* ── Swipe Delete ──────────────────────────────────── */

.swipe-container {
    overflow: hidden;
    position: relative;
}

.swipe-delete {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 72px;
    background: var(--coral);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
}

/* ── Data Sync Bar ─────────────────────────────────── */

.sync-bar {
    padding: 10px 16px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.75rem;
    color: var(--text-muted);
}
.sync-bar svg { width: 14px; height: 14px; }

/* ── Year selector ─────────────────────────────────── */

.year-select {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-default);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 24px 4px 8px;
    border-radius: var(--radius-sm);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 6px center;
}
