/* Unsafe Saskatoon - Dark Theme Styles */

:root {
    /* Colors */
    --bg-primary: #0d0d0d;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #262626;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --accent-red: #e74c3c;
    --accent-red-dark: #c0392b;
    --accent-orange: #f39c12;
    --accent-green: #27ae60;
    --accent-blue: #3498db;
    --border-color: #333;

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 25px rgba(231, 76, 60, 0.25);

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.4s ease;

    /* Border radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

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

/* Animation classes */
.animate-fade-in {
    animation: fadeIn 0.6s ease forwards;
}

.animate-fade-in-up {
    animation: fadeInUp 0.6s ease forwards;
}

.animate-delay-1 { animation-delay: 0.1s; }
.animate-delay-2 { animation-delay: 0.2s; }
.animate-delay-3 { animation-delay: 0.3s; }
.animate-delay-4 { animation-delay: 0.4s; }

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
        Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.7;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Navigation */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 30px;
    background: rgba(26, 26, 26, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand a {
    color: var(--accent-red);
    text-decoration: none;
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    transition: var(--transition-fast);
}

.nav-brand a:hover {
    text-shadow: 0 0 20px rgba(231, 76, 60, 0.5);
}

/* Navbar Search */
.nav-search {
    display: flex;
    align-items: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    overflow: hidden;
    transition: var(--transition-fast);
}

.nav-search:focus-within {
    border-color: var(--accent-red);
    box-shadow: 0 0 0 2px rgba(231, 76, 60, 0.2);
}

.nav-search input {
    background: transparent;
    border: none;
    color: var(--text-primary);
    padding: 8px 12px;
    font-size: 0.9rem;
    width: 200px;
    outline: none;
}

.nav-search input::placeholder {
    color: var(--text-secondary);
}

.nav-search {
    position: relative;
}

.search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    max-height: 300px;
    overflow-y: auto;
    z-index: 200;
    display: none;
}

.search-dropdown.visible {
    display: block;
}

.search-dropdown-item {
    padding: 10px 12px;
    cursor: pointer;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--border-color);
    transition: var(--transition-fast);
}

.search-dropdown-item:last-child {
    border-bottom: none;
}

.search-dropdown-item:hover,
.search-dropdown-item.selected {
    background: var(--bg-tertiary);
}

.search-dropdown-item strong {
    display: block;
    color: var(--text-primary);
}

.search-dropdown-item span {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.search-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 8px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

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

.nav-links {
    display: flex;
    gap: 25px;
}

.nav-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    transition: var(--transition-fast);
    position: relative;
    padding-bottom: 4px;
}

.nav-links a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--accent-red);
    transition: width var(--transition-normal);
}

.nav-links a:hover::after,
.nav-links a.active::after {
    width: 100%;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--text-primary);
}

/* Hero Section */
.hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 65vh;
    padding: 80px 20px;
    text-align: center;
    background: linear-gradient(180deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(231, 76, 60, 0.08) 0%, transparent 70%);
    pointer-events: none;
}

.hero h1 {
    font-size: 3.5rem;
    font-weight: 800;
    margin-bottom: 15px;
    letter-spacing: -1.5px;
    animation: fadeInUp 0.8s ease forwards;
}

.hero-subtitle {
    font-size: 1.3rem;
    color: var(--text-secondary);
    margin-bottom: 45px;
    opacity: 0;
    animation: fadeInUp 0.8s ease 0.15s forwards;
}

.hero-stats {
    display: flex;
    gap: 60px;
    margin-bottom: 45px;
    opacity: 0;
    animation: fadeInUp 0.8s ease 0.3s forwards;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 30px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: var(--transition-normal);
}

