/* === MODERN ELEGANT STYLE === */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

:root {
  --bg: #f9f9f9;
  --text: #1a1a1a;
  --primary: #003c44;
  --accent: #00646b;
  --bar-bg: #ffffff;
  --card-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  --light: #d4eff0; /* Slightly darker teal for better contrast */
  --border: #007c84;
}

.dark {
  --bg: #121212;
  --text: #f0f0f0;
  --primary: #003c44;
  --accent:  #00646b;
  --bar-bg: #1e1e1e;
  --card-shadow: 0 4px 12px rgba(255, 255, 255, 0.05);
}


body {
  font-family: 'Inter', sans-serif;
  background: var(--bg); /* Light gray in light mode */
  color: var(--text);
  margin: 0;
  padding: 0;
  line-height: 1.5;
  transition: background 0.3s ease, color 0.3s ease;
}

/* Header */
header {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1em;
  background: var(--primary); /* Blue header */
  color: #ffffff;
  border-radius: 0 0 16px 16px;
  box-shadow: var(--card-shadow);
  position: relative;
}

header img {
  width: 60px;
  height: 60px;
  border-radius: 50%; /* Circular icon */
  margin-bottom: 0.5em;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

header h1 {
  font-size: 1.8em;
  margin: 0;
  font-weight: 600;
}

header p {
  font-size: 0.95em;
  opacity: 0.85;
  margin: 0.3em 0 0.6em 0;
}

.header-checks {
  position: absolute;
  top: 1em;     /* less distance from top */
  left: 1em;    /* less distance from left */
  font-size: 0.8em;
  line-height: 1.4em;
  text-align: left;
  opacity: 0.9;
  max-width: 150px; /* optional: restrict width */
}


/* Top Buttons */
.top-banner-right {
  position: absolute;
  top: 0.75em;
  right: 1em;
  display: flex;
  gap: 10px;
}

.top-banner-right #language-toggle,
.top-banner-right #toggleTheme {
  background: transparent;
  border: none;
  color: #ffffff;
  font-size: 1.2em;
  cursor: pointer;
  padding: 0;
  width: 2.5em;
  height: 2.5em;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.3s ease;
}

.top-banner-right #language-toggle:hover,
.top-banner-right #toggleTheme:hover {
  color: var(--accent);
}

/* Main */
main {
  padding: 1em;
  max-width: 720px;
  margin: auto;
  background: var(--bg); /* Light gray, not white */
}

/* Tabs */
.tabs {
  display: flex;
  background: var(--bar-bg); /* #ffffff in light, #1e1e1e in dark */
  border-radius: 10px; /* Slightly larger for cohesive look */
  margin: 0.5em auto; /* Reduced margin for tighter integration */
  max-width: 720px;
  overflow: hidden; /* ensures buttons appear merged */
  padding: 0;
  border: none;
  box-shadow: 0 2px 8px var(--card-shadow); /* Subtle shadow for unity */
}

.tab-button {
  flex: 1;
  padding: 0.8em;
  background: transparent; /* Blends with .tabs container */
  color: var(--text); /* #1a1a1a in light, #f0f0f0 in dark */
  border: none;
  border-radius: 0; /* Change from 10px */
  margin: 0;
  font-weight: 500;
  font-size: 1rem; /* Consistent size */
  cursor: pointer;
  transition: background 0.3s ease, color 0.3s ease, transform 0.1s ease;
}

.tab-button:hover {
  background-color: #007c84; /* Slightly brighter than accent */
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2); /* Stronger shadow for integration */
}

.tab-button.active {
  background-color: var(--accent); /* Use accent instead of primary */
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  position: relative;
  z-index: 2;
}



/* Tab Content */
.tab-content {
  display: none;
  padding: 0.5em 1em;
  max-width: 720px;
  margin: auto;
  background: var(--bg); /* Light gray background */
  animation: fadeIn 0.3s ease-in;
}

.tab-content.active {
  display: block;
}

.tab-content#files {
  padding-top: 0.3em;
}

.tabs + .tab-content#files {
  margin-top: 0.2em;
}

/* Inputs and Buttons */
input,
button {
  font-family: inherit;
  padding: 0.6em 1em;
  border-radius: 8px;
  border: 1px solid var(--accent);
  font-size: 1em;
  margin: 0.3em 0;
  transition: border-color 0.3s ease, box-shadow 0.3s ease, transform 0.1s ease;
}

#hubForm label {
  display: block;
  margin-top: 0.5em;
}

input:focus,
button:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(51, 102, 255, 0.2);
}

button {
  background: var(--primary); /* Blue buttons */
  color: #ffffff;
  border: none;
  cursor: pointer;
  font-weight: 500;
}

button:hover {
  background: var(--accent);
  transform: scale(1.02);
}

button:disabled {
  background: #cccccc;
  cursor: not-allowed;
  opacity: 0.6;
}

/* Files Tab Buttons */
.files-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0.3em 0;
}

