/**
 * CheckMate! Hub - Styles
 * Dark theme with accent color #00d4aa
 */

/* ============================================================================
   Reset & Base
   ============================================================================ */

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

:root {
    --bg-dark: #0d1528;
    --bg-card: #16213e;
    --bg-hover: #1a2744;
    --bg-input: #1a1a2e;
    --accent: #00d4aa;
    --accent-dark: #00b894;
    --text: #e0e0e0;
    --text-muted: #888;
    --text-dim: #666;
    --success: #00d4aa;
    --warning: #f0c040;
    --danger: #ff6b6b;
    --border: #2a2a4e;
    --shadow: rgba(0, 0, 0, 0.3);
}

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

#app {
    min-height: 100vh;
}

/* ============================================================================
   App Layout
   ============================================================================ */

.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 220px;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.sidebar-header {
    padding: 20px 16px;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h1 {
    font-size: 17px;
    color: var(--accent);
    margin: 0 0 6px 0;
    line-height: 1.2;
    white-space: nowrap;
}

.user-badge {
    font-size: 12px;
    color: var(--text-muted);
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-type-badge {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    margin-top: 4px;
    display: inline-block;
}

.user-type-badge.admin {
    background: var(--accent);
    color: var(--bg-dark);
}

.user-type-badge.viewer {
    background: rgba(100, 149, 237, 0.2);
    color: #6495ed;
}

/* Shared user notice for empty state */
.shared-user-notice {
    text-align: center;
    padding: 60px 20px;
    background: var(--bg-card);
    border-radius: 12px;
    margin: 20px 0;
}

.shared-user-notice .notice-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.shared-user-notice h3 {
    color: var(--text);
    margin-bottom: 8px;
}

.shared-user-notice p {
    color: var(--text-muted);
    max-width: 400px;
    margin: 0 auto;
}

/* Shared by badge for device cards */
.shared-by-badge {
    font-size: 11px;
    color: var(--text-dim);
    background: var(--bg-hover);
    padding: 2px 8px;
    border-radius: 4px;
    margin-top: 4px;
}

.nav-menu {
    list-style: none;
    padding: 12px 0;
    flex: 1;
}

.nav-menu li {
    padding: 12px 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-muted);
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.nav-menu li:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.nav-menu li.active {
    background: var(--bg-hover);
    color: var(--accent);
    border-left-color: var(--accent);
}

.nav-icon {
    font-size: 16px;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
}

.license-info {
    font-size: 11px;
    color: var(--text-dim);
    margin-bottom: 10px;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    margin-bottom: 10px;
    padding: 6px 10px;
    background: var(--bg-hover);
    border-radius: 6px;
}

.connection-status .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.connection-status .status-dot.online {
    background: var(--success);
    box-shadow: 0 0 6px var(--success);
}

.connection-status .status-dot.offline {
    background: var(--danger);
    animation: blink 1s infinite;
}

.connection-status .status-text {
    color: var(--text-muted);
}

.main-content {
    flex: 1;
    margin-left: 220px;
    padding: 24px;
    background: var(--bg-dark);
    min-height: 100vh;
}

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

.content-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.content-header h2 {
    font-size: 24px;
    font-weight: 600;
    color: var(--text);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
}

.search-input {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 8px 14px;
    border-radius: 6px;
    color: var(--text);
    font-size: 14px;
    min-width: 200px;
}

.search-input:focus {
    outline: none;
    border-color: var(--accent);
}

/* ============================================================================
   Filter Bar
   ============================================================================ */

.filter-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    padding: 12px 16px;
    background: var(--bg-card);
    border-radius: 8px;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.filter-btn:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.filter-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--bg-dark);
}

.sort-group select {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
}

.sort-btn {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.view-toggle {
    display: flex;
    gap: 4px;
    margin-left: auto;
}

.view-toggle button {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 6px 10px;
    cursor: pointer;
    font-size: 14px;
}

.view-toggle button:first-child {
    border-radius: 4px 0 0 4px;
}

.view-toggle button:last-child {
    border-radius: 0 4px 4px 0;
}

.view-toggle button.active {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--bg-dark);
}

/* ============================================================================
   Device Grid
   ============================================================================ */

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

.device-card {
    background: var(--bg-card);
    border-radius: 10px;
    border: 1px solid var(--border);
    overflow: hidden;
    transition: all 0.2s;
    cursor: pointer;
}

.device-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 20px var(--shadow);
}

.device-card.dragging {
    opacity: 0.5;
    transform: scale(0.98);
}

.device-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-dot.online {
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
}

.status-dot.offline {
    background: var(--text-dim);
}