.stat:hover {
    background: rgba(255, 255, 255, 0.06);
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.stat-value {
    font-size: 2.8rem;
    font-weight: 700;
    color: var(--accent-red);
    letter-spacing: -1px;
}

.stat-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 8px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.hero-buttons {
    display: flex;
    gap: 15px;
    opacity: 0;
    animation: fadeInUp 0.8s ease 0.45s forwards;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 12px 28px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.2s;
    cursor: pointer;
    border: none;
}

.btn-primary {
    background: var(--accent-red);
    color: white;
}

.btn-primary:hover {
    background: #c0392b;
    transform: translateY(-1px);
}

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

.btn-secondary:hover {
    background: var(--border-color);
}

.btn-small {
    padding: 6px 14px;
    font-size: 0.85rem;
}

/* Danger Callout - Hero Section */
.danger-callout {
    background: linear-gradient(135deg, rgba(231, 76, 60, 0.2) 0%, rgba(192, 57, 43, 0.15) 100%);
    border: 2px solid rgba(231, 76, 60, 0.5);
    border-radius: var(--radius-lg);
    padding: 35px 50px;
    text-align: center;
    max-width: 550px;
    width: 100%;
    margin: 0 auto 40px;
    position: relative;
    box-shadow: 0 0 40px rgba(231, 76, 60, 0.3), inset 0 0 60px rgba(231, 76, 60, 0.05);
    animation: fadeInUp 0.8s ease 0.2s forwards, pulseGlow 3s ease-in-out 1s infinite;
    opacity: 0;
}

@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 0 40px rgba(231, 76, 60, 0.3), inset 0 0 60px rgba(231, 76, 60, 0.05); }
    50% { box-shadow: 0 0 60px rgba(231, 76, 60, 0.5), inset 0 0 80px rgba(231, 76, 60, 0.08); }
}

.danger-badge {
    position: absolute;
    top: -14px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent-red);
    color: white;
    font-size: 0.75rem;
    font-weight: 800;
    padding: 6px 18px;
    border-radius: 20px;
    letter-spacing: 2px;
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.4);
}

.danger-label {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 10px;
}

.danger-block-name {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--accent-red);
    margin-bottom: 5px;
    letter-spacing: -0.5px;
    text-shadow: 0 0 30px rgba(231, 76, 60, 0.3);
}

.danger-neighbourhood {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 15px;
}

.danger-crimes {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
}

.danger-crimes-value {
    font-size: 3rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -1px;
}

.danger-crimes-label {
    font-size: 1rem;
    color: var(--text-secondary);
}

.btn-danger {
    background: var(--accent-red);
    color: white;
    padding: 12px 30px;
    font-weight: 700;
    box-shadow: 0 4px 20px rgba(231, 76, 60, 0.4);
    transition: all 0.2s;
}

.btn-danger:hover {
    background: #c0392b;
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(231, 76, 60, 0.5);
}

/* Preview Section */
.preview-section {
    padding: 60px 20px;
    max-width: 800px;
    margin: 0 auto;
}

.preview-section h2 {
    text-align: center;
    margin-bottom: 30px;
    font-size: 1.8rem;
}

.preview-list {
    background: var(--bg-secondary);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.preview-item {
    display: flex;
    align-items: center;
    padding: 18px 25px;
    border-bottom: 1px solid var(--border-color);
}

.preview-item:last-child {
    border-bottom: none;
}

.preview-rank {
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--accent-red);
    width: 50px;
}

.preview-name {
    flex: 1;
    font-weight: 500;
}

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

.see-all {
    display: block;
    text-align: center;
    margin-top: 20px;
    color: var(--accent-blue);
    text-decoration: none;
}

.see-all:hover {
    text-decoration: underline;
}

/* Rankings Page */
.rankings-page {
    padding: 40px 20px;
    max-width: 1200px;
    margin: 0 auto;
}

.page-header {
    text-align: center;
    margin-bottom: 40px;
}

.page-header h1 {
    font-size: 2.2rem;
    margin-bottom: 10px;
}

.page-header p {
    color: var(--text-secondary);
}

.filters {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 20px;
}

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

