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

:root {
    /* Sorcer Brand Colors */
    --primary: #F06449;
    --primary-dark: #DE4A2E;
    --primary-light: #FF8F7A;
    --secondary: #9466FF;
    --background: #FDFCFB;
    --surface: #FFFFFF;
    --surface-light: #F9F7F6;
    --text: #1F1D1B;
    --text-secondary: #5C5651;
    --border: #E8E4E1;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --mist: rgba(240, 100, 73, 0.1);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--background);
    color: var(--text);
    min-height: 100vh;
}

.app {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
    padding-top: 5rem; /* Space for fixed nav */
}

header {
    text-align: center;
    padding: 1.5rem 0;
}

header h1 {
    font-family: 'DM Sans', sans-serif;
    font-size: 1.75rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text);
}

header h1 span {
    background: linear-gradient(135deg, #F06449, #9466FF);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline {
    font-family: 'Inter', sans-serif;
    color: var(--text-secondary);
    margin-top: 0.25rem;
    font-size: 0.875rem;
    font-weight: 400;
}

.location-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--surface);
    padding: 0.75rem 1rem;
    border-radius: 12px;
    margin-bottom: 1rem;
    border: 1px solid var(--border);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.03);
}

.location-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#location-status {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.btn {
    font-family: 'DM Sans', sans-serif;
    background: var(--surface);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    padding: 0.5rem 0.875rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.375rem;
    transition: all 0.2s ease;
}

.btn:hover:not(:disabled) {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(240, 100, 73, 0.25);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn .icon {
    font-size: 1.1rem;
}

.main-content {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 768px) {
    .main-content {
        grid-template-columns: 1fr 400px;
    }
}

#map-container {
    background: var(--surface);
    border-radius: 12px;
    overflow: hidden;
    min-height: 400px;
    border: 1px solid var(--border);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

#map {
    width: 100%;
    height: 400px;
}

@media (min-width: 768px) {
    #map {
        height: 600px;
    }
}

