/* Root Design System Variables */
:root {
    --bg-dark: #0f172a;
    --bg-card: rgba(30, 41, 59, 0.75);
    --bg-card-border: rgba(255, 255, 255, 0.12);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-emerald: #10b981;
    --accent-emerald-glow: rgba(16, 185, 129, 0.4);
    --accent-cyan: #06b6d4;
    --accent-purple: #8b5cf6;
    --danger: #ef4444;
    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
    --radius-lg: 16px;
    --radius-md: 12px;
    --shadow-glow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

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

body, html {
    height: 100%;
    width: 100%;
    font-family: var(--font-family);
    background-color: var(--bg-dark);
    color: var(--text-primary);
    overflow: hidden;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
}

/* Header Navbar */
.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--bg-card-border);
    z-index: 1000;
}

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

.badge-pulse {
    width: 10px;
    height: 10px;
    background-color: var(--accent-emerald);
    border-radius: 50%;
    box-shadow: 0 0 0 0 var(--accent-emerald-glow);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 10px rgba(16, 185, 129, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

.app-title {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, #ffffff 0%, #cbd5e1 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header-status {
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--accent-emerald);
}

/* Main Layout */
.main-layout {
    position: relative;
    flex: 1;
    width: 100%;
    height: calc(100vh - 55px);
}

.map-container {
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* Glassmorphism Info Card */
.glass {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--bg-card-border);
    box-shadow: var(--shadow-glow);
}

.info-card {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 32px);
    max-width: 520px;
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    z-index: 999;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.walker-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    box-shadow: 0 4px 12px rgba(6, 182, 212, 0.3);
}

.walker-name {
    font-size: 1rem;
    font-weight: 600;
}

.sub-text {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.btn-icon {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--bg-card-border);
    color: var(--text-primary);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.18);
    transform: scale(1.05);
}

/* Progress Bar */
.progress-section {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.progress-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.highlight-val {
    color: var(--accent-cyan);
    font-weight: 600;
}

.progress-bar-bg {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-cyan) 0%, var(--accent-emerald) 100%);
    border-radius: 4px;
    transition: width 0.6s ease-out;
}

/* Metrics Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.metric-card {
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md);
    padding: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.metric-label {
    font-size: 0.68rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 2px;
}

.metric-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: #ffffff;
}

.metric-value small {
    font-size: 0.7rem;
    font-weight: 400;
    color: var(--text-secondary);
}

.metric-sub {
    font-size: 0.68rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* Leaflet Custom Marker Styling */
.custom-live-marker {
    display: flex;
    align-items: center;
    justify-content: center;
}

.marker-pin {
    width: 20px;
    height: 20px;
    background-color: var(--accent-emerald);
    border: 3px solid #ffffff;
    border-radius: 50%;
    box-shadow: 0 0 15px var(--accent-emerald);
    position: relative;
}

.marker-pin::after {
    content: '';
    position: absolute;
    top: -6px;
    left: -6px;
    right: -6px;
    bottom: -6px;
    border-radius: 50%;
    border: 2px solid var(--accent-emerald);
    animation: ping 1.8s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes ping {
    75%, 100% {
        transform: scale(2);
        opacity: 0;
    }
}

/* Auth / Admin Pages */
.auth-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    border-radius: var(--radius-lg);
    padding: 32px 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.auth-header {
    text-align: center;
}

.auth-icon {
    font-size: 2.5rem;
}

.auth-header h2 {
    font-size: 1.4rem;
    margin-top: 8px;
}

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

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.form-group input {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--bg-card-border);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    color: #ffffff;
    font-size: 0.95rem;
    outline: none;
}

.form-group input:focus {
    border-color: var(--accent-cyan);
}

.btn {
    padding: 12px;
    border-radius: var(--radius-md);
    border: none;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-emerald));
    color: #000;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444, #b91c1c);
    color: #fff;
}

.btn-danger:hover {
    background: linear-gradient(135deg, #f87171, #ef4444);
}

.alert-danger {
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid var(--danger);
    color: #fca5a5;
    padding: 10px;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
}

.alert-success {
    background: rgba(16, 185, 129, 0.2);
    border: 1px solid var(--accent-emerald);
    color: #6ee7b7;
    padding: 10px;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    margin-bottom: 4px;
}

.danger-zone {
    border: 1px solid rgba(239, 68, 68, 0.35);
}

.danger-zone h2 {
    color: #fca5a5;
}

.back-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    display: block;
    text-align: center;
}

.admin-container {
    padding: 24px;
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
}

.admin-card {
    padding: 24px;
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.code-block {
    background: rgba(0, 0, 0, 0.4);
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-family: monospace;
    font-size: 0.9rem;
}

pre {
    background: rgba(0, 0, 0, 0.6);
    padding: 14px;
    border-radius: var(--radius-md);
    overflow-x: auto;
    font-size: 0.85rem;
}

/* Responsive adjustments for narrow screens */
@media (max-width: 480px) {
    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }
    .info-card {
        bottom: 12px;
        padding: 12px 14px;
    }
}
