/* Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Body */
body {
    font-family: Arial, sans-serif;
    display: flex;
    height: 100vh;
    overflow: hidden;
    background-color: #1a1a1a;
}

/* Main content */
.main-content {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    padding: 10px;
    gap: 10px;
    align-content: flex-start;
    overflow-y: auto;
}

.camera-container {
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    position: relative;
    transition: box-shadow 0.3s ease;
}

.camera-container.alarm {
    box-shadow: 0 0 0 5px #ff0000, 0 0 20px rgba(255,0,0,0.8);
    animation: pulse-red 0.5s ease-in-out;
}

@keyframes pulse-red {
    0%,100% { box-shadow: 0 0 0 5px #ff0000, 0 0 20px rgba(255,0,0,0.8); }
    50% { box-shadow: 0 0 0 8px #ff0000, 0 0 30px rgba(255,0,0,1); }
}

.camera-container img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    background: #000;
}

.camera-label {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: bold;
    z-index: 10;
}

.alarm-label {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255,0,0,0.9);
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    z-index: 10;
    display: none;
    animation: blink 0.5s infinite;
}

.camera-container.alarm .alarm-label {
    display: block;
}

@keyframes blink {
    0%,50%,100% { opacity: 1; }
    25%,75% { opacity: 0.5; }
}

/* Sidebar */
.sidebar {
    width: 320px;
    background: #2c2c2c;
    color: white;
    display: flex;
    flex-direction: column;
    box-shadow: -2px 0 10px rgba(0,0,0,0.5);
    direction: rtl;
    text-align: right;
}

.sidebar-header {
    padding: 20px;
    background: #1a1a1a;
    border-bottom: 2px solid #444;
}

.camera-list {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

.camera-item {
    background: #3a3a3a;
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 6px;
    border-left: 4px solid #4CAF50;
}

.camera-item h3 {
    font-size: 16px;
    margin-bottom: 5px;
    color: #4CAF50;
}

.camera-item p {
    font-size: 12px;
    color: #aaa;
    margin-bottom: 10px;
    word-break: break-all;
}

.delete-btn {
    background: #f44336;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.3s;
}

.delete-btn:hover { background: #d32f2f; }

.add-camera-form {
    padding: 20px;
    background: #1a1a1a;
    border-top: 2px solid #444;
}

.add-camera-form h3 { margin-bottom: 15px; font-size: 18px; }

.form-group { margin-bottom: 15px; }

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 13px;
    color: #ccc;
}

.form-group input {
    width: 100%;
    padding: 10px;
    border: 1px solid #444;
    border-radius: 4px;
    background: #3a3a3a;
    color: white;
    font-size: 14px;
}

.form-group input:focus { outline: none; border-color: #4CAF50; }

.add-btn {
    width: 100%;
    background: #4CAF50;
    color: white;
    border: none;
    padding: 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: background 0.3s;
}

.add-btn:hover { background: #45a049; }

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.empty-state h3 { margin-bottom: 10px; }

/* Responsive grids */
.main-content[data-count="1"] .camera-container { width: calc(100% - 20px); height: calc(100vh - 40px); }
.main-content[data-count="2"] .camera-container { width: calc(50% - 15px); height: calc(100vh - 40px); }
.main-content[data-count="3"] .camera-container:nth-child(1),
.main-content[data-count="3"] .camera-container:nth-child(2) { width: calc(50% - 15px); height: calc(50vh - 25px); }
.main-content[data-count="3"] .camera-container:nth-child(3) { width: calc(100% - 20px); height: calc(50vh - 25px); }
.main-content[data-count="4"] .camera-container { width: calc(50% - 15px); height: calc(50vh - 25px); }
.main-content[data-count="5"] .camera-container:nth-child(1),
.main-content[data-count="5"] .camera-container:nth-child(2),
.main-content[data-count="5"] .camera-container:nth-child(3),
.main-content[data-count="5"] .camera-container:nth-child(4) { width: calc(50% - 15px); height: calc(33.33vh - 20px); }
.main-content[data-count="5"] .camera-container:nth-child(5) { width: calc(100% - 20px); height: calc(33.33vh - 20px); }
.main-content[data-count="6"] .camera-container,
.main-content[data-count="7"] .camera-container,
.main-content[data-count="8"] .camera-container,
.main-content[data-count="9"] .camera-container,
.main-content[data-count="10"] .camera-container { width: calc(50% - 15px); height: calc(33.33vh - 20px); }
