@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    /* Color Palette - Midnight Premium */
    --bg-dark: #0f172a;
    --bg-card: rgba(30, 41, 59, 0.7);
    --bg-header: rgba(15, 23, 42, 0.8);

    --primary: #6366f1;
    /* Indigo */
    --primary-glow: rgba(99, 102, 241, 0.3);
    --secondary: #06b6d4;
    /* Cyan */
    --accent: #f43f5e;
    /* Rose */

    --text-main: #f1f5f9;
    --text-muted: #94a3b8;

    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --glass-blur: 12px;

    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: 'Outfit', sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--bg-dark);
    background-image:
        radial-gradient(circle at 0% 0%, rgba(99, 102, 241, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 100% 100%, rgba(6, 182, 212, 0.15) 0%, transparent 50%);
    background-attachment: fixed;
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
}

/* Glassmorphism Classes */
.glass {
    background: var(--bg-card);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    border-radius: 16px;
    transition: var(--transition);
}

.glass:hover {
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.5);
}

/* Header & Nav */
header {
    background: var(--bg-header);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--glass-border);
    padding: 1.25rem 0;
    margin-bottom: 3rem;
    position: sticky;
    top: 0;
    z-index: 1000;
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    margin: 0;
    font-size: 1.75rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.02em;
}

nav {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

nav a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 10px;
    transition: var(--transition);
}

nav a:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
}

nav a.active {
    color: #fff;
    background: var(--primary);
    box-shadow: 0 0 20px var(--primary-glow);
}

.site-selector {
    display: flex;
    gap: 0.75rem;
}

select,
input[type="date"] {
    background: rgba(15, 23, 42, 0.6);
    color: var(--text-main);
    border: 1px solid var(--glass-border);
    padding: 0.6rem 1rem;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
}

select:focus,
input[type="date"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.btn-logout {
    color: var(--accent) !important;
    font-weight: 600;
}

/* Dashboard Content */
main {
    padding-bottom: 5rem;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
}

.metric-card {
    text-align: left;
    padding: 2rem;
}

.metric-card h3 {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 600;
}

.metric-card .value {
    font-size: 2.5rem;
    font-weight: 700;
    margin: 0.75rem 0 0 0;
    color: #fff;
    display: block;
}

/* Charts & Map Sections */
.charts-section {
    padding: 2rem;
    margin-bottom: 3rem;
}

.chart-container {
    height: 400px;
    position: relative;
}

.map-container-wrapper {
    width: 100%;
    margin-top: 2.5rem;
    position: relative;
    z-index: 10;
}

#visitorMap {
    height: 500px;
    width: 100%;
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
}

/* Details Grid */
.details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 2rem;
}

.details-card {
    padding: 2rem;
}

.details-card h3 {
    margin-top: 0;
    margin-bottom: 1.5rem;
    font-size: 1.25rem;
    color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

li {
    padding: 1rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--transition);
}

li:hover {
    padding-left: 0.5rem;
    background: rgba(255, 255, 255, 0.02);
}

li span {
    color: var(--text-muted);
    font-size: 0.95rem;
}

li strong {
    color: var(--secondary);
    font-family: monospace;
    font-size: 1.1rem;
}

li:last-child {
    border-bottom: none;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-card);
    border-radius: 5px;
    border: 2px solid var(--bg-dark);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* Responsive Fixes & Mobile Styles */
