/* ========================================
   HIVEMIND - MAIN STYLESHEET
   ======================================== */

/* CSS Variables */
:root {
  --primary-color: #2C3E50;
  --secondary-color: #18BC9C;
  --accent-color: #E74C3C;
  --success-color: #27AE60;
  --warning-color: #F39C12;
  --info-color: #3498DB;
  --background-color: #ECF0F1; /* Default page background */
  --text-color: #2C3E50; /* Default dark text for light backgrounds */
  --light-text-color: #7F8C8D; /* Muted text */
  --border-color: #BDC3C7;
  --box-shadow: rgba(0, 0, 0, 0.1);
  --font-family: 'Roboto', sans-serif;
  --amber-color: #FFC107; /* Accent for login button & other highlights */
}

/* General Reset / Base */
body {
  margin: 0;
  padding: 0;
  background-color: var(--background-color);
  font-family: var(--font-family);
  color: var(--text-color);
  position: relative;
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

.exit-button {
  background-color: #ccc;
  color: #000;
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 999;
  padding: 10px 20px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}

/* ✅ V2.2.3: Red styling for exit button when it has btn-danger class */
.exit-button.btn-danger {
  background: linear-gradient(135deg, rgba(220, 53, 69, 0.85) 0%, rgba(200, 35, 51, 0.85) 100%) !important;
  border: 2px solid rgba(220, 53, 69, 0.9) !important;
  box-shadow: 0 4px 12px rgba(220, 53, 69, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.3) !important;
  color: #fff !important;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2) !important;
  position: relative;
  overflow: hidden;
  border-radius: 8px !important;
  padding: 0.625rem 1.25rem !important;
  font-weight: 500 !important;
  transition: all 0.2s ease !important;
}

.exit-button.btn-danger::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  transform: rotate(45deg);
  transition: all 0.5s;
}

.exit-button.btn-danger:hover::before {
  left: 100%;
}

.exit-button.btn-danger:hover {
  transform: translateY(-3px) scale(1.03) !important;
  box-shadow: 0 8px 20px rgba(220, 53, 69, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.4) !important;
  background: linear-gradient(135deg, rgba(220, 53, 69, 1) 0%, rgba(200, 35, 51, 1) 100%) !important;
}

.exit-button.btn-danger:active {
  transform: translateY(-1px) scale(1.01) !important;
  box-shadow: 0 4px 10px rgba(220, 53, 69, 0.4), inset 0 2px 4px rgba(0, 0, 0, 0.2) !important;
}

/* Master containers for full-page sections */
.main-page,
.modes-page,
.mode-page,
.question-page,
.completion-page,
.progress-page,
.interim-feedback-page,
.final-feedback-page {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  box-sizing: border-box;
}

/* Landscape orientation optimizations - ONLY when landscape overlay is active */
@media (orientation: landscape) and (max-height: 500px) {
  body.landscape-overlay-active .main-page,
  body.landscape-overlay-active .modes-page,
  body.landscape-overlay-active .mode-page,
  body.landscape-overlay-active .question-page,
  body.landscape-overlay-active .completion-page,
  body.landscape-overlay-active .progress-page,
  body.landscape-overlay-active .interim-feedback-page,
  body.landscape-overlay-active .final-feedback-page {
    width: 100vw !important;
    height: 100vh !important;
    min-width: 100vw !important;
    min-height: 100vh !important;
    position: fixed !important;
    overflow: hidden !important;
  }

  /* Login page landscape optimization for small devices */
  body.landscape-overlay-active #login-page.main-page {
    width: 100vw !important;
    height: 100vh !important;
    min-width: 100vw !important;
    min-height: 100vh !important;
    padding: 3px !important;
    position: fixed !important;
    overflow: hidden !important;
    background-size: cover !important;
    background-position: center !important;
  }

  /* Menu page landscape optimization for small devices */
  body.landscape-overlay-active #menu-page .page-container {
    padding: 8px !important;
  }

  /* Mode groups landscape layout for small devices */
  body.landscape-overlay-active .mode-groups {
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
    padding: 8px !important;
    height: calc(100vh - 16px) !important;
  }

  body.landscape-overlay-active .mode-group {
    min-height: calc(50vh - 16px) !important;
    padding: 6px !important;
  }

  body.landscape-overlay-active .mode-group h3 {
    font-size: 0.8rem !important;
    margin-bottom: 4px !important;
  }

  body.landscape-overlay-active .mode-group p {
    font-size: 0.7rem !important;
    line-height: 1.1 !important;
  }

  /* Ensure proper button spacing in small device landscape */
  body.landscape-overlay-active #show-progress-btn {
    margin-bottom: 15px !important;
    padding: 10px 20px !important;
    font-size: 0.9rem !important;
  }

  body.landscape-overlay-active #logout-button {
    bottom: 10px !important;
    left: 10px !important;
    z-index: 1050 !important;
  }

  body.landscape-overlay-active .exit-button {
    bottom: 10px !important;
    right: 10px !important;
    z-index: 1050 !important;
    padding: 8px 14px !important;
    font-size: 0.85rem !important;
  }

  body.landscape-overlay-active #feedback-btn-in-footer,
  body.landscape-overlay-active #feedback-footer-chip {
    bottom: 20px !important; /* Position at bottom-right in overlay mode */
    right: 20px !important;
    z-index: 1040 !important;
  }
}

