/* -------------------------------------------------------------
 * CCTV Multi-View Dashboard - Style System (v3.0)
 * Designed with a premium Dark Glassmorphism aesthetic.
 * Fonts: Kanit (for clean Thai text) and Inter (for digits/ENG)
 * ------------------------------------------------------------- */

:root {
    --bg-dark: #070a13;
    --bg-darker: #03050a;
    --card-bg: rgba(13, 20, 38, 0.6);
    --card-border: rgba(255, 255, 255, 0.08);
    --glass-accent: rgba(59, 130, 246, 0.15);
    
    /* Colors */
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --primary-glow: rgba(59, 130, 246, 0.5);
    --secondary: #1e293b;
    --secondary-hover: #334155;
    
    --color-active: #10b981;
    --color-active-glow: rgba(16, 185, 129, 0.5);
    --color-warning: #f59e0b;
    --color-warning-glow: rgba(245, 158, 11, 0.5);
    --color-offline: #ef4444;
    --color-offline-glow: rgba(239, 68, 68, 0.5);
    
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --text-dark: #64748b;
    
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Inter', 'Kanit', -apple-system, BlinkMacSystemFont, sans-serif;
    background: radial-gradient(circle at 50% 50%, var(--bg-dark), var(--bg-darker));
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

/* Scrollbar Styles */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-darker);
}
::-webkit-scrollbar-thumb {
    background: #1e293b;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #334155;
}

/* Glassmorphism Header */
.glass-header {
    background: rgba(8, 12, 24, 0.7);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-bottom: 1px solid var(--card-border);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.4);
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-icon {
    font-size: 2.2rem;
    color: var(--primary);
    text-shadow: 0 0 15px var(--primary-glow);
}

.header-logo h1 {
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: #fff;
}

.header-logo p {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* System Stats Badges */
.system-stats {
    display: flex;
    gap: 1.2rem;
}

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

.stat-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.dot-active {
    background-color: var(--color-active);
    box-shadow: 0 0 8px var(--color-active-glow);
}
.dot-warning {
    background-color: var(--color-warning);
    box-shadow: 0 0 8px var(--color-warning-glow);
    animation: pulse 1.5s infinite;
}
.dot-offline {
    background-color: var(--color-offline);
    box-shadow: 0 0 8px var(--color-offline-glow);
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Layout Grid Buttons */
.layout-selector {
    display: flex;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    padding: 0.2rem;
}

.layout-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.5rem 0.8rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    transition: var(--transition-smooth);
}

.layout-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
}

.layout-btn.active {
    color: #fff;
    background: var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
}

/* Button styles */
.btn {
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-family: inherit;
    transition: var(--transition-smooth);
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}
.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.5);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--secondary);
    color: var(--text-main);
    border: 1px solid var(--card-border);
}
.btn-secondary:hover {
    background: var(--secondary-hover);
    color: #fff;
}

.btn-block {
    width: 100%;
    justify-content: center;
}

.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}
.btn-danger:hover {
    background: var(--color-offline);
    color: #fff;
    box-shadow: 0 4px 15px var(--color-offline-glow);
}

/* Main Dashboard Viewport */
.dashboard-viewport {
    flex: 1;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* Grid Layouts */
.camera-grid {
    width: 100%;
    max-width: 1600px;
    display: grid;
    gap: 1.2rem;
    margin: 0 auto;
    transition: var(--transition-smooth);
}

.grid-1x1 {
    grid-template-columns: 1fr;
}
.grid-2x2 {
    grid-template-columns: repeat(2, 1fr);
}
@media (max-width: 900px) {
    .grid-2x2 {
        grid-template-columns: 1fr;
    }
}
.grid-3x3 {
    grid-template-columns: repeat(3, 1fr);
}
@media (max-width: 1200px) {
    .grid-3x3 {
        grid-template-columns: repeat(2, 1fr);
    }
}
@media (max-width: 800px) {
    .grid-3x3 {
        grid-template-columns: 1fr;
    }
}

.grid-auto {
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
}
@media (max-width: 480px) {
    .grid-auto {
        grid-template-columns: 1fr;
    }
}

/* Camera Card Container */
.camera-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    aspect-ratio: 16 / 9;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    transition: var(--transition-smooth);
    display: flex;
    flex-direction: column;
}