@media (max-width: 1024px) {
    .container {
        padding: 0 1.5rem;
    }

    .metrics-grid {
        grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
        gap: 1.5rem;
    }

    .details-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    header {
        padding: 1rem 0;
        margin-bottom: 2rem;
    }

    header .container {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    nav {
        width: 100%;
        flex-direction: column;
        gap: 0.5rem;
        display: none;
        /* Hide nav by default on mobile */
    }

    nav.active {
        display: flex;
        /* Show when active */
    }

    nav a {
        width: 100%;
        text-align: left;
        padding: 0.75rem 1rem;
    }

    .site-selector {
        flex-direction: column;
        width: 100%;
    }

    select,
    input[type="date"] {
        width: 100%;
    }

    .metrics-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .metric-card {
        padding: 1.5rem;
    }

    .metric-card .value {
        font-size: 2rem;
    }

    .charts-section {
        padding: 1rem;
    }

    .chart-container {
        height: 300px;
    }

    #visitorMap {
        height: 350px;
    }

    .details-card {
        padding: 1.5rem;
    }

    /* Mobile Menu Toggle */
    .menu-toggle {
        display: block;
        background: none;
        border: none;
        color: var(--text-main);
        font-size: 1.5rem;
        cursor: pointer;
        padding: 0.5rem;
        position: absolute;
        right: 1.5rem;
        top: 1.25rem;
    }

    /* Table Responsiveness */
    .glass {
        overflow-x: auto;
    }

    table.sites-table {
        min-width: 600px;
    }

    .site-form form {
        flex-direction: column;
        align-items: stretch !important;
    }

    .site-form .btn {
        margin-top: 1rem;
    }

    .login-card {
        padding: 2rem;
    }
}

@media (min-width: 769px) {
    .menu-toggle {
        display: none;
    }
}

/* Global Table Styles */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin: 1.5rem 0;
}

th,
td {
    padding: 1.25rem 1rem;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    vertical-align: top;
}

th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: rgba(255, 255, 255, 0.02);
}

tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

/* Form Styles */
.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    margin-bottom: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.9rem;
}

input[type="text"],
input[type="password"],
input[type="email"],
textarea {
    width: 100%;
    background: rgba(15, 23, 42, 0.6);
    color: var(--text-main);
    border: 1px solid var(--glass-border);
    padding: 0.75rem 1rem;
    border-radius: 10px;
    font-family: inherit;
    transition: var(--transition);
}

input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
    cursor: pointer;
    opacity: 0.7;
    transition: var(--transition);
}

input[type="date"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

.btn {
    display: inline-block;
    padding: 0.75rem 1.75rem;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    text-decoration: none;
    font-size: 0.95rem;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    box-shadow: 0 0 20px var(--primary-glow);
    transform: translateY(-1px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    border: 1px solid var(--glass-border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
}

/* Alert Styles */
.alert {
    padding: 1rem 1.5rem;
    border-radius: 12px;
    margin-bottom: 2rem;
    border: 1px solid transparent;
    font-weight: 500;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 2.5rem;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    transform: scale(0.9);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.5rem;
}

.close-modal {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    transition: var(--transition);
}

.close-modal:hover {
    color: var(--accent);
}

.modal-body p {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.copy-container {
    position: relative;
    margin-top: 1rem;
}

.btn-copy {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--primary);
    color: white;
    padding: 1rem 2rem;
    border-radius: 12px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 3000;
}

.toast.active {
    transform: translateY(0);
    opacity: 1;
}

.alert-info {
    background: rgba(6, 182, 212, 0.1);
    color: var(--secondary);
    border-color: rgba(6, 182, 212, 0.2);
}

/* Snippet Styling */
.snippet {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    background: rgba(0, 0, 0, 0.3);
    padding: 1.25rem;
    border-radius: 12px;
    font-size: 0.85rem;
    display: block;
    color: #cbd5e1;
    border: 1px solid var(--glass-border);
    white-space: pre-wrap;
    word-break: break-all;
    line-height: 1.5;
    margin: 0;
}

.btn-delete {
    color: var(--accent);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    transition: var(--transition);
}

.btn-delete:hover {
    text-shadow: 0 0 10px var(--accent);
    opacity: 0.8;
}

/* Login Specific Layout */
.login-layout {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
}

.login-card {
    width: 100%;
    max-width: 420px;
    padding: 3rem;
    text-align: center;
}

.login-card h2 {
    margin-top: 0;
    margin-bottom: 2rem;
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.error {
    background: rgba(244, 63, 94, 0.1);
    color: var(--accent);
    padding: 0.75rem;
    border-radius: 10px;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    border: 1px solid rgba(244, 63, 94, 0.2);
    font-weight: 500;
}

/* Leaflet Customization */
.leaflet-container {
    font-family: inherit;
    background: var(--bg-dark) !important;
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
    background: var(--bg-dark) !important;
    color: var(--text-main) !important;
    backdrop-filter: blur(8px);
    border: 1px solid var(--glass-border);
}