* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

header {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

header h1 {
    font-size: 24px;
    color: #333;
}

.header-right {
    display: flex;
    gap: 20px;
    align-items: center;
    flex-wrap: wrap;
}

.motion-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 6px;
}

.motion-indicator.detected {
    background: #fff3cd;
    color: #856404;
}

.motion-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #6c757d;
    transition: all 0.3s ease;
}

.motion-indicator.detected .motion-dot {
    background: #ffc107;
    animation: motionPulse 0.5s infinite;
    box-shadow: 0 0 10px rgba(255, 193, 7, 0.5);
}

@keyframes motionPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); opacity: 0.8; }
}

.status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #e74c3c;
    animation: pulse 2s infinite;
}

.status.connected .status-dot {
    background: #27ae60;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

main {
    display: grid;
    gap: 20px;
}

.video-section {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.video-container {
    position: relative;
    width: 100%;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 20px;
    aspect-ratio: 16 / 9;
}

.video-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border: 3px solid transparent;
    border-radius: 8px;
    pointer-events: none;
    transition: all 0.3s ease;
    z-index: 10;
}

.video-container.motion-detected::before {
    border-color: #ffc107;
    box-shadow: 0 0 20px rgba(255, 193, 7, 0.5);
    animation: borderPulse 1s infinite;
}

@keyframes borderPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

#localVideo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.settings-panel {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 1px solid #e9ecef;
}

.settings-panel h3 {
    margin-bottom: 15px;
    color: #333;
    font-size: 18px;
}

.setting-item {
    margin-bottom: 15px;
}

.setting-item:last-child {
    margin-bottom: 0;
}

.setting-item label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: #555;
    cursor: pointer;
    flex-wrap: wrap;
}

.setting-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.setting-item input[type="range"] {
    flex: 1;
    min-width: 150px;
    cursor: pointer;
}

.setting-item input[type="number"] {
    width: 80px;
    padding: 6px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.setting-item #sensitivityValue {
    font-weight: 600;
    color: #3498db;
    min-width: 45px;
}

.controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(52, 152, 219, 0.3);
}

.btn-danger {
    background: #e74c3c;
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #c0392b;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(231, 76, 60, 0.3);
}

.btn-record {
    background: #e74c3c;
    color: white;
}

.btn-record.recording {
    background: #27ae60;
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.recordings-section {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.recordings-section h2 {
    margin-bottom: 15px;
    color: #333;
    font-size: 20px;
}

.recordings-list {
    display: grid;
    gap: 10px;
}

.recording-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    transition: all 0.3s ease;
}

.recording-item:hover {
    background: #e9ecef;
    transform: translateX(5px);
}

.recording-info {
    flex: 1;
}

.recording-name {
    font-weight: 600;
    color: #333;
    margin-bottom: 5px;
}

.recording-meta {
    font-size: 14px;
    color: #666;
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.recording-actions {
    display: flex;
    gap: 10px;
}

.btn-small {
    padding: 8px 16px;
    font-size: 14px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-download {
    background: #3498db;
    color: white;
}

.btn-download:hover {
    background: #2980b9;
}

.btn-delete {
    background: #e74c3c;
    color: white;
}

.btn-delete:hover {
    background: #c0392b;
}

.empty-message {
    text-align: center;
    color: #999;
    padding: 40px;
    font-style: italic;
}

@media (max-width: 768px) {
    header {
        flex-direction: column;
        text-align: center;
    }

    .header-right {
        flex-direction: column;
        width: 100%;
    }

    .motion-indicator,
    .status {
        width: 100%;
        justify-content: center;
    }

    .settings-panel {
        padding: 15px;
    }

    .setting-item label {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .setting-item input[type="range"] {
        width: 100%;
    }

    .controls {
        flex-direction: column;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }

    .recording-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .recording-actions {
        width: 100%;
    }

    .btn-small {
        flex: 1;
    }
}

