/* --- Global Styles & Variables --- */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

:root {
    --primary-color: #4F46E5; /* Indigo */
    --secondary-color: #EC4899; /* Pink */
    --success-color: #10B981; /* Emerald */
    --danger-color: #EF4444; /* Red */
    --warning-color: #F59E0B; /* Amber */
    --info-color: #3B82F6; /* Blue */
    --light-bg: #f8f9fa;
    --medium-bg: #e9ecef;
    --dark-text: #1f2937; /* Darker Gray */
    --medium-text: #4b5563; /* Medium Gray */
    --light-text: #ffffff;
    --grey-text: #6b7280; /* Gray */
    --border-color: #d1d5db; /* Lighter Gray Border */
    --font-family: 'Poppins', sans-serif;
    --box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --box-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --border-radius: 6px;
    --transition-speed: 0.3s;
    --transition-timing: ease-in-out;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    line-height: 1.6;
    color: var(--dark-text);
    background-color: var(--light-bg); /* Light background for the whole page */
    font-size: 16px;
    overflow-x: hidden; /* Prevent horizontal scroll */
}

/* --- Container & Layout --- */
.container {
    max-width: 900px;
    margin: 30px auto; /* Increased top/bottom margin */
    padding: 30px; /* Increased padding */
    background-color: var(--light-text);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    border: 1px solid var(--border-color);
}

/* --- Headings & Text --- */
h1, h2, h3, h4, h5, h6 {
    margin-bottom: 1rem;
    font-weight: 600;
    line-height: 1.3;
    color: var(--dark-text);
}

h1 { font-size: 2rem; }
h2 { font-size: 1.75rem; margin-top: 1.5rem; border-bottom: 1px solid var(--border-color); padding-bottom: 0.5rem;}
h3 { font-size: 1.4rem; font-weight: 500; }
p { margin-bottom: 1rem; color: var(--medium-text); }
a { color: var(--primary-color); text-decoration: none; transition: color var(--transition-speed) var(--transition-timing); }
a:hover { color: var(--secondary-color); text-decoration: underline; }
strong { font-weight: 600; }
code {
    background-color: var(--medium-bg);
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-size: 0.9em;
    font-family: monospace;
}
pre {
    background-color: var(--dark-text);
    color: var(--light-bg);
    padding: 15px;
    border-radius: var(--border-radius);
    font-size: 0.9em;
    overflow-x: auto; /* Allow horizontal scroll for long code */
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* --- Buttons --- */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: 500;
    font-size: 1rem;
    text-align: center;
    transition: all var(--transition-speed) var(--transition-timing);
    box-shadow: 0 1px 2px 0 rgba(0,0,0,0.05);
}
.btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--box-shadow);
    opacity: 0.95;
}
.btn:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 1px 2px 0 rgba(0,0,0,0.05);
}
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary { background: linear-gradient(90deg, var(--primary-color), var(--secondary-color)); color: var(--light-text); }
.btn-secondary { background-color: var(--grey-text); color: var(--light-text); }
.btn-secondary:hover:not(:disabled) { background-color: var(--medium-text); }
.btn-success { background-color: var(--success-color); color: var(--light-text); }
.btn-success:hover:not(:disabled) { background-color: #059669; } /* Darker success */
.btn-danger { background-color: var(--danger-color); color: var(--light-text); }
.btn-danger:hover:not(:disabled) { background-color: #DC2626; } /* Darker danger */

.btn-sm { padding: 6px 12px; font-size: 0.9rem; }
.small-btn { padding: 4px 8px; font-size: 0.8rem; } /* Even smaller */

/* --- Forms --- */
.form-group {
    margin-bottom: 1.5rem;
}
label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--dark-text);
    font-size: 0.95rem;
}
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea,
input[type="file"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background-color: var(--light-text);
    color: var(--dark-text);
    font-size: 1rem;
    transition: border-color var(--transition-speed) var(--transition-timing), box-shadow var(--transition-speed) var(--transition-timing);
}
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2); /* Primary color focus ring */
}
textarea {
    min-height: 100px;
    resize: vertical;
}
input[type="file"] {
    padding: 8px; /* Adjust padding for file input */
    background-color: var(--light-bg);
}
input::placeholder {
    color: var(--grey-text);
    opacity: 0.8;
}

