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

:root {
  /* Light Mode Colors */
  --bg-primary: #f3f4f6; /* gray-100 */
  --bg-secondary: #ffffff; /* white */
  --bg-tertiary: #e5e7eb; /* gray-200 */
  --bg-accent: #ef4444; /* red-500 */
  --bg-button: #e5e7eb; /* gray-200 */
  --bg-button-hover: #d1d5db; /* gray-300 */
  --bg-record-active: #dc2626; /* red-600 */
  --text-primary: #111827; /* gray-900 */
  --text-secondary: #6b7280; /* gray-500 */
  --text-on-accent: #ffffff; /* white */
  --border-primary: #e5e7eb; /* gray-200 */
  --border-secondary: #d1d5db; /* gray-300 */
  --shadow-color: rgba(0, 0, 0, 0.1);
  --icon-filter: invert(0); /* No change for light mode */
  --placeholder-bg: #d1d5db; /* gray-300 */
  --indicator-active: #dc2626; /* red-600 */

  /* Dark Mode Colors (overridden when .dark class is present) */
  --dark-bg-primary: #111827; /* gray-900 */
  --dark-bg-secondary: #1f2937; /* gray-800 */
  --dark-bg-tertiary: #374151; /* gray-700 */
  --dark-bg-accent: #3b82f6; /* blue-500 */
  --dark-bg-button: #374151; /* gray-700 */
  --dark-bg-button-hover: #4b5563; /* gray-600 */
  --dark-bg-record-active: #dc2626; /* red-600 */ /* Keep red for record */
  --dark-text-primary: #f9fafb; /* gray-50 */
  --dark-text-secondary: #9ca3af; /* gray-400 */
  --dark-text-on-accent: #ffffff; /* white */
  --dark-border-primary: #374151; /* gray-700 */
  --dark-border-secondary: #4b5563; /* gray-600 */
  --dark-shadow-color: rgba(0, 0, 0, 0.3);
  --dark-icon-filter: invert(1); /* Invert for dark mode */
  --dark-placeholder-bg: #4b5563; /* gray-600 */
  --dark-indicator-active: #3b82f6; /* blue-500 */
}

html.dark {
  --bg-primary: var(--dark-bg-primary);
  --bg-secondary: var(--dark-bg-secondary);
  --bg-tertiary: var(--dark-bg-tertiary);
  --bg-accent: var(--dark-bg-accent);
  --bg-button: var(--dark-bg-button);
  --bg-button-hover: var(--dark-bg-button-hover);
  --bg-record-active: var(--dark-bg-record-active);
  --text-primary: var(--dark-text-primary);
  --text-secondary: var(--dark-text-secondary);
  --text-on-accent: var(--dark-text-on-accent);
  --border-primary: var(--dark-border-primary);
  --border-secondary: var(--dark-border-secondary);
  --shadow-color: var(--dark-shadow-color);
  --icon-filter: var(--dark-icon-filter);
  --placeholder-bg: var(--dark-placeholder-bg);
  --indicator-active: var(--dark-indicator-active);
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* --- Header --- */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem; /* py-3 px-4 */
    border-bottom: 1px solid var(--border-primary);
    background-color: var(--bg-secondary);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.app-header h1 {
    font-size: 1.25rem; /* text-xl */
    font-weight: 600; /* font-semibold */
}

#darkModeToggle {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.5rem; /* Adjust size as needed */
    padding: 0.25rem;
    border-radius: 9999px; /* rounded-full */
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem; /* w-10 */
    height: 2.5rem; /* h-10 */
    background-color: var(--bg-button);
    transition: background-color 0.2s ease-in-out;
}

#darkModeToggle:hover {
    background-color: var(--bg-button-hover);
}

#darkModeToggle .icon-dark { display: none; }
#darkModeToggle .icon-light { display: block; }
html.dark #darkModeToggle .icon-dark { display: block; }
html.dark #darkModeToggle .icon-light { display: none; }

/* --- Main Content Layout --- */
.main-content {
    display: flex;
    flex: 1; /* Take remaining height */
    overflow: hidden; /* Prevent content overflow */
    min-height: 0; /* Crucial for flex children with overflow */
}

