/* HikVision Camera Monitor - Modern CSS Styling */

:root {
    --primary-color: #1976d2;
    --primary-dark: #1565c0;
    --success-color: #4caf50;
    --danger-color: #f44336;
    --warning-color: #ff9800;
    --bg-color: #f5f7fa;
    --card-bg: #ffffff;
    --text-primary: #2c3e50;
    --text-secondary: #7f8c8d;
    --border-color: #e0e0e0;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.15);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding: 20px;
    background: var(--card-bg);
    border-radius: 10px;
    box-shadow: var(--shadow);
}

header h1 {
    font-size: 28px;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.camera-link {
    font-size: 18px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: normal;
    padding: 4px 12px;
    background: #f0f0f0;
    border-radius: 6px;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.camera-link:hover {
    background: var(--primary-color);
    color: white;
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(25, 118, 210, 0.3);
}

/* Connection Status */
.connection-status {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    background: #f5f5f5;
    border-radius: 20px;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #ccc;
    animation: pulse 2s infinite;
}

.status-dot.connected {
    background: var(--success-color);
}

.status-dot.disconnected {
    background: var(--danger-color);
    animation: none;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.status-text {
    font-size: 14px;
    font-weight: 500;
}

/* Grid Layout */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.full-width {
    grid-column: 1 / -1;
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: 10px;
    padding: 24px;
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.card h2 {
    font-size: 20px;
    margin-bottom: 20px;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

/* Info Grid */
.info-grid {
    display: grid;
    gap: 12px;
}

.info-item {
    display: flex;
    justify-content: space-between;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 6px;
}

.info-item .label {
    font-weight: 500;
    color: var(--text-secondary);
}

.info-item .value {
    font-weight: 600;
    color: var(--text-primary);
}

.status-active {
    color: var(--success-color) !important;
}

/* Statistics */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

.stat-box {
    text-align: center;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
    color: white;
}

.stat-box:nth-child(2) {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.stat-box:nth-child(3) {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.stat-box:nth-child(4) {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
}

.stat-value {
    font-size: 32px;
    font-weight: bold;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 13px;
    opacity: 0.9;
}

/* Inline Statistics */
.stats-inline {
    display: flex;
    justify-content: space-around;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.stat-inline {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
    color: white;
    min-width: 120px;
    flex: 1;
}

.stat-inline:nth-child(2) {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.stat-inline:nth-child(3) {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.stat-inline:nth-child(4) {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
}

.stat-inline .stat-value {
    font-size: 28px;
    font-weight: bold;
    margin-bottom: 5px;
}

.stat-inline .stat-label {
    font-size: 12px;
    opacity: 0.9;
}

/* Split Layout for Live Event & Camera */
.split-layout {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.split-left {
    flex: 0 0 33%;
    min-width: 250px;
}

.split-left h3 {
    font-size: 16px;
    margin-bottom: 15px;
    color: var(--primary-color);
}

.split-right {
    flex: 1;
}

@media (max-width: 968px) {
    .split-layout {
        flex-direction: column;
    }

    .split-left {
        flex: 1;
        width: 100%;
    }
}

/* Live Event */
.live-event {
    min-height: 150px;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
    color: white;
}

.no-event {
    text-align: center;
    padding: 50px;
    opacity: 0.7;
    font-size: 18px;
}

.event-content {
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.event-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.event-type {
    font-size: 24px;
    font-weight: bold;
}

.event-time {
    font-size: 14px;
    opacity: 0.8;
}

.event-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.event-detail {
    background: rgba(255, 255, 255, 0.1);
    padding: 12px;
    border-radius: 6px;
}

.event-detail-label {
    font-size: 12px;
    opacity: 0.8;
    margin-bottom: 4px;
}

.event-detail-value {
    font-size: 18px;
    font-weight: 600;
}

/* Camera Snapshot */
.camera-snapshot {
    position: relative;
    text-align: center;
}

.camera-snapshot img {
    width: 100%;
    height: 400px;
    object-fit: cover;
    object-position: top;
    border-radius: 8px;
    margin-bottom: 10px;
}

.camera-placeholder {
    padding: 60px 20px;
    background: #f5f5f5;
    border-radius: 8px;
    color: #999;
}

.camera-placeholder span {
    font-size: 48px;
    display: block;
    margin-bottom: 10px;
}

.btn-refresh {
    padding: 10px 20px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}

.btn-refresh:hover {
    background: var(--primary-dark);
}

/* Filter Buttons */
.filter-buttons {
    display: flex;
    gap: 10px;
}

.filter-btn {
    padding: 8px 16px;
    background: #f5f5f5;
    border: 2px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.filter-btn:hover {
    background: #e0e0e0;
}

.filter-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Table */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background: var(--primary-color);
    color: white;
}

th,
td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    font-weight: 600;
    font-size: 14px;
}

td {
    font-size: 13px;
}

tbody tr {
    transition: background 0.2s;
}

tbody tr:hover {
    background: #f8f9fa;
}

tbody tr.new-event {
    animation: highlightRow 1s ease-out;
}

@keyframes highlightRow {
    0% {
        background: #fff3cd;
    }

    100% {
        background: transparent;
    }
}

.no-data {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

/* Forms */
.config-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-weight: 600;
    color: var(--text-primary);
}

.form-group input,
.form-group select {
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-group small {
    color: var(--text-secondary);
    font-size: 12px;
}

.button-group {
    display: flex;
    gap: 10px;
}

/* Buttons */
.btn-primary,
.btn-secondary,
.btn-danger {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(25, 118, 210, 0.3);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: #d32f2f;
}

.btn-config,
.btn-back {
    display: inline-block;
    padding: 10px 20px;
    background: var(--primary-color);
    color: white;
    text-decoration: none;
    border-radius: 6px;
    transition: background 0.2s;
}

.btn-config:hover,
.btn-back:hover {
    background: var(--primary-dark);
}

.btn-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.btn-link:hover {
    text-decoration: underline;
}

.btn-link-small {
    padding: 4px 12px;
    background: var(--primary-color);
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-size: 12px;
    margin-left: 10px;
}

/* Messages */
.message {
    padding: 15px 20px;
    border-radius: 6px;
    margin-bottom: 20px;
    font-weight: 500;
}

.message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Endpoint List */
.endpoint-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin: 20px 0;
}

.endpoint-item {
    padding: 15px;
    background: #f8f9fa;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.endpoint-item strong {
    color: var(--primary-color);
}

.endpoint-item code {
    background: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 13px;
    display: block;
    overflow-x: auto;
}

/* Info Box */
.info-box {
    background: #e3f2fd;
    padding: 20px;
    border-radius: 8px;
    margin-top: 20px;
    border-left: 4px solid var(--primary-color);
}

.info-box h3 {
    color: var(--primary-color);
    margin-bottom: 15px;
}

.info-box ol {
    margin-left: 20px;
}

.info-box li {
    margin-bottom: 8px;
}

.info-box code {
    background: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 13px;
}

/* Footer */
footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: var(--card-bg);
    border-radius: 10px;
    box-shadow: var(--shadow);
    margin-top: 20px;
}

.footer-text {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Responsive */
@media (max-width: 768px) {
    .grid {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    header {
        flex-direction: column;
        gap: 15px;
    }

    footer {
        flex-direction: column;
        gap: 15px;
    }

    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
}