/* Additional landscape optimizations for smaller devices */
@media (orientation: landscape) and (max-height: 500px) {
  /* Login page landscape optimization for small devices */
  #login-page.main-page {
    padding: 5px !important;
  }

  #login-input-group {
    bottom: 15vh !important;
    gap: 0.5rem !important;
  }

  #login-button-group-wrapper {
    bottom: 1vh !important;
    right: 1vw !important;
  }

  .login-input.form-control,
  #login-page-enrollment-code-input {
    padding: 0.5rem 0.7rem !important;
    font-size: 0.8rem !important;
  }

  #login-action-button.btn {
    padding: 0.5rem 0.8rem !important;
    font-size: 0.9rem !important;
    max-width: 120px !important;
  }

  #login-links {
    font-size: 0.7rem !important;
  }

  /* Menu page landscape optimization for small devices */
  #menu-page .page-container {
    padding: 8px !important;
  }

  /* Mode groups landscape layout for small devices */
  .mode-groups {
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
    padding: 8px !important;
    height: calc(100vh - 16px) !important;
  }

  .mode-group {
    min-height: calc(50vh - 16px) !important;
    padding: 6px !important;
  }

  .mode-group h3 {
    font-size: 0.8rem !important;
    margin-bottom: 4px !important;
  }

  .mode-group p {
    font-size: 0.7rem !important;
    line-height: 1.1 !important;
  }

  /* Ensure proper button spacing in small device landscape */
  #show-progress-btn {
    margin-bottom: 15px !important;
    padding: 10px 20px !important;
    font-size: 0.9rem !important;
  }

  #logout-button {
    bottom: 10px !important;
    left: 10px !important;
    z-index: 1050 !important;
  }

  .exit-button {
    bottom: 10px !important;
    right: 10px !important;
    z-index: 1050 !important;
    padding: 8px 14px !important;
    font-size: 0.85rem !important;
  }

  #feedback-btn-in-footer,
  #feedback-footer-chip {
    bottom: 60px !important; /* Adjust for small devices */
    right: 10px !important;
    z-index: 1040 !important;
  }
}

/* Generic padding for some page types */
.progress-page,
.modes-page, 
.question-page {
  padding: 20px;
}

/* Page Container (white card) */
.page-container {
  background-color: #fff;
  color: #2C3E50;
  padding: 20px;
  border-radius: 8px;
  margin: 20px auto;
  max-width: 1200px;
  min-width: 300px;
  position: relative;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Ensure page containers provide positioning context for absolute elements */
.modes-page .page-container,
.progress-page .page-container {
  position: relative;
}

/* Main Menu / "Modes" Page */
#menu-page .page-container {
  min-height: 80vh;
  overflow-y: auto;
  position: relative;
  margin: 20px auto;
  padding: 20px;
  background-color: #fff;
  color: #2C3E50;
  border-radius: 8px;
  max-width: 1200px;
  min-width: 300px;
}