.filters select {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    border-radius: 4px;
    margin: 0 8px;
    cursor: pointer;
}

/* Rankings Table */
.rankings-table-container {
    overflow-x: auto;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}

.rankings-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.rankings-table th,
.rankings-table td {
    padding: 16px 20px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    transition: var(--transition-fast);
}

.rankings-table th {
    background: var(--bg-tertiary);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

.rankings-table tbody tr {
    transition: var(--transition-fast);
}

.rankings-table tbody tr:hover {
    background: var(--bg-tertiary);
}

.rankings-table tbody tr.high-risk {
    border-left: 3px solid var(--accent-red);
}

.rankings-table tbody tr.medium-risk {
    border-left: 3px solid var(--accent-orange);
}

.rankings-table tbody tr.low-risk {
    border-left: 3px solid var(--accent-green);
}

.rankings-table tbody tr.high-risk .rank-badge {
    background: var(--accent-red);
}

.rankings-table tbody tr.medium-risk .rank-badge {
    background: var(--accent-orange);
    color: #000;
}

.rankings-table tbody tr.low-risk .rank-badge {
    background: var(--accent-green);
}

.rank-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 4px;
    font-weight: bold;
    font-size: 0.9rem;
    color: white;
    background: var(--bg-tertiary);
}

.name-cell strong {
    display: block;
}

.zone-code {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.crime-count {
    font-weight: bold;
    font-size: 1.1rem;
}

.crimes-cell {
    font-size: 0.85rem;
    color: var(--text-secondary);
    max-width: 300px;
}

/* Footer */
.footer {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    border-top: 1px solid var(--border-color);
    margin-top: 40px;
}

.footer p {
    margin: 5px 0;
}

/* Loading & Error States */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

.loading-spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 3px solid var(--bg-tertiary);
    border-top-color: var(--accent-red);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.error {
    text-align: center;
    padding: 40px;
    color: var(--accent-red);
    background: rgba(231, 76, 60, 0.1);
    border-radius: var(--radius-md);
    border: 1px solid rgba(231, 76, 60, 0.3);
}

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-tertiary) 25%,
        var(--bg-secondary) 50%,
        var(--bg-tertiary) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

.skeleton-text {
    height: 16px;
    margin-bottom: 8px;
}

.skeleton-text.short {
    width: 60%;
}

.skeleton-stat {
    height: 48px;
    width: 80px;
}

.skeleton-row {
    height: 60px;
    margin-bottom: 4px;
}

/* Map loading overlay */
.map-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(13, 13, 13, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: opacity var(--transition-normal);
}

.map-loading.hidden {
    opacity: 0;
    pointer-events: none;
}

.map-loading-text {
    margin-top: 16px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Search Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition-normal);
}

.modal-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 30px;
    max-width: 500px;
    width: 90%;
    position: relative;
    transform: translateY(20px);
    transition: var(--transition-normal);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
}

.modal-overlay.visible .modal-content {
    transform: translateY(0);
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.8rem;
    cursor: pointer;
    line-height: 1;
    transition: var(--transition-fast);
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-disclaimer {
    background: rgba(243, 156, 18, 0.15);
    border: 1px solid rgba(243, 156, 18, 0.4);
    border-radius: var(--radius-md);
    padding: 15px;
    margin-bottom: 20px;
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.disclaimer-icon {
    background: var(--accent-orange);
    color: #000;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.disclaimer-text {
    font-size: 0.85rem;
    color: var(--text-primary);
    line-height: 1.5;
}

.modal-content h2 {
    font-size: 1.5rem;
    margin-bottom: 5px;
}

.modal-address {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 20px;
}

.modal-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

.modal-stat {
    text-align: center;
    padding: 15px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
}

.modal-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-red);
    display: block;
}

.modal-stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 5px;
    display: block;
}

.modal-percentile {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 20px;
}

.modal-action {
    width: 100%;
}

