/* =========================================
   TraceBack Alert: Universal Responsive CSS
   ========================================= */

:root {
    /* Color Palette - High Contrast Dark Mode */
    --bg-main: #09090b;
    --bg-surface: #18181b;
    --border-color: #27272a;
    
    --text-primary: #f8fafc;
    --text-secondary: #a1a1aa;
    
    --accent-red: #e11d48;
    --accent-red-hover: #f43f5e;
    --accent-green: #059669;
    --accent-green-light: #34d399;
    --accent-blue: #2563eb;
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    
    /* Fluid Spacing */
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
}

/* --- Resets & Base --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent; /* Removes blue tap flash on mobile */
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    padding: var(--space-md);
    
    /* FIX: Force vertical stacking and center the children */
    display: flex;
    flex-direction: column;
    align-items: center; 
}

/* --- Layout Container --- */
.container {
    width: 100%;
    /* Max width prevents stretching on desktop, margin centers it */
    max-width: 640px; 
    margin: 0 auto;
    padding-top: var(--space-lg);
    padding-bottom: 80px;
}

/* --- Typography --- */
header {
    margin-bottom: var(--space-lg);
}

header h1 {
    /* Fluid typography: scales dynamically between mobile and desktop */
    font-size: clamp(1.75rem, 5vw, 2.5rem);
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-bottom: 4px;
}

header p {
    color: var(--text-secondary);
    font-size: clamp(0.9rem, 2.5vw, 1.05rem);
}

/* --- Controls (Dropdowns & Tabs) --- */
.controls {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

select {
    width: 100%;
    padding: 14px;
    background-color: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    appearance: none; /* Removes default OS styling */
    outline: none;
    cursor: pointer;
    /* Custom dropdown arrow */
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23a1a1aa%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right 14px top 50%;
    background-size: 12px auto;
}

select:focus {
    border-color: var(--text-secondary);
}

.tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-surface);
    padding: 6px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    overflow-x: auto; /* Allows swiping on very narrow phones */
    scrollbar-width: none; /* Hide scrollbar Firefox */
}
.tabs::-webkit-scrollbar { display: none; } /* Hide scrollbar Chrome/Safari */

.tab-btn {
    flex: 1;
    min-width: 100px; /* Prevents squishing */
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 12px 8px; /* High touch target area */
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    text-align: center;
}

.tab-btn.active {
    background: var(--border-color);
    color: var(--text-primary);
}

#locate-btn {
    width: 100%;
    background-color: var(--accent-blue);
    color: white;
    border: none;
    padding: 14px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

#locate-btn:active {
    opacity: 0.8;
}

/* --- Data Grid & Cards --- */
#data-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.contact-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    padding: var(--space-md);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column; /* Stacked by default for mobile */
    gap: var(--space-md);
    transition: transform 0.1s ease;
}

/* Tablet & Desktop Layout Override for Cards */
@media (min-width: 500px) {
    .contact-card {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        padding: 20px var(--space-lg);
    }
    
    .card-info {
        max-width: 65%;
    }
}

.card-info h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
}

.card-details {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 6px;
}

/* --- Buttons & Badges --- */
.call-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: var(--accent-red);
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 1rem;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    width: 100%; /* Full width on mobile */
    transition: background-color 0.2s ease;
}

@media (min-width: 500px) {
    .call-btn {
        width: auto; /* Shrink to fit on tablet/desktop */
    }
}

.call-btn:hover {
    background-color: var(--accent-red-hover);
}

.status-badge {
    font-size: 0.9rem;
    font-weight: 700;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    text-align: center;
    width: 100%;
}

@media (min-width: 500px) {
    .status-badge {
        width: auto;
    }
}

.status-badge.clear {
    background-color: rgba(5, 150, 105, 0.2);
    color: var(--accent-green-light);
    border: 1px solid var(--accent-green);
}

.status-badge.avoid {
    background-color: rgba(225, 29, 72, 0.2);
    color: #fda4af;
    border: 1px solid var(--accent-red);
}

/* --- Utility States --- */
#loading, .empty-state {
    text-align: center;
    color: var(--text-secondary);
    padding: 30px 10px;
    font-style: italic;
}

footer {
    margin-top: 40px;
    text-align: center;
    border-top: 1px solid var(--border-color);
    padding-top: 24px;
}

footer p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}