@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

/* CSS Variables for design tokens */
:root {
    --bg-primary: #0a0b10;
    --bg-surface: rgba(18, 20, 32, 0.65);
    --bg-surface-hover: rgba(26, 29, 46, 0.85);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-color-focus: rgba(124, 77, 255, 0.5);
    
    --text-primary: #f5f6fa;
    --text-secondary: #8b97b0;
    --text-muted: #576584;

    --accent-indigo: #7c4dff;
    --accent-violet: #b388ff;
    --accent-cyan: #00f5d4;
    --accent-teal: #00bbf9;
    --accent-rose: #ff007f;
    --accent-success: #2ecc71;
    --accent-warning: #f1c40f;

    --gradient-primary: linear-gradient(135deg, var(--accent-indigo), var(--accent-rose));
    --gradient-secondary: linear-gradient(135deg, var(--accent-cyan), var(--accent-teal));
    --gradient-dark: linear-gradient(180deg, #121420, #0a0b10);
    --shadow-premium: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --glass-blur: blur(12px);
    
    --font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Global Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-family);
}

body {
    background-color: var(--bg-primary);
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(124, 77, 255, 0.1) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(255, 0, 127, 0.08) 0%, transparent 45%);
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--accent-indigo);
}

/* Container Utility */
.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* Auth Portal Styling */
.auth-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 1rem;
}

.auth-card {
    background: var(--bg-surface);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 3rem;
    width: 100%;
    max-width: 480px;
    box-shadow: var(--shadow-premium);
    animation: fadeIn 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.auth-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.auth-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    border-radius: 18px;
    background: var(--gradient-primary);
    margin-bottom: 1rem;
    box-shadow: 0 0 20px rgba(124, 77, 255, 0.4);
}

.auth-logo svg {
    width: 32px;
    height: 32px;
    fill: #fff;
}

.auth-title {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(to right, #ffffff, var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.auth-subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-top: 0.5rem;
}

/* Forms controls */
.form-group {
    margin-bottom: 1.5rem;
    position: relative;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.8rem 1rem;
    color: var(--text-primary);
    font-size: 1rem;
    transition: all 0.3s ease;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent-indigo);
    box-shadow: 0 0 0 3px rgba(124, 77, 255, 0.15);
    background: rgba(0, 0, 0, 0.4);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 0.85rem 1.5rem;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    border: none;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--gradient-primary);
    color: #fff;
    box-shadow: 0 4px 15px rgba(124, 77, 255, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(124, 77, 255, 0.45), 0 0 10px rgba(255, 0, 127, 0.2);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

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

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.4);
}

.auth-switch {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.auth-switch a {
    color: var(--accent-violet);
    text-decoration: none;
    font-weight: 600;
}

.auth-switch a:hover {
    text-decoration: underline;
}

/* Dashboard Layout */
.dashboard-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 2rem;
    background: var(--bg-surface);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.35rem;
    font-weight: 700;
    text-decoration: none;
    color: #fff;
}

.nav-brand span {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-badge {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-color);
    padding: 0.4rem 1rem;
    border-radius: 50px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.user-badge::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--accent-cyan);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--accent-cyan);
}

/* Grid & Cards system */
.dashboard-grid {
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 2rem;
    margin-top: 2rem;
    height: calc(100vh - 120px);
}

.sidebar-panel {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.dashboard-card {
    background: var(--bg-surface);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 1.5rem;
    box-shadow: var(--shadow-premium);
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #fff;
}

.card-title-badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.6rem;
    border-radius: 50px;
    background: rgba(124, 77, 255, 0.15);
    color: var(--accent-violet);
    border: 1px solid rgba(124, 77, 255, 0.3);
}

/* Broadcasting Status widget */
.status-widget {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.status-dot {
    position: relative;
    width: 24px;
    height: 24px;
}

.status-dot-inner {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: var(--text-muted);
}

.status-widget.active .status-dot-inner {
    background: var(--accent-success);
    box-shadow: 0 0 12px var(--accent-success);
}

.status-widget.active .status-dot::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: var(--accent-success);
    top: 0;
    left: 0;
    opacity: 0.6;
    animation: ping 1.5s cubic-bezier(0, 0, 0.2, 1) infinite;
}

.status-text h4 {
    font-weight: 600;
    font-size: 1rem;
}

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