.files-buttons button {
  flex: 1;
  min-width: 110px;
  padding: 0.6em;
  text-align: center;
  border-radius: 8px;
}

/* Forms Buttons */
.forms-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0.3em 0;
}

.forms-buttons button {
  flex: 1;
  min-width: 110px;
  padding: 0.6em;
  text-align: center;
  border-radius: 8px;
}

/* Slide Controls */
#slideControls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 0.5em 0;
}

#slideInput {
  flex: 1;
  max-width: 200px;
}

/* Slides Container */
#slidesContainer {
  display: none;
  border: 1px solid var(--accent);
  padding: 12px;
  border-radius: 8px;
  background: var(--bar-bg);
  margin: 0.5em 0;
  max-height: 300px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--primary) var(--bar-bg);
  box-shadow: var(--card-shadow);
}

#slidesContainer img,
#slidesContainer embed {
  object-fit: contain;
  max-width: 120px;
  max-height: 120px;
  margin: 5px;
  border-radius: 6px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#slidesContainer div {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 5px 0;
}

#slidesContainer button {
  padding: 0.4em 0.8em;
  font-size: 0.9em;
}

/* Slide Status */
#slideStatus {
  font-size: 0.9em;
  color: var(--text);
  margin: 0.5em 0;
  opacity: 0.8;
}

/* Upload Buttons */
#uploadBtn,
#uploadSlidesBtn {
  padding: 8px 16px;
  min-width: 100px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}

/* File, Poll, Template, and Quiz Lists */
ul {
  list-style: none;
  padding: 0;
}

li.placeholder {
  background: var(--bar-bg);
  border: 1px solid var(--accent);
  border-radius: 8px;
  margin: 0.5em 0;
  padding: 0.8em;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background 0.3s ease, transform 0.1s ease;
  cursor: pointer;
  box-shadow: var(--card-shadow);
}



li.placeholder:hover {
  background: var(--accent);
  color: #ffffff;
  transform: translateY(-1px);
}

li.placeholder span {
  flex: 1;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-right: 10px;
}

.file-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.file-actions button {
  background: transparent;
  border: none;
  color: var(--primary);
  font-size: 1.2em;
  cursor: pointer;
  transition: color 0.3s ease;
}

.file-actions button:hover {
  color: var(--accent);
}

/* Preview Overlay */
#previewOverlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.65);
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

/* Feedback Form */
#feedbackForm textarea {
  width: 100%;
  min-height: 100px; /* Larger input bar for feedback */
  resize: vertical; /* Allows vertical resizing only */
  padding: 0.6em;
  border-radius: 8px;
  border: 1px solid var(--accent);
  font-family: inherit;
  font-size: 1em;
  margin: 0.5em 0;
  box-sizing: border-box;
}

#feedbackForm textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(51, 102, 255, 0.2);
}

/* Arabic RTL for feedback form */
body.arabic #feedbackForm textarea,
body.arabic #feedbackForm label {
  direction: rtl;
  text-align: right;
}

body.arabic #feedbackForm h3 {
  text-align: right;
}

#feedbackLink {
  user-select: none; /* Prevents text selection */
  -webkit-user-select: none; /* For Safari */
  -webkit-touch-callout: none; /* Disable iOS long-press menu */
}


#previewBox {
  background: var(--bg); /* Light gray in light mode */
  padding: 1.5em;
  border-radius: 12px;
  max-width: 85vw;
  width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

#previewContent p,
#previewContent div,
#previewContent form {
  margin: 0.5em 0;
  padding: 0.5em;
}

#previewContent strong {
  font-weight: 600;
}

body.dimmed {
  overflow: hidden;
}

/* Spinner */
.spinner-container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
  animation: pulse 1.6s ease-in-out infinite;
}

.spinner {
  border: 5px solid var(--bar-bg);
  border-top: 5px solid var(--primary);
  border-radius: 50%;
  width: 24px;
  height: 24px;
  animation: spin 0.8s linear infinite;
}

/* Poll Options */
#pollOptions input {
  display: block;
  margin-bottom: 0.5em;
}

/* Share Screen Button */
#shareScreenBtn {
  margin: 0.5em 0;
  padding: 0.6em 1em;
  border-radius: 8px;
  font-weight: 500;
}

/* Live View */
#liveViewContainer video {
  width: 100%;
  margin-top: 12px;
  border: 2px solid var(--accent);
  border-radius: 8px;
}

#liveSnapshot:fullscreen {
  width: 100vw;
  height: 100vh;
  object-fit: contain;
  background: var(--bg);
}

/* Floating Help Button */
#floatingHelpBtn {
  position: fixed;
  bottom: 1.5em;
  right: 1.5em;
  background: var(--primary);
  color: #ffffff;
  width: 3em;
  height: 3em;
  border-radius: 50%;
  border: none;
  font-size: 1.2em;
  box-shadow: var(--card-shadow);
  cursor: pointer;
  transition: transform 0.2s ease, background 0.3s ease;
  z-index: 2001; /* Above all, including help box */
  display: none;
}