/* --- Messages & Indicators --- */
.message {
    padding: 12px 15px;
    margin-bottom: 1.5rem;
    border-radius: var(--border-radius);
    border: 1px solid transparent;
    font-size: 0.95rem;
}
.success-message { background-color: #ECFDF5; color: #065F46; border-color: #A7F3D0; } /* Softer Success */
.error-message { background-color: #FEF2F2; color: #991B1B; border-color: #FECACA; }   /* Softer Error */
.info-message { background-color: #EFF6FF; color: #1E40AF; border-color: #BFDBFE; }    /* Softer Info */
.warning-message { background-color: #FFFBEB; color: #92400E; border-color: #FDE68A; } /* Softer Warning */

.small-msg { padding: 6px 10px; font-size: 0.9em; margin-top: 5px; margin-bottom: 5px; display: inline-block; }
.inline-msg { display: inline-block; margin-left: 10px; vertical-align: middle; }

#global-loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(5px);
    display: flex; /* Keep flex for centering */
    justify-content: center;
    align-items: center;
    z-index: 9999;
    font-size: 1.3em;
    color: var(--primary-color);
    font-weight: 500;
    transition: opacity 0.4s ease-in-out;
}
#global-loading.hidden { /* Transition opacity for fade out */
    opacity: 0;
    pointer-events: none;
}

/* --- Animations --- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

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

.fa-spinner {
    animation: spin 1s linear infinite;
}

/* Apply fade-in to sections when they appear */
#auth-section,
#dashboard-section,
#mock-interview-setup-section,
#mock-interview-section,
#mock-report-section {
    animation: fadeIn 0.6s var(--transition-timing) forwards;
}

/* --- Header --- */
header.container {
    background-color: transparent; /* Header container itself no background */
    box-shadow: none;
    border: none;
    padding-top: 15px;
    padding-bottom: 15px;
    margin-bottom: 0; /* Remove bottom margin if main content has top margin */
    border-bottom: 1px solid var(--border-color);
}
.header-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap; /* Allow wrapping */
    margin-bottom: 10px; /* Space before user info */
}
.header-main h1 {
    margin-bottom: 0; /* Remove margin if flex alignment is enough */
    font-size: 1.8rem; /* Slightly smaller h1 */
}
.home-link-container {
    /* Styling for the container if needed */
}
.home-link {
    text-decoration: none;
    color: var(--primary-color);
    font-size: 0.95em;
    font-weight: 500;
    transition: color 0.2s ease;
}
.home-link:hover {
    text-decoration: none; /* Remove underline on hover if desired */
    color: var(--secondary-color);
}
.home-link i {
    margin-right: 6px;
}

#user-info {
    display: flex; /* Use flex instead of JS style */
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-top: 1px solid var(--medium-bg);
    margin-top: 10px;
    font-size: 0.9rem;
    color: var(--medium-text);
}
#user-info strong {
    color: var(--dark-text);
    font-weight: 500;
}
#user-info #logout-btn {
    background-color: transparent;
    color: var(--danger-color);
    border: 1px solid var(--danger-color);
    padding: 5px 10px;
}
#user-info #logout-btn:hover {
    background-color: var(--danger-color);
    color: var(--light-text);
    transform: none; /* Disable lift on small button */
    box-shadow: none;
}

/* --- Auth Section --- */
#auth-section h2 {
    text-align: center;
    border-bottom: none; /* Remove border for auth title */
    margin-bottom: 1.5rem;
}
#auth-section p {
    text-align: center;
    margin-bottom: 2rem;
    color: var(--grey-text);
}
#login-form, #signup-form {
    max-width: 400px;
    margin: 0 auto;
    padding: 20px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background-color: var(--light-bg);
}
#login-form h3, #signup-form h3 {
    text-align: center;
    margin-bottom: 1.5rem;
    font-weight: 500;
}
#auth-section form button[type="submit"] {
    width: 100%;
    margin-top: 1rem;
    padding: 12px;
    font-size: 1.1rem;
}
#auth-section form p {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.9rem;
}

