/* ===========================================
   DESIGN TOKENS & RESET
   =========================================== */
:root {
    --clr-primary: #2563eb;
    --clr-primary-hover: #1d4ed8;
    --clr-primary-light: #eff6ff;
    --clr-accent: #059669;
    --clr-danger: #dc2626;
    --clr-warn-bg: #fef9c3;
    --clr-warn-border: #fbbf24;
    --clr-warn-text: #92400e;

    --clr-bg: #f1f5f9;
    --clr-surface: #ffffff;
    --clr-border: #e2e8f0;

    --clr-text-heading: #0f172a;
    --clr-text-body: #334155;
    --clr-text-muted: #64748b;

    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 20px;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, .08), 0 1px 2px rgba(0, 0, 0, .06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, .08), 0 2px 4px rgba(0, 0, 0, .05);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, .10), 0 4px 8px rgba(0, 0, 0, .06);

    --font: 'Inter', system-ui, sans-serif;
    --transition: 0.2s ease;
}

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

body {
    font-family: var(--font);
    background-color: var(--clr-bg);
    color: var(--clr-text-body);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.6;
}

/* ===========================================
   LAYOUT
   =========================================== */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
}

.main-layout {
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 28px;
    padding-top: 32px;
    padding-bottom: 40px;
    flex: 1;
    align-items: start;
}

/* ===========================================
   HEADER
   =========================================== */
.app-header {
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
    color: white;
    padding: 24px 0;
    box-shadow: var(--shadow-md);
}

.brand {
    display: flex;
    align-items: center;
    gap: 16px;
}

.brand-icon {
    font-size: 2.5rem;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .2));
}

.brand h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.brand p {
    font-size: 0.88rem;
    opacity: 0.85;
    margin-top: 2px;
}

/* ===========================================
   PANELS
   =========================================== */
.panel {
    background: var(--clr-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 28px;
}

.panel__title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--clr-text-heading);
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--clr-border);
}

/* ===========================================
   FORM
   =========================================== */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--clr-text-heading);
    margin-bottom: 8px;
}

.label-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.label-dot--green {
    background: #16a34a;
    box-shadow: 0 0 0 3px #bbf7d0;
}

.label-dot--red {
    background: #dc2626;
    box-shadow: 0 0 0 3px #fecaca;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid var(--clr-border);
    border-radius: var(--radius-md);
    font-family: var(--font);
    font-size: 0.95rem;
    color: var(--clr-text-body);
    background: #fafafa;
    transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
    outline: none;
}

.form-input:focus {
    border-color: var(--clr-primary);
    background: white;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.form-input::placeholder {
    color: #94a3b8;
}

.form-input.input--error {
    border-color: var(--clr-danger);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12);
}

.form-error {
    display: block;
    font-size: 0.8rem;
    color: var(--clr-danger);
    margin-top: 5px;
    min-height: 18px;
}

/* Transport Options */
.transport-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.transport-option {
    cursor: pointer;
}

.transport-option input[type="radio"] {
    display: none;
}

.transport-card {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 12px;
    border: 1.5px solid var(--clr-border);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--clr-text-muted);
    background: #fafafa;
    transition: all var(--transition);
    text-align: center;
}

.transport-option:hover .transport-card {
    border-color: var(--clr-primary);
    color: var(--clr-primary);
    background: var(--clr-primary-light);
}

.transport-option input[type="radio"]:checked+.transport-card {
    border-color: var(--clr-primary);
    background: var(--clr-primary-light);
    color: var(--clr-primary);
    font-weight: 600;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

/* ===========================================
   BUTTONS
   =========================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 13px 24px;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    outline: none;
}

.btn--primary {
    background: var(--clr-primary);
    color: white;
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.3);
}

.btn--primary:hover:not(:disabled) {
    background: var(--clr-primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.4);
}

.btn--primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn--primary:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none;
}

.btn--full {
    width: 100%;
    margin-top: 8px;
}

/* Spinner inside button */
.btn-spinner {
    width: 18px;
    height: 18px;
    border: 2.5px solid rgba(255, 255, 255, 0.4);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

/* ===========================================
   ALERTS
   =========================================== */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 14px 16px;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    margin-top: 18px;
}

.alert-icon {
    font-size: 1rem;
    flex-shrink: 0;
    margin-top: 1px;
}

.alert--error {
    background: #fee2e2;
    border: 1px solid #fca5a5;
    color: #991b1b;
}

.alert--warn {
    background: var(--clr-warn-bg);
    border: 1px solid var(--clr-warn-border);
    color: var(--clr-warn-text);
}

/* ===========================================
   STATE CONTAINERS (empty, loading)
   =========================================== */
.state-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 48px 24px;
    gap: 14px;
}