#floatingHelpBtn:hover {
  background: var(--accent);
  transform: scale(1.1);
}

#floatingHelpBox {
  position: fixed;
  bottom: 5em;
  right: 1.5em;
  background: var(--bar-bg);
  color: var(--text);
  padding: 1em;
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  max-width: 280px;
  font-size: 0.9em;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 2000; /* Ensure above poll bars */
}

#floatingHelpBox.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

/* Animations */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Dark Mode Adjustments */
@media (prefers-color-scheme: dark) {
  #floatingHelpBtn {
    background: var(--accent);
    color: #1a1a1a;
  }
  #floatingHelpBox {
    border-color: #444;
  }
}

/* Upload Progress */
#uploadProgress {
  margin-left: 12px;
  font-size: 0.9em;
  color: var(--primary);
  opacity: 0.8;
}

/* === Explicit Light Mode Fixes === */
body:not(.dark) header {
  background: var(--primary); /* Blue header in light mode */
  color: #ffffff; /* White text */
}

body:not(.dark) button:not(.file-actions button):not(#language-toggle):not(#toggleTheme) {
  background: var(--primary); /* Blue background for buttons */
  color: #ffffff; /* White text */
}

body:not(.dark) button:not(.file-actions button):not(#language-toggle):not(#toggleTheme):hover {
  background: var(--accent); /* Lighter blue on hover */
  color: #ffffff;
}

/* Light mode tab styles are handled by .tab-button, .tab-button:hover, and .tab-button.active */

body:not(.dark) .file-actions button {
  background: transparent; /* Transparent for file action buttons */
  color: var(--primary); /* Blue icons */
}

body:not(.dark) .file-actions button:hover {
  color: var(--accent); /* Lighter blue on hover */
}

body:not(.dark) #language-toggle,
body:not(.dark) #toggleTheme {
  background: transparent; /* Transparent for theme/language toggle */
  color: #ffffff; /* White icons */
}

body:not(.dark) #language-toggle:hover,
body:not(.dark) #toggleTheme:hover {
  color: var(--accent); /* Lighter blue on hover */
}

/* Make the subtitle responsive in size but single-line */
.header-subtitle {
  font-size: clamp(0.8rem, 2vw, 1.2rem);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.header-features {
  font-size: clamp(0.6rem, 2.5vw, 1rem); /* more flexible on small screens */
  color: white;
  opacity: 0.85;
  text-align: center;
  margin-top: 0.3em;
  white-space: nowrap;
  max-width: 90vw; /* keeps it within screen */
}


/* Rooms Tab Container */
#rooms {
  position: relative;
}

/* Join Code Container */
.join-code-container {
  position: absolute;
  top: 10px;
  right: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 10;
}

.join-code-container input#joinCodeInput {
  width: 100px; /* Shortened input width */
  padding: 0.4em 0.8em;
  font-size: 0.9em;
  border-radius: 6px;
  border: 1px solid var(--primary);
  background: var(--background);
  color: var(--text);
}

.join-code-container button#joinCodeBtn {
  padding: 0.4em 0.8em;
  font-size: 0.9em;
  min-width: 60px;
  border-radius: 6px;
  background: var(--accent);
  color: var(--background);
  border: none;
}


/* Ensure consistent tab button styling in both themes */
.tabs .tab-button {
  background: transparent;
  color: var(--text);
  border: none;
}

.tabs .tab-button.active {
  background: #007c84 !important;
  color: #ffffff !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  font-weight: 600;
  z-index: 3;
  border: none;
}


.tabs .tab-button:hover {
  background: var(--accent);
  color: #fff;
}

.tab-button {
  transition: background 0.3s ease, color 0.3s ease;
}


/* Poll question text styling */
#pollList li.placeholder span {
  white-space: normal; /* Allow text to wrap */
  overflow: visible; /* Prevent overflow hiding */
  text-overflow: unset; /* Remove ellipsis */
  flex: 1; /* Ensure it takes available space */
  padding: 0; /* No padding to blend with container */
  margin: 0; /* No margin */
}

/* Poll list item layout */
#pollList li.placeholder.poll-race {
     flex-direction: column;
     align-items: flex-start;
     gap: 12px;
     padding: 1em;
     box-sizing: border-box;
     border: 1px solid var(--accent);
     border-radius: 12px;
     background: var(--bar-bg);
     box-shadow: var(--card-shadow);
   }

#pollList li.placeholder.poll-race:hover {
  background: var(--accent);
  color: #ffffff;
}

/* Ensure options and delete button align neatly */
.poll-results {
     width: 100%;
     margin-top: 0.6em;
     display: flex;
     flex-direction: column;
     gap: 10px;
   }

   .poll-bar-row {
     display: flex;
     align-items: center;
     background: var(--bar-bg); /* Default white-ish background */
     border: 1px solid var(--accent);
     border-radius: 8px;
     overflow: hidden;
     min-height: 40px;
     position: relative;
   }

   .poll-bar-row::before {
     content: '';
     position: absolute;
     top: 0;
     left: 0;
     height: 100%;
     background: var(--primary); /* Teal fill */
     width: var(--percentage);
     transition: width 1.2s ease-out; /* Loading animation */
     z-index: 0; /* Above row background, below text */
   }

   .poll-bar-row:hover:not(.voted) {
     background: var(--light); /* Change to light teal on hover */
   }