.camera-card:hover {
    transform: scale(1.015);
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5), 0 0 15px rgba(255, 255, 255, 0.05);
}

.camera-card.border-online:hover {
    border-color: var(--color-active);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5), 0 0 15px rgba(16, 185, 129, 0.2);
}
.camera-card.border-offline:hover {
    border-color: var(--color-offline);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5), 0 0 15px rgba(239, 68, 68, 0.2);
}
.camera-card.border-connecting:hover {
    border-color: var(--color-warning);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5), 0 0 15px rgba(245, 158, 11, 0.2);
}

/* Feed Wrapper (Video Container) */
.camera-feed-wrap {
    width: 100%;
    height: 100%;
    position: relative;
    background: #000;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

.camera-feed-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: filter 0.5s ease;
}

/* Camera Card Overlay HUD */
.camera-hud-top {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 0.8rem 1rem;
    background: linear-gradient(to bottom, rgba(0,0,0,0.85), rgba(0,0,0,0));
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
}

.camera-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.camera-type-badge {
    font-size: 0.65rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    color: var(--text-muted);
    text-transform: uppercase;
}

.camera-status-overlay {
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255,255,255,0.05);
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.camera-hud-bottom {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0.8rem 1rem;
    background: linear-gradient(to top, rgba(0,0,0,0.8), rgba(0,0,0,0));
    display: flex;
    justify-content: space-between;
    align-items: center;
    opacity: 0;
    transform: translateY(10px);
    transition: var(--transition-smooth);
    z-index: 10;
}

.camera-card:hover .camera-hud-bottom {
    opacity: 1;
    transform: translateY(0);
}

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

.action-btn {
    background: rgba(15, 23, 42, 0.75);
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--text-main);
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    font-size: 0.85rem;
    transition: var(--transition-smooth);
}

.action-btn:hover {
    color: #fff;
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 0 8px var(--primary-glow);
}

.action-btn-danger:hover {
    background: var(--color-offline);
    border-color: var(--color-offline);
    box-shadow: 0 0 8px var(--color-offline-glow);
}

/* Empty State Styles */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem;
    text-align: center;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    max-width: 500px;
    margin: 4rem auto;
}

.empty-icon-wrap {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--card-border);
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 1.5rem;
}

.empty-icon {
    font-size: 2.5rem;
    color: var(--text-dark);
}

.empty-state h2 {
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.empty-state p {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 2rem;
    line-height: 1.5;
}

/* Modal Windows styling */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: var(--transition-smooth);
}

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

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(2, 4, 8, 0.75);
    backdrop-filter: blur(8px);
}

.modal-content {
    background: rgba(10, 16, 32, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--card-border);
    width: 90%;
    max-width: 580px;
    border-radius: 16px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.6);
    z-index: 1001;
    overflow: hidden;
    transform: scale(0.95);
    transition: var(--transition-smooth);
}

.modal:not(.hidden) .modal-content {
    transform: scale(1);
}

.modal-header {
    padding: 1.2rem 1.8rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.15rem;
    font-weight: 600;
}

.btn-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.8rem;
    cursor: pointer;
    line-height: 1;
    transition: var(--transition-smooth);
}

.btn-close:hover {
    color: #fff;
}

/* Forms styling */
form {
    padding: 1.5rem 1.8rem;
}

.form-group {
    margin-bottom: 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.form-row {
    display: flex;
    gap: 1rem;
}

.col-8 { flex: 2; }
.col-4 { flex: 1; }
.col-6 { flex: 1; }

label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.required {
    color: var(--color-offline);
}

input[type="text"],
input[type="password"],
input[type="number"],
select {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    padding: 0.65rem 0.9rem;
    color: #fff;
    font-family: inherit;
    font-size: 0.9rem;
    transition: var(--transition-smooth);
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.05);
    box-shadow: 0 0 8px var(--primary-glow);
}

