/* Admin Panel Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.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;
}

header h1 {
    color: #667eea;
    font-size: 24px;
}

.header-actions {
    display: flex;
    gap: 20px;
    align-items: center;
}

/* Status Bar */
.status-bar {
    background: white;
    padding: 20px 30px;
    margin: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    gap: 40px;
    flex-wrap: wrap;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-item .label {
    font-weight: 600;
    color: #666;
}

.status-online { color: #48bb78; font-weight: bold; }
.status-offline { color: #cbd5e0; font-weight: bold; }
.status-error { color: #f56565; font-weight: bold; }

/* 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;
}

/* 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;
}

.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: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.metric-card h4 {
    margin-bottom: 15px;
    color: #666;
    font-size: 14px;
    text-transform: uppercase;
}

.metric-value {
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.metric-value.network-metric {
    font-size: 14px;
}

.metric-bar {
    width: 100%;
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    margin-top: 10px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    background: #667eea;
    transition: width 0.5s ease-out;
}

.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; }
}

/* 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;
    }
}

@media (max-width: 480px) {
    .metrics-grid {
        grid-template-columns: 1fr;
    }
    
    .status-bar {
        flex-direction: column;
        gap: 10px;
    }
    
    /* Hide table columns on mobile */
    .hide-mobile {
        display: none;
    }
    
    /* Adjust table for mobile */
    .cameras-table th,
    .cameras-table td {
        padding: 10px 12px;
    }
    
    .cameras-table th:first-child,
    .cameras-table td:first-child {
        padding-left: 12px;
    }
    
    /* Smaller action buttons on mobile */
    .action-btn {
        width: 32px;
        height: 32px;
    }
    
    .action-btn svg {
        width: 14px;
        height: 14px;
    }
    
    /* Mobile card view - show on mobile */
    .cameras-table-container.mobile-view .cameras-table {
        display: none;
    }
    
    .cameras-table-container.mobile-view .mobile-camera-cards {
        display: block;
        padding: 12px;
    }
    
    /* 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) {
    .camera-name-cell .camera-name {
        font-size: 13px;
    }
    
    .camera-status {
        font-size: 10px;
        padding: 4px 8px;
    }
    
    .action-btn {
        width: 30px;
        height: 30px;
    }
    
    /* Stack toolbar buttons */
    .toolbar {
        flex-direction: column;
    }
    
    .toolbar .btn-primary,
    .toolbar .btn-secondary {
        width: 100%;
    }
}