.modal-error {
    text-align: center;
    padding: 30px;
}

.modal-error-icon {
    font-size: 3rem;
    margin-bottom: 15px;
}

.modal-error h2 {
    margin-bottom: 10px;
}

.modal-error p {
    color: var(--text-secondary);
}

/* Risk badge in modal */
.modal-content .risk-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: bold;
    text-transform: uppercase;
}

.risk-badge.high {
    background: var(--accent-red);
    color: white;
}

.risk-badge.medium {
    background: var(--accent-orange);
    color: #000;
}

.risk-badge.low {
    background: var(--accent-green);
    color: white;
}

/* Responsive */
@media (max-width: 768px) {
    .navbar {
        padding: 12px 15px;
        flex-wrap: wrap;
        gap: 10px;
    }

    .nav-brand a {
        font-size: 1.2rem;
    }

    .nav-links {
        gap: 15px;
    }

    .nav-search {
        order: 3;
        width: 100%;
        margin-top: 5px;
        border-radius: var(--radius-md);
    }

    .nav-search input {
        width: 100%;
        flex: 1;
        min-width: 0;
        padding: 12px 15px;
        font-size: 1rem;
    }

    .nav-search .search-btn {
        padding: 12px 15px;
    }

    .search-dropdown {
        position: fixed;
        top: auto;
        left: 15px;
        right: 15px;
        margin-top: 5px;
        border-radius: var(--radius-md);
    }

    .modal-stats {
        grid-template-columns: 1fr;
    }

    .hero h1 {
        font-size: 2.2rem;
    }

    .hero-subtitle {
        font-size: 1rem;
    }

    .danger-callout {
        padding: 25px 15px;
        max-width: 100%;
        margin: 0 15px 30px;
        opacity: 1 !important;
        animation: pulseGlow 3s ease-in-out infinite;
    }

    .danger-badge {
        font-size: 0.65rem;
        padding: 5px 12px;
        letter-spacing: 1px;
    }

    .danger-label {
        font-size: 0.75rem;
        letter-spacing: 1px;
    }

    .danger-block-name {
        font-size: 1.4rem;
        line-height: 1.2;
    }

    .danger-neighbourhood {
        font-size: 0.95rem;
    }

    .danger-crimes {
        flex-direction: column;
        gap: 2px;
    }

    .danger-crimes-value {
        font-size: 2.5rem;
    }

    .danger-crimes-label {
        font-size: 0.85rem;
    }

    .btn-danger {
        padding: 10px 24px;
        font-size: 0.9rem;
    }

    .hero-stats {
        flex-direction: column;
        gap: 25px;
    }

    .stat-value {
        font-size: 2rem;
    }

    .hero-buttons {
        flex-direction: column;
        width: 100%;
        max-width: 300px;
    }

    .btn {
        width: 100%;
        text-align: center;
    }

    .rankings-table th,
    .rankings-table td {
        padding: 12px 10px;
        font-size: 0.85rem;
    }

    .crimes-cell {
        display: none;
    }

    .filters {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .navbar {
        padding: 10px 12px;
    }

    .nav-search input {
        padding: 10px 12px;
        font-size: 0.95rem;
    }

    .nav-search .search-btn {
        padding: 10px 12px;
    }

    .hero h1 {
        font-size: 1.8rem;
    }

    .hero-subtitle {
        font-size: 0.9rem;
        margin-bottom: 30px;
    }

    .danger-callout {
        padding: 20px 12px;
        margin: 0 10px 25px;
        opacity: 1 !important;
    }

    .danger-block-name {
        font-size: 1.2rem;
    }

    .danger-crimes-value {
        font-size: 2rem;
    }

    .preview-item {
        flex-wrap: wrap;
    }

    .preview-name {
        width: 100%;
        order: 1;
    }

    .preview-rank {
        order: 0;
    }

    .preview-count {
        order: 2;
        width: 100%;
        margin-top: 5px;
    }
}
