/* Admin Panel Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* CSS Variables for Theming */
:root {
    --bg-primary: #f5f7fa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f7fafc;
    --text-primary: #2d3748;
    --text-secondary: #4a5568;
    --text-muted: #718096;
    --border-color: #e2e8f0;
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.12);
    --accent-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

[data-theme="dark"] {
    --bg-primary: #111827;
    --bg-secondary: #1f2937;
    --bg-tertiary: #374151;
    --text-primary: #f9fafb;
    --text-secondary: #e5e7eb;
    --text-muted: #9ca3af;
    --border-color: #374151;
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.4);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.5);
    --input-bg: #374151;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--accent-gradient);
    min-height: 100vh;
    color: var(--text-primary);
}

[data-theme="dark"] body {
    background: #111827;
}

.container {
    width: 100%;
    min-height: 100vh;
}

/* Authentication */
.auth-container {
    max-width: 400px;
    margin: 100px auto;
    background: white;
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.auth-container h2 {
    margin-bottom: 30px;
    text-align: center;
    color: #333;
}

#loginForm input {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
}

#loginForm button {
    width: 100%;
    padding: 12px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.3s;
}

#loginForm button:hover {
    background: #5a67d8;
}

.error {
    color: #e53e3e;
    margin-top: 10px;
    font-size: 14px;
}

/* Admin Panel */
#adminPanel {
    background: #f7fafc;
    min-height: 100vh;
}

header {
    background: white;
    padding: 20px 30px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

header h1 {
    color: #667eea;
    font-size: 24px;
}

.header-actions {
    display: flex;
    gap: 20px;
    align-items: center;
}

/* Status Bar */
.status-bar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin: 20px;
}

.status-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.status-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

.status-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.status-card-icon svg {
    width: 24px;
    height: 24px;
}

.status-card-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.status-card-value {
    font-size: 28px;
    font-weight: 700;
    line-height: 1;
}

.status-card-label {
    font-size: 13px;
    color: #718096;
    font-weight: 500;
}

/* Status Card Colors */
.status-card-total .status-card-icon {
    background: #ebf4ff;
    color: #4299e1;
}
.status-card-total .status-card-value {
    color: #2b6cb0;
}

.status-card-online .status-card-icon {
    background: #f0fff4;
    color: #48bb78;
}
.status-card-online .status-card-value {
    color: #276749;
}

.status-card-offline .status-card-icon {
    background: #f7fafc;
    color: #a0aec0;
}
.status-card-offline .status-card-value {
    color: #718096;
}

.status-card-error .status-card-icon {
    background: #fff5f5;
    color: #fc8181;
}
.status-card-error .status-card-value {
    color: #c53030;
}

/* Tabs */
.tabs {
    padding: 0 20px;
    display: flex;
    gap: 10px;
    border-bottom: 2px solid #e2e8f0;
}

.tab-btn {
    padding: 12px 24px;
    background: none;
    border: none;
    color: #666;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.3s;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
}

.tab-btn:hover {
    color: #333;
}

.tab-btn.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

/* Tab Content */
.tab-content {
    padding: 20px;
    display: none;
}

.tab-content.active {
    display: block;
}

/* Toolbar */
.toolbar {
    margin-bottom: 20px;
    display: flex;
    gap: 10px;
}

.toolbar button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.toolbar button svg {
    flex-shrink: 0;
}

/* Filter Bar */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.filter-search {
    position: relative;
    flex: 1;
    min-width: 200px;
}

.filter-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.filter-search input {
    width: 100%;
    padding: 8px 12px 8px 36px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 14px;
    transition: border-color 0.2s;
}

.filter-search input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

.filter-search input::placeholder {
    color: var(--text-muted);
}

.filter-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-controls select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
}

.filter-controls select:focus {
    outline: none;
    border-color: #667eea;
}

.btn-small {
    padding: 6px 10px !important;
    font-size: 13px !important;
    gap: 4px;
}

.filter-results {
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
}

