/* ESPILON C2 - Violet Theme */

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

:root {
    /* Background colors - deep dark with violet undertones */
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-tertiary: #06060a;
    --bg-elevated: #1a1a25;

    /* Border colors */
    --border-color: #2a2a3d;
    --border-light: #3d3d55;

    /* Text colors */
    --text-primary: #e4e4ed;
    --text-secondary: #8888a0;
    --text-muted: #5a5a70;

    /* Accent colors - violet palette */
    --accent-primary: #a855f7;
    --accent-primary-hover: #c084fc;
    --accent-primary-bg: rgba(168, 85, 247, 0.15);
    --accent-primary-glow: rgba(168, 85, 247, 0.4);

    --accent-secondary: #818cf8;
    --accent-secondary-bg: rgba(129, 140, 248, 0.15);

    /* Status colors */
    --status-online: #22d3ee;
    --status-online-bg: rgba(34, 211, 238, 0.15);
    --status-warning: #fbbf24;
    --status-warning-bg: rgba(251, 191, 36, 0.15);
    --status-error: #f87171;
    --status-error-bg: rgba(248, 113, 113, 0.15);
    --status-success: #4ade80;
    --status-success-bg: rgba(74, 222, 128, 0.15);

    /* Button colors */
    --btn-primary: #7c3aed;
    --btn-primary-hover: #8b5cf6;
    --btn-secondary: #1e1e2e;
    --btn-secondary-hover: #2a2a3d;

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #7c3aed 0%, #a855f7 100%);
    --gradient-glow: radial-gradient(circle at center, var(--accent-primary-glow) 0%, transparent 70%);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
}

/* ========== Header ========== */

header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    backdrop-filter: blur(10px);
}

.logo {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 2px;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.main-nav {
    display: flex;
    gap: 4px;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 8px;
    transition: all 0.2s ease;
    position: relative;
}

.nav-link:hover {
    color: var(--text-primary);
    background: var(--bg-elevated);
}

.nav-link.active {
    color: var(--accent-primary);
    background: var(--accent-primary-bg);
}

.nav-link.active::after {
    content: '';
    position: absolute;
    bottom: -13px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 2px;
    background: var(--accent-primary);
    border-radius: 2px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    padding: 6px 12px;
    background: var(--bg-elevated);
    border-radius: 20px;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--status-online);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--status-online);
    animation: pulse 2s infinite;
}

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

.logout {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    padding: 6px 12px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.logout:hover {
    color: var(--text-primary);
    background: var(--bg-elevated);
}

/* ========== Main Content ========== */

main {
    padding: 24px;
    max-width: 1400px;
    margin: 0 auto;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.page-title {
    font-size: 13px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.page-title span {
    color: var(--text-primary);
    font-weight: 600;
    margin-left: 8px;
}

/* ========== Cards Grid ========== */

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.grid-cameras {
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
}

.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.2s ease;
}

.card:hover {
    border-color: var(--border-light);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.card-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
}

.card-header .name {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 500;
    color: var(--text-primary);
}

.card-header .badge {
    font-size: 10px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-live {
    color: var(--status-online);
    background: var(--status-online-bg);
}

.badge-connected {
    color: var(--status-success);
    background: var(--status-success-bg);
}

.badge-inactive {
    color: var(--status-warning);
    background: var(--status-warning-bg);
}

.card-body {
    padding: 16px;
}

.card-body-image {
    background: var(--bg-tertiary);
    min-height: 240px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.card-body-image img {
    width: 100%;
    height: auto;
    display: block;
}

/* ========== Device Card ========== */

.device-info {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.device-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
}

.device-row .label {
    color: var(--text-muted);
}

.device-row .value {
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
}

/* ========== Empty State ========== */

.empty {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-secondary);
}

.empty h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.empty p {
    font-size: 14px;
    color: var(--text-muted);
}

/* ========== Header Stats ========== */

.header-stats {
    display: flex;
    gap: 24px;
}

.header-stats .stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.header-stats .stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--accent-primary);
    font-family: 'JetBrains Mono', monospace;
}

.header-stats .stat-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
}

/* ========== Lain Empty State ========== */

.empty-lain {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
    text-align: center;
    padding: 40px 20px;
}

.lain-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

.lain-ascii {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    line-height: 1.2;
    color: var(--accent-primary);
    opacity: 0.7;
    text-shadow: 0 0 10px var(--accent-primary-glow);
    animation: pulse-glow 3s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% { opacity: 0.5; text-shadow: 0 0 10px var(--accent-primary-glow); }
    50% { opacity: 0.9; text-shadow: 0 0 20px var(--accent-primary-glow), 0 0 40px var(--accent-primary-glow); }
}

.lain-message h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.lain-message .typing {
    font-size: 14px;
    color: var(--accent-secondary);
    margin-bottom: 16px;
}

.lain-message .quote {
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
    opacity: 0.7;
}

/* ========== MLAT Container ========== */

.mlat-container {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 20px;
}

@media (max-width: 900px) {
    .mlat-container {
        grid-template-columns: 1fr;
    }
}

/* View Toggle Buttons */
.view-toggle {
    display: flex;
    gap: 4px;
    background: var(--bg-secondary);
    padding: 4px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

.view-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.view-btn:hover {
    color: var(--text-primary);
    background: var(--bg-elevated);
}

.view-btn.active {
    background: var(--accent-primary-bg);
    color: var(--accent-primary);
}

.view-btn svg {
    opacity: 0.7;
}

.view-btn.active svg {
    opacity: 1;
}

/* Map/Plan View Wrapper */
.mlat-view-wrapper {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    position: relative;
}

.mlat-view-wrapper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--gradient-primary);
    opacity: 0.5;
    z-index: 10;
}