.device-card-header .device-name {
    flex: 1;
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.device-badges {
    display: flex;
    gap: 6px;
}

.badge {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 500;
}

.badge.live {
    background: rgba(255, 107, 107, 0.2);
    color: var(--danger);
}

.badge.recording {
    background: rgba(255, 68, 68, 0.25);
    color: #ff4444;
    animation: blink 1s ease-in-out infinite;
}

.badge.gps {
    background: rgba(0, 212, 170, 0.2);
    color: var(--accent);
}

.badge.gps.clickable {
    cursor: pointer;
    transition: all 0.2s ease;
}

.badge.gps.clickable:hover {
    background: rgba(0, 212, 170, 0.4);
    transform: scale(1.1);
}

.badge.used {
    background: rgba(136, 136, 136, 0.2);
    color: var(--text-muted);
}

/* Device card recording state */
.device-card.recording {
    border-color: #ff4444;
    box-shadow: 0 0 8px rgba(255, 68, 68, 0.3);
}

/* Table row recording state */
tr.recording {
    background: rgba(255, 68, 68, 0.05);
}

.device-card-body {
    padding: 14px 16px;
}

.device-serial {
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.device-model {
    font-size: 12px;
    color: var(--text-dim);
    margin-bottom: 8px;
}

.device-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
}

.device-meta .last-seen {
    color: var(--text-dim);
}

.device-card-actions {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    background: var(--bg-hover);
}

.device-card-actions .btn {
    flex: 1;
}

/* ============================================================================
   Device Table
   ============================================================================ */

.table-container {
    background: var(--bg-card);
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.devices-table {
    width: 100%;
    border-collapse: collapse;
}

.devices-table th {
    background: var(--bg-hover);
    padding: 12px 16px;
    text-align: left;
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}

.devices-table th.sortable {
    cursor: pointer;
}

.devices-table th.sortable:hover {
    color: var(--accent);
}

.devices-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.devices-table tr:last-child td {
    border-bottom: none;
}

.devices-table tr:hover {
    background: var(--bg-hover);
}

.devices-table tr.dragging {
    opacity: 0.5;
}

.devices-table td.mono {
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 12px;
    color: var(--text-muted);
}

.devices-table td.actions {
    display: flex;
    gap: 6px;
}

/* ============================================================================
   Live View
   ============================================================================ */

.liveview-container {
    display: flex;
    gap: 20px;
    height: calc(100vh - 140px);
}

.liveview-sidebar {
    width: 240px;
    background: var(--bg-card);
    border-radius: 10px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.liveview-sidebar h4 {
    font-size: 14px;
    margin-bottom: 8px;
    color: var(--accent);
}

.liveview-sidebar .hint {
    font-size: 11px;
    color: var(--text-dim);
    margin-bottom: 16px;
}

.camera-list {
    flex: 1;
    overflow-y: auto;
}

.camera-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: var(--bg-hover);
    border-radius: 6px;
    margin-bottom: 6px;
    cursor: grab;
    transition: all 0.2s;
}

.camera-item:hover {
    background: var(--bg-input);
}

.camera-item.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

/* No longer graying out in-use items */
.camera-item .badge.used {
    background: rgba(0, 212, 170, 0.2);
    color: var(--accent);
    font-size: 9px;
    padding: 2px 5px;
}

.camera-item .camera-name {
    flex: 1;
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.camera-info-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 12px;
    padding: 2px 4px;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.camera-info-btn:hover {
    opacity: 1;
}

.liveview-grid {
    flex: 1;
    display: grid;
    gap: 12px;
    height: 100%;
}

.liveview-grid.grid-1 {
    grid-template-columns: 1fr;
}

.liveview-grid.grid-4 {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
}

.liveview-grid.grid-6 {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
}

.liveview-grid.grid-9 {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
}

.liveview-grid.grid-16 {
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
}

.liveview-slot {
    background: var(--bg-card);
    border-radius: 10px;
    border: 2px dashed var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.2s;
}

.liveview-slot.empty {
    justify-content: center;
    align-items: center;
}

.liveview-slot.occupied {
    border-style: solid;
}

.liveview-slot.drag-over {
    border-color: var(--accent);
    background: rgba(0, 212, 170, 0.1);
}

.slot-placeholder {
    text-align: center;
    color: var(--text-dim);
}

.slot-placeholder .drop-icon {
    font-size: 32px;
    opacity: 0.5;
    display: block;
    margin-bottom: 8px;
}

.slot-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: var(--bg-hover);
    border-bottom: 1px solid var(--border);
    gap: 8px;
}

.slot-title {
    font-size: 13px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.slot-indicators {
    display: flex;
    align-items: center;
    gap: 8px;
}

.recording-indicator {
    font-size: 10px;
    color: #ff4444;
    font-weight: 600;
    background: rgba(255, 68, 68, 0.15);
    padding: 2px 6px;
    border-radius: 4px;
    animation: blink 1s ease-in-out infinite;
}

.live-indicator {
    font-size: 10px;
    color: #ff4444;
    font-weight: 600;
    animation: blink 1s ease-in-out infinite;
}

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

.liveview-slot.streaming {
    border-color: var(--accent);
    box-shadow: 0 0 10px rgba(0, 212, 170, 0.3);
}

.slot-header-buttons {
    display: flex;
    align-items: center;
    gap: 4px;
}

.slot-controls-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 14px;
    cursor: pointer;
    padding: 2px 4px;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.slot-controls-btn:hover {
    opacity: 1;
    color: var(--accent);
}

.slot-info {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 14px;
    cursor: pointer;
    padding: 2px 4px;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.slot-info:hover {
    opacity: 1;
}

.slot-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    padding: 0 4px;
}

.slot-remove:hover {
    color: var(--danger);
}

.slot-video {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #000;
    position: relative;
}

/* Recording overlay on video */
.recording-overlay {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(255, 0, 0, 0.9);
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 4px;
    animation: blink 1s ease-in-out infinite;
    z-index: 20;
}

/* Viewer count overlay on video */
.viewer-overlay {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    font-size: 11px;
    font-weight: 500;
    padding: 4px 8px;
    border-radius: 4px;
    z-index: 20;
}

/* Viewer count in slot header */
.viewer-count {
    font-size: 10px;
    color: var(--accent);
    background: rgba(0, 212, 170, 0.15);
    padding: 2px 6px;
    border-radius: 4px;
}

.video-placeholder {
    text-align: center;
    color: var(--text-dim);
}

.video-placeholder .play-icon {
    font-size: 48px;
    cursor: pointer;
    display: block;
    margin-bottom: 8px;
    transition: all 0.2s;
}

.video-placeholder .play-icon:hover {
    color: var(--accent);
    transform: scale(1.1);
}

.video-feed {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
    position: relative;
    z-index: 1;
}

/* Audio Controls Overlay */
.audio-controls {
    position: absolute;
    bottom: 30px;
    left: 8px;
    right: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(0, 0, 0, 0.85);
    padding: 6px 8px;
    border-radius: 6px;
    z-index: 15;
}

.audio-btn {
    background: transparent;
    border: none;
    font-size: 14px;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    transition: all 0.2s;
    color: rgba(255, 255, 255, 0.8);
    min-width: 28px;
    text-align: center;
    line-height: 1;
}

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

.audio-btn.unmuted {
    color: var(--success);
    background: rgba(0, 212, 170, 0.2);
}

.audio-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.vu-meter {
    flex: 1;
    height: 8px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    overflow: hidden;
    min-width: 60px;
}

.vu-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(to right, #00d4aa, #00d4aa 60%, #f0c040 75%, #ff6b6b 90%);
    border-radius: 4px;
    transition: width 0.05s ease-out;
}

.vu-db {
    font-size: 10px;
    color: #888;
    min-width: 42px;
    text-align: right;
    font-family: monospace;
}

.video-error {
    color: var(--danger);
    text-align: center;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.video-error .icon {
    font-size: 32px;
    margin-bottom: 10px;
}

.video-error .error-detail {
    font-size: 11px;
    color: var(--text-dim);
    margin: 8px 0;
}

.video-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    background: rgba(0, 0, 0, 0.3);
}

.video-loading .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 12px;
}

.video-loading p {
    font-size: 13px;
    animation: pulse 1.5s ease-in-out infinite;
}

/* Loading overlay - positioned on top of video element */
.video-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    color: var(--text-muted);
    z-index: 5;
    transition: opacity 0.3s ease;
}

.video-loading-overlay .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 12px;
}

.video-loading-overlay p {
    font-size: 13px;
    animation: pulse 1.5s ease-in-out infinite;
}

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

.slot-controls {
    display: flex;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-hover);
    justify-content: center;
}

/* ============================================================================
   Device Detail
   ============================================================================ */

.device-detail-container {
    height: calc(100vh - 200px);
    background: var(--bg-card);
    border-radius: 10px;
    overflow: auto;
    padding: 24px;
}

.device-detail-content {
    display: grid;
    gap: 24px;
    max-width: 900px;
    margin: 0 auto;
}

.device-info-card,
.device-actions-card {
    background: var(--bg-hover);
    border-radius: 10px;
    padding: 20px;
}

.device-info-card h3,
.device-actions-card h3 {
    font-size: 16px;
    margin-bottom: 16px;
    color: var(--text);
}

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

.info-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

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

.info-item span {
    font-size: 14px;
    color: var(--text);
}

.info-item .status-text.online {
    color: var(--success);
}

.device-actions-grid {
    display: grid;
    gap: 12px;
}