/* Help text block inside Modal */
.form-help-info {
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 8px;
    padding: 0.8rem 1rem;
    margin-bottom: 1.5rem;
    display: flex;
    gap: 0.8rem;
    align-items: flex-start;
}

.info-icon {
    color: var(--primary);
    margin-top: 0.2rem;
}

.form-help-info p {
    font-size: 0.78rem;
    color: #bfdbfe;
    line-height: 1.4;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.8rem;
    padding-top: 0.5rem;
}

/* Drawer CSS */
.drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 100%;
    height: 100%;
    z-index: 999;
    display: flex;
    justify-content: flex-end;
    transition: var(--transition-smooth);
}

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

.drawer-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(2, 4, 8, 0.6);
    backdrop-filter: blur(4px);
}

.drawer-content {
    background: rgba(10, 16, 32, 0.9);
    backdrop-filter: blur(25px);
    border-left: 1px solid var(--card-border);
    width: 90%;
    max-width: 440px;
    height: 100%;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    box-shadow: -15px 0 35px rgba(0, 0, 0, 0.5);
    transform: translateX(100%);
    transition: var(--transition-smooth);
}

.drawer:not(.hidden) .drawer-content {
    transform: translateX(0);
}

.drawer-header {
    padding: 1.5rem 1.8rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 1.8rem;
}

.drawer-footer {
    padding: 1.2rem 1.8rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

/* Drawer Camera List Item */
.camera-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.camera-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--card-border);
    padding: 0.9rem 1rem;
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--transition-smooth);
}

.camera-item:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.15);
}

.camera-item-info h4 {
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 0.2rem;
}

.camera-item-info p {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.camera-item-actions {
    display: flex;
    gap: 0.4rem;
}

/* Fullscreen Overlay Style */
.fullscreen-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    transition: var(--transition-smooth);
}

.fullscreen-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.fullscreen-header {
    padding: 1rem 2rem;
    background: linear-gradient(to bottom, rgba(0,0,0,0.9), transparent);
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.fullscreen-header h2 {
    font-size: 1.2rem;
    font-weight: 600;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}

.fullscreen-video-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #000;
    width: 100%;
    height: 100%;
}

.fullscreen-video-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.fullscreen-footer {
    padding: 1rem 2rem;
    background: linear-gradient(to top, rgba(0,0,0,0.9), transparent);
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.btn-icon {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.1);
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    font-size: 1.1rem;
    transition: var(--transition-smooth);
}

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

/* Animations */
@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.6; }
    100% { transform: scale(1); opacity: 1; }
}

.glow-pulse {
    animation: glow-pulse 3s infinite;
}

@keyframes glow-pulse {
    0% { filter: drop-shadow(0 0 2px var(--primary-glow)); }
    50% { filter: drop-shadow(0 0 10px var(--primary)); }
    100% { filter: drop-shadow(0 0 2px var(--primary-glow)); }
}

/* Ripple button effect (subtle animation trigger) */
.ripple {
    position: relative;
    overflow: hidden;
}

/* Local Subnet Scanner & Radar Styles */
.scanner-animation {
    position: relative;
    width: 100px;
    height: 100px;
    background: rgba(59, 130, 246, 0.05);
    border: 2px solid rgba(59, 130, 246, 0.15);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.1);
}

.scanner-center-icon {
    font-size: 2.2rem;
    color: var(--primary);
    text-shadow: 0 0 10px var(--primary-glow);
    z-index: 2;
}

.radar-ping {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: transparent;
    border: 3px solid var(--primary);
    animation: radar-sweep 2s cubic-bezier(0.1, 0.8, 0.3, 1) infinite;
    z-index: 1;
}

@keyframes radar-sweep {
    0% {
        transform: scale(0.6);
        opacity: 1;
        box-shadow: 0 0 0 0 var(--primary-glow);
    }
    100% {
        transform: scale(2.2);
        opacity: 0;
        box-shadow: 0 0 40px 10px transparent;
    }
}