[data-theme="dark"] .filter-search input,
[data-theme="dark"] .filter-controls select {
    background: var(--input-bg, #374151);
    border-color: var(--border-color);
    color: var(--text-primary);
}

/* Buttons */
.btn-primary, .btn-secondary {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5a67d8;
}

.btn-secondary {
    background: #e2e8f0;
    color: #333;
}

.btn-secondary:hover {
    background: #cbd5e0;
}

/* Camera Table */
.cameras-table-container {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    overflow: hidden;
}

.cameras-table {
    width: 100%;
    border-collapse: collapse;
}

/* Desktop/Mobile view switching */
.desktop-only {
    display: block;
}

.mobile-only {
    display: none;
}

/* RTSP URL Cell with Copy Button */
.rtsp-url-cell {
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 280px;
}

.rtsp-url-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: monospace;
    font-size: 12px;
    color: #4a5568;
}

.copy-btn {
    flex-shrink: 0;
    background: #edf2f7;
    border: none;
    border-radius: 4px;
    padding: 4px 6px;
    cursor: pointer;
    color: #4a5568;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.copy-btn:hover {
    background: #e2e8f0;
    color: #2d3748;
}

.camera-id-label {
    display: block;
    font-size: 11px;
    color: #a0aec0;
    margin-top: 2px;
}

/* Mobile Camera Cards */
.cameras-cards-container {
    padding: 12px;
}

.camera-card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    padding: 16px;
    margin-bottom: 12px;
}

.camera-card:last-child {
    margin-bottom: 0;
}

.camera-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.camera-card-name {
    font-weight: 600;
    font-size: 16px;
    color: #2d3748;
}

.camera-card-id {
    font-size: 12px;
    color: #a0aec0;
    margin-bottom: 8px;
}

.camera-card-url {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f7fafc;
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 12px;
}

.camera-card-url .rtsp-url-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.camera-card-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.cameras-table thead {
    background: #f7fafc;
    border-bottom: 2px solid #e2e8f0;
}

.cameras-table th {
    padding: 14px 16px;
    text-align: left;
    font-weight: 600;
    color: #4a5568;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cameras-table td {
    padding: 14px 16px;
    border-bottom: 1px solid #e2e8f0;
    vertical-align: middle;
}

.cameras-table tbody tr:hover {
    background: #f7fafc;
}

.cameras-table tbody tr:last-child td {
    border-bottom: none;
}

/* Camera name cell */
.camera-name-cell {
    font-weight: 500;
    color: #2d3748;
}

.camera-name-cell .camera-name {
    display: block;
    font-size: 14px;
}

.camera-name-cell .camera-status-msg {
    display: block;
    font-size: 12px;
    color: #718096;
    margin-top: 2px;
}

/* Camera ID cell */
.camera-id-cell {
    font-family: monospace;
    font-size: 13px;
    background: #f7fafc;
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
}

/* RTSP URL cell */
.camera-url-cell {
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: monospace;
    font-size: 12px;
    color: #718096;
}