.mlat-view {
    display: none;
    height: 500px;
}

.mlat-view.active {
    display: block;
}

/* Leaflet Map */
#leaflet-map {
    width: 100%;
    height: 100%;
    background: var(--bg-tertiary);
}

/* Leaflet Dark Theme Override */
.leaflet-container {
    background: var(--bg-tertiary);
    font-family: inherit;
}

.leaflet-popup-content-wrapper {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.leaflet-popup-tip {
    background: var(--bg-secondary);
}

.leaflet-control-zoom {
    border: 1px solid var(--border-color) !important;
}

.leaflet-control-zoom a {
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    border-bottom-color: var(--border-color) !important;
}

.leaflet-control-zoom a:hover {
    background: var(--bg-elevated) !important;
}

.leaflet-control-attribution {
    background: var(--bg-secondary) !important;
    color: var(--text-muted) !important;
    font-size: 10px;
}

.leaflet-control-attribution a {
    color: var(--accent-secondary) !important;
}

/* Plan View */
#plan-view {
    display: flex;
    flex-direction: column;
}

.plan-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border-color);
}

.control-divider {
    width: 1px;
    height: 24px;
    background: var(--border-color);
    margin: 0 4px;
}

.toggle-btn {
    opacity: 0.5;
    transition: opacity 0.2s ease;
}

.toggle-btn.active {
    opacity: 1;
    background: var(--accent-primary-bg);
    color: var(--accent-primary);
}

.control-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.zoom-level,
.size-display {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 55px;
    text-align: center;
    padding: 4px 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

.plan-canvas-wrapper {
    flex: 1;
    padding: 16px;
    overflow: hidden;
}

#plan-canvas {
    width: 100%;
    height: 100%;
    background: var(--bg-tertiary);
    border-radius: 8px;
    cursor: grab;
}

#plan-canvas:active {
    cursor: grabbing;
}

/* Sidebar */
.mlat-sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.mlat-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
}

.mlat-panel h3 {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 14px;
    color: var(--text-secondary);
}

.mlat-stat {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.mlat-stat:last-child {
    border-bottom: none;
}

.mlat-stat .label {
    color: var(--text-muted);
}

.mlat-stat .value {
    color: var(--accent-primary);
    font-family: 'JetBrains Mono', monospace;
    font-weight: 500;
}

.scanner-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
}

.scanner-list .empty {
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

.scanner-item {
    background: var(--bg-elevated);
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 12px;
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

.scanner-item:hover {
    border-color: var(--border-light);
}

.scanner-item .scanner-id {
    font-weight: 600;
    color: var(--accent-secondary);
}

.scanner-item .scanner-details {
    color: var(--text-muted);
    margin-top: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
}

/* Button Group */
.btn-group {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

/* Custom Leaflet Markers */
.scanner-marker {
    background: var(--accent-secondary);
    border: 2px solid #fff;
    border-radius: 50%;
    width: 16px !important;
    height: 16px !important;
    margin-left: -8px !important;
    margin-top: -8px !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.target-marker {
    width: 24px !important;
    height: 24px !important;
    margin-left: -12px !important;
    margin-top: -12px !important;
}

.target-marker svg {
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
}

/* Range Circle */
.range-circle {
    fill: rgba(129, 140, 248, 0.1);
    stroke: rgba(129, 140, 248, 0.4);
    stroke-width: 2;
}

/* ========== Config Panel ========== */

.config-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
}

.config-row:last-child {
    border-bottom: none;
}

.config-row label {
    font-size: 13px;
    color: var(--text-secondary);
}

.config-row input {
    width: 80px;
    padding: 6px 10px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 13px;
    font-family: 'JetBrains Mono', monospace;
    text-align: right;
    transition: all 0.2s ease;
}

.config-row input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-primary-bg);
}

/* ========== Buttons ========== */

.btn {
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

.btn-primary {
    background: var(--gradient-primary);
    color: #fff;
    box-shadow: 0 2px 10px var(--accent-primary-bg);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px var(--accent-primary-glow);
}

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

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

/* ========== Login Page ========== */

.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    position: relative;
}

.login-container::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 600px;
    height: 600px;
    background: var(--gradient-glow);
    pointer-events: none;
}

.login-box {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 380px;
    position: relative;
    backdrop-filter: blur(10px);
}

.login-box .logo {
    text-align: center;
    margin-bottom: 32px;
    font-size: 24px;
}

.error {
    background: var(--status-error-bg);
    border: 1px solid var(--status-error);
    color: var(--status-error);
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 13px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.form-group input {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    transition: all 0.2s ease;
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-primary-bg);
}

.form-group input::placeholder {
    color: var(--text-muted);
}

.btn-login {
    width: 100%;
    padding: 14px 20px;
    background: var(--gradient-primary);
    border: none;
    border-radius: 8px;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 10px var(--accent-primary-bg);
}

.btn-login:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px var(--accent-primary-glow);
}

/* ========== Scrollbar ========== */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-light);
}

/* ========== Selection ========== */

::selection {
    background: var(--accent-primary-bg);
    color: var(--accent-primary);
}