.planes-section {
    background: var(--surface);
    border-radius: 12px;
    padding: 1rem;
    max-height: 600px;
    overflow-y: auto;
    border: 1px solid var(--border);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.section-header h2 {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.875rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.badge {
    font-family: 'DM Sans', sans-serif;
    background: var(--primary);
    color: white;
    padding: 0.25rem 0.6rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.planes-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.loading-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem;
    color: var(--text-secondary);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

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

.plane-card {
    background: var(--surface-light);
    border-radius: 10px;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid var(--border);
}

.plane-card:hover {
    transform: translateY(-2px);
    border-color: var(--primary);
    box-shadow: 0 8px 16px rgba(240, 100, 73, 0.15);
}

.plane-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}

.callsign {
    font-family: 'DM Sans', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
}

.country {
    font-size: 0.8rem;
    color: var(--text-secondary);
    background: var(--surface);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    border: 1px solid var(--border);
}

.plane-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

.stat {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-family: 'Inter', sans-serif;
    font-size: 0.65rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-weight: 500;
}

.stat-value {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
}

.stat-value.altitude {
    color: var(--secondary);
}

.stat-value.speed {
    color: var(--success);
}

.stat-value.heading {
    color: var(--warning);
}

.stat-value.distance {
    color: var(--primary);
}

.no-planes {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

.no-planes p {
    margin-bottom: 0.5rem;
}

/* Modal styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(31, 29, 27, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--surface);
    border-radius: 16px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    border: 1px solid var(--border);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: var(--surface-light);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 1.5rem;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
    transition: all 0.3s ease;
}

.modal-close:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

#modal-body {
    padding: 1.5rem;
}

.detail-header {
    text-align: center;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1rem;
}

.detail-callsign {
    font-family: 'DM Sans', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
}

.detail-icao {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-family: monospace;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.detail-item {
    background: var(--surface-light);
    padding: 1rem;
    border-radius: 10px;
    border: 1px solid var(--border);
}

.detail-item.full-width {
    grid-column: 1 / -1;
}

.detail-label {
    font-family: 'Inter', sans-serif;
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.detail-value {
    font-family: 'DM Sans', sans-serif;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text);
}

.heading-indicator {
    display: inline-block;
    margin-left: 0.5rem;
    transition: transform 0.3s;
}

/* Plane icon for map */
.plane-icon {
    font-size: 24px;
    color: var(--primary);
}

/* Custom Leaflet styles */
.leaflet-popup-content-wrapper {
    background: var(--surface);
    color: var(--text);
    border-radius: 10px;
    border: 1px solid var(--border);
}

.leaflet-popup-tip {
    background: var(--surface);
}

.leaflet-popup-content {
    margin: 0.75rem;
}

.popup-content h3 {
    font-family: 'DM Sans', sans-serif;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.popup-content p {
    margin: 0.25rem 0;
    font-size: 0.9rem;
    color: var(--text);
}

/* User location marker */
.user-marker {
    background: var(--primary);
    border: 3px solid white;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    box-shadow: 0 0 10px rgba(240, 100, 73, 0.5);
}

.user-marker-pulse {
    position: absolute;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(240, 100, 73, 0.3);
    animation: pulse 2s ease-out infinite;
    top: -12px;
    left: -12px;
}

@keyframes pulse {
    0% {
        transform: scale(0.5);
        opacity: 1;
    }
    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

/* Error state */
.error-message {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--error);
    border-radius: 10px;
    padding: 1rem;
    text-align: center;
    color: var(--error);
}

/* Scrollbar styling */
.planes-section::-webkit-scrollbar {
    width: 6px;
}

.planes-section::-webkit-scrollbar-track {
    background: var(--background);
}

.planes-section::-webkit-scrollbar-thumb {
    background: rgba(232, 165, 152, 0.3);
    border-radius: 3px;
}

.planes-section::-webkit-scrollbar-thumb:hover {
    background: rgba(232, 165, 152, 0.5);
}

/* Route info styles */
.route-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.airline-badge {
    background: linear-gradient(135deg, #F06449, #9466FF);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.private-badge {
    background: var(--text-secondary);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.route-arrow {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.destination {
    color: var(--success);
    font-weight: 600;
    font-size: 0.9rem;
}

.detail-route {
    margin-top: 0.5rem;
}

/* Follow button styles */
.plane-actions {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.follow-btn {
    width: 100%;
    background: var(--surface);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.follow-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.follow-btn.active {
    background: var(--warning);
    border-color: var(--warning);
    color: var(--text);
}

.follow-plane-btn {
    width: 100%;
    background: var(--surface);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.follow-plane-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    box-shadow: 0 8px 24px rgba(240, 100, 73, 0.35);
}

/* Following state */
.plane-card.following {
    border-color: var(--warning);
    box-shadow: 0 0 20px rgba(245, 158, 11, 0.2);
}

/* Plane marker wrapper */
.plane-icon-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
    transition: transform 0.1s ease-out;
}

.plane-marker {
    z-index: 500;
}

/* Improve popup styles */
.leaflet-popup-content-wrapper {
    background: var(--surface) !important;
    color: var(--text) !important;
    border-radius: 10px !important;
    border: 1px solid var(--border) !important;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1) !important;
}

.leaflet-popup-tip {
    background: var(--surface) !important;
}

.leaflet-popup-close-button {
    color: var(--text-secondary) !important;
}

.leaflet-popup-close-button:hover {
    color: var(--primary) !important;
}

/* Map controls styling */
.leaflet-control-zoom a {
    background: var(--surface) !important;
    color: var(--text) !important;
    border-color: var(--border) !important;
}

.leaflet-control-zoom a:hover {
    background: var(--surface-light) !important;
    color: var(--primary) !important;
}

.leaflet-control-attribution {
    background: rgba(253, 252, 251, 0.9) !important;
    color: var(--text-secondary) !important;
}

.leaflet-control-attribution a {
    color: var(--primary) !important;
}

/* Selection */
::selection {
    background: var(--primary);
    color: var(--background);
}
