/* --- Color & Theme Definitions --- */
:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: monospace;
  --bg-primary: #f0f2f5;
  --bg-secondary: #ffffff;
  --bg-tertiary: #e4e6eb;
  --text-primary: #050505;
  --text-secondary: #65676b;
  --border-color: #ced0d4;
  --accent-color: #1a73e8;
  --accent-color-hover: #1868d1;
  --success-color: #31a24c;
  --danger-color: #d93025;
  --danger-color-hover: #c22a21;
  --shadow-color: rgba(0, 0, 0, 0.1);
}
body.dark-mode {
  --bg-primary: #121212;
  --bg-secondary: #1e1e1e;
  --bg-tertiary: #2a2a2a;
  --text-primary: #e4e6eb;
  --text-secondary: #b0b3b8;
  --border-color: #393a3b;
  --accent-color: #1db954;
  --accent-color-hover: #1ed760;
  --success-color: #1db954;
  --danger-color: #ff453a;
  --danger-color-hover: #ff6861;
  --shadow-color: rgba(0, 0, 0, 0.3);
}

/* --- General Body & Layout --- */
body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  margin: 0;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  box-sizing: border-box;
}
.hidden { display: none; }
.container {
  width: 100%;
  max-width: 1600px;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.header {
  text-align: center;
  margin-bottom: 25px;
  position: relative;
  flex-shrink: 0;
}
.header h1 {
  margin-bottom: 8px;
  padding: 0 80px; 
}

/* --- Theme Toggle Button --- */
.theme-switch-wrapper { position: absolute; top: 10px; right: 10px; display: flex; align-items: center; gap: 10px; }
.theme-switch-label { font-size: 0.9em; }
.theme-switch { position: relative; display: inline-block; width: 50px; height: 28px; cursor: pointer; }
.theme-switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute;inset: 0; background-color: #ccc; transition: .4s; border-radius: 28px; }
.slider:before { position: absolute; content: ""; height: 20px; width: 20px; left: 4px; bottom: 4px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .slider { background-color: var(--accent-color); }
input:checked + .slider:before { transform: translateX(22px); }

/* --- Generic UI Components --- */
.card { background-color: var(--bg-secondary); padding: 25px; border-radius: 12px; border: 1px solid var(--border-color); box-shadow: 0 4px 12px var(--shadow-color); margin-bottom: 25px; }
.main-content .card { margin-bottom: 0; }
input[type="text"], input[type="password"], input[type="email"] { width: calc(100% - 24px); padding: 12px; margin: 8px 0; border-radius: 6px; border: 1px solid var(--border-color); background-color: var(--bg-primary); color: var(--text-primary); font-size: 1em; }
input[type="text"]:focus, input[type="password"]:focus, input[type="email"]:focus { outline: none; border-color: var(--accent-color); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-color) 25%, transparent); }
button, input[type="submit"] { padding: 12px 24px; border-radius: 8px; border: none; background-color: var(--accent-color); color: #fff; font-weight: bold; cursor: pointer; font-size: 1em; transition: background-color 0.2s ease; }
button:hover, input[type="submit"]:hover { background-color: var(--accent-color-hover); }
button.google-btn { background-color: #4285F4; color: white; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
button.google-btn:hover { background-color: #357ae8; }
button.google-btn img { background-color: #fff; border-radius: 2px; padding: 2px; height: 1.2em; width: 1.2em; }
.btn-danger { background-color: var(--danger-color); }
.btn-danger:hover { background-color: var(--danger-color-hover); }
.auth-separator { display: flex; align-items: center; text-align: center; color: var(--text-secondary); margin: 20px 0; }
.auth-separator::before, .auth-separator::after { content: ''; flex: 1; border-bottom: 1px solid var(--border-color); }
.auth-separator:not(:empty)::before { margin-right: .5em; }
.auth-separator:not(:empty)::after { margin-left: .5em; }
a { color: var(--accent-color); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Room Page Grid Layout --- */
.main-content { flex-grow: 1; min-height: 0; display: grid; grid-template-columns: 1fr minmax(350px, 450px); gap: 25px; }
.left-panel, .right-panel { display: flex; flex-direction: column; gap: 25px; min-height: 0; }
.video-card { padding: 20px; }
.video-container { position: relative; padding-bottom: 56.25%; height: 0; margin-bottom: 20px; }
.video-container iframe { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 8px; }
#add-video-form { display: flex; gap: 10px; }
#add-video-form input { flex-grow: 1; margin: 0; }
#add-video-form button { flex-shrink: 0; }
.info-card { flex-shrink: 0; }
#share-link { background-color: var(--bg-tertiary); padding: 10px; border-radius: 6px; font-family: var(--font-mono); word-break: break-all; white-space: pre-wrap; cursor: pointer; }
.queue-card { flex-grow: 1; min-height: 0; display: flex; flex-direction: column; }
.queue-scroll-wrapper { flex-grow: 1; min-height: 0; display: flex; }
#video-queue { width: 100%; overflow-y: auto; list-style: none; padding: 0; margin: 0; }
#video-queue li { padding: 12px 15px; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; }
#video-queue li.now-playing { background-color: var(--bg-tertiary); }
#video-queue li:last-child { border-bottom: none; }
#video-queue .video-title { flex-grow: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-right: 10px; cursor: pointer; }
.remove-video-btn { background: none; border: none; color: var(--text-secondary); cursor: pointer; font-size: 1.2rem; padding: 0 5px; }
.video-chat-container { flex-shrink: 0; }
#video-streams { display: flex; flex-wrap: wrap; gap: 15px; margin-top: 15px; min-height: 150px; background-color: var(--bg-primary); border-radius: 8px; padding: 10px; }
.video-element-container { position: relative; }
.video-element-container video { width: 200px; height: 150px; object-fit: cover; border-radius: 8px; background-color: #000; }
.video-username-overlay { position: absolute; bottom: 5px; left: 5px; background: rgba(0,0,0,0.5); color: white; padding: 2px 6px; border-radius: 4px; font-size: 0.8em; }
#in-call-controls { display: flex; justify-content: center; gap: 15px; margin-top: 15px; }
#in-call-controls button.active-toggle { background-color: var(--danger-color); }
#in-call-controls button.active-toggle:hover { background-color: var(--danger-color-hover); }

/* --- Responsive Layout --- */
@media (max-width: 960px) {
  .main-content { grid-template-columns: 1fr; }
  .right-panel { order: -1; }
  .queue-card { height: 350px; }
}

@media (max-width: 600px) {
    .header {
        /* Change to a flex column layout on small screens */
        display: flex;
        flex-direction: column-reverse; /* Puts title below the switch */
        align-items: center;
        gap: 15px;
        margin-bottom: 30px; /* Add some space below the new stacked header */
    }
    .header h1 {
        padding: 0; /* Remove horizontal padding on mobile */
        margin: 0;
    }
    .theme-switch-wrapper {
        position: static; 
    }
}


.footer {
  text-align: center;
  color: var(--text-secondary);
  padding-top: 25px;
  width: 100%;
  flex-shrink: 0;
  font-size: 0.8em;
}