.poll-bar-row.voted::after {
     content: "\2714";
     font-weight: bold;
     position: absolute;
     right: 0.5em;
     top: 50%;
     transform: translateY(-50%);
     color: var(--text); /* Adapts to light/dark mode */
     z-index: 3; /* Above .poll-bar (z-index: 1) and .poll-bar-row::before (z-index: 0) */
     display: inline-block;
   }

.poll-bar-stats {
     position: absolute;
     right: 2em; /* Space for checkmark */
     top: 50%;
     transform: translateY(-50%);
     color: var(--text); /* Adapts to light/dark mode */
     font-size: 0.95em;
     font-weight: bold;
     z-index: 3; /* Above .poll-bar and ::before */
     display: inline-block;
   }

   .poll-bar-row.voted .poll-bar-label::before,
   .poll-bar-row.voted .poll-bar-label::after {
     content: "";
   }

.poll-bar-label {
     flex: 1;
     padding: 0.5em 0.8em;
     color: var(--text);
     font-size: 0.95em;
     white-space: nowrap;
     overflow: hidden;
     text-overflow: ellipsis;
     position: relative; /* Ensure above ::before */
     z-index: 2; /* Higher than ::before (z-index: 0) */
   }

   body.arabic .poll-bar-row.voted .poll-bar-label::after,
   body.arabic .poll-bar-row.voted .poll-bar-label::before {
     content: "";
   }

 

   .poll-delete-btn {
     background: transparent;
     border: none;
     color: var(--primary);
     font-size: 1.2em;
     cursor: pointer;
     padding: 0.5em;
     margin-left: auto;
     position: relative;
     z-index: 1; /* Above ::before */
   }

   .poll-delete-btn:hover {
     color: var(--accent);
   }

   body.arabic .poll-bar-row {
     flex-direction: row-reverse;
   }

   body.arabic .poll-bar-row::before {
     left: unset;
     right: 0;
   }

   body.arabic .poll-bar-row .poll-bar-label {
     text-align: right;
   }

   body.arabic .poll-bar-stats {
     left: 2em; /* Space for checkmark */
     right: unset;
     top: 50%;
     transform: translateY(-50%);
     color: var(--text); /* Adapts to light/dark mode */
     font-size: 0.95em;
     font-weight: bold;
     z-index: 3; /* Above .poll-bar and ::before */
     display: inline-block;
   }

      body.arabic .poll-bar-row.voted::after {
     content: "\2714";
     font-weight: bold;
     position: absolute;
     left: 0.5em;
     right: unset;
     top: 50%;
     transform: translateY(-50%);
     color: var(--text); /* Adapts to light/dark mode */
     z-index: 3; /* Above .poll-bar and ::before */
     display: inline-block;
   }

.poll-bar {
     position: relative;
     z-index: 1; /* Below .poll-bar-label and checkmark (z-index: 2) */
   }
   @media (max-width: 480px) {
     .poll-bar-row {
       min-height: 36px;
     }
     .poll-bar-label {
       font-size: 0.9em;
       padding: 0.4em 0.6em;
     }
     .poll-delete-btn {
       font-size: 1.1em;
       padding: 0.4em;
     }
   }


/* Arabic RTL text styling for specific elements */
body.arabic #floatingHelpBox {
  direction: rtl;
  text-align: right;
}

body.arabic #pollList li.placeholder span {
  direction: rtl;
  text-align: right;
}

body.arabic #quizList li.placeholder,
body.arabic #templateList li.placeholder {
  direction: rtl;
  text-align: right;
}

body.arabic #previewContent div:not(.export-row),
body.arabic #previewContent p,
body.arabic #previewContent b,
body.arabic #previewContent label,
body.arabic #previewContent strong {
  direction: rtl;
  text-align: right;
}

body.arabic #previewContent form input,
body.arabic #previewContent form button {
  direction: ltr; /* Ensure inputs and buttons remain LTR */
  text-align: left;
}

/* Prevent buttons and file actions from being reversed */
body.arabic #pollList li.placeholder .resultsDiv,
body.arabic #pollList li.placeholder .file-actions,
body.arabic #previewContent .export-row {
  direction: ltr;
  text-align: left;
}


/* Reverse floating help box colors */
body:not(.dark) #floatingHelpBox {
  background: var(--primary); /* Dark background in light mode */
  color: #ffffff; /* White text in light mode */
}

body.dark #floatingHelpBox {
  background: #ffffff; /* Light background in dark mode */
  color: #1a1a1a; /* Dark text in dark mode */
}