.device-action-btn {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 16px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    color: var(--text);
    transition: all 0.2s;
}

.device-action-btn:hover {
    border-color: var(--accent);
    background: rgba(0, 212, 170, 0.05);
}

.device-action-btn.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--bg);
}

.device-action-btn.primary:hover {
    background: var(--accent-hover);
}

.device-action-btn.primary .hint {
    color: rgba(0, 0, 0, 0.6);
}

.device-action-btn .icon {
    font-size: 24px;
}

.device-action-btn .label {
    font-size: 14px;
    font-weight: 500;
}

.device-action-btn .hint {
    font-size: 12px;
    color: var(--text-muted);
}

/* Device View Tabs */
.device-view-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    background: var(--bg-card);
    padding: 6px;
    border-radius: 8px;
    width: fit-content;
}

.tab-btn {
    padding: 8px 16px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
    text-decoration: none;
}

.tab-btn:hover {
    background: var(--bg-hover);
    color: var(--text);
}

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

.tab-btn.external {
    margin-left: auto;
    color: var(--text-dim);
}

.tab-btn.external:hover {
    color: var(--accent);
}

.tab-btn.external.primary {
    background: var(--accent);
    color: var(--bg);
    border-color: var(--accent);
}

.tab-btn.external.primary:hover {
    background: var(--accent-hover);
}

.device-status-iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: #fff;
}

/* Iframe loading state */
#iframeContainer {
    position: relative;
    margin: -24px;
    width: calc(100% + 48px);
    height: calc(100% + 48px);
}

#iframeContainer.iframe-loading .device-status-iframe {
    opacity: 0.3;
}

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    z-index: 10;
}

.loading-overlay p {
    margin-top: 16px;
    color: var(--text-muted);
}

.device-header-badges {
    display: flex;
    gap: 10px;
    align-items: center;
}

.status-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.status-badge.online {
    background: rgba(0, 212, 170, 0.2);
    color: var(--success);
}

.status-badge.offline {
    background: rgba(136, 136, 136, 0.2);
    color: var(--text-muted);
}

.offline-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: var(--text-muted);
}

.offline-message .icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.offline-message h3 {
    font-size: 20px;
    margin-bottom: 8px;
    color: var(--text);
}

.device-info-summary {
    margin-top: 24px;
    text-align: left;
    background: var(--bg-hover);
    padding: 16px 24px;
    border-radius: 8px;
}

.device-info-summary p {
    margin: 8px 0;
}

.iframe-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: var(--text-muted);
}

.iframe-error .icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.iframe-error h3 {
    margin-bottom: 8px;
    color: var(--text);
}

.iframe-error p {
    margin-bottom: 20px;
}

.error-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.iframe-warning {
    padding: 10px 16px;
    text-align: center;
    font-size: 12px;
    color: var(--warning);
    background: rgba(255, 193, 7, 0.1);
    border: 1px solid rgba(255, 193, 7, 0.3);
    border-radius: 6px;
    margin-bottom: 12px;
}

.iframe-warning a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}

.iframe-warning a:hover {
    text-decoration: underline;
}

.iframe-hint {
    padding: 8px 16px;
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    background: var(--bg-hover);
    border-top: 1px solid var(--border);
}

.iframe-hint a {
    color: var(--accent);
    text-decoration: none;
}

.iframe-hint a:hover {
    text-decoration: underline;
}

/* ============================================================================
   Map View
   ============================================================================ */

.map-layout {
    display: flex;
    height: calc(100vh - 140px);
    gap: 16px;
}

.map-sidebar {
    width: 300px;
    background: var(--bg-card);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.map-sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.map-sidebar-header h3 {
    margin: 0;
    font-size: 14px;
}

.live-gps-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    cursor: pointer;
}

.live-gps-toggle input {
    cursor: pointer;
}

.map-device-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.map-device-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--bg-hover);
    border-radius: 6px;
    margin-bottom: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.map-device-item:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
}

.map-device-item.selected {
    background: rgba(0, 210, 180, 0.15);
    border: 1px solid var(--accent);
}

.map-device-item.offline {
    opacity: 0.6;
}

.map-device-item .device-info {
    flex: 1;
    min-width: 0;
}

.map-device-item .device-name {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.map-device-item .device-coords {
    font-size: 10px;
    color: var(--text-dim);
    font-family: monospace;
}

.selected-device-info {
    padding: 16px;
    border-top: 1px solid var(--border);
    background: var(--bg-hover);
}

.selected-device-info h4 {
    margin: 0 0 12px 0;
    font-size: 14px;
    color: var(--accent);
}

.selected-device-info .device-details {
    font-size: 12px;
    margin-bottom: 12px;
}

.selected-device-info .device-details p {
    margin: 4px 0;
}

.selected-device-info .device-actions {
    display: flex;
    gap: 8px;
}

.map-container-wrapper {
    flex: 1;
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    min-height: 400px;
}

.leaflet-map {
    width: 100%;
    height: 100%;
    min-height: 400px;
    background: #1a1a2e;
}

.live-gps-indicator {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(0, 0, 0, 0.8);
    color: var(--success);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 1000;
}

.live-gps-indicator .pulse {
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse-scale 1.5s ease-in-out infinite;
}

/* Map Toolbar */
.map-toolbar {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 1000;
    display: flex;
    gap: 8px;
    align-items: center;
}

.map-layer-select {
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 12px;
    cursor: pointer;
}

.map-layer-select:hover {
    border-color: var(--accent);
}

.map-toolbar-btn {
    background: rgba(0, 0, 0, 0.8);
    color: #4285f4;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 11px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}

.map-toolbar-btn:hover {
    background: rgba(0, 0, 0, 0.9);
    border-color: var(--accent);
}

@keyframes pulse-scale {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.2); }
}

/* Custom map markers */
.custom-marker {
    background: none;
    border: none;
}

.map-marker {
    width: 36px;
    height: 36px;
    background: var(--bg-card);
    border: 3px solid var(--success);
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.map-marker.offline {
    border-color: var(--text-dim);
    opacity: 0.7;
}

.map-marker.selected {
    border-color: var(--accent);
    background: rgba(0, 210, 180, 0.2);
    transform: rotate(-45deg) scale(1.2);
}

.map-marker .marker-icon {
    transform: rotate(45deg);
    font-size: 16px;
}

/* Leaflet popup customization */
.leaflet-popup-content-wrapper {
    background: var(--bg-card);
    color: var(--text);
    border-radius: 8px;
}

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

/* Ensure Leaflet popup shows on top */
.leaflet-popup {
    z-index: 1000 !important;
}

.leaflet-popup-content-wrapper {
    background: var(--bg-card);
    color: var(--text);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.leaflet-popup-content {
    margin: 12px;
}

.map-popup {
    padding: 4px;
    font-size: 13px;
}

.map-popup button,
.map-popup-btn {
    background: var(--bg-hover);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
}

.map-popup-btn.primary {
    background: var(--accent);
    color: var(--bg);
    border-color: var(--accent);
}

.map-popup-btn:hover {
    opacity: 0.8;
}

/* Map Video Modal */
.map-video-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.map-video-modal-content {
    background: var(--bg-card);
    border-radius: 12px;
    overflow: hidden;
    width: 480px;
    max-width: 90vw;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.map-video-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-hover);
    border-bottom: 1px solid var(--border);
}

.map-video-header .device-name {
    font-weight: 600;
    font-size: 14px;
}

.map-video-header .modal-actions {
    display: flex;
    gap: 8px;
}

.map-video-container {
    position: relative;
    background: #000;
    aspect-ratio: 16/9;
}

.map-video-container video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.map-video-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.8);
    color: var(--text-muted);
}

