/* ==========================================================================
   GuruStudy - Global Layout & Text Overflow Anti-Squish Utility Engine
   Ensures zero vertical letter-by-letter breaking on all mobile screens (320px–430px)
   ========================================================================== */

/* 1. Global Viewport & Text Overflow Protection */
html, body {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden !important;
  word-break: normal;
  overflow-wrap: break-word;
}

*, *::before, *::after {
  box-sizing: border-box;
}

/* 2. Universal Badges, Pills & Tags Anti-Squish Protection */
.badge,
.pill,
.tag,
.pill-badge,
.profile-badge-pill,
.streak-badge,
.goal-badge,
.subject-chip,
.video-duration-badge,
.video-tag-badge,
.schedule-time-badge,
.revision-badge,
.chip-btn,
.video-filter-chip,
.ambient-chip,
.alarm-duration-pill,
.mode-pill-btn,
.focus-subject-tag {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 6px !important;
  white-space: nowrap !important;
  flex-shrink: 0 !important;
  max-width: 100% !important;
  word-break: normal !important;
  overflow-wrap: normal !important;
  text-overflow: ellipsis;
}

/* 3. Containers Wrapping Multiple Pills/Badges/Chips (Always allow multi-line wrapping) */
.profile-badges-row,
.badges-container,
.pill-container,
.chips-row,
.header-actions,
.notes-toolbar,
.chapter-meta,
.video-shelf-header,
.ambient-bar,
.mode-pill-selector,
.schedule-bottom,
.schedule-bottom > div,
.legal-links-row {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 8px !important;
  align-items: center !important;
}

/* 4. Dedicated Horizontal Scroll Containers */
.syllabus-filter-chips,
.video-filter-bar,
.video-carousel-row {
  display: flex !important;
  flex-wrap: nowrap !important;
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  max-width: 100%;
}

.syllabus-filter-chips::-webkit-scrollbar,
.video-filter-bar::-webkit-scrollbar {
  display: none;
}

/* 5. Flex Children Text Protection: Prevent flex child squeeze */
.card-title,
.subject-name,
.chapter-title,
.header-subtitle,
.mission-title,
.schedule-subject-name,
.schedule-chapter-text,
.schedule-desc-text,
.video-card-title,
.progress-main-stat,
.progress-sub-stat,
.greeting-text,
.user-name-title {
  min-width: 0 !important;
  word-break: normal !important;
  overflow-wrap: break-word !important;
}

/* 6. Buttons & Interactive Controls */
.btn-primary,
.btn-secondary,
.btn-alarm-start,
.btn-alarm-snooze,
.btn-alarm-dismiss,
.btn-timer-action,
.btn-icon,
.btn-watch-card-lecture,
.btn-start-card-study,
button {
  white-space: nowrap;
  word-break: normal;
  overflow-wrap: normal;
  flex-shrink: 0;
}

/* 7. Bottom Navigation Bar Responsive Optimization */
.bottom-nav {
  display: flex !important;
  justify-content: space-around !important;
  align-items: center !important;
  width: 100% !important;
  max-width: 520px !important;
  padding: 0 4px !important;
  box-sizing: border-box !important;
}

.nav-item {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  flex: 1 1 0 !important;
  min-width: 0 !important;
  padding: 6px 2px !important;
  font-size: clamp(0.65rem, 2.5vw, 0.78rem) !important;
  white-space: nowrap !important;
}

.nav-item span:not(.nav-item-icon) {
  white-space: nowrap !important;
  font-size: clamp(0.65rem, 2.5vw, 0.76rem) !important;
  text-overflow: ellipsis;
  overflow: hidden;
  max-width: 100%;
}

/* 8. Profile Card & Student Control Center Specifics */
.profile-card-center {
  background: var(--surface-glass-elevated);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 20px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-glass);
}

.profile-avatar-circle {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3B82F6, #1D4ED8);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  color: #FFFFFF;
  flex-shrink: 0;
}

.profile-badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  flex-shrink: 0;
  padding: 6px 12px;
  border-radius: 9999px;
  font-size: clamp(0.7rem, 2.6vw, 0.78rem);
  font-weight: 600;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: #A5B4FC;
}

.profile-badge-pill.goal-pill {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.3);
  color: #34D399;
}

.profile-badge-pill.streak-pill {
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.3);
  color: #FBBF24;
}

.legal-btn-link {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-decoration: underline;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
  white-space: nowrap;
}