/* Responsive styling for Choose File bar */
#fileInput {
  width: 100%;
  max-width: 400px; /* Prevent the bar from getting too long */
  box-sizing: border-box; /* Ensure padding doesn’t increase width */
}

/* Adjust for small screens */
@media (max-width: 600px) {
  #fileInput {
    max-width: 90%; /* Slightly smaller on mobile for better fit */
    padding: 8px; /* Reduce padding for compact appearance */
    font-size: 14px; /* Smaller font size for mobile */
  }
}

/* Ensure container supports responsive file input */
#uploadSection {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
}

/* Responsive styling for Join by Code bar */
@media (max-width: 480px) {
  .join-code-container input#joinCodeInput {
    width: 80px; /* Reduce width on small screens to prevent overlap */
  }
}

#floatingHelpBox p {
  margin: 0.3em 0; /* Reduce vertical spacing */
}


button, [role="button"], [style*="cursor: pointer"] {
  touch-action: manipulation; /* Prevent mobile browser gestures */
  -webkit-touch-callout: none; /* Disable iOS context menu */
  user-select: none; /* Prevent text selection */
  -webkit-user-select: none; /* For Safari */
}


.beta-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background-color: var(--primary); /* dark teal */
  color: #ffffff;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75em;
  font-weight: 500;
  z-index: 1000;
  direction: rtl;
  border: 1px solid var(--border); /* subtle outline */
  box-shadow: none !important;
  text-shadow: none !important;
  opacity: 0.85;

display: flex;
  align-items: center;  /* ✅ vertical centering */
  height: 1.8em;         /* ✅ consistent height for better centering */
  line-height: 1;        /* ✅ avoid vertical drift */
}


/* iOS fullscreen overlay */
#iosFsOverlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.96);
  z-index: 99999;
  display: none;            /* toggled via JS */
  align-items: center;      /* center content */
  justify-content: center;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  padding:
    env(safe-area-inset-top)
    env(safe-area-inset-right)
    env(safe-area-inset-bottom)
    env(safe-area-inset-left);
}

#iosFsOverlay.show { display: flex; }

#iosFsContent {
  position: relative;
  width: 99vw;
  height: calc(var(--ios-vh, 100vh) * 0.99); /* 99% of inner height */
  max-width: 100vw;
  max-height: calc(var(--ios-vh, 100vh));
  display: flex;
  align-items: center;
  justify-content: center;   /* centers the canvas */
  overflow: visible;         /* lets the exit button be half outside */
}

/* Half-visible exit button (sits partly beyond the top-right corner) */
#iosFsExit {
  position: absolute;
  top: -12px;
  right: -12px;
  width: 44px;
  height: 44px;
  border-radius: 9999px;
  border: 1px solid rgba(255,255,255,0.35);
  background: rgba(30,30,30,0.7);
  color: #fff;
  font-size: 28px;
  line-height: 40px;
  text-align: center;
  cursor: pointer;
  opacity: 0.9;
}

#iosFsExit:active { transform: scale(0.98); }

/* Prevent page scroll bounce behind overlay on iOS */
html.ios-overlay-lock,
body.ios-overlay-lock {
  overflow: hidden !important;
  height: 100% !important;
}




@import url('https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@400&display=swap');
#notebookArea-${nbId} {
  color: #000 !important;
  z-index: 2 !important;
}


#rooms p, #rooms span, #rooms input, #rooms label, #rooms li {
color: var(--text) !important;
}
#rooms input {
background: var(--bar-bg) !important;
}


/* Whiteboard container styling (default for all devices) */
.whiteboard-container {
  width: 90vw; /* Responsive width */
  max-width: 360px; /* Cap to typical mobile viewport width */
  max-height: 95vh; /* Use 95% of viewport height to include tools */
  padding: 1em;
  background: var(--bar-bg);
  border-radius: 8px;
  box-shadow: var(--card-shadow);
  box-sizing: border-box;
  margin: 0 auto; /* Center the container */
}

/* Whiteboard canvas styling */
.whiteboard-canvas {
  width: 100% !important; /* Fill container width */
  height: auto !important; /* Maintain aspect ratio */
  aspect-ratio: 3/4; /* Taller aspect ratio for more height */
  max-height: calc(95vh - 4.5em); /* Reserve space for header and tools */
  background: #fff;
  border: 1px solid var(--accent);
  border-radius: 8px;
}

/* Non-mobile devices (laptops, desktops) */
@media screen and (min-width: 768px) {
  .whiteboard-container {
    width: 100%; /* Use available width up to max */
    max-width: 360px; /* Same cap as mobile for consistent content */
    max-height: 95vh; /* Use 95% of viewport height */
  }
  .whiteboard-canvas {
    aspect-ratio: 3/4; /* Consistent taller aspect ratio */
    max-height: calc(95vh - 4.5em); /* Reserve space for header and tools */
  }
}