@media (max-width: 992px) {
  #menu-page .page-container {
    min-height: 70vh;
  }
}

@media (max-width: 576px) {
  #menu-page .page-container {
    min-height: 80vh;
  }
}

/* "Developed by" pinned to bottom-right inside .page-container */
#menu-page .page-container .developed-by {
  position: absolute;
  bottom: 20px;
  right: 20px;
  font-size: 0.9rem;
  cursor: pointer;
  text-align: right;
}

@media (max-width: 992px) {
  #menu-page .page-container .developed-by {
    bottom: 15px;
    right: 15px;
    font-size: 0.85rem;
  }
}

@media (max-width: 576px) {
  #menu-page .page-container .developed-by {
    bottom: 10px;
    right: 10px;
    font-size: 0.8rem;
  }
}

/* Logout Button */
#logout-button {
  position: absolute;
  bottom: 20px;
  left: 20px;
  z-index: 10;
  height: auto;
}

/* Mobile-specific button spacing - FIXED */
@media (max-width: 768px) {
  /* Only add bottom padding to specific pages that need it */
  .progress-page .page-container,
  .modes-page .page-container {
    padding-bottom: 80px !important;
  }

  .question-page .page-container {
    padding-bottom: 100px !important;
  }

  /* Fix logout button positioning - only when NOT in landscape overlay mode */
  body:not(.landscape-overlay-active) #logout-button {
    position: fixed !important;
    bottom: 20px !important;
    left: 20px !important;
    z-index: 1050 !important;
  }

  /* Fix exit button positioning */
  body:not(.landscape-overlay-active) .exit-button {
    position: fixed !important;
    bottom: 20px !important;
    right: 20px !important;
    z-index: 1050 !important;
    padding: 12px 20px !important;
    font-size: 1rem !important;
  }

  /* Position feedback button at bottom-right of container, not floating over content */
  body:not(.landscape-overlay-active) #feedback-btn-in-footer {
    position: absolute !important; /* Use absolute instead of fixed */
    bottom: 20px !important;
    right: 20px !important;
    z-index: 1040 !important;
  }

  /* For the footer chip that's not in a container */
  body:not(.landscape-overlay-active) #feedback-footer-chip {
    position: fixed !important; /* Keep fixed for the chip version */
    bottom: 20px !important;
    right: 20px !important;
    z-index: 1040 !important;
  }

  /* Ensure "Show My Progress" button has proper spacing - feedback button now positioned absolutely within container */
  #show-progress-btn {
    margin-bottom: 20px !important; /* Reset spacing since feedback button is now absolute positioned */
  }

  /* Fix mode groups layout on mobile */
  .mode-groups {
    margin-bottom: 40px !important;
  }
}

/* Additional mobile optimizations for very small screens */
@media (max-width: 480px) {
  .progress-page .page-container,
  .modes-page .page-container {
    padding-bottom: 100px !important;
  }

  .question-page .page-container {
    padding-bottom: 120px !important;
  }

  body:not(.landscape-overlay-active) #logout-button {
    bottom: 15px !important;
    left: 15px !important;
  }

  body:not(.landscape-overlay-active) .exit-button {
    bottom: 15px !important;
    right: 15px !important;
    padding: 10px 16px !important;
    font-size: 0.9rem !important;
  }

  #show-progress-btn {
    margin-bottom: 20px !important; /* Reset spacing since feedback button is now absolute positioned */
  }

  .mode-groups {
    margin-bottom: 50px !important;
  }
}

/* Broadcast Message Area - Centered between streak flower and HiveMind icon */
#broadcast-message-area {
  display: flex;
  justify-content: center;
  padding: 0;
  margin: 0 auto;
  box-sizing: border-box;
  max-width: 500px;
  position: relative;
}

/* === Study Schedule (Progress Page) === */

#tab-study-schedule .study-schedule-table-wrapper {
  max-width: 100%;
}