/* --- Dashboard Section --- */
#dashboard-section #start-mock-interview-btn {
    display: block;
    width: fit-content; /* Button only as wide as text */
    margin: 1rem auto 2rem auto; /* Center button */
    padding: 12px 25px;
    font-size: 1.1rem;
}
#past-interviews-list h3 {
    margin-top: 2.5rem; /* More space before past interviews */
    font-size: 1.2rem;
    color: var(--medium-text);
}
#interviews-history {
    list-style: none;
    padding: 0;
    margin-top: 1rem;
}
#interviews-history li {
    background-color: var(--light-bg);
    padding: 15px;
    margin-bottom: 10px;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color var(--transition-speed) var(--transition-timing);
}
#interviews-history li:hover {
    background-color: var(--medium-bg);
}
#interviews-history .interview-info span {
    display: block;
    font-size: 0.9rem;
    color: var(--grey-text);
}
#interviews-history .interview-info strong {
    font-size: 1rem;
    color: var(--dark-text);
    margin-right: 10px;
}
#interviews-history .interview-actions .btn {
    margin-left: 5px;
}


/* --- Mock Interview Setup Section --- */
#mock-interview-setup-section h2 {
    text-align: center;
    border-bottom: none;
    margin-bottom: 1.5rem;
}
#mock-interview-setup-form {
    max-width: 600px; /* Wider form */
    margin: 0 auto;
}
#mock-resume-status {
    font-size: 0.85rem;
    margin-top: 5px;
    display: block; /* Ensure it takes its own line */
}
#mock-interview-setup-form .form-group:last-child {
    text-align: center; /* Center the final buttons */
    margin-top: 2rem;
}
#mock-interview-setup-form .form-group:last-child .btn {
    margin: 0 10px; /* Space between buttons */
}

/* --- Mock Interview Active Section --- */
#mock-interview-section h2 {
    text-align: center;
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    border: none;
}
#mock-interview-qa-area {
    background-color: var(--light-bg);
    padding: 20px;
    border-radius: var(--border-radius);
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
}
#mock-question-title {
    font-size: 1rem;
    color: var(--grey-text);
    margin-bottom: 0.5rem;
    font-weight: 500;
}
#mock-question-text {
    font-size: 1.2em;
    color: var(--dark-text);
    margin-bottom: 0; /* Remove bottom margin if it's the only element */
    line-height: 1.5;
}

#mock-video-area {
    background-color: var(--dark-text); /* Dark background for video area */
    padding: 20px;
    border-radius: var(--border-radius);
    margin-bottom: 2rem;
    box-shadow: var(--box-shadow);
}
#mock-webcam-feed {
    display: block;
    width: 100%;
    max-width: 450px; /* Max width for the video */
    margin: 0 auto 15px auto; /* Center video */
    border-radius: var(--border-radius);
    border: 3px solid var(--medium-bg); /* Border around video */
    background-color: #000; /* Black bg if video not loaded */
}
.video-controls-status {
    text-align: center;
    color: var(--light-bg); /* Light text on dark background */
}
#mock-recording-status {
    display: inline-block;
    padding: 5px 10px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    font-size: 0.9rem;
    margin-right: 15px;
}
#mock-question-timer-display {
    font-weight: bold;
    font-size: 1.1rem;
    color: var(--light-bg);
}
#mock-loading-answer {
    margin-top: 10px;
    font-size: 0.9rem;
    color: var(--info-color);
}
#mock-stt-simulation-note {
    margin-top: 10px;
    display: inline-block; /* Keep inline */
}
.recording-controls {
    margin-top: 15px;
}
.recording-controls .btn {
    margin: 0 5px;
}
.recording-controls .btn i {
    margin-right: 5px;
}

.interview-navigation {
    text-align: center;
    margin-top: 1.5rem;
    padding-bottom: 1.5rem;
}
.interview-navigation .btn {
    margin: 0 10px;
}
.exit-controls {
     text-align: center;
     margin-top: 2rem;
     padding-top: 1.5rem;
     border-top: 1px solid var(--border-color);
}