.map-video-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    background: var(--bg-hover);
    border-top: 1px solid var(--border);
    font-size: 12px;
}

.map-video-footer .status-indicator {
    color: var(--text-muted);
}

.map-video-footer .coords {
    color: var(--text-dim);
    font-family: monospace;
}

.gps-count {
    font-size: 13px;
    color: var(--text-muted);
}

.gps-link {
    color: var(--accent);
    text-decoration: none;
}

.gps-link:hover {
    text-decoration: underline;
}

.coords {
    font-family: monospace;
    font-size: 11px;
    color: var(--text-dim);
}

/* ============================================================================
   Users & Settings Views
   ============================================================================ */

.users-container,
.settings-container {
    max-width: 800px;
}

/* ============================================================================
   Stats View
   ============================================================================ */

.stats-container {
    max-width: 1000px;
}

.stats-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stats-card {
    background: var(--bg-card);
    border-radius: 10px;
    padding: 20px;
    text-align: center;
}

.stats-card .stats-value {
    font-size: 36px;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 4px;
}

.stats-card .stats-label {
    font-size: 14px;
    color: var(--text-muted);
}

.stats-section {
    background: var(--bg-card);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
}

.stats-section h3 {
    font-size: 16px;
    margin-bottom: 16px;
    color: var(--accent);
}

.stats-devices-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.stats-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.stats-empty .icon {
    font-size: 48px;
    display: block;
    margin-bottom: 12px;
}

.stats-empty .hint {
    font-size: 13px;
    color: var(--text-dim);
    margin-top: 8px;
}

.stats-device-card {
    background: var(--bg-hover);
    border-radius: 8px;
    padding: 16px;
    border-left: 3px solid var(--border);
}

.stats-device-card.has-viewers {
    border-left-color: var(--accent);
}

.stats-device-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.stats-device-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.stats-device-name {
    font-weight: 600;
    color: var(--text);
}

.stats-device-serial {
    font-family: monospace;
    font-size: 12px;
    color: var(--text-muted);
}

.stats-viewer-count .viewer-badge {
    background: var(--accent);
    color: var(--bg-dark);
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 13px;
}

.stats-viewers-list {
    background: var(--bg-dark);
    border-radius: 6px;
    padding: 12px;
    margin-top: 12px;
}

.stats-viewers-header {
    display: grid;
    grid-template-columns: 1fr 80px 80px;
    gap: 8px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
}

.stats-viewer-row {
    display: grid;
    grid-template-columns: 1fr 80px 80px;
    gap: 8px;
    font-size: 12px;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
}

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

.viewer-id {
    font-family: monospace;
    font-size: 11px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.viewer-status {
    color: var(--text-dim);
    font-size: 11px;
}

.viewer-status.connected {
    color: var(--success);
}

.viewer-duration {
    color: var(--text-muted);
    font-size: 11px;
}

.stats-device-meta {
    margin-top: 12px;
    font-size: 12px;
    color: var(--text-dim);
}

.user-card,
.settings-section {
    background: var(--bg-card);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
}

.user-card h3,
.settings-section h3 {
    font-size: 16px;
    margin-bottom: 16px;
    color: var(--accent);
}

.account-info {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.account-info .info-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

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

.account-info .label {
    color: var(--text-muted);
}

.account-info .value {
    font-weight: 500;
}

.account-info .status-active {
    color: var(--success);
}

.license-stats {
    display: flex;
    justify-content: space-around;
    margin-bottom: 16px;
}

.stat-item {
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 28px;
    font-weight: 600;
    color: var(--accent);
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
}

.license-bar {
    height: 8px;
    background: var(--bg-hover);
    border-radius: 4px;
    overflow: hidden;
}

.license-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 4px;
    transition: width 0.3s;
}

/* ============================================================================
   Shares View
   ============================================================================ */

.shares-container {
    max-width: 900px;
}

/* Shares Tabs */
.shares-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-hover);
    border-radius: 10px;
    padding: 4px;
    margin-bottom: 20px;
}

.shares-tab {
    flex: 1;
    padding: 14px 20px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.shares-tab:hover:not(.active) {
    color: var(--text);
    background: rgba(255, 255, 255, 0.05);
}

.shares-tab.active {
    background: var(--bg-card);
    color: var(--accent);
}

.shares-tab .tab-count {
    background: rgba(0, 212, 170, 0.2);
    color: var(--accent);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
}

.shares-tab.active .tab-count {
    background: var(--accent);
    color: var(--bg-dark);
}

/* My Devices Shares Tab */
.my-devices-shares {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.device-share-card {
    background: var(--bg-card);
    border-radius: 12px;
    overflow: hidden;
}

.device-share-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: var(--bg-hover);
    border-bottom: 1px solid var(--border);
}

.device-share-header .device-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.device-share-header .device-name {
    font-weight: 600;
    font-size: 15px;
    color: var(--text);
}

.device-share-header .device-serial {
    font-size: 12px;
    color: var(--text-muted);
    font-family: monospace;
}

.device-share-actions {
    display: flex;
    gap: 8px;
}

.device-shares-content {
    padding: 16px;
}

.shares-loading,
.shares-not-loaded {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
}

.no-shares-message {
    text-align: center;
    padding: 20px;
    color: var(--text-dim);
    font-size: 14px;
}

.no-shares-message span {
    font-size: 24px;
    display: block;
    margin-bottom: 8px;
}

/* Share Sections (Accepted, Pending, Rejected) */
.share-section {
    margin-bottom: 16px;
}

.share-section:last-child {
    margin-bottom: 0;
}

.share-section-header {
    font-size: 12px;
    font-weight: 600;
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.share-section-header.accepted {
    background: rgba(0, 212, 170, 0.1);
    color: var(--accent);
}

.share-section-header.pending {
    background: rgba(240, 192, 64, 0.1);
    color: #f0c040;
}

.share-section-header.rejected {
    background: rgba(255, 107, 107, 0.1);
    color: #ff6b6b;
}

.share-section-header .count {
    background: currentColor;
    color: var(--bg-dark);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
}

/* Invite Items */
.invite-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: var(--bg-hover);
    border-radius: 6px;
    margin-bottom: 6px;
}

.invite-item:last-child {
    margin-bottom: 0;
}

.invite-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.invite-email {
    font-size: 14px;
    color: var(--text);
}

/* Shared With Me Tab */
.shared-with-me-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.sharer-group {
    background: var(--bg-card);
    border-radius: 12px;
    overflow: hidden;
}

.sharer-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--bg-hover);
    border-bottom: 1px solid var(--border);
}