/* Ensure the preview overlay centers the whiteboard */
.previewOverlay {
  display: flex;
  justify-content: center;
  align-items: center;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.65);
  z-index: 1000;
  overflow: hidden; /* Prevent scrolling in overlay */
}


#previewOverlay {
  z-index: 1000; /* File preview above submission overlay */
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
}
#submissionOverlay {
  z-index: 500; /* Submission overlay below file preview */
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
}
#previewBox {
  background: var(--bar-bg); /* Use theme background */
  color: var(--text); /* Use theme text color */
  padding: 20px;
  border-radius: 8px;
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}
#previewContent {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
#previewContent .file-action-link {
  margin-right: 20px;
  color: var(--primary); /* Match app's primary color */
  text-decoration: underline;
  cursor: pointer;
  display: inline-block;
}
#previewContent .file-action-link:hover {
  color: var(--accent); /* Match hover style */
}
.spinner-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100px;
}


/* Defining notebook-specific colors */
:root {
  --notebook-bg: #FFF8E1; /* Cream/light yellow for notebook background */
  --notebook-text: #333; /* Dark text for readability */
  --notebook-line: #ADD8E6; /* Light blue for horizontal lines */
  --notebook-margin: #FF4040; /* Red for left margin line */
}

/* Styling the notebook modal for responsiveness */
.previewOverlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  overflow: auto;
  padding: 1rem;
  box-sizing: border-box;
}

/* Ensuring notebook container is responsive */
#notebookList + div > div[id^="notebook-"] {
  width: 100%;
  max-width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1rem;
  box-sizing: border-box;
}

/* Styling textarea for notebook appearance */
textarea[id^="notebookArea-"] {
  width: 100%;
  min-height: 40vh;
  max-height: 80vh;
  padding: 1rem 1rem 1rem 2rem; /* Extra left padding for margin line */
  box-sizing: border-box;
  border: 1px solid var(--accent, #ccc);
  border-radius: 8px;
  font-family: 'Georgia', serif;
  line-height: 1.75rem; /* Matches canvas line spacing */
  background: var(--notebook-bg);
  color: var(--notebook-text);
  resize: vertical;
  overflow-y: auto;
font-size: 1.2rem;
}

/* Media query for smaller screens */
@media screen and (max-width: 600px) {
  .previewOverlay {
    padding: 0.5rem;
  }

  #notebookList + div > div[id^="notebook-"] {
    max-width: 95vw;
    padding: 0.5rem;
  }

  textarea[id^="notebookArea-"] {
    min-height: 50vh;
    padding: 0.5rem 0.5rem 0.5rem 1.5rem;
    font-size: 1.1rem;
  }
}

/* Media query for very small screens (e.g., mobile) */
@media screen and (max-width: 400px) {
  textarea[id^="notebookArea-"] {
    font-size: 1.0rem;
    line-height: 1.5rem;
  }

  /* Adjust canvas line spacing for smaller screens */
  #notebookList + div > div[id^="notebook-"] canvas[id^="notebookCanvas-"] {
    --line-spacing: 1.5rem;
  }
}

.add-item-btn {
  position: fixed;
  bottom: 1.5em;
  right: 1.5em;
  width: 3em;
  height: 3em;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-size: 1.5em;
  border: none;
  cursor: pointer;
  box-shadow: var(--card-shadow);
  z-index: 100;
  transition: transform 0.1s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.add-item-btn:hover {
  transform: scale(1.1);
  background: var(--accent);
}

.item-drawer {
  position: fixed;
  bottom: -80%;
  left: 0;
  width: 100%;
  height: 80%;
  background: var(--bar-bg);
  transition: bottom 0.3s ease;
  z-index: 99;
  overflow-y: auto;
  box-shadow: var(--card-shadow);
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
}

.item-drawer.open {
  bottom: 0;
}

.drawer-content {
  padding: 1em;
}

.category {
  margin-bottom: 1.5em;
}

.category h4 {
  color: var(--primary);
  font-size: 1.2em;
  margin-bottom: 0.5em;
}

.category button {
  display: block;
  width: 100%;
  padding: 0.6em;
  margin: 0.3em 0;
  background: var(--bar-bg);
  border: 1px solid var(--accent);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  font-size: 1em;
  text-align: left;
}

.category button:hover {
  background: var(--accent);
  color: white;
}




.file-input-wrapper {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.file-input-wrapper input[type="file"] {
  flex: 1;
  min-width: 150px;
}

.file-input-wrapper button#uploadBtn {
  padding: 8px 16px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1em;
  white-space: nowrap;
}

.file-input-wrapper button#uploadBtn:hover {
  background: var(--accent);
}


/* Update the progress bar fill with a more elegant gradient and animation */
.file-input-wrapper #progressBar {
  height: 12px; /* Maintain existing height */
  width: 0%; /* Controlled by JS */
  background: linear-gradient(90deg, #2dd4bf, #10b981); /* Teal to emerald gradient for elegance */
  border-radius: 8px; /* Maintain rounded corners */
  transition: width 0.3s ease-in-out, background 0.5s ease; /* Smooth width and background transition */
  position: relative;
  overflow: hidden; /* Ensure gradient stays within bounds */
  animation: shimmer 2s infinite linear; /* Subtle shimmer animation */
}