.empty-illustration {
    font-size: 5rem;
    line-height: 1;
    filter: grayscale(0.3);
}

.state-container h3 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--clr-text-heading);
}

.state-container p {
    color: var(--clr-text-muted);
    font-size: 0.95rem;
    max-width: 340px;
}

/* Loading ring */
.loader-ring {
    width: 56px;
    height: 56px;
    border: 5px solid var(--clr-border);
    border-top-color: var(--clr-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-text {
    color: var(--clr-text-muted);
    font-size: 0.95rem;
    font-style: italic;
}

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

/* ===========================================
   RESULTS
   =========================================== */
.results-header {
    margin-bottom: 20px;
}

.route-summary {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.location-tag {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.88rem;
    font-weight: 600;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.location-tag--origin {
    background: #dcfce7;
    color: #15803d;
    border: 1px solid #86efac;
}

.location-tag--destination {
    background: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fca5a5;
}

.route-arrow {
    color: var(--clr-text-muted);
    font-size: 1.2rem;
    font-weight: 700;
}

/* Primary Route Card */
.result-card {
    border-radius: var(--radius-md);
    padding: 24px;
    margin-bottom: 20px;
    position: relative;
    overflow: hidden;
}

.result-card--primary {
    background: linear-gradient(135deg, #1e3a8a, #2563eb);
    color: white;
    box-shadow: var(--shadow-lg);
}

.card-badge {
    display: inline-block;
    padding: 3px 10px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    margin-bottom: 12px;
}

.card-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 18px;
    line-height: 1.3;
}

.card-metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 16px;
}

.metric {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.metric-icon {
    font-size: 1.4rem;
}

.metric-label {
    display: block;
    font-size: 0.72rem;
    opacity: 0.75;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 500;
}

.metric-value {
    display: block;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.2;
    margin-top: 2px;
}

.card-description {
    font-size: 0.9rem;
    opacity: 0.85;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    padding-top: 14px;
    line-height: 1.7;
}

/* Alternatives */
.section-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--clr-text-heading);
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-title::before {
    content: '';
    display: inline-block;
    width: 3px;
    height: 18px;
    background: var(--clr-primary);
    border-radius: 2px;
}

.alternatives-grid {
    display: grid;
    gap: 12px;
    margin-bottom: 20px;
}

.alt-card {
    background: var(--clr-surface);
    border: 1.5px solid var(--clr-border);
    border-radius: var(--radius-md);
    padding: 18px 20px;
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 12px;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.alt-card:hover {
    border-color: var(--clr-primary);
    box-shadow: var(--shadow-sm);
}

.alt-card-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--clr-text-heading);
    margin-bottom: 4px;
}

.alt-card-desc {
    font-size: 0.82rem;
    color: var(--clr-text-muted);
}

.alt-card-meta {
    text-align: right;
    flex-shrink: 0;
}

.alt-card-distance {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--clr-primary);
    display: block;
}

.alt-card-time {
    font-size: 0.8rem;
    color: var(--clr-text-muted);
}

/* Tips Card */
.tips-card {
    background: #f0fdf4;
    border: 1.5px solid #86efac;
    border-radius: var(--radius-md);
    padding: 20px 22px;
}

.tips-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #15803d;
    margin-bottom: 12px;
}

.tips-card ul {
    padding-left: 18px;
}

.tips-card li {
    font-size: 0.88rem;
    color: #166534;
    margin-bottom: 6px;
    line-height: 1.5;
}

.tips-card p {
    font-size: 0.88rem;
    color: #166534;
    line-height: 1.6;
}

/* ===========================================
   FOOTER
   =========================================== */
.app-footer {
    background: var(--clr-surface);
    border-top: 1px solid var(--clr-border);
    padding: 16px 0;
    text-align: center;
}

.app-footer p {
    font-size: 0.8rem;
    color: var(--clr-text-muted);
}

/* ===========================================
   UTILITY
   =========================================== */
.hidden {
    display: none !important;
}

/* ===========================================
   RESPONSIVE
   =========================================== */
@media (max-width: 768px) {
    .main-layout {
        grid-template-columns: 1fr;
        padding-top: 20px;
    }

    .card-metrics {
        grid-template-columns: 1fr 1fr;
    }

    .brand h1 {
        font-size: 1.25rem;
    }
}

@media (max-width: 480px) {
    .card-metrics {
        grid-template-columns: 1fr;
    }

    .alt-card {
        grid-template-columns: 1fr;
    }

    .alt-card-meta {
        text-align: left;
    }
}