/* ===== CSS Variables ===== */
:root {
    --primary-color: #3b82f6;
    --secondary-color: #1e40af;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --dark-color: #1f2937;
    --light-color: #f8fafc;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --border-radius: 8px;
    --transition: all 0.3s ease;
}

/* Dark Theme Variables */
[data-theme="dark"] {
    --primary-color: #60a5fa;
    --secondary-color: #3b82f6;
    --dark-color: #111827;
    --light-color: #1f2937;
    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --border-color: #374151;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
}

/* ===== Reset & Base Styles ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Cairo', sans-serif;
    background: linear-gradient(135deg, var(--light-color) 0%, #e2e8f0 100%);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    transition: var(--transition);
}

[data-theme="dark"] body {
    background: linear-gradient(135deg, var(--dark-color) 0%, #0f172a 100%);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===== Header ===== */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    padding: 20px 30px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    margin-bottom: 30px;
    transition: var(--transition);
}

[data-theme="dark"] .header {
    background: var(--light-color);
}

.logo {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo i {
    font-size: 2rem;
    color: var(--primary-color);
}

.logo h1 {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
}

.theme-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 12px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    transition: var(--transition);
    box-shadow: var(--shadow);
}

.theme-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* ===== Main Content ===== */
.main-content {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 2fr;
    grid-template-rows: auto 1fr;
    gap: 30px;
    grid-template-areas: 
        "controls preview"
        "recordings recordings";
}

/* ===== Control Panel ===== */
.control-panel {
    grid-area: controls;
    background: white;
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    height: fit-content;
    transition: var(--transition);
}

[data-theme="dark"] .control-panel {
    background: var(--light-color);
}

.recording-controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 30px;
}

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 15px 20px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    font-family: inherit;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--secondary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #dc2626;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-warning {
    background: var(--warning-color);
    color: white;
}

.btn-warning:hover:not(:disabled) {
    background: #d97706;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: #059669;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* ===== Recording Options ===== */
.recording-options {
    border-top: 2px solid var(--border-color);
    padding-top: 20px;
}

.option-group {
    margin-bottom: 20px;
}

.option-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-primary);
}

.option-group select {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    background: white;
    color: var(--text-primary);
    font-size: 1rem;
    transition: var(--transition);
}

[data-theme="dark"] .option-group select {
    background: var(--dark-color);
    border-color: var(--border-color);
}

.option-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* ===== Preview Section ===== */
.preview-section {
    grid-area: preview;
    background: white;
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    transition: var(--transition);
}

[data-theme="dark"] .preview-section {
    background: var(--light-color);
}

.preview-container {
    position: relative;
    width: 100%;
    height: 400px;
    background: #000;
    border-radius: var(--border-radius);
    overflow: hidden;
}

#previewVideo {
    width: 100%;
    height: 100%;
    object-fit: cover;
}



.preview-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: var(--transition);
}

.preview-container:hover .preview-overlay {
    opacity: 1;
}

.recording-status {
    text-align: center;
    color: white;
}

.recording-indicator {
    display: none;
    align-items: center;
    gap: 10px;
    font-size: 1.2rem;
    margin-bottom: 10px;
}

.recording-indicator.active {
    display: flex;
}

.recording-indicator i {
    color: var(--danger-color);
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.recording-timer {
    font-size: 2rem;
    font-weight: 700;
    font-family: 'Courier New', monospace;
}

/* ===== Recordings Section ===== */
.recordings-section {
    grid-area: recordings;
    background: white;
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    transition: var(--transition);
}

[data-theme="dark"] .recordings-section {
    background: var(--light-color);
}

.recordings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.recordings-header h2 {
    color: var(--text-primary);
    font-size: 1.5rem;
    margin: 0;
}

.recordings-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.storage-info {
    background: var(--light-color);
    padding: 8px 15px;
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

[data-theme="dark"] .storage-info {
    background: var(--dark-color);
}

.recordings-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.no-recordings {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.no-recordings i {
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: 0.5;
}

.no-recordings p {
    font-size: 1.2rem;
}

/* ===== Footer ===== */
.footer {
    text-align: center;
    padding: 20px;
    margin-top: 30px;
    color: var(--text-secondary);
    border-top: 1px solid var(--border-color);
}

/* ===== Modals ===== */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    animation: modalSlideIn 0.3s ease;
}

[data-theme="dark"] .modal-content {
    background: var(--light-color);
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    color: var(--text-primary);
    font-size: 1.3rem;
}

.close-modal {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition);
}

.close-modal:hover {
    color: var(--danger-color);
}

.modal-body {
    padding: 30px;
}

.setting-group {
    margin-bottom: 20px;
}

.setting-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-primary);
}