.sharer-icon {
    font-size: 24px;
}

.sharer-email {
    font-weight: 600;
    font-size: 15px;
    color: var(--text);
    flex: 1;
}

.sharer-count {
    font-size: 12px;
    color: var(--text-muted);
    background: var(--bg-hover);
    padding: 4px 10px;
    border-radius: 12px;
}

.shared-devices {
    padding: 12px;
}

.shared-path-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: var(--bg-hover);
    border-radius: 8px;
    margin-bottom: 8px;
}

.shared-path-item:last-child {
    margin-bottom: 0;
}

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

.status-indicator {
    font-size: 18px;
}

.shared-device-name {
    font-weight: 600;
    color: var(--text);
}

.shared-device-meta {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    gap: 8px;
}

.shared-device-meta .serial {
    font-family: monospace;
}

.shared-status-badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.shared-status-badge.accepted {
    background: rgba(0, 212, 170, 0.15);
    color: var(--accent);
}

.shared-status-badge.pending {
    background: rgba(240, 192, 64, 0.15);
    color: #f0c040;
}

.shared-status-badge.rejected {
    background: rgba(255, 107, 107, 0.15);
    color: #ff6b6b;
}

/* Share Modal */
.share-modal-device {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--bg-hover);
    border-radius: 8px;
    margin-bottom: 16px;
    font-weight: 600;
}

.share-modal-device .icon {
    font-size: 20px;
}

/* By Email Tab Styles */
.by-email-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.email-controls {
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
}

.email-search {
    flex: 1;
    min-width: 200px;
    position: relative;
}

.email-search input {
    width: 100%;
    padding: 10px 36px 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
}

.email-search input:focus {
    outline: none;
    border-color: var(--accent);
}

.email-search .search-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 8px;
    font-size: 14px;
}

.email-search .search-clear:hover {
    color: var(--text);
}

.email-sort {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sort-label {
    font-size: 13px;
    color: var(--text-muted);
}

.sort-btn {
    padding: 6px 12px;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.sort-btn:hover {
    background: var(--bg-card);
    color: var(--text);
}

.sort-btn.active {
    background: var(--accent);
    color: var(--bg-dark);
    border-color: var(--accent);
}

.email-results-count {
    font-size: 13px;
    color: var(--text-muted);
}

.no-results {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-dim);
}

.no-results span {
    font-size: 32px;
    display: block;
    margin-bottom: 12px;
}

.email-shares-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.email-share-card {
    background: var(--bg-card);
    border-radius: 12px;
    overflow: hidden;
}

.email-share-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: var(--bg-hover);
    border-bottom: 1px solid var(--border);
}

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

.email-icon {
    font-size: 24px;
}

.email-address {
    font-weight: 600;
    font-size: 15px;
    color: var(--text);
}

.email-stats {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

.email-stats .stat {
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 4px;
}

.email-stats .stat.accepted {
    background: rgba(0, 212, 170, 0.15);
    color: var(--accent);
}

.email-stats .stat.pending {
    background: rgba(240, 192, 64, 0.15);
    color: #f0c040;
}

.email-stats .stat.rejected {
    background: rgba(255, 107, 107, 0.15);
    color: #ff6b6b;
}

.email-stats .stat.total {
    background: var(--bg-hover);
    color: var(--text-muted);
}

.email-actions {
    display: flex;
    gap: 8px;
}

.email-devices-list {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.email-device-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: var(--bg-hover);
    border-radius: 6px;
}

.email-device-item .device-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.email-device-item .status-indicator {
    font-size: 14px;
}

.email-device-item .device-name {
    font-weight: 500;
    color: var(--text);
}

.email-device-item .device-serial {
    font-size: 11px;
    color: var(--text-muted);
    font-family: monospace;
    margin-left: 8px;
}

/* Legacy shares list styles (kept for backward compatibility) */
.shares-list {
    background: var(--bg-card);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 20px;
}

.shares-header {
    display: grid;
    grid-template-columns: 2fr 2fr 2fr 80px;
    gap: 16px;
    padding: 12px 16px;
    background: var(--bg-hover);
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

.share-item {
    display: grid;
    grid-template-columns: 2fr 2fr 2fr 80px;
    gap: 16px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    align-items: center;
}

.share-item:last-child {
    border-bottom: none;
}

.share-item .col-device {
    display: flex;
    align-items: center;
    gap: 8px;
}

.perm-badge {
    display: inline-block;
    padding: 2px 8px;
    background: rgba(0, 212, 170, 0.15);
    color: var(--accent);
    border-radius: 4px;
    font-size: 11px;
    margin-right: 4px;
}

.shares-info-section {
    background: var(--bg-card);
    border-radius: 10px;
    padding: 20px;
}

.shares-info-section h3 {
    color: var(--accent);
    margin-bottom: 12px;
}

.shares-info-section ul {
    margin: 12px 0 12px 20px;
    color: var(--text-muted);
}

.shares-info-section li {
    margin: 6px 0;
}

.hint {
    color: var(--text-dim);
    font-size: 13px;
    margin-top: 8px;
}

/* ============================================================================
   Modal
   ============================================================================ */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background: var(--bg-card);
    border-radius: 12px;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.modal-header h3 {
    font-size: 18px;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    padding: 4px 8px;
    border-radius: 4px;
}

.modal-close:hover {
    color: var(--text);
    background: var(--bg-hover);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-body .form-group {
    margin-bottom: 16px;
}

.modal-body .form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    color: var(--text-muted);
}

.modal-body select,
.modal-body input[type="email"],
.modal-body input[type="text"] {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 14px;
}

.modal-body select:focus,
.modal-body input:focus {
    outline: none;
    border-color: var(--accent);
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px !important;
    color: var(--text) !important;
}

.checkbox-group input[type="checkbox"] {
    width: 16px;
    height: 16px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}

/* Camera Controls Modal */
.camera-controls-modal {
    max-width: 420px;
}

.camera-controls-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.device-status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: var(--bg-hover);
    border-radius: 8px;
}

.device-status-bar .device-name {
    font-weight: 600;
    color: var(--text);
}

.device-status-bar .device-serial {
    font-family: monospace;
    font-size: 12px;
    color: var(--text-muted);
}

.control-section {
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.control-section:last-child {
    border-bottom: none;
}

.control-section.recording-section.is-recording {
    background: rgba(255, 68, 68, 0.1);
    padding: 12px;
    border-radius: 8px;
    margin: -4px;
}

.control-label {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.recording-badge {
    font-size: 10px;
    color: #ff4444;
    background: rgba(255, 68, 68, 0.15);
    padding: 2px 6px;
    border-radius: 4px;
    animation: blink 1s ease-in-out infinite;
}

.recording-duration {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 8px;
}

.control-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.control-buttons.camera-buttons,
.control-buttons.rotation-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.control-buttons .btn {
    flex: none;
}

/* Zoom control */
.zoom-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

.zoom-control input[type="range"] {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: var(--bg-hover);
    border-radius: 3px;
    outline: none;
}

.zoom-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
}

.zoom-control input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

/* Controls loading/error states */
.controls-loading,
.controls-error {
    text-align: center;
    padding: 30px 20px;
}

.controls-loading .spinner {
    margin: 0 auto 12px;
}

.controls-error {
    color: var(--text-muted);
}

.controls-error p {
    margin-bottom: 8px;
}

.controls-error .error-detail {
    font-size: 12px;
    color: #ff6b6b;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.setting-item:last-child {
    border-bottom: none;
}

.setting-item label {
    color: var(--text-muted);
    font-size: 14px;
}

.setting-value {
    font-family: monospace;
    font-size: 13px;
}

.setting-item select {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 6px 10px;
    border-radius: 4px;
}

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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

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

.btn-primary:hover {
    background: var(--accent-dark);
}

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

.btn-secondary:hover {
    background: var(--bg-input);
}

.btn-success {
    background: var(--success);
    color: var(--bg-dark);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

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

.btn-xs {
    padding: 4px 8px;
    font-size: 11px;
}

.btn-block {
    width: 100%;
}

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

.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, var(--bg-dark) 0%, #1a1a2e 100%);
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg-card);
    border-radius: 16px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-header h1 {
    font-size: 28px;
    color: var(--accent);
    margin-bottom: 8px;
}

.login-header p {
    color: var(--text-muted);
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    color: var(--text-muted);
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
}

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

.form-hint {
    font-size: 12px;
    color: var(--text-dim);
    margin-top: 6px;
}

.error-message {
    background: rgba(255, 107, 107, 0.1);
    border: 1px solid var(--danger);
    color: var(--danger);
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 20px;
    font-size: 13px;
}

/* ============================================================================
   Toast Notifications
   ============================================================================ */

.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 14px 24px;
    border-radius: 8px;
    background: var(--bg-card);
    color: var(--text);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s;
    z-index: 1000;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast-success {
    border-left: 4px solid var(--success);
}

.toast-error {
    border-left: 4px solid var(--danger);
}

.toast-info {
    border-left: 4px solid var(--accent);
}

/* ============================================================================
   Loading Overlay
   ============================================================================ */

#loadingOverlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(13, 21, 40, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Loading State */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-muted);
    min-height: 300px;
}

.loading-state .spinner {
    margin-bottom: 16px;
}

.loading-state p {
    font-size: 14px;
}

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

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state .icon {
    font-size: 64px;
    display: block;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state p {
    font-size: 16px;
}

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

/* ============================================================================
   Grid Select
   ============================================================================ */

.grid-select {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 14px;
}

/* ============================================================================
   Responsive
   ============================================================================ */

@media (max-width: 1024px) {
    .filter-bar {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .view-toggle {
        margin-left: 0;
        margin-top: 10px;
    }
    
    .liveview-container {
        flex-direction: column;
    }
    
    .liveview-sidebar {
        width: 100%;
        max-height: 200px;
    }
}

/* ============================================================================
   MOBILE RESPONSIVE STYLES
   ============================================================================ */

/* Mobile Menu Toggle Button */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 1001;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--text);
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 2px 8px var(--shadow);
}

.mobile-menu-toggle:active {
    background: var(--bg-hover);
}

/* Mobile Header Bar */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    z-index: 999;
    align-items: center;
    padding: 0 16px 0 60px;
}