.scan-table th,
.scan-table td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--card-border);
    vertical-align: middle;
}

.scan-table tbody tr {
    transition: var(--transition-smooth);
}

.scan-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.source-badge {
    font-size: 0.65rem;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-weight: 500;
}

.source-badge.onvif {
    background: rgba(16, 185, 129, 0.15);
    color: #a7f3d0;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.source-badge.port {
    background: rgba(59, 130, 246, 0.15);
    color: #bfdbfe;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

/* 4x4 Grid Layout */
.camera-grid.grid-4x4 {
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
}
@media (max-width: 1200px) {
    .camera-grid.grid-4x4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Live RTSP Test Connection Section */
.test-connection-section {
    margin-top: 1rem;
    margin-bottom: 1rem;
}
.test-result-box {
    margin-top: 0.6rem;
    padding: 0.8rem 1rem;
    border-radius: 8px;
    font-size: 0.82rem;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--card-border);
    transition: var(--transition-smooth);
}
.test-result-box.success {
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.3);
    color: #a7f3d0;
}
.test-result-box.error {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}
.test-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top: 2px solid var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* NVR Preset Guide & Code Badges */
.badge-code {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.8rem;
    color: #38bdf8;
}
.nvr-guide-card {
    background: rgba(59, 130, 246, 0.05);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 10px;
    padding: 1.2rem;
    margin-bottom: 1.2rem;
}
.nvr-presets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}
.nvr-preset-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    padding: 1rem;
    transition: var(--transition-smooth);
}
.nvr-preset-item:hover {
    border-color: var(--primary-glow);
    background: rgba(255, 255, 255, 0.04);
}
.nvr-preset-item h5 {
    font-size: 0.95rem;
    font-weight: 600;
    color: #fff;
    margin-bottom: 0.4rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.nvr-preset-item p {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 0.6rem;
}

/* 2x4 Grid Layout (Perfect for 8 cameras fill) */
.camera-grid.grid-2x4 {
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(2, 1fr);
}
@media (max-width: 1200px) {
    .camera-grid.grid-2x4 {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: repeat(4, 1fr);
    }
}

/* Live Clock Widget Header Card */
.live-clock-card {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--card-border);
    padding: 0.4rem 1.2rem;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.3);
}
.clock-time {
    font-family: 'Inter', monospace;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: #38bdf8;
    text-shadow: 0 0 10px rgba(56, 189, 248, 0.4);
    line-height: 1.1;
}
.clock-date {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 400;
    margin-top: 2px;
}

/* Live Weather & PM2.5 Widget for Samut Songkhram */
.live-weather-card {
    background: rgba(15, 23, 42, 0.65);
    border: 1px solid var(--card-border);
    padding: 0.35rem 0.9rem;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.3);
}
.weather-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
}
.weather-location {
    font-size: 0.78rem;
    font-weight: 600;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}