/* Add shimmer animation for a polished effect */
@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

/* Update text color to white in light mode */
.file-input-wrapper #uploadProgress::after {
  content: attr(data-file-name, "Uploading...") " " attr(data-percentage, "0%"); /* Unchanged */
  position: absolute;
  top: 50%;
  left: 12px;
  transform: translateY(-50%);
  color: #ffffff; /* White text in light mode */
  font-size: 0.9em; /* Unchanged */
  font-weight: 500; /* Unchanged */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: calc(100% - 24px); /* Unchanged */
}

/* Ensure dark mode text remains white for consistency */
body.dark .file-input-wrapper #uploadProgress::after {
  color: #ffffff !important; /* White text in dark mode (unchanged) */
}



.sheet-grid {
  border-collapse: collapse;
  width: 100%;
  font-family: 'Roboto Mono', monospace;
  font-size: 14px;
}
.sheet-grid td {
  border: 1px solid var(--accent);
  min-width: 80px;
  padding: 4px;
  white-space: nowrap;
  overflow: hidden;
}
.sheet-grid td:focus {
  outline: 2px solid var(--primary);
}






/* 🎯 Taboo Game Modal — Fun Game-Like Look */
.taboo-modal {
  position: fixed !important;
  inset: 0 !important;
  z-index: 9999 !important;
  background: radial-gradient(circle at center, rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0.9)) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  animation: fadeIn 0.3s ease-out;
  backdrop-filter: blur(6px);
}