/* Status badge */
.camera-status {
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.status-online {
    background: #c6f6d5;
    color: #22543d;
}

.status-offline {
    background: #e2e8f0;
    color: #4a5568;
}

.status-error {
    background: #fed7d7;
    color: #742a2a;
}

.status-reconnecting {
    background: #fed7aa;
    color: #9a3412;
}

.status-pending,
.status-starting {
    background: #fef3c7;
    color: #92400e;
}

.status-disabled {
    background: #e2e8f0;
    color: #4a5568;
}

/* Spinner for loading states */
.spinner {
    display: inline-block;
    width: 10px;
    height: 10px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Action Buttons - Icon Style */
.camera-actions {
    display: flex;
    gap: 6px;
    flex-wrap: nowrap;
}

.action-btn {
    width: 34px;
    height: 34px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.action-btn svg {
    width: 16px;
    height: 16px;
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Tooltip */
.action-btn::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #2d3748;
    color: white;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
    margin-bottom: 5px;
    z-index: 100;
}

.action-btn::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #2d3748;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
    z-index: 100;
}

.action-btn:hover::after,
.action-btn:hover::before {
    opacity: 1;
    visibility: visible;
}

/* Button Colors */
.btn-view { background: #4299e1; color: white; }
.btn-view:hover:not(:disabled) { background: #3182ce; }

.btn-edit { background: #48bb78; color: white; }
.btn-edit:hover { background: #38a169; }

.btn-toggle { background: #ed8936; color: white; }
.btn-toggle:hover { background: #dd6b20; }

.btn-toggle.btn-enable { background: #48bb78; }
.btn-toggle.btn-enable:hover { background: #38a169; }

.btn-delete { background: #f56565; color: white; }
.btn-delete:hover { background: #e53e3e; }

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #718096;
}

.empty-state td {
    border-bottom: none !important;
}

/* Mobile Cards View */
.mobile-camera-cards {
    display: none;
}

.mobile-card {
    background: white;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.mobile-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.mobile-card-title {
    font-weight: 600;
    font-size: 16px;
    color: #2d3748;
}

.mobile-card-body {
    font-size: 13px;
    color: #718096;
    margin-bottom: 12px;
}

.mobile-card-body p {
    margin: 4px 0;
}

.mobile-card-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* System Header */
.system-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.system-header h3 {
    margin: 0;
}

.metrics-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.update-time {
    font-size: 12px;
    color: #718096;
}

.metrics-status {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.metrics-status.live {
    background: #c6f6d5;
    color: #22543d;
    animation: pulse 2s infinite;
}

.metrics-status.paused {
    background: #fed7aa;
    color: #9a3412;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Metrics */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.metric-card {
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s, box-shadow 0.2s;
}

.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.metric-wide {
    grid-column: span 2;
}

.metric-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.metric-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.metric-icon svg {
    width: 20px;
    height: 20px;
}

.metric-cpu .metric-icon { background: #ebf4ff; color: #667eea; }
.metric-memory .metric-icon { background: #f0fff4; color: #48bb78; }
.metric-disk .metric-icon { background: #fffaf0; color: #ed8936; }
.metric-network .metric-icon { background: #e6fffa; color: #38b2ac; }
.metric-streams .metric-icon { background: #faf5ff; color: #9f7aea; }

[data-theme="dark"] .metric-cpu .metric-icon { background: rgba(102, 126, 234, 0.2); }
[data-theme="dark"] .metric-memory .metric-icon { background: rgba(72, 187, 120, 0.2); }
[data-theme="dark"] .metric-disk .metric-icon { background: rgba(237, 137, 54, 0.2); }
[data-theme="dark"] .metric-network .metric-icon { background: rgba(56, 178, 172, 0.2); }
[data-theme="dark"] .metric-streams .metric-icon { background: rgba(159, 122, 234, 0.2); }

.metric-card h4 {
    margin: 0;
    color: var(--text-muted);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.metric-value-large {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.metric-value {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.metric-value.network-metric {
    font-size: 14px;
    color: var(--text-secondary);
}

.metric-bar {
    width: 100%;
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    background: #667eea;
    transition: width 0.5s ease-out;
    border-radius: 4px;
}

.bar-cpu { background: linear-gradient(90deg, #667eea, #764ba2); }
.bar-memory { background: linear-gradient(90deg, #48bb78, #38a169); }
.bar-disk { background: linear-gradient(90deg, #ed8936, #dd6b20); }

/* Charts Section */
.charts-section {
    background: white;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.charts-section h4 {
    margin: 0 0 20px 0;
    color: #333;
    font-size: 16px;
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
}

.chart-container {
    background: #f7fafc;
    border-radius: 8px;
    padding: 15px;
    height: 280px;
    position: relative;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    height: 30px;
}

.chart-title {
    font-weight: 600;
    color: #4a5568;
    font-size: 14px;
}

.chart-legend {
    display: flex;
    gap: 15px;
    font-size: 12px;
    color: #718096;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

.legend-color.cpu { background: #667eea; }
.legend-color.memory { background: #48bb78; }
.legend-color.rx { background: #4299e1; }
.legend-color.tx { background: #ed8936; }

.chart-container canvas {
    width: 100% !important;
    height: 220px !important;
}

.system-actions {
    margin-top: 20px;
}

/* Logs */
.logs-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 15px;
}

.logs-title-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.logs-title-section h3 {
    margin: 0;
}

.logs-status-info {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 12px;
}

.logs-status {
    padding: 3px 8px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
}

.logs-status.live {
    background: #c6f6d5;
    color: #22543d;
    animation: pulse 2s infinite;
}

.logs-status.paused {
    background: #fed7d7;
    color: #742a2a;
}

.logs-update-time {
    color: #718096;
}

.logs-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.logs-controls select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 13px;
    background: white;
    cursor: pointer;
}

.logs-legend {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
    font-size: 12px;
    color: #666;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.legend-dot.api { background: #4299e1; }
.legend-dot.php { background: #ed8936; }
.legend-dot.ingest { background: #48bb78; }
.legend-dot.ffmpeg { background: #9f7aea; }

.logs-container {
    background: #1a202c;
    border-radius: 8px;
    padding: 15px;
    max-height: 500px;
    overflow-y: auto;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 12px;
    color: #e2e8f0;
}

.log-entry {
    padding: 6px 10px;
    border-left: 3px solid transparent;
    margin-bottom: 2px;
    border-radius: 2px;
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.log-entry:hover {
    background: rgba(255, 255, 255, 0.05);
}

.log-source-api { border-left-color: #4299e1; }
.log-source-php { border-left-color: #ed8936; }
.log-source-ingest { border-left-color: #48bb78; }
.log-source-ffmpeg { border-left-color: #9f7aea; }

.log-time {
    color: #718096;
    white-space: nowrap;
    min-width: 140px;
}

.log-level {
    font-weight: 600;
    min-width: 70px;
}

.log-level-info { color: #4299e1; }
.log-level-warning { color: #ed8936; }
.log-level-error { color: #fc8181; }
.log-level-debug { color: #68d391; }

.log-message {
    flex: 1;
    word-break: break-word;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Logs Pagination */
.logs-pagination {
    margin-top: 15px;
    padding: 10px 15px;
    background: white;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: #718096;
}

/* Camera Pagination */
.pagination-container {
    margin-top: 20px;
    padding: 16px 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    justify-content: flex-end;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.pagination-container.pagination-top {
    margin-top: 0;
    margin-bottom: 16px;
}

.pagination-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #4a5568;
}

.pagination-info select {
    padding: 6px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 14px;
    background: white;
    cursor: pointer;
}

.pagination-summary {
    margin-left: 16px;
    color: #718096;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

.pagination-btn {
    min-width: 36px;
    height: 36px;
    padding: 0 12px;
    border: 1px solid #e2e8f0;
    background: white;
    border-radius: 6px;
    font-size: 14px;
    color: #4a5568;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pagination-btn:hover:not(:disabled) {
    background: #f7fafc;
    border-color: #cbd5e0;
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination-btn.active {
    background: #4299e1;
    border-color: #4299e1;
    color: white;
}

.pagination-btn.nav-btn {
    font-weight: 600;
}

.pagination-ellipsis {
    padding: 0 8px;
    color: #a0aec0;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 8px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-large {
    max-width: 800px;
}

.modal-content h3 {
    margin-bottom: 20px;
    color: #333;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    color: #666;
    font-size: 14px;
}

.form-group input[type="text"],
.form-group input[type="url"],
.form-group input[type="email"],
.form-group input[type="password"] {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
}

.form-group small {
    display: block;
    margin-top: 5px;
    color: #999;
    font-size: 12px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* Video Player */
#videoContainer {
    margin: 20px 0;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
}

#videoPlayer {
    width: 100%;
    max-height: 450px;
}

.stream-url {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 20px;
}

.stream-url input {
    flex: 1;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: monospace;
    font-size: 12px;
}

/* Utility */
.hidden {
    display: none !important;
}

.loading {
    opacity: 0.5;
    pointer-events: none;
}

/* Settings */
.settings-section {
    background: white;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.settings-section h4 {
    margin-bottom: 20px;
    color: #333;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 10px;
}

.settings-form {
    max-width: 500px;
}

.settings-form .form-group {
    margin-bottom: 15px;
}

.settings-form input[type="number"],
.settings-form input[type="password"] {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
}

/* Logs Header */
.logs-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.logs-header h3 {
    margin: 0;
}

.logs-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.logs-controls select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
}

/* Notification Toast */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 25px;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    z-index: 2000;
    animation: slideIn 0.3s ease;
}

.notification.success {
    background: #48bb78;
}

.notification.error {
    background: #f56565;
}

.notification.info {
    background: #4299e1;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .system-header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }
    
    .metrics-controls {
        width: 100%;
        justify-content: space-between;
    }
    
    .metrics-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    .charts-grid {
        grid-template-columns: 1fr;
    }
    
    .chart-container {
        min-height: 200px;
    }
    
    .chart-header {
        flex-direction: column;
        gap: 5px;
        align-items: flex-start;
    }
}

/* Responsive: Tablet */
@media (max-width: 900px) {
    .rtsp-url-cell {
        max-width: 180px;
    }
}

/* Responsive: Mobile */
@media (max-width: 768px) {
    /* Switch to card view on mobile */
    .desktop-only {
        display: none;
    }
    
    .mobile-only {
        display: block;
    }
    
    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .status-bar {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .status-card {
        padding: 16px;
    }
    
    .status-card-icon {
        width: 40px;
        height: 40px;
    }
    
    .status-card-value {
        font-size: 24px;
    }
    
    /* Header adjustments */
    header {
        flex-direction: column;
        gap: 15px;
        padding: 15px;
    }
    
    header h1 {
        font-size: 20px;
    }
    
    /* Tabs scroll on mobile */
    .tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .tab-btn {
        padding: 10px 16px;
        font-size: 14px;
        white-space: nowrap;
    }
    
    /* Toolbar */
    .toolbar {
        flex-wrap: wrap;
    }
    
    .toolbar .btn-primary,
    .toolbar .btn-secondary {
        flex: 1;
        min-width: 120px;
    }
}

@media (max-width: 480px) {
    .metrics-grid {
        grid-template-columns: 1fr;
    }
    
    .status-bar {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
    
    .status-card {
        padding: 12px;
        gap: 10px;
    }
    
    .status-card-icon {
        width: 36px;
        height: 36px;
    }
    
    .status-card-icon svg {
        width: 18px;
        height: 18px;
    }
    
    .status-card-value {
        font-size: 20px;
    }
    
    .status-card-label {
        font-size: 11px;
    }
    
    .camera-card-actions {
        justify-content: center;
    }
    
    .action-btn {
        width: 36px;
        height: 36px;
    }
    
    /* Stack toolbar buttons */
    .toolbar {
        flex-direction: column;
    }
    
    .toolbar .btn-primary,
    .toolbar .btn-secondary {
        width: 100%;
    }
    
    .metric-wide {
        grid-column: span 1;
    }
}

/* Theme Toggle Button */
.theme-toggle {
    width: 42px;
    height: 42px;
    border: none;
    background: #667eea;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    color: white;
}

.theme-toggle:hover {
    background: #5a67d8;
    transform: scale(1.05);
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
}

.theme-toggle .moon-icon {
    display: none;
}

[data-theme="dark"] .theme-toggle {
    background: #6366f1;
}

[data-theme="dark"] .theme-toggle:hover {
    background: #818cf8;
}

[data-theme="dark"] .theme-toggle .sun-icon {
    display: none;
}

[data-theme="dark"] .theme-toggle .moon-icon {
    display: block;
}

/* Back to Top Button */
.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    border: none;
    background: #667eea;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    transition: all 0.3s;
    opacity: 0;
    visibility: hidden;
    z-index: 1000;
    color: white;
}

[data-theme="dark"] .back-to-top {
    background: #4c51bf;
    box-shadow: 0 4px 15px rgba(76, 81, 191, 0.4);
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
}

.back-to-top:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.back-to-top svg {
    width: 24px;
    height: 24px;
}

/* Settings Grid Layout */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

.settings-full-width {
    grid-column: span 2;
}

.settings-section {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

.settings-section-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.settings-section-header svg {
    width: 24px;
    height: 24px;
    color: #667eea;
}

.settings-section-header h4 {
    margin: 0;
    font-size: 16px;
    color: var(--text-primary);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.settings-form .form-group {
    margin-bottom: 16px;
}

.settings-form label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 14px;
}

.settings-form input[type="text"],
.settings-form input[type="password"],
.settings-form input[type="number"] {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.settings-form input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Toggle Switch */
.security-toggle {
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e0;
    transition: 0.3s;
    border-radius: 28px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + .toggle-slider {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

.toggle-label {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.toggle-title {
    font-weight: 600;
    color: var(--text-primary);
}

.toggle-desc {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
}

/* Transcode Mode Selector */
.transcode-options {
    display: flex;
    gap: 8px;
    margin-top: 6px;
}

.transcode-option {
    flex: 1;
    cursor: pointer;
}

.transcode-option input[type="radio"] {
    display: none;
}

.transcode-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 8px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-tertiary);
    text-align: center;
    transition: all 0.2s ease;
    color: var(--text-muted);
}

.transcode-card:hover {
    border-color: #a0aec0;
    background: var(--bg-secondary);
}

.transcode-option input[type="radio"]:checked + .transcode-card {
    border-color: #667eea;
    background: linear-gradient(135deg, rgba(102,126,234,0.08) 0%, rgba(118,75,162,0.08) 100%);
    color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.12);
}

.transcode-card svg {
    opacity: 0.6;
    transition: opacity 0.2s;
}

.transcode-option input[type="radio"]:checked + .transcode-card svg {
    opacity: 1;
}

.transcode-card-title {
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
}

.transcode-card-desc {
    font-size: 11px;
    line-height: 1.2;
    opacity: 0.75;
}

/* Dark Theme Overrides */
[data-theme="dark"] #adminPanel {
    background: #111827;
}

[data-theme="dark"] header {
    background: #1f2937;
    border-bottom: 1px solid #374151;
}

[data-theme="dark"] header h1 {
    color: #f9fafb;
}

[data-theme="dark"] .status-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
}

[data-theme="dark"] .cameras-table-container,
[data-theme="dark"] .camera-card,
[data-theme="dark"] .charts-section,
[data-theme="dark"] .pagination-container,
[data-theme="dark"] .logs-pagination,
[data-theme="dark"] .metric-card,
[data-theme="dark"] .settings-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
}

[data-theme="dark"] .logs-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
}

[data-theme="dark"] .cameras-table thead {
    background: #374151;
    border-bottom-color: #4b5563;
}

[data-theme="dark"] .cameras-table th,
[data-theme="dark"] .cameras-table td {
    color: var(--text-primary);
    border-bottom-color: #374151;
}

[data-theme="dark"] .cameras-table tbody tr:hover {
    background: #374151;
}

[data-theme="dark"] .tabs {
    border-bottom-color: #374151;
}

[data-theme="dark"] .tab-btn {
    color: #9ca3af;
}

[data-theme="dark"] .tab-btn:hover {
    color: #e5e7eb;
}

[data-theme="dark"] .tab-btn.active {
    color: #818cf8;
    border-bottom-color: #818cf8;
}

[data-theme="dark"] .btn-secondary {
    background: #374151;
    color: #f9fafb;
    border: 1px solid #4b5563;
}

[data-theme="dark"] .btn-secondary:hover {
    background: #4b5563;
}

[data-theme="dark"] .btn-primary {
    background: #6366f1;
}

[data-theme="dark"] .btn-primary:hover {
    background: #818cf8;
}

[data-theme="dark"] .modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
}

[data-theme="dark"] .modal-content h3 {
    color: var(--text-primary);
}

[data-theme="dark"] .chart-container {
    background: #374151;
}

[data-theme="dark"] .auth-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
}

[data-theme="dark"] .auth-container h2 {
    color: var(--text-primary);
}

[data-theme="dark"] #loginForm input {
    background: #374151;
    border-color: #4b5563;
    color: #f9fafb;
}

[data-theme="dark"] #loginForm input::placeholder {
    color: #9ca3af;
}

/* Dark Theme - Forms and Inputs */
[data-theme="dark"] .form-group label {
    color: #e5e7eb;
}

[data-theme="dark"] .form-group input,
[data-theme="dark"] .settings-form input {
    background: #374151;
    border-color: #4b5563;
    color: #f9fafb;
}

[data-theme="dark"] .form-group input::placeholder,
[data-theme="dark"] .settings-form input::placeholder {
    color: #9ca3af;
}

[data-theme="dark"] .form-group input:focus,
[data-theme="dark"] .settings-form input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

[data-theme="dark"] .settings-section-header {
    border-bottom-color: #374151;
}

[data-theme="dark"] .toggle-slider {
    background-color: #4b5563;
}

/* Dark Theme - Transcode Cards */
[data-theme="dark"] .transcode-card {
    border-color: #4b5563;
    background: #374151;
    color: #9ca3af;
}

[data-theme="dark"] .transcode-card:hover {
    border-color: #6b7280;
    background: #4b5563;
}

[data-theme="dark"] .transcode-option input[type="radio"]:checked + .transcode-card {
    border-color: #818cf8;
    background: rgba(99, 102, 241, 0.15);
    color: #a5b4fc;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* Dark Theme - Logs View */
[data-theme="dark"] .logs-header,
[data-theme="dark"] .logs-legend {
    color: var(--text-primary);
}

[data-theme="dark"] .logs-controls select,
[data-theme="dark"] .pagination-info select {
    background: #374151;
    border-color: #4b5563;
    color: #f9fafb;
}

[data-theme="dark"] .log-entry {
    color: #e5e7eb;
    border-bottom-color: #374151;
}

[data-theme="dark"] .log-time {
    color: #9ca3af;
}

[data-theme="dark"] .log-message {
    color: #f9fafb;
}

[data-theme="dark"] .pagination-btn {
    background: #374151;
    border-color: #4b5563;
    color: #e5e7eb;
}

[data-theme="dark"] .pagination-btn:hover:not(:disabled) {
    background: #4b5563;
}

[data-theme="dark"] .pagination-btn.active {
    background: #6366f1;
    border-color: #6366f1;
}

/* Dark Theme - Status Cards */
[data-theme="dark"] .status-card {
    background: #1f2937 !important;
    border: 1px solid #374151 !important;
}

[data-theme="dark"] .status-card-total .status-card-icon {
    background: rgba(66, 153, 225, 0.15);
    color: #63b3ed;
}
[data-theme="dark"] .status-card-total .status-card-value {
    color: #63b3ed;
}

[data-theme="dark"] .status-card-online .status-card-icon {
    background: rgba(72, 187, 120, 0.15);
    color: #68d391;
}
[data-theme="dark"] .status-card-online .status-card-value {
    color: #68d391;
}

[data-theme="dark"] .status-card-offline .status-card-icon {
    background: rgba(160, 174, 192, 0.15);
    color: #a0aec0;
}
[data-theme="dark"] .status-card-offline .status-card-value {
    color: #a0aec0;
}

[data-theme="dark"] .status-card-error .status-card-icon {
    background: rgba(252, 129, 129, 0.15);
    color: #fc8181;
}
[data-theme="dark"] .status-card-error .status-card-value {
    color: #fc8181;
}

[data-theme="dark"] .status-card-label {
    color: #9ca3af;
}

/* Dark Theme - Action Buttons */
[data-theme="dark"] .action-btn {
    background: #374151;
    border-color: #4b5563;
}

[data-theme="dark"] .action-btn:hover:not(:disabled) {
    background: #4b5563;
}

[data-theme="dark"] .copy-btn {
    background: #374151;
    color: #e5e7eb;
}

[data-theme="dark"] .copy-btn:hover {
    background: #4b5563;
}

/* Dark Theme - Toolbar */
[data-theme="dark"] .toolbar {
    background: transparent;
}

[data-theme="dark"] .toolbar .btn-primary {
    background: #6366f1;
}

/* Dark Theme - Camera Status Badges */
[data-theme="dark"] .camera-status {
    background: #374151;
    color: #e5e7eb;
}

[data-theme="dark"] .camera-status.status-online {
    background: rgba(72, 187, 120, 0.2);
    color: #68d391;
}

[data-theme="dark"] .camera-status.status-disabled {
    background: rgba(160, 174, 192, 0.2);
    color: #a0aec0;
}

[data-theme="dark"] .camera-status.status-error {
    background: rgba(252, 129, 129, 0.2);
    color: #fc8181;
}

[data-theme="dark"] .camera-status.status-starting,
[data-theme="dark"] .camera-status.status-reconnecting {
    background: rgba(246, 173, 85, 0.2);
    color: #f6ad55;
}

/* Dark Theme - RTSP URL */
[data-theme="dark"] .rtsp-url-text {
    color: #9ca3af;
}

[data-theme="dark"] .camera-id-label {
    color: #6b7280;
}

/* Dark Theme - Empty State */
[data-theme="dark"] .empty-state {
    color: #9ca3af;
}

@media (max-width: 768px) {
    .settings-grid {
        grid-template-columns: 1fr;
    }
    
    .settings-full-width {
        grid-column: span 1;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .back-to-top {
        bottom: 20px;
        right: 20px;
        width: 44px;
        height: 44px;
    }
}