.mobile-header h1 {
    font-size: 16px;
    color: var(--accent);
    margin: 0;
}

/* Sidebar Overlay for Mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

.sidebar-overlay.visible {
    display: block;
}

/* Tablet Styles (768px - 1024px) */
@media (max-width: 1024px) and (min-width: 769px) {
    .sidebar {
        width: 180px;
    }
    
    .main-content {
        margin-left: 180px;
    }
    
    .devices-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .liveview-grid.grid-4,
    .liveview-grid.grid-6 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .map-sidebar {
        width: 280px;
    }
}

/* Mobile/Tablet Portrait Styles (< 768px) */
@media (max-width: 768px) {
    /* Show mobile menu button */
    .mobile-menu-toggle {
        display: block;
    }
    
    .mobile-header {
        display: flex;
    }
    
    /* Sidebar becomes slide-out drawer */
    .sidebar {
        width: 280px;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: 4px 0 20px var(--shadow);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    /* Hide text labels in sidebar when collapsed - but show when open on mobile */
    .sidebar.open .sidebar-header h1,
    .sidebar.open .sidebar-header .user-badge,
    .sidebar.open .nav-menu li span,
    .sidebar.open .license-info {
        display: block;
    }
    
    .main-content {
        margin-left: 0;
        padding: 70px 12px 12px 12px;
        width: 100%;
    }
    
    /* Content header adjustments */
    .content-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .content-header h2 {
        font-size: 20px;
    }
    
    .header-actions {
        width: 100%;
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .header-actions .btn {
        flex: 1;
        min-width: 120px;
        justify-content: center;
    }
    
    /* Filter bar mobile */
    .filter-bar {
        flex-direction: column;
        gap: 10px;
    }
    
    .filter-bar .search-box {
        width: 100%;
    }
    
    .filter-bar input[type="text"] {
        width: 100%;
    }
    
    .view-toggle {
        width: 100%;
        justify-content: center;
    }
    
    /* Devices grid - single column */
    .devices-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    /* Device card mobile optimizations */
    .device-card {
        padding: 14px;
    }
    
    .device-card .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .device-card .card-actions {
        width: 100%;
        display: flex;
        gap: 8px;
        margin-top: 8px;
    }
    
    .device-card .card-actions .btn {
        flex: 1;
        padding: 10px;
        font-size: 14px;
    }
    
    /* Live View mobile */
    .liveview-container {
        flex-direction: column;
        height: auto;
        min-height: calc(100vh - 70px);
    }
    
    .liveview-sidebar {
        width: 100%;
        max-height: 150px;
        min-height: 100px;
        order: 2;
        border-right: none;
        border-top: 1px solid var(--border);
    }
    
    .liveview-main {
        order: 1;
        flex: 1;
        min-height: 300px;
    }
    
    .liveview-grid {
        grid-template-columns: 1fr !important;
        gap: 8px;
        padding: 8px;
    }
    
    .liveview-grid.grid-1 {
        grid-template-columns: 1fr !important;
    }
    
    .liveview-grid.grid-4,
    .liveview-grid.grid-6,
    .liveview-grid.grid-9 {
        grid-template-columns: 1fr !important;
    }
    
    .video-slot {
        min-height: 200px;
        aspect-ratio: 16/9;
    }
    
    .video-slot .slot-overlay {
        padding: 8px;
    }
    
    .video-slot .slot-controls {
        gap: 4px;
    }
    
    .video-slot .slot-controls .btn {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    /* Toolbar mobile */
    .liveview-toolbar {
        flex-wrap: wrap;
        gap: 8px;
        padding: 10px;
    }
    
    .liveview-toolbar .grid-select {
        flex: 1;
        min-width: 100px;
    }
    
    /* Map view mobile */
    .map-container {
        flex-direction: column;
        height: auto;
        min-height: calc(100vh - 70px);
    }
    
    .map-sidebar {
        width: 100%;
        max-height: 200px;
        order: 2;
        border-right: none;
        border-top: 1px solid var(--border);
    }
    
    .map-main {
        order: 1;
        flex: 1;
        min-height: 350px;
    }
    
    .leaflet-map {
        min-height: 350px;
    }
    
    /* Map popup mobile */
    .leaflet-popup-content-wrapper {
        max-width: 280px;
    }
    
    .map-popup-btn {
        padding: 8px 14px;
        font-size: 13px;
    }
    
    /* Device detail mobile */
    .device-detail-container {
        flex-direction: column;
    }
    
    .device-detail-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border);
        max-height: none;
    }
    
    .device-detail-main {
        padding: 12px;
    }
    
    .device-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    
    .device-actions .action-btn {
        padding: 14px 10px;
        font-size: 13px;
    }
    
    /* Tab navigation mobile */
    .tab-nav {
        flex-wrap: wrap;
        gap: 4px;
    }
    
    .tab-nav button {
        flex: 1;
        min-width: 80px;
        padding: 10px 8px;
        font-size: 12px;
    }
    
    /* Modal mobile - full screen */
    .modal-overlay {
        padding: 0;
    }
    
    .modal-content,
    .modal {
        width: 100% !important;
        max-width: 100% !important;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        margin: 0;
    }
    
    .modal-header {
        padding: 16px;
        position: sticky;
        top: 0;
        background: var(--bg-card);
        z-index: 10;
    }
    
    .modal-body {
        padding: 16px;
        overflow-y: auto;
        flex: 1;
    }
    
    .modal-footer {
        padding: 16px;
        position: sticky;
        bottom: 0;
        background: var(--bg-card);
    }
    
    /* Map video modal mobile */
    .map-video-modal-content {
        width: 95%;
        max-width: 95%;
        max-height: 90vh;
    }
    
    .map-video-container {
        max-height: 50vh;
    }
    
    /* Form inputs mobile - larger touch targets */
    input[type="text"],
    input[type="password"],
    input[type="email"],
    input[type="search"],
    input[type="number"],
    select,
    textarea {
        padding: 14px 12px;
        font-size: 16px; /* Prevents iOS zoom */
        min-height: 48px;
    }
    
    /* Buttons mobile - larger touch targets */
    .btn {
        padding: 12px 16px;
        font-size: 14px;
        min-height: 44px;
    }
    
    .btn-xs {
        padding: 8px 12px;
        min-height: 36px;
    }
    
    .btn-sm {
        padding: 10px 14px;
        min-height: 40px;
    }
    
    /* Toast notifications mobile */
    .toast {
        left: 12px;
        right: 12px;
        max-width: none;
        bottom: 70px;
    }
    
    /* Tables mobile */
    .data-table {
        display: block;
        overflow-x: auto;
    }
    
    .data-table th,
    .data-table td {
        padding: 10px 8px;
        font-size: 13px;
    }
    
    /* Stats cards mobile */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .stat-card {
        padding: 14px;
    }
    
    .stat-card .value {
        font-size: 24px;
    }
    
    /* Login page mobile */
    .login-container {
        padding: 16px;
    }
    
    .login-card {
        padding: 24px 20px;
        width: 100%;
        max-width: 100%;
    }
    
    /* Device list mobile */
    .device-list {
        gap: 8px;
    }
    
    .device-list-item {
        padding: 12px;
    }
    
    /* Iframe container mobile */
    .iframe-container {
        height: calc(100vh - 200px);
        min-height: 400px;
    }
    
    /* Share modal mobile */
    .share-device-modal .modal-content {
        width: 100%;
    }
}

/* Small phones (< 400px) */
@media (max-width: 400px) {
    .mobile-header h1 {
        font-size: 14px;
    }
    
    .content-header h2 {
        font-size: 18px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .device-actions {
        grid-template-columns: 1fr;
    }
    
    .header-actions .btn {
        min-width: 100%;
    }
    
    .liveview-toolbar {
        flex-direction: column;
    }
    
    .liveview-toolbar > * {
        width: 100%;
    }
}

/* Landscape orientation on mobile */
@media (max-width: 900px) and (orientation: landscape) {
    .main-content {
        padding-top: 60px;
    }
    
    .liveview-container {
        flex-direction: row;
        height: calc(100vh - 60px);
    }
    
    .liveview-sidebar {
        width: 200px;
        max-height: none;
        order: 1;
        border-right: 1px solid var(--border);
        border-top: none;
    }
    
    .liveview-main {
        order: 2;
    }
    
    .liveview-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    .video-slot {
        min-height: 150px;
    }
    
    .map-container {
        flex-direction: row;
        height: calc(100vh - 60px);
    }
    
    .map-sidebar {
        width: 220px;
        max-height: none;
        order: 1;
        border-right: 1px solid var(--border);
        border-top: none;
    }
    
    .map-main {
        order: 2;
    }
}

/* iPad / Tablet specific */
@media (min-width: 768px) and (max-width: 1024px) {
    .devices-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .liveview-grid.grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .liveview-grid.grid-6 {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .liveview-grid.grid-9 {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .nav-menu li {
        padding: 16px 20px;
        min-height: 52px;
    }
    
    .device-card:hover {
        transform: none; /* Disable hover effects */
    }
    
    .btn:hover {
        transform: none;
    }
    
    /* Active states instead of hover */
    .btn:active {
        transform: scale(0.98);
        opacity: 0.9;
    }
    
    .device-card:active {
        transform: scale(0.99);
    }
    
    /* Remove hover-only elements */
    .card-actions-hover {
        opacity: 1;
        visibility: visible;
    }
    
    /* Scrolling improvements */
    .device-list,
    .liveview-sidebar,
    .map-sidebar {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }
    
    /* Disable text selection on interactive elements */
    .btn,
    .nav-menu li,
    .device-card,
    .tab-nav button {
        -webkit-user-select: none;
        user-select: none;
    }
}

/* Safe area insets for notched devices (iPhone X+) */
@supports (padding: max(0px)) {
    .sidebar {
        padding-bottom: max(16px, env(safe-area-inset-bottom));
    }
    
    .main-content {
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }
    
    .mobile-header {
        padding-top: max(0px, env(safe-area-inset-top));
        height: calc(56px + env(safe-area-inset-top));
    }
    
    @media (max-width: 768px) {
        .main-content {
            padding-top: calc(70px + env(safe-area-inset-top));
        }
    }
    
    .toast {
        bottom: max(70px, calc(70px + env(safe-area-inset-bottom)));
    }
}

/* ============================================================================
   Password Reset Flow
   ============================================================================ */

.login-footer {
    margin-top: 24px;
    text-align: center;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.forgot-password-link,
.back-link {
    color: var(--accent);
    text-decoration: none;
    font-size: 14px;
    transition: color 0.2s;
}

.forgot-password-link:hover,
.back-link:hover {
    color: #4ae3c0;
    text-decoration: underline;
}

.help-text {
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 20px;
    line-height: 1.5;
}

.success-message {
    text-align: center;
    padding: 24px;
    margin-bottom: 24px;
}

.success-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 16px;
}

.success-message p {
    color: var(--text);
    margin: 8px 0;
    line-height: 1.6;
}

.success-message p:first-of-type {
    font-size: 16px;
    font-weight: 500;
    color: var(--success);
}

/* Improved form input styling for password reset */
.login-card input::placeholder {
    color: var(--text-muted);
    opacity: 0.7;
}

.login-card input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.login-card button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ============================================================================
   Custom Scrollbar Styling
   ============================================================================ */

/* Webkit browsers (Chrome, Safari, Edge) */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

/* Camera list in live view sidebar */
.camera-list {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.camera-list::-webkit-scrollbar {
    width: 4px;
}

.camera-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

.camera-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.35);
}

/* Table scrollbar */
.device-table-container {
    scrollbar-width: thin;
}

.device-table-container::-webkit-scrollbar {
    height: 6px;
}

/* Sidebar scrollbar */
.liveview-sidebar {
    scrollbar-width: thin;
}

.liveview-sidebar::-webkit-scrollbar {
    width: 4px;
}

/* ============================================================================
   Live View Sidebar Compact Controls
   ============================================================================ */

.liveview-sidebar .camera-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.liveview-sidebar .camera-header h4 {
    margin: 0;
    font-size: 14px;
}

.liveview-sidebar .camera-header .count {
    font-weight: normal;
    color: var(--text-muted);
    font-size: 12px;
}

.sidebar-controls {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
}

.search-input.compact {
    flex: 1;
    padding: 6px 10px;
    font-size: 12px;
    border-radius: 4px;
    min-width: 0;
}

.sort-select.compact {
    padding: 6px 8px;
    font-size: 12px;
    border-radius: 4px;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    color: var(--text);
    cursor: pointer;
    min-width: 70px;
}

.sort-select.compact:focus {
    outline: none;
    border-color: var(--accent);
}

.liveview-sidebar .hint {
    font-size: 11px;
    color: var(--text-muted);
    margin: 0 0 8px 0;
}

/* ============================================================================
   Connection Status Indicator
   ============================================================================ */

#connection-indicator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10000;
    display: none;
}

.connection-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 500;
    animation: slideDown 0.3s ease-out;
}

.connection-indicator.offline {
    background: linear-gradient(135deg, #3d0a0a 0%, #2d0808 100%);
    color: #ff6b6b;
    border-bottom: 2px solid #ff6b6b;
}

.connection-indicator.reconnecting {
    background: linear-gradient(135deg, #3d3a0a 0%, #2d2808 100%);
    color: #f0c040;
    border-bottom: 2px solid #f0c040;
}

.connection-indicator .indicator-icon {
    font-size: 18px;
    animation: pulse 1.5s ease-in-out infinite;
}

.connection-indicator .indicator-text {
    flex: 1;
}

.connection-indicator .indicator-countdown {
    font-size: 12px;
    opacity: 0.8;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Mobile touch drag feedback */
.touch-dragging {
    opacity: 0.6;
    transform: scale(0.95);
    background: var(--accent) !important;
    color: var(--bg) !important;
}

.mobile-hint {
    display: none;
    color: var(--text-muted);
    font-size: 11px;
    margin-top: 4px;
}

@media (hover: none) and (pointer: coarse) {
    .mobile-hint {
        display: block;
    }
}

/* Prevent text selection during touch drag */
.camera-item {
    touch-action: none;
}


/* Online count in sidebar */
.online-count {
    font-size: 11px;
    color: #00d4aa;
    font-weight: normal;
    opacity: 0.9;
}

/* Shares page improvements */
.shares-load-prompt {
    background: var(--bg-hover);
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

.section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.device-share-card.minimal {
    padding: 12px;
}

.device-share-card.minimal .device-shares-content {
    display: none;
}

.more-devices-note {
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
    padding: 8px;
    font-style: italic;
}

.no-devices-message {
    padding: 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

/* Stats page improvements */
.stats-device-badges {
    display: flex;
    gap: 8px;
    align-items: center;
}

.bitrate-badge {
    background: var(--bg-hover);
    color: var(--primary);
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.stats-viewers-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    margin-top: 8px;
}

.stats-viewers-table th {
    text-align: left;
    padding: 8px 12px;
    background: var(--bg-hover);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stats-viewers-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}

.stats-viewers-table tr:last-child td {
    border-bottom: none;
}

.stats-viewers-table tr.viewer-connected {
    background: rgba(0, 212, 170, 0.05);
}

.viewer-user {
    display: flex;
    align-items: center;
    gap: 6px;
}

.user-icon {
    font-size: 14px;
}

.user-name {
    font-weight: 500;
}

.viewer-ip {
    font-family: monospace;
    font-size: 12px;
    color: var(--text-muted);
}

.viewer-bitrate {
    font-family: monospace;
    font-size: 12px;
    color: var(--primary);
}

.status-badge.checking {
    background: rgba(240, 192, 64, 0.2);
    color: #f0c040;
}

.stats-no-viewers {
    padding: 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    font-style: italic;
}

.stats-device-meta {
    display: flex;
    gap: 16px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    margin-top: 8px;
    font-size: 11px;
    color: var(--text-muted);
}

/* Remember me checkbox and invite link */
.remember-me-group {
    margin-bottom: 16px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--primary);
}

.login-divider {
    height: 1px;
    background: var(--border);
    margin: 12px 0;
}

.invite-link {
    display: block;
    color: var(--primary);
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s;
    padding: 10px 16px;
    background: rgba(0, 212, 170, 0.1);
    border-radius: 8px;
    margin-top: 8px;
}

.invite-link:hover {
    color: #fff;
    background: var(--primary);
    text-decoration: none;
}

.login-footer {
    text-align: center;
    margin-top: 20px;
}

.login-footer .forgot-password-link {
    color: var(--primary);
    text-decoration: none;
    font-size: 13px;
}

.login-footer .forgot-password-link:hover {
    text-decoration: underline;
}

/* Direct URL link in device info */
.direct-url-link {
    color: var(--primary);
    text-decoration: none;
    word-break: break-all;
    font-family: monospace;
    font-size: 12px;
}

.direct-url-link:hover {
    text-decoration: underline;
}

/* Map marker recording state */
.map-marker.recording {
    animation: pulse-recording 1.5s ease-in-out infinite;
}

@keyframes pulse-recording {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Video stats bar at bottom of video */
.video-stats-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    background: rgba(0, 0, 0, 0.85);
    padding: 4px 8px;
    font-size: 11px;
    font-family: monospace;
    color: #ccc;
    z-index: 15;
}

.video-stats-bar span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.video-stats-bar span::before {
    content: "|";
    color: #555;
}

.video-stats-bar span:first-child::before {
    content: "";
}
