/* --- General Setup & Variables --- */
:root {
    --primary-color: #14213D; /* Dark Blue */
    --accent-color: #FCA311; /* Yellow */
    --light-gray: #E5E5E5;
    --white: #FFFFFF;
    --danger-color: #D90429;
    --font-family: 'Montserrat', sans-serif;
    --panel-width: 320px;
}

body, html {
    font-family: var(--font-family);
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden; /* Prevents scrollbars from the full-screen video */
    background-color: #000;
    color: var(--primary-color);
}

/* --- Startup Screen --- */
#startupScreen {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    background-color: var(--white);
    padding: 2rem 3rem;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    z-index: 200; /* Ensure it's on top */
}

#startupScreen h1 {
    font-weight: 700;
    font-size: 2.5rem;
    margin-top: 0;
    margin-bottom: 0.5rem;
}

/* --- Main App Container --- */
#mainApp {
    width: 100%;
    height: 100%;
    display: none;
    animation: fadeIn 0.5s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* --- Fullscreen Video --- */
.video-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

#webcam {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover; /* Cover the entire area, might crop */
    background-color: #000;
}

/* --- Overlaid Main Controls --- */
.main-controls {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1.5rem;
    background-color: rgba(20, 33, 61, 0.7); /* Semi-transparent dark blue */
    border-radius: 16px;
    z-index: 10;
    flex-wrap: wrap;
}

#timer {
    font-size: 1.5rem;
    font-family: monospace;
    color: var(--white);
    background: transparent;
    padding: 0.5rem 1rem;
}

#downloadContainer {
    margin-left: 10px;
}

/* --- Buttons --- */
button, #downloadLink {
    font-family: var(--font-family);
    font-weight: 700;
    font-size: 1rem;
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    border: none;
    border-radius: 8px;
    background-color: var(--accent-color);
    color: var(--primary-color);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    text-decoration: none;
    display: inline-block;
}

button:hover, #downloadLink:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

#recordButton.recording {
    background-color: var(--danger-color);
    color: var(--white);
}

#pauseButton {
    background-color: #6c757d;
    color: var(--white);
}

#startAllBtn {
    background-color: #2a9d8f;
    color: var(--white);
}

/* --- Side Panels --- */
.side-panel {
    position: fixed;
    top: 0;
    height: 100%;
    width: var(--panel-width);
    max-width: 90vw;
    background-color: var(--white);
    box-shadow: 0 0 20px rgba(0,0,0,0.2);
    z-index: 100;
    transition: transform 0.3s ease-in-out;
    overflow-y: auto;
    padding: 1.5rem;
    box-sizing: border-box;
}

#leftPanel {
    left: 0;
    transform: translateX(-100%);
}

#rightPanel {
    right: 0;
    transform: translateX(100%);
}

#leftPanel.open {
    transform: translateX(0);
}

#rightPanel.open {
    transform: translateX(0);
}

/* --- Panel Toggle Buttons --- */
.panel-toggle-btn {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    z-index: 101;
    background-color: var(--accent-color);
    color: var(--primary-color);
    border: none;
    border-radius: 0 8px 8px 0;
    width: 40px;
    height: 60px;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
}

.panel-toggle-btn.left {
    left: 0;
}

.panel-toggle-btn.right {
    right: 0;
    border-radius: 8px 0 0 8px;
    display: none; /* Hidden by default */
}

#mainApp.teleprompter-enabled .panel-toggle-btn.right {
    display: flex; /* Show only when teleprompter is enabled */
}


/* --- Controls Inside Panels --- */
.control-section {
    padding: 0; /* Padding is now on the panel itself */
}

.control-section h3 {
    margin-top: 0;
    margin-bottom: 1.5rem;
    font-size: 1.2rem;
    color: var(--primary-color);
}

label {
    font-weight: 700;
    margin-right: 0.5rem;
    display: block;
    margin-bottom: 0.5rem;
}

#aspectRatio, #teleprompterInput {
    width: 100%;
    padding: 0.75rem;
    border-radius: 8px;
    border: 2px solid var(--light-gray);
    font-family: var(--font-family);
    font-size: 1rem;
    box-sizing: border-box;
    margin-bottom: 1rem;
}

#teleprompterInput {
    resize: vertical;
    min-height: 350px; /* Increased from 200px */
    flex-grow: 1; /* Allow it to take available space */
}

input[type="range"] {
    width: 100%;
}

.effect-sliders > div {
    margin-bottom: 1rem;
}

.effect-buttons {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin-top: 1rem;
}

.effect-buttons button {
    background-color: var(--light-gray);
    flex-grow: 1;
}

/* --- Teleprompter Overlay --- */
#teleprompterOverlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, rgba(0,0,0,0.7) 0%, rgba(0,0,0,0.3) 50%, rgba(0,0,0,0.7) 100%);
    color: var(--white);
    font-size: clamp(1.5rem, 4vw, 3rem);
    font-weight: 700;
    line-height: 1.5;
    overflow: hidden;
    text-align: center;
    display: none;
    justify-content: center;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8);
    z-index: 5;
}

#teleprompterText {
    position: absolute;
    width: 80%;
    white-space: pre-wrap;
}

/* --- Responsive Design --- */
@media (max-width: 768px) {
    .main-controls {
        bottom: 1rem;
        gap: 0.5rem;
        padding: 0.5rem 1rem;
    }

    button, #downloadLink {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
    }

    .panel-toggle-btn {
        width: 35px;
        height: 50px;
        font-size: 1.2rem;
    }
}

/* --- Panel Footer --- */
.panel-footer {
    margin-top: auto; /* Pushes footer to the bottom */
    padding-top: 1.5rem;
    border-top: 2px solid var(--light-gray);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
}

.panel-footer img {
    max-height: 50px;
    opacity: 0.8;
    transition: opacity 0.2s ease;
}

.panel-footer img:hover {
    opacity: 1;
}

/* Make the control section a flex column to push footer down */
#teleprompterControls {
    display: flex;
    flex-direction: column;
    height: 100%;
}