#tab-study-schedule .study-schedule-table-wrapper table {
  min-width: 900px;
  table-layout: fixed;
}

#tab-study-schedule .study-slot-cell {
  cursor: pointer;
  vertical-align: middle;
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
  border-color: #e0e0e0;
  position: relative;
}

#tab-study-schedule .study-slot-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

#tab-study-schedule .study-slot-selected {
  box-shadow: inset 0 0 0 2px var(--info-color);
}

#tab-study-schedule .study-subject-pill {
  font-size: 0.8rem;
}

/* Day headers and time column styling */
#tab-study-schedule .study-day-header {
  background-color: #f4f6fb;
  font-weight: 600;
  border-bottom: 2px solid #d0d4e4;
}

#tab-study-schedule .study-day-weekend {
  background-color: #f7f0ff;
}

#tab-study-schedule .study-time-header {
  background-color: #fcfcff;
  font-weight: 500;
  white-space: nowrap;
}

/* Zebra striping by hour row */
#tab-study-schedule tbody tr:nth-child(even) {
  background-color: #fafafa;
}

#tab-study-schedule tbody tr:nth-child(even) .study-time-header {
  background-color: #f7f7fc;
}

/* Hover and selected indicator */
#tab-study-schedule .study-slot-cell:hover {
  box-shadow: inset 0 0 0 2px rgba(52, 152, 219, 0.5);
}

#tab-study-schedule .study-slot-cell.study-slot-selected::after {
  content: "\f304"; /* fa-pen */
  font-family: "Font Awesome 5 Free";
  font-weight: 900;
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 0.65rem;
  color: #34495e;
  opacity: 0.85;
}

/* Glossy schedule buttons (reusing Test Zone style language) */
#tab-study-schedule .btn-schedule-glossy {
  background: linear-gradient(135deg, rgba(13, 110, 253, 0.85) 0%, rgba(0, 86, 179, 0.85) 100%) !important;
  border: 2px solid rgba(13, 110, 253, 0.9) !important;
  box-shadow: 0 4px 12px rgba(13, 110, 253, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.3) !important;
  color: #fff !important;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2) !important;
  font-weight: 600;
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
  border-radius: 999px;
}

#tab-study-schedule .btn-schedule-glossy::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  transform: rotate(45deg);
  transition: all 0.5s;
}

#tab-study-schedule .btn-schedule-glossy:hover::before {
  left: 100%;
}

#tab-study-schedule .btn-schedule-glossy:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 6px 16px rgba(13, 110, 253, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.4) !important;
  background: linear-gradient(135deg, rgba(13, 110, 253, 1) 0%, rgba(0, 86, 179, 1) 100%) !important;
}

#tab-study-schedule .btn-schedule-glossy:active {
  transform: translateY(0) scale(1.01);
  box-shadow: 0 4px 10px rgba(13, 110, 253, 0.4), inset 0 2px 4px rgba(0, 0, 0, 0.2) !important;
}

@media (max-width: 768px) {
  #tab-study-schedule .study-schedule-table-wrapper table {
    min-width: 720px;
  }
}

#broadcast-message-area .alert {
  max-width: 100%;
  width: 100%;
  margin: 0;
}

/* Go to Message Button - Shiny transparent dynamic styling */
#feedback-notification-alert .feedback-go-btn {
  background: linear-gradient(135deg, rgba(13, 110, 253, 0.85) 0%, rgba(0, 86, 179, 0.85) 100%) !important;
  border: 2px solid rgba(13, 110, 253, 0.9) !important;
  box-shadow: 0 4px 12px rgba(13, 110, 253, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.3) !important;
  color: #fff !important;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2) !important;
  font-weight: 600;
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.5;
}

/* Shiny effect for Go to Message button */
#feedback-notification-alert .feedback-go-btn::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  transform: rotate(45deg);
  transition: all 0.5s;
}

#feedback-notification-alert .feedback-go-btn:hover::before {
  left: 100%;
}