.taboo-modal > div {
  background: linear-gradient(145deg, #ffffff, #f5f7fa) !important;
  color: #222 !important;
  padding: 2rem !important;
  border-radius: 1.5rem !important;
  width: 22rem !important;
  max-width: 90vw !important;
  text-align: center !important;
  position: relative !important;
  box-shadow: 0 0 25px rgba(0, 0, 0, 0.3);
  border: 3px solid #2563eb; /* Tailwind blue-600 */
  animation: slideUp 0.35s ease-out;
}

.taboo-modal h3, .taboo-modal h4 {
  color: #1e3a8a !important; /* Blue headline */
  text-shadow: 0 0 4px rgba(37,99,235,0.3);
}

.taboo-modal button {
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.taboo-modal button:hover {
  transform: scale(1.08);
  box-shadow: 0 0 10px rgba(37,99,235,0.4);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes slideUp {
  from { transform: translateY(40px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}



/* ==== iHere.me Trivia Game Styles (Refined + Hybrid Gamified) ==== */

/* Overlay for main trivia modal */
.trivia-modal {
  position: fixed !important;
  inset: 0 !important;
  z-index: 9999 !important;
  background: radial-gradient(circle at center, rgba(0, 0, 40, 0.75), rgba(0, 0, 0, 0.9)) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  animation: fadeIn 0.3s ease-out;
  backdrop-filter: blur(8px);
}

/* Inner trivia window – elegant + lightly gamified */
.trivia-modal > div {
  background: linear-gradient(145deg, #ffffff, #f5f7fa) !important;
  color: #111 !important;
  padding: 2rem !important;
  border-radius: 1.5rem !important;
  width: 95vw !important;
  max-width: 480px !important;
  max-height: 85vh !important;
  overflow-y: auto !important;
  text-align: left !important;
  position: relative !important;
  border: 3px solid #2563eb;
  box-shadow: 0 0 35px rgba(37,99,235,0.35);
  animation: slideUp 0.35s ease-out, pulseFrame 2s infinite alternate;
}

/* Close button */
.trivia-modal button.close {
  background: transparent !important;
  border: none !important;
  font-size: 1.4rem !important;
  color: #444 !important;
  cursor: pointer !important;
  position: absolute !important;
  top: 10px !important;
  right: 14px !important;
  transition: color 0.2s ease;
}
.trivia-modal button.close:hover { color: #000 !important; }

/* Headings */
.trivia-modal h3, .trivia-modal h4 {
  color: #1e3a8a !important;
  text-shadow: 0 0 6px rgba(37,99,235,0.3);
  text-align: center;
}

/* Fix long question wrapping — target actual runtime element */
.trivia-modal .font-semibold.mb-2 {
  display: block !important;
  white-space: normal !important;
  overflow-wrap: anywhere !important;
  word-wrap: break-word !important;
  font-weight: 700 !important;
  text-align: center !important;
  line-height: 1.4 !important;
  font-size: clamp(1rem, 4vw, 1.6rem) !important;
  margin-bottom: 1rem !important;
}



/* === Question Editing Overlay === */
.trivia-editor-overlay {
  position: fixed !important;
  inset: 0 !important;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000 !important;
}
.trivia-editor-overlay > div {
  background: linear-gradient(145deg, #ffffff, #f9fafb);
  color: #222;
  border-radius: 1.2rem;
  width: 95vw;
  max-width: 640px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 1.5rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  border: 3px solid #2563eb;
}

/* Ensure Items tab stays below editor */
.items-tab { z-index: 9500 !important; }

/* === Choices Layout === */
#choicesArea {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(48%, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.choiceBtn {
  border: none;
  border-radius: 1rem;
  padding: 14px;
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.2s, filter 0.2s ease;
  -webkit-appearance: none !important;
  appearance: none !important;
  background-clip: padding-box !important;
}
.choiceBtn:hover { transform: scale(1.06); filter: brightness(1.1); }
.choiceBtn:disabled { opacity: 0.7; cursor: not-allowed; }

/* Choice colors (with solid fallback + gradient) */
.choiceBtn:nth-child(1) { background: #ff595e linear-gradient(135deg, #ff595e, #ff7b80) !important; }
.choiceBtn:nth-child(2) { background: #1982c4 linear-gradient(135deg, #1982c4, #3aa9f0) !important; }
.choiceBtn:nth-child(3) { background: #8ac926 linear-gradient(135deg, #8ac926, #a5e12f) !important; }
.choiceBtn:nth-child(4) { background: #ffca3a linear-gradient(135deg, #ffca3a, #ffe066) !important; }
.choiceBtn:nth-child(5) { background: #6a4c93 linear-gradient(135deg, #6a4c93, #8c66b9) !important; }
.choiceBtn:nth-child(6) { background: #f15bb5 linear-gradient(135deg, #f15bb5, #ff7cd3) !important; }

/* === Timer Styling === */
#questionTimer {
  text-align: center;
  font-size: 2.4rem;
  font-weight: 900;
  color: #ff595e;
  margin-bottom: 10px;
  text-shadow: 0 0 6px rgba(0,0,0,0.4);
  animation: timerPulse 1.2s infinite ease-in-out alternate;
}

/* === Speed Mode Indicator === */
.speed-mode-indicator {
  margin-left: 8px;
  font-size: 1.6rem;
  vertical-align: middle;
  color: #ffca3a;
  filter: drop-shadow(0 0 4px rgba(255,200,50,0.6));
}

.choiceBtn.selected {
  position: relative;
  background: linear-gradient(145deg, #1e3a8a, #2563eb) !important;
  color: #fff !important;
  border: 3px solid #fff !important;
  box-shadow:
    0 0 10px 4px rgba(255,255,255,0.6),
    0 0 25px 10px rgba(37,99,235,0.85),
    0 0 45px 20px rgba(37,99,235,0.6),
    inset 0 0 14px rgba(255,255,255,0.5);
  transform: scale(1.1);
  z-index: 6;
  animation: pulseChosen 1.3s infinite alternate ease-in-out;
}




.choiceBtn.correct {
  animation: pulseCorrect 1s infinite alternate;
  background: linear-gradient(135deg, #16a34a, #22c55e) !important;
  color: #fff !important;
}
.choiceBtn.wrong {
  background: linear-gradient(135deg, #dc2626, #ef4444) !important;
  color: #fff !important;
  opacity: 0.85;
}

/* === Animations === */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(40px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes pulseFrame {
  from { box-shadow: 0 0 30px rgba(37,99,235,0.3); }
  to { box-shadow: 0 0 45px rgba(255,220,120,0.5); }
}

/* === Responsive Text Wrapping Improvements === */

/* Improve long question wrapping */
.trivia-modal h3, 
.trivia-modal h4 {
  word-wrap: break-word !important;
  overflow-wrap: break-word !important;
  white-space: normal !important;
  line-height: 1.4 !important;
  font-size: clamp(1rem, 4vw, 1.6rem) !important;
  text-align: center !important;
  margin-bottom: 1rem !important;
}



/* Choice text wrapping */
.choiceBtn {
  white-space: normal !important;
  word-wrap: break-word !important;
  overflow-wrap: break-word !important;
  text-align: center;
  line-height: 1.3;
  font-size: clamp(0.9rem, 3.2vw, 1.1rem);
  padding: 12px 10px;
}

/* On very small screens */
@media (max-width: 420px) {
  #choicesArea {
    grid-template-columns: 1fr !important;
  }
  .choiceBtn {
    font-size: 1rem !important;
    padding: 12px !important;
  }
}



@keyframes pulseCorrect {
  from { box-shadow: 0 0 10px 3px rgba(16,185,129,0.8); }
  to { box-shadow: 0 0 18px 6px rgba(52,211,153,0.9); }
}
@keyframes timerPulse {
  from { transform: scale(1); color: #ff595e; }
  to { transform: scale(1.15); color: #ffca3a; }
}

/* === Responsive === */
@media (max-width: 480px) {
  .trivia-modal > div, .trivia-editor-overlay > div {
    width: 96vw !important;
    padding: 1rem !important;
    border-radius: 1rem !important;
  }
  #questionTimer {
    font-size: 1.8rem !important;
  }
}