/* 9. YouTube Teacher Action Buttons & Video Shelf (Android App Prompts 1, 2, 9, 10) */
.chapter-video-links-box {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 8px !important;
  align-items: center !important;
  margin-top: 12px;
  padding: 10px 12px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px dashed rgba(239, 68, 68, 0.35);
  border-radius: 12px;
  width: 100%;
  box-sizing: border-box;
}

.chapter-video-links-label {
  font-size: 0.76rem;
  font-weight: 700;
  color: #F87171;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
}

.yt-teacher-btn {
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
  white-space: nowrap !important;
  flex-shrink: 0 !important;
  padding: 7px 13px !important;
  border-radius: 10px !important;
  font-size: clamp(0.72rem, 2.7vw, 0.8rem) !important;
  font-weight: 600 !important;
  color: #FFFFFF !important;
  background: #EF4444 !important;
  border: 1px solid rgba(255, 255, 255, 0.15) !important;
  cursor: pointer !important;
  position: relative !important;
  z-index: 5 !important;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.25) !important;
  transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease !important;
  text-decoration: none !important;
  user-select: none !important;
  -webkit-tap-highlight-color: transparent !important;
}

.yt-teacher-btn:hover {
  background: #DC2626 !important;
  box-shadow: 0 6px 16px rgba(239, 68, 68, 0.4) !important;
}

.yt-teacher-btn:active {
  transform: scale(0.97) !important;
  background: #B91C1C !important;
}

.yt-teacher-btn.btn-pw {
  background: #4F46E5 !important;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25) !important;
}

.yt-teacher-btn.btn-pw:hover {
  background: #4338CA !important;
}

.yt-teacher-btn.btn-pw:active {
  background: #3730A3 !important;
}

.yt-teacher-btn.btn-pyq {
  background: #D97706 !important;
  box-shadow: 0 4px 12px rgba(217, 119, 6, 0.25) !important;
}

.yt-teacher-btn.btn-pyq:hover {
  background: #B45309 !important;
}

/* Home Active Chapter Card Integration (Android App Prompt 9) */
.active-chapter-banner {
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 10px;
  padding: 8px 12px;
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.active-chapter-title-text {
  font-size: 0.8rem;
  font-weight: 600;
  color: #C7D2FE;
  min-width: 0;
  flex: 1 1 180px;
  word-break: normal;
  overflow-wrap: break-word;
}

/* 10. Botpress Webchat Integration with "Ask Guru AI" Button (/app/) */
body.gurustudy-app-shell .bpFabContainer,
body.gurustudy-app-shell .bpFabWrapper,
body.gurustudy-app-shell .bpFab {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

.bpWebchat,
.bpContainer,
#bp-web-widget-container {
  z-index: 99999 !important;
}

/* 11. Web App Android Parity UI: Timer Setup, Alarm Center, NCERT Chapter Reader & Work Completion */
.timer-setup-card {
  width: 100%;
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid rgba(99, 102, 241, 0.28);
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.timer-presets-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

/* Alarm Center Modal */
.alarm-center-box {
  width: 100%;
  max-width: 500px;
  max-height: 88vh;
  overflow-y: auto;
  background: #0B132B;
  border: 1px solid rgba(99, 102, 241, 0.35);
  border-radius: 20px;
  padding: 18px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.75);
}

.alarm-section-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 10px;
}

.alarm-slot-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 10px;
  flex-wrap: wrap;
}

.alarm-toggle-wrap {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
  flex-shrink: 0;
}

.alarm-toggle-wrap input {
  opacity: 0;
  width: 0;
  height: 0;
}

.alarm-toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #334155;
  border-radius: 999px;
  transition: 0.2s;
}

.alarm-toggle-slider::before {
  position: absolute;
  content: '';
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: #FFFFFF;
  border-radius: 50%;
  transition: 0.2s;
}

.alarm-toggle-wrap input:checked + .alarm-toggle-slider {
  background: #10B981;
}

.alarm-toggle-wrap input:checked + .alarm-toggle-slider::before {
  transform: translateX(18px);
}

/* NCERT Chapter Reader Modal */
.reader-shell {
  width: 100%;
  max-width: 560px;
  height: 92vh;
  max-height: 820px;
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(99, 102, 241, 0.35);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.8);
}

.reader-shell[data-reader-theme="dark"] {
  background: #0B132B;
  color: #F8FAFC;
  --r-surface: rgba(30, 41, 59, 0.72);
  --r-border: rgba(255, 255, 255, 0.1);
}