/* Maps & Widgets styling */
.map-container {
    border-radius: 24px;
    overflow: hidden;
    position: relative;
    box-shadow: var(--shadow-premium);
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
}

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

/* Map Dark Theme Overrides for Leaflet */
.leaflet-container {
    background: #0f1015 !important;
}

.leaflet-tile {
    filter: invert(100%) hue-rotate(180deg) brightness(95%) contrast(90%);
}

.leaflet-bar {
    border: 1px solid var(--border-color) !important;
    box-shadow: var(--shadow-premium) !important;
}

.leaflet-bar a {
    background-color: #121420 !important;
    color: var(--text-primary) !important;
    border-bottom: 1px solid var(--border-color) !important;
}

.leaflet-bar a:hover {
    background-color: var(--accent-indigo) !important;
    color: #fff !important;
}

.leaflet-popup-content-wrapper {
    background: rgba(18, 20, 32, 0.9) !important;
    backdrop-filter: var(--glass-blur) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 12px !important;
}

.leaflet-popup-tip {
    background: rgba(18, 20, 32, 0.9) !important;
}

/* Stat Grid */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.stat-item {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
    border-radius: 12px;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.stat-value {
    font-size: 1.15rem;
    font-weight: 700;
    color: #fff;
    margin-top: 0.25rem;
}

/* Playback Control Panel */
.playback-controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.range-picker {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.timeline-slider-wrapper {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 0.5rem;
}

.timeline-slider {
    flex-grow: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.1);
    outline: none;
}

.timeline-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent-indigo);
    cursor: pointer;
    box-shadow: 0 0 10px var(--accent-indigo);
    transition: transform 0.1s;
}

.timeline-slider::-webkit-slider-thumb:hover {
    transform: scale(1.25);
}

.playback-btn-group {
    display: flex;
    gap: 0.5rem;
}

/* List elements style */
.panel-list {
    list-style: none;
    max-height: 250px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.list-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
}

.list-item:hover {
    background: var(--bg-surface-hover);
    border-color: var(--accent-indigo);
}

.list-info h5 {
    font-weight: 600;
    font-size: 0.95rem;
}

.list-info p {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.badge {
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-pending {
    background: rgba(241, 196, 15, 0.15);
    color: var(--accent-warning);
    border: 1px solid rgba(241, 196, 15, 0.3);
}

.badge-approved {
    background: rgba(46, 204, 113, 0.15);
    color: var(--accent-success);
    border: 1px solid rgba(46, 204, 113, 0.3);
}

.badge-revoked {
    background: rgba(231, 76, 60, 0.15);
    color: var(--accent-rose);
    border: 1px solid rgba(231, 76, 60, 0.3);
}

.list-actions {
    display: flex;
    gap: 0.5rem;
}

.action-btn {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    color: #fff;
}

.action-btn-approve {
    background: var(--accent-success);
}
.action-btn-approve:hover {
    box-shadow: 0 0 8px var(--accent-success);
}

.action-btn-revoke {
    background: var(--accent-rose);
}
.action-btn-revoke:hover {
    box-shadow: 0 0 8px var(--accent-rose);
}

.token-box {
    background: rgba(0, 0, 0, 0.3);
    border: 1px dashed var(--border-color-focus);
    border-radius: 12px;
    padding: 1rem;
    text-align: center;
    font-family: monospace;
    font-size: 1.1rem;
    color: var(--accent-cyan);
    letter-spacing: 1px;
    margin: 1rem 0;
    position: relative;
    cursor: pointer;
    overflow: hidden;
}

.token-box::after {
    content: 'Click to copy';
    position: absolute;
    bottom: 4px;
    right: 8px;
    font-size: 0.65rem;
    font-family: var(--font-family);
    color: var(--text-muted);
}

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

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

/* Alerts Toast System */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    z-index: 9999;
}

.toast {
    background: rgba(18, 20, 32, 0.9);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--accent-indigo);
    border-radius: 12px;
    padding: 1rem 1.5rem;
    box-shadow: var(--shadow-premium);
    backdrop-filter: var(--glass-blur);
    color: var(--text-primary);
    min-width: 300px;
    animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.toast-enter {
    border-left-color: var(--accent-cyan);
}

.toast-exit {
    border-left-color: var(--accent-rose);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Responsive Overrides */
@media (max-width: 992px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
        height: auto;
    }
    .sidebar-panel {
        max-height: none;
        overflow-y: visible;
    }
    .map-container {
        height: 500px;
    }
}