#feedback-notification-alert .feedback-go-btn:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 6px 20px rgba(13, 110, 253, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.4) !important;
  background: linear-gradient(135deg, rgba(13, 110, 253, 1) 0%, rgba(0, 86, 179, 1) 100%) !important;
}

#feedback-notification-alert .feedback-go-btn:active {
  transform: translateY(0) scale(1.02);
  box-shadow: 0 4px 10px rgba(13, 110, 253, 0.4), inset 0 2px 4px rgba(0, 0, 0, 0.2) !important;
}

/* Main Loader Overlay */
.main-loader-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(236, 240, 241, 0.9);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.3s ease-in-out;
}

.main-loader-overlay.hidden {
  display: none;
}

.main-loader-content {
  text-align: center;
  color: var(--primary-color);
}

/* Keyframes for animations */
@keyframes fadeInPage {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideInFromLeftInputs {
  0% {
    transform: translateX(-60px);
    opacity: 0;
  }
  100% {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideUpAndFadeButtonGroupNoInitialTransform {
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes slideUpAndFadeButtonGroup {
  0% {
    transform: translateY(50px);
    opacity: 0;
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Class to apply the animation */
.fade-in-active {
  animation-name: fadeInPage;
  animation-duration: 0.7s;
  animation-timing-function: ease-in-out;
  animation-fill-mode: forwards;
}

#menu-page {
  opacity: 0;
}

#menu-page:not(.hidden).fade-in-active {
  opacity: 1;
}

#menu-page.hidden {
  opacity: 0 !important;
  display: none !important;
}

/* Hide reCAPTCHA badge */
.grecaptcha-badge {
  visibility: hidden !important;
}

/* ========================================
   LANDSCAPE ORIENTATION OVERLAY STYLES
   ======================================== */

/* Main landscape overlay container */
.rotate-landscape-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw !important;
  height: 100vh !important;
  min-width: 100vw !important;
  min-height: 100vh !important;
  background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
  z-index: 10001 !important; /* Higher than all other elements */
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  box-sizing: border-box;
}

.rotate-landscape-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  display: none;
}

/* Hide all other content when landscape overlay is active */
.rotate-landscape-overlay:not(.hidden) ~ * {
  display: none !important;
}

/* Ensure overlay covers everything including scrollbars */
body.landscape-overlay-active {
  overflow: hidden !important;
}

body.landscape-overlay-active * {
  pointer-events: none !important;
}

body.landscape-overlay-active .rotate-landscape-overlay {
  pointer-events: auto !important;
}

.rotate-landscape-content {
  text-align: center;
  color: white;
  max-width: 400px;
  padding: 40px 20px;
}

.rotate-icon {
  position: relative;
  margin: 0 auto 30px;
  display: inline-block;
}

.rotate-icon-sync {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(45deg);
  animation: rotate 3s linear infinite;
  opacity: 0.7;
}

.rotate-title {
  font-size: 2rem;
  font-weight: bold;
  margin-bottom: 20px;
  color: #ffffff;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.rotate-message {
  font-size: 1.2rem;
  margin-bottom: 15px;
  color: #f0f0f0;
  line-height: 1.5;
}

.rotate-subtext {
  font-size: 1rem;
  color: #e0e0e0;
  opacity: 0.9;
  line-height: 1.4;
}

@keyframes rotate {
  from {
    transform: translate(-50%, -50%) rotate(0deg);
  }
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

/* Mobile-specific styles */
@media (max-width: 768px) {
  .rotate-landscape-content {
    padding: 30px 15px;
  }

  .rotate-title {
    font-size: 1.8rem;
    margin-bottom: 15px;
  }

  .rotate-message {
    font-size: 1.1rem;
    margin-bottom: 12px;
  }

  .rotate-subtext {
    font-size: 0.9rem;
  }
}

@media (max-width: 480px) {
  .rotate-landscape-content {
    padding: 20px 10px;
  }

  .rotate-title {
    font-size: 1.5rem;
    margin-bottom: 12px;
  }

  .rotate-message {
    font-size: 1rem;
    margin-bottom: 10px;
  }

  .rotate-subtext {
    font-size: 0.85rem;
  }
}