.setting-group select {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    background: white;
    color: var(--text-primary);
    font-size: 1rem;
    transition: var(--transition);
}

[data-theme="dark"] .setting-group select {
    background: var(--dark-color);
    border-color: var(--border-color);
}

.setting-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* ===== Recording Item ===== */
.recording-item {
    background: var(--light-color);
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

[data-theme="dark"] .recording-item {
    background: var(--dark-color);
}

.recording-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.recording-thumbnail {
    position: relative;
    width: 100%;
    height: 150px;
    background: #000;
    border-radius: var(--border-radius);
    margin-bottom: 15px;
    overflow: hidden;
}

.recording-thumbnail video,
.recording-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.recording-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: var(--transition);
}

.recording-item:hover .recording-overlay {
    opacity: 1;
}

.recording-overlay i {
    font-size: 2rem;
    color: white;
}

.recording-info h3 {
    color: var(--text-primary);
    margin-bottom: 8px;
    font-size: 1.1rem;
}

.recording-meta {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 15px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.recording-meta span {
    display: flex;
    align-items: center;
    gap: 5px;
}

.recording-meta i {
    font-size: 0.8rem;
}

.recording-actions {
    display: flex;
    gap: 10px;
}

.btn-small {
    padding: 8px 12px;
    font-size: 0.9rem;
    border-radius: 6px;
}

/* ===== Checkbox Styling ===== */
.option-group input[type="checkbox"] {
    display: none;
}

.checkmark {
    position: relative;
    display: inline-block;
    width: 20px;
    height: 20px;
    background: white;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition);
    vertical-align: middle;
    margin-right: 8px;
}

[data-theme="dark"] .checkmark {
    background: var(--dark-color);
}

.option-group input[type="checkbox"]:checked + .checkmark {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.option-group input[type="checkbox"]:checked + .checkmark::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-weight: bold;
    font-size: 12px;
}

/* ===== Notifications ===== */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    padding: 15px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 1001;
    min-width: 300px;
    animation: slideInRight 0.3s ease;
    border-left: 4px solid var(--primary-color);
}

[data-theme="dark"] .notification {
    background: var(--light-color);
}

.notification-success {
    border-left-color: var(--success-color);
}

.notification-error {
    border-left-color: var(--danger-color);
}

.notification-warning {
    border-left-color: var(--warning-color);
}

.notification-info {
    border-left-color: var(--primary-color);
}

.notification i {
    font-size: 1.2rem;
}

.notification-success i {
    color: var(--success-color);
}

.notification-error i {
    color: var(--danger-color);
}

.notification-warning i {
    color: var(--warning-color);
}

.notification-info i {
    color: var(--primary-color);
}

.notification span {
    flex: 1;
    color: var(--text-primary);
}

.notification-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition);
}

.notification-close:hover {
    color: var(--danger-color);
}

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

/* ===== Loading Spinner ===== */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
    .main-content {
        grid-template-columns: 1fr;
        grid-template-areas:
            "controls"
            "preview"
            "recordings";
    }

    .header {
        padding: 15px 20px;
    }

    .logo h1 {
        font-size: 1.4rem;
    }

    .container {
        padding: 15px;
    }

    .control-panel,
    .preview-section,
    .recordings-section {
        padding: 20px;
    }

    .preview-container {
        height: 250px;
    }

    .recordings-list {
        grid-template-columns: 1fr;
    }

    .modal-content {
        width: 95%;
    }

    .modal-header,
    .modal-body {
        padding: 20px;
    }

    .notification {
        right: 10px;
        left: 10px;
        min-width: auto;
    }
}