.reader-shell[data-reader-theme="sepia"] {
  background: #F4ECD8;
  color: #3E2F1C;
  --r-surface: #FFF9EB;
  --r-border: #DFCBB0;
}

.reader-shell[data-reader-theme="light"] {
  background: #F8FAFC;
  color: #0F172A;
  --r-surface: #FFFFFF;
  --r-border: #E2E8F0;
}

.reader-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 16px;
  background: linear-gradient(135deg, #4F46E5, #2563EB);
  color: #FFFFFF;
}

.reader-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 14px;
  background: var(--r-surface);
  border-bottom: 1px solid var(--r-border);
}

.reader-tabs-bar {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 8px 14px;
  background: var(--r-surface);
  border-bottom: 1px solid var(--r-border);
  scrollbar-width: none;
}

.reader-tabs-bar::-webkit-scrollbar {
  display: none;
}

.reader-scroll-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.reader-card {
  background: var(--r-surface);
  border: 1px solid var(--r-border);
  border-radius: 14px;
  padding: 14px;
}

.reader-section-label {
  font-size: 0.8rem;
  font-weight: 800;
  color: #6366F1;
  margin-bottom: 6px;
}

.reader-prose {
  line-height: 1.65;
  word-break: normal;
  overflow-wrap: break-word;
}

.reader-concepts-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0;
  margin: 0;
}

.reader-concept-item {
  line-height: 1.5;
}

.reader-formula-chip {
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(99, 102, 241, 0.12);
  border-left: 3px solid #6366F1;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 600;
}

.reader-solution-details {
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.reader-mcq-opt {
  text-align: left;
  width: 100%;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--r-border);
  background: transparent;
  color: inherit;
  cursor: pointer;
  white-space: normal !important;
  word-break: normal !important;
  overflow-wrap: break-word !important;
  transition: background 0.15s, border-color 0.15s;
}

.reader-mcq-opt.is-correct {
  background: rgba(16, 185, 129, 0.2);
  border-color: #10B981;
  font-weight: 700;
}

.reader-mcq-opt.is-wrong {
  background: rgba(239, 68, 68, 0.2);
  border-color: #EF4444;
}

.reader-mcq-exp {
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(99, 102, 241, 0.12);
  font-size: 0.78rem;
  line-height: 1.5;
}

.reader-step-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--r-border);
  cursor: pointer;
}

.reader-step-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #10B981;
  flex-shrink: 0;
}

/* Day Switcher & Completed Card States */
.day-switcher-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: 12px;
  margin-bottom: 12px;
}

.schedule-card.is-slot-done {
  border-color: rgba(16, 185, 129, 0.55) !important;
  background: rgba(16, 185, 129, 0.06) !important;
}

.continue-reading-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  margin-bottom: 12px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.16), rgba(37, 99, 235, 0.12));
  border: 1px solid rgba(99, 102, 241, 0.35);
  border-radius: 14px;
  flex-wrap: wrap;
}

/* 12. Fullscreen Ringing Alarm Overlay (alarm-engine.js #guru-alarm-modal) */
.guru-alarm-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100000;
  background: rgba(6, 11, 25, 0.92);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.guru-alarm-overlay.active {
  display: flex !important;
}

.alarm-card-glow {
  width: 100%;
  max-width: 420px;
  background: #0F172A;
  border: 2px solid rgba(99, 102, 241, 0.6);
  border-radius: 24px;
  padding: 28px 22px;
  text-align: center;
  box-shadow: 0 0 60px rgba(99, 102, 241, 0.45), 0 24px 60px rgba(0, 0, 0, 0.8);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.alarm-pulsing-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.2);
  border: 1px solid rgba(245, 158, 11, 0.5);
  color: #FBBF24;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.alarm-subject-title {
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1.2;
}

.alarm-chapter-name {
  font-size: 0.92rem;
  color: #CBD5E1;
  line-height: 1.4;
}

.alarm-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  margin-top: 10px;
}

.btn-alarm-primary {
  width: 100%;
  padding: 13px 18px;
  border-radius: 14px;
  border: none;
  background: linear-gradient(135deg, #10B981, #059669);
  color: #FFFFFF;
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(16, 185, 129, 0.4);
}

.btn-alarm-secondary {
  width: 100%;
  padding: 11px 18px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.06);
  color: #E2E8F0;
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
}
