/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f8f9fa;
}

.hidden {
    display: none !important;
}

/* Header */
header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

header h1 {
    font-size: 1.8rem;
}

header p {
    font-size: 0.9rem;
    opacity: 0.9;
    margin-left: 1rem;
}

header button {
    background: rgba(255,255,255,0.2);
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
    padding: 0.5rem 1rem;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.3s;
}

header button:hover {
    background: rgba(255,255,255,0.3);
}

/* Main content */
#main-content {
    display: flex;
    flex-direction: column;
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

.panel {
    background: white;
    border-radius: 10px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

#recording-controls h2 {
    margin-bottom: 1rem;
    color: #444;
}

.config-toggles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.config-toggles label {
    display: flex;
    align-items: center;
    font-weight: 500;
}

.config-toggles input[type="checkbox"] {
    margin-right: 0.5rem;
    transform: scale(1.2);
}

#config-summary {
    background: #e3f2fd;
    padding: 0.5rem;
    border-radius: 5px;
    margin-bottom: 1rem;
    font-style: italic;
}

#start-recording {
    background: #4CAF50;
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 5px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: background 0.3s;
    width: 100%;
}

#start-recording:hover:not(:disabled) {
    background: #45a049;
}

#start-recording:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Preview Area */
#preview-area {
    position: relative;
    margin: 1rem 0;
}

#preview-video {
    width: 100%;
    max-width: 800px;
    height: auto;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.pip-info {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 8px;
    padding: 1rem;
    margin: 1rem 0;
    text-align: center;
}

.pip-info p {
    margin-bottom: 0.5rem;
    color: #856404;
    font-size: 0.9rem;
    line-height: 1.4;
}

.pip-btn {
    background: #ffc107;
    color: #212529;
    border: 1px solid #ffc107;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.3s;
}

.pip-btn:hover {
    background: #e0a800;
    border-color: #d39e00;
}

#stop-recording {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #f44336;
    color: white;
    border: none;
    padding: 1rem;
    border-radius: 5px;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(244,67,54,0.4);
    transition: transform 0.2s;
}

#stop-recording:hover {
    transform: scale(1.1);
}

/* Notifications */
#error-notifications {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
}

.toast {
    background: #333;
    color: white;
    padding: 1rem;
    border-radius: 5px;
    margin-bottom: 0.5rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Sidebar */
#sidebar {
    position: fixed;
    right: -400px;
    top: 0;
    width: 400px;
    max-width: 90vw;
    height: 100vh;
    background: white;
    box-shadow: -2px 0 10px rgba(0,0,0,0.1);
    transition: right 0.3s;
    overflow-y: auto;
    z-index: 100;
}

#sidebar.open {
    right: 0;
}

.close-sidebar {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #999;
    z-index: 101;
}

.close-sidebar:hover {
    color: #333;
}

#sidebar h2 {
    position: relative;
    padding: 1rem;
    border-bottom: 1px solid #eee;
    margin: 0;
}

#saved-list {
    padding: 1rem;
}

.saved-card {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.saved-card-header {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.saved-card-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: auto;
}

@media (max-width: 600px) {
    .saved-card-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .saved-card-actions {
        justify-content: center;
    }
}

.saved-card img {
    width: 80px;
    height: 60px;
    object-fit: cover;
    border-radius: 5px;
    flex-shrink: 0;
}

.saved-card-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.saved-card-info h3 {
    margin: 0;
    font-size: 1rem;
}

.saved-card-info p {
    margin: 0;
    font-size: 0.9rem;
    color: #666;
}

.saved-card-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: auto;
    padding-top: 0.5rem;
    border-top: 1px solid #eee;
}

.saved-card-actions button {
    padding: 0.3rem 0.6rem;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.8rem;
    white-space: nowrap;
}

.play-btn { background: #2196F3; color: white; }
.download-btn { background: #4CAF50; color: white; }
.delete-btn { background: #f44336; color: white; }

.empty-state {
    text-align: center;
    color: #999;
    font-style: italic;
}

#clear-all {
    width: 100%;
    padding: 1rem;
    background: #ff9800;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200;
}

.modal-content {
    position: relative;
    background: white;
    padding: 2rem;
    border-radius: 10px;
    max-width: 90%;
    max-height: 90%;
}

.close {
    position: absolute;
    top: 10px;
    right: 20px;
    font-size: 2rem;
    cursor: pointer;
    color: #999;
}

#modal-video {
    width: 100%;
    height: auto;
    max-height: 70vh;
}

/* Footer */
footer {
    text-align: center;
    padding: 1rem;
    background: #eee;
    margin-top: 2rem;
}

#storage-info {
    font-weight: bold;
    color: #666;
}

/* Responsive */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        gap: 1rem;
    }

    #main-content {
        padding: 1rem;
    }

    .config-toggles {
        grid-template-columns: 1fr;
    }

    #sidebar {
        width: 100%;
        right: -100%;
    }
}