/* --- Mock Interview Report Section --- */
#mock-report-section h2 {
    text-align: center;
    border-bottom: none;
    margin-bottom: 1.5rem;
}
#mock-loading-feedback, #mock-error-feedback {
    text-align: center;
    padding: 20px;
    font-size: 1.1rem;
}
#mock-feedback-content {
    margin-top: 1.5rem;
}
#mock-feedback-content h3 {
    font-size: 1.3rem;
    margin-top: 2rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--primary-color); /* Highlight report headings */
    color: var(--primary-color);
}
#mock-feedback-content h4 {
     font-size: 1.1rem;
     font-weight: 600;
     margin-top: 1.5rem;
     margin-bottom: 0.5rem;
     color: var(--dark-text);
}
.feedback-score-summary {
    background-color: var(--light-bg);
    padding: 15px;
    border-radius: var(--border-radius);
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-color);
    font-size: 1.1em;
}
.feedback-qa-log .qa-block {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    padding: 15px;
    border: 1px solid var(--medium-bg);
    border-radius: var(--border-radius);
    background-color: #fff; /* White background for QA blocks */
}
.feedback-qa-log .qa-block strong { /* Question/Answer labels */
    display: block;
    margin-bottom: 0.5rem;
    color: var(--primary-color);
    font-weight: 600;
}
.feedback-qa-log .qa-divider {
    border: 0;
    height: 1px;
    background-color: var(--border-color);
    margin: 2rem 0; /* More space around divider */
}
.video-link-container {
    margin-top: 10px; /* Space above video link */
    font-size: 0.9rem;
}
.video-link-container a {
    font-weight: 500;
}
.video-link-container i {
    margin-right: 5px;
}

.report-actions {
    text-align: center;
    margin-top: 2.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

/* --- Footer --- */
footer.container {
    text-align: center;
    margin-top: 40px;
    padding-top: 20px;
    padding-bottom: 20px;
    border-top: 1px solid var(--border-color);
    font-size: 0.9em;
    color: var(--grey-text);
    background: transparent; /* Footer container no background */
    box-shadow: none;
    border-bottom: none; /* Remove duplicate border if header has bottom */
}
footer .disclaimer {
    font-size: 0.8em;
    color: #9ca3af; /* Lighter grey */
    margin-top: 5px;
}

/* --- Utility Classes --- */
.hidden { display: none !important; }
.d-block { display: block !important; }
.mx-auto { margin-left: auto !important; margin-right: auto !important; }
.mt-1 { margin-top: 0.25rem !important; }
.mt-2 { margin-top: 0.5rem !important; }
.mt-3 { margin-top: 1rem !important; }
.mb-1 { margin-bottom: 0.25rem !important; }
.mb-2 { margin-bottom: 0.5rem !important; }
.mb-3 { margin-bottom: 1rem !important; }
.text-center { text-align: center !important; }

/* --- Responsiveness --- */
@media (max-width: 768px) {
    .container {
        margin: 20px auto;
        padding: 20px;
    }
    h1 { font-size: 1.8rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.25rem; }

    .header-main {
        flex-direction: column;
        align-items: flex-start;
    }
    .home-link-container {
         margin-top: 8px;
    }
     #user-info {
        font-size: 0.85rem;
        flex-direction: column;
        align-items: flex-start;
    }
     #user-info #logout-btn {
        margin-top: 8px;
    }

    #login-form, #signup-form {
        padding: 15px;
    }
}

@media (max-width: 576px) {
    body {
        font-size: 15px;
    }
    .container {
        margin: 15px auto;
        padding: 15px;
        border-radius: 0; /* Full width on small screens */
        border-left: none;
        border-right: none;
        box-shadow: none;
    }
    header.container, footer.container {
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    h1 { font-size: 1.6rem; }
    h2 { font-size: 1.4rem; }

    .btn { padding: 10px 15px; font-size: 0.95rem; }
    .btn-sm { padding: 5px 10px; font-size: 0.85rem; }

    #mock-webcam-feed {
        max-width: 100%; /* Allow video full width */
    }

    .interview-navigation .btn,
    #mock-interview-setup-form .form-group:last-child .btn {
        display: block; /* Stack buttons */
        width: 100%;
        margin: 10px 0 !important; /* Adjust spacing when stacked */
    }
    .exit-controls .btn {
         width: 80%; /* Make exit button not full width */
         margin: 10px auto;
    }
}