/* css/global.css
   Master stylesheet for Ready4Exam — imported by ALL pages.
*/

/* ===========================
   BASE & LAYOUT
   =========================== */
html {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  max-width: 100%;
  min-width: 0;
  font-family: 'Inter', sans-serif;
  background-color: #f8fafc;
  color: #1f2937;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

#app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  width: 100%;
  max-width: 100vw;
  box-sizing: border-box;
}

#app-header h2, #app-header p {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===========================
   UI COMPONENTS
   =========================== */
.glass-panel {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
}

.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: 8px;
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ===========================
   FORMULA VAULT & MATH RENDERING
   =========================== */

/* Unified Container Fixes */
#content-container, .grid {
    min-width: 0 !important; /* Critical for preventing flex items from stretching parents */
}

/* Card individual item behavior */
#content-container .bg-white .grid > div {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 100px; 
}

/* Force wrapping for all Math/Formula labels and zones */
.formula-card-content, 
.formula-render-zone, 
.font-mono.text-lg, 
[id^="formula"] {
    display: block !important;
    width: 100% !important;
    white-space: normal !important;
    overflow-wrap: anywhere !important; 
    word-break: break-word;
    line-height: 1.6;
}

/* Character Clumping Fix (Italics) */
.katex, .mjx-chtml, .math-tex {
    letter-spacing: 0.05rem !important; 
    font-variant-numeric: tabular-nums;
}

/* Internal Math Renderer constraints */
.mjx-container, .katex-display {
    display: inline-block !important;
    max-width: 100% !important;
    white-space: normal !important; /* Allows internal wrapping if supported */
    overflow-x: auto; /* Mobile safety */
    overflow-y: hidden;
    padding: 2px 0;
    margin: 0.5em 0;
}

/* Hide Math Errors while debugging */
.katex-error {
    background: transparent !important;
    color: inherit !important;
}

/* ===========================
   RESPONSIVE DESIGN
   =========================== */
@media (max-width: 640px) {
  #app-header {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
    gap: 0.75rem;
  }

  #content-container .grid {
    grid-template-columns: 1fr !important; /* Stack cards on mobile */
    gap: 1rem;
  }

  #difficulty-display {
    max-width: 4.75rem;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* ===========================
   WHATSAPP & UTILITIES
   =========================== */
.whatsapp-float {
  position: fixed;
  bottom: 80px;
  right: 20px;
  background-color: #25d366;
  color: white;
  width: 55px;
  height: 55px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  transition: transform 0.2s;
}