/* --- Transcript Column (Left) --- */
.transcript-column {
    width: 33.3333%; /* w-1/3 */
    border-right: 1px solid var(--border-primary);
    background-color: var(--bg-secondary);
    padding: 1rem; /* p-4 */
    display: flex;
    flex-direction: column;
    overflow-y: hidden; /* Prevent this column itself from scrolling */
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.transcript-column h2 {
    margin-bottom: 0.75rem; /* mb-3 */
    font-size: 1.125rem; /* text-lg */
    font-weight: 600;
    color: var(--text-secondary);
    transition: color 0.3s ease;
}

.transcript-output-area {
    flex: 1; /* Take available space */
    overflow-y: auto; /* Allow scrolling */
    border-radius: 0.5rem; /* rounded-lg */
    background-color: var(--bg-tertiary);
    padding: 1rem; /* p-4 */
    font-family: monospace;
    white-space: pre-wrap;
    line-height: 1.6;
    transition: background-color 0.3s ease;
}

/* --- Video Column (Right) --- */
.video-column {
    flex: 1; /* Take remaining width */
    padding: 1.5rem; /* p-6 */
    display: flex;
    flex-direction: column;
    position: relative; /* For absolute positioning children */
}

/* --- Video Area --- */
.video-area {
    position: relative;
    flex: 1; /* Take up available vertical space */
    background-color: var(--bg-tertiary); /* bg-gray-200 / bg-gray-700 */
    border-radius: 0.5rem; /* rounded-lg */
    overflow: hidden; /* Clip webcam preview if needed */
    margin-bottom: 1rem; /* Space before controls */
    box-shadow: 0 4px 6px -1px var(--shadow-color), 0 2px 4px -2px var(--shadow-color); /* shadow-lg */
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
    min-height: 200px; /* Ensure minimum height */
}

.webcam-preview {
    position: absolute;
    bottom: 1rem; /* bottom-4 */
    right: 1rem; /* right-4 */
    width: 12rem; /* w-48 */
    height: 9rem; /* h-36 */
    border-radius: 0.5rem; /* rounded-lg */
    border: 2px solid var(--bg-secondary); /* border-white / border-gray-800 equivalent */
    background-color: var(--placeholder-bg); /* Show a placeholder color */
    object-fit: cover;
    z-index: 10;
    transition: border-color 0.3s ease, background-color 0.3s ease;
    /* Hide if stream not available? Or keep placeholder color? */
}

#recordingCanvas {
    display: block; /* Remove extra space below */
    width: 100%;
    height: 100%;
    object-fit: contain; /* Maintain aspect ratio within the area */
    background-color: #000; /* Black background while loading/inactive */
}

.recording-indicator {
    position: absolute;
    top: 1rem; /* top-4 */
    right: 1rem; /* right-4 */
    display: none; /* Hidden by default */
    align-items: center;
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    padding: 0.25rem 0.75rem; /* py-1 px-3 */
    border-radius: 9999px; /* rounded-full */
    font-size: 0.875rem; /* text-sm */
    z-index: 10;
}

.recording-indicator span {
    display: inline-block;
    width: 0.75rem; /* w-3 */
    height: 0.75rem; /* h-3 */
    background-color: var(--bg-record-active); /* bg-red-600 */
    border-radius: 50%;
    margin-right: 0.5rem; /* space-x-2 */
    animation: pulse 1.5s infinite ease-in-out;
}

/* --- Status & Controls --- */
.status-text {
    margin-top: 1rem; /* mt-4 */
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.875rem;
    min-height: 1.25rem; /* Ensure space */
}

.controls-container {
    margin-top: 1.5rem; /* mt-6 */
    display: flex;
    justify-content: center;
    gap: 1rem; /* space-x-4 */
}

.control-button {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 3rem; /* h-12 */
    width: 7rem; /* w-28 */
    padding: 0 1rem;
    border: none;
    border-radius: 0.375rem; /* rounded-md */
    font-weight: 500; /* font-medium */
    cursor: pointer;
    background-color: var(--bg-button);
    color: var(--text-primary);
    transition: background-color 0.2s ease-in-out, color 0.2s ease-in-out, opacity 0.2s ease;
}

.control-button:hover:not(:disabled) {
    background-color: var(--bg-button-hover);
}

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

.record-button.recording {
    background-color: var(--bg-record-active);
    color: var(--text-on-accent);
}

.record-button.recording:hover {
    background-color: #b91c1c; /* Slightly darker red */
}

.record-button .icon-record {
    display: inline-block; /* Or flex if needed */
    width: 1.25rem; /* w-5 */
    height: 1.25rem; /* h-5 */
    margin-right: 0.5rem; /* mr-2 */
}

.record-button.recording .icon-record span { /* The pulsing dot */
    display: inline-block;
    width: 0.75rem; /* w-3 */
    height: 0.75rem; /* h-3 */
    background-color: white;
    border-radius: 50%;
    animation: pulse 1.5s infinite ease-in-out;
}

.record-button:not(.recording) .icon-record svg {
    fill: currentColor;
    width: 100%;
    height: 100%;
}

/* --- Countdown Timer --- */
.countdown-overlay {
    position: absolute;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 5rem;
    font-weight: bold;
    display: none; /* Hidden by default */
    align-items: center;
    justify-content: center;
    z-index: 20;
    backdrop-filter: blur(5px);
}

/* --- Animations --- */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(0.9);
    }
}