.weather-temp {
    font-family: 'Inter', monospace;
    font-size: 0.95rem;
    font-weight: 700;
    color: #38bdf8;
}
.weather-bottom {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.7rem;
}
.weather-cond {
    color: var(--text-muted);
}
.pm25-badge {
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-size: 0.68rem;
    font-weight: 600;
    line-height: 1.2;
}
.aqi-good {
    background: rgba(16, 185, 129, 0.18);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
}
.aqi-moderate {
    background: rgba(59, 130, 246, 0.18);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.3);
}
.aqi-warning {
    background: rgba(245, 158, 11, 0.18);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.3);
}
.aqi-unhealthy {
    background: rgba(249, 115, 22, 0.18);
    color: #fb923c;
    border: 1px solid rgba(249, 115, 22, 0.3);
}
.aqi-danger {
    background: rgba(239, 68, 68, 0.18);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.tv-wall-weather-pill {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.25rem 0.7rem;
    border-radius: 20px;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-right: 0.3rem;
}

/* TV Wall Fullscreen Kiosk Mode (Fixed 100vw x 100vh Bounds, Prevents Vertical Overflow) */
body.tv-wall-mode {
    overflow: hidden !important;
    position: fixed !important;
    width: 100vw !important;
    height: 100vh !important;
}

body.tv-wall-mode .glass-header {
    display: none !important;
}

body.tv-wall-mode .tv-wall-floating-badge {
    display: flex !important;
}

body.tv-wall-mode .dashboard-viewport {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: hidden !important;
    z-index: 1000 !important;
    background: #000 !important;
    display: block !important;
}

/* TV Wall Floating Non-blocking Badge */
.tv-wall-floating-badge {
    position: fixed;
    top: 15px;
    right: 15px;
    z-index: 2500;
    background: rgba(8, 12, 24, 0.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    padding: 0.4rem 1rem;
    border-radius: 50px;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
    pointer-events: auto;
}
.badge-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: #fff;
}
.badge-center {
    font-family: 'Inter', monospace;
    font-size: 0.95rem;
    font-weight: 700;
    color: #38bdf8;
}
.btn-exit-floating {
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
    padding: 0.25rem 0.6rem;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    transition: var(--transition-smooth);
}
.btn-exit-floating:hover {
    background: rgba(239, 68, 68, 0.5);
    color: #fff;
}

/* Flush Edge-to-Edge Grid Layout (Zero Gap, Zero Margin, Zero Overflow) */
.camera-grid.grid-wall-flush,
body.tv-wall-mode .camera-grid {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    grid-template-rows: repeat(2, 1fr) !important;
    gap: 2px !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
}

.camera-grid.grid-wall-flush .camera-card,
body.tv-wall-mode .camera-card {
    aspect-ratio: unset !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    max-height: 50vh !important;
    border-radius: 0 !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    box-shadow: none !important;
    background: #000 !important;
    margin: 0 !important;
    overflow: hidden !important;
    position: relative !important;
}

/* Camera 1 (Featured) spans 2 columns in 4x2 grid so 7 cameras fill 8 grid slots */
.camera-grid.grid-wall-flush .camera-card:first-child,
body.tv-wall-mode .camera-card:first-child {
    grid-column: span 2 !important;
}

.camera-grid.grid-wall-flush .camera-feed-wrap,
body.tv-wall-mode .camera-feed-wrap {
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    position: relative !important;
}

/* Default Object-Fit: fill (100% full camera field of view visible, zero cropping!) */
.camera-feed-wrap img,
.camera-grid.grid-wall-flush .camera-feed-wrap img,
body.tv-wall-mode .camera-feed-wrap img {
    object-fit: fill !important;
    width: 100% !important;
    height: 100% !important;
}

/* Image Fit Mode Overrides */
body.fit-mode-fill .camera-feed-wrap img {
    object-fit: fill !important;
}
body.fit-mode-contain .camera-feed-wrap img {
    object-fit: contain !important;
    background: #000;
}
body.fit-mode-cover .camera-feed-wrap img {
    object-fit: cover !important;
}

@media (max-width: 1000px) {
    .camera-grid.grid-wall-flush,
    body.tv-wall-mode .camera-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        grid-template-rows: repeat(4, 1fr) !important;
    }
    .camera-grid.grid-wall-flush .camera-card,
    body.tv-wall-mode .camera-card {
        max-height: 25vh !important;
    }
    .camera-grid.grid-wall-flush .camera-card:first-child,
    body.tv-wall-mode .camera-card:first-child {
        grid-column: span 2 !important;
    }
}

/* Drag and Drop Reordering Styles */
.drag-handle {
    cursor: grab;
    padding: 0.2rem 0.4rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
}
.drag-handle:hover, .drag-handle:active {
    color: var(--accent-glow);
    cursor: grabbing;
}
.camera-card.dragging {
    opacity: 0.4;
    transform: scale(0.97);
    border: 2px dashed var(--accent-glow) !important;
}
.camera-card.drag-over {
    border: 2px solid var(--accent-glow) !important;
    box-shadow: 0 0 25px rgba(56, 189, 248, 0.5) !important;
    transform: scale(1.02);
}




