/* ═══════════════════════════════════════════════════════════════════════════
   REDESIGN.CSS - Trip Cost Calculator Styles
   Performance optimized with critical CSS first
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Critical: Above-the-fold styles ── */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ── Dark/Light Mode Base ── */
.dark {
    color-scheme: dark;
}

body {
    font-family: "Noto Sans", system-ui, -apple-system, sans-serif;
    margin: 0;
    line-height: 1.5;
    background: #f6f7f8;
    color: #1f2937;
}

.dark body {
    background: #101822;
    color: #e2e8f0;
}

h1, h2, h3, h4, h5, h6, .font-display {
    font-family: "Space Grotesk", system-ui, sans-serif;
}

/* ── Critical Color Classes (fallback before Tailwind loads) ── */
.bg-primary { background-color: #136dec; }
.bg-success { background-color: #22c55e; }
.bg-secondary { background-color: #FF5722; }
.text-primary { color: #136dec; }
.text-success { color: #22c55e; }
.text-secondary { color: #FF5722; }
.text-white { color: #fff; }
.border-primary { border-color: #136dec; }
.border-success { border-color: #22c55e; }

/* ── Material Icons ── */
.material-icons-outlined {
    font-family: 'Material Icons Outlined', sans-serif;
    font-weight: normal;
    font-style: normal;
    font-size: 24px;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    display: inline-block;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    -webkit-font-smoothing: antialiased;
    font-feature-settings: 'liga';
}

/* ── Performance: GPU acceleration for animations ── */
.gpu-accelerated {
    transform: translateZ(0);
    will-change: transform;
    backface-visibility: hidden;
}

/* ── Custom Scrollbar ── */
::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

::-webkit-scrollbar-track {
    background: #101822;
}

::-webkit-scrollbar-thumb {
    background: #233348;
    border-radius: 2px;
}

/* Light mode scrollbar */
html:not(.dark) ::-webkit-scrollbar-track {
    background: #f1f5f9;
}

html:not(.dark) ::-webkit-scrollbar-thumb {
    background: #cbd5e1;
}

/* ── Autocomplete Suggestions ── */
.suggestion-item {
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.15s;
}

.suggestion-item:hover,
.suggestion-item.active {
    background: rgba(19, 109, 236, 0.15);
}

/* ── Map Containers ── */
#mapDesktop,
#mapMobile {
    width: 100%;
    height: 100%;
}

/* ── Animations ── */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.animate-fade-in {
    animation: fadeIn 0.3s ease-out;
}

.animate-slide-up {
    animation: slideUp 0.3s ease-out;
}

.animate-pulse {
    animation: pulse 2s infinite;
}

.animate-spin {
    animation: spin 1s linear infinite;
}

/* ── Modal Styles ── */
.modal-backdrop {
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

/* ── Map Legend ── */
.map-legend {
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* ── Button Transitions ── */
button {
    transition: all 0.2s ease;
}

/* ── Input Focus States ── */
input:focus {
    outline: none;
}

/* ── Route Card Selection ── */
.route-card-selected {
    box-shadow: 0 0 0 2px rgba(19, 109, 236, 0.5);
}

/* ── Stop Point Remove Button ── */
.stop-remove-btn {
    opacity: 0.6;
    transition: opacity 0.2s;
}

.stop-remove-btn:hover {
    opacity: 1;
}

/* ── Tooltip ── */
.tooltip {
    position: relative;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 4px 8px;
    background: #1e293b;
    color: white;
    font-size: 12px;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.tooltip:hover::after {
    opacity: 1;
}

/* ── Mobile Bottom Sheet ── */
@media (max-width: 1023px) {
    .bottom-sheet {
        border-top-left-radius: 1rem;
        border-top-right-radius: 1rem;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    }
}

/* ── Print Styles ── */
@media print {
    .no-print {
        display: none !important;
    }

    body {
        background: white !important;
    }
}

/* ── Loading State ── */
.loading-overlay {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

/* ── Number Counter Animation ── */
.count-up {
    transition: all 0.3s ease-out;
}

/* ── Route Line Colors ── */
.route-line-fastest {
    stroke: #136dec;
}

.route-line-cheapest {
    stroke: #22c55e;
}

.route-line-toll {
    stroke: #f59e0b;
}

.route-line-vignette {
    stroke: #9333ea;
}

/* ── Performance: Reduce paint areas ── */
.contain-layout {
    contain: layout;
}

.contain-paint {
    contain: paint;
}

.contain-strict {
    contain: strict;
}

/* ── Performance: Optimize images ── */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ── Reduced Motion ── */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ── Focus Visible ── */
:focus-visible {
    outline: 2px solid #136dec;
    outline-offset: 2px;
}

:focus:not(:focus-visible) {
    outline: none;
}

/* ── Touch Optimization ── */
@media (pointer: coarse) {
    button,
    a,
    input,
    select {
        min-height: 44px;
    }
}

/* ── High Contrast Mode ── */
@media (prefers-contrast: high) {
    .dark button,
    .dark a {
        border: 1px solid currentColor;
    }
}

/* ── Safe Area Insets for notched devices ── */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .safe-area-bottom {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

