/* Manara — shared mobile styles (loaded by every page, after the page's own <style>) */
@media (max-width: 900px) {

  html, body { height: auto !important; min-height: 100%; overflow-x: hidden; -webkit-text-size-adjust: 100%; }
  img { max-width: 100%; }

  /* ---------- Layout: stack sidebar on top, content below ---------- */
  .app[aria-hidden="true"] { display: none !important; }
  .app:not([aria-hidden="true"]) { display: block !important; grid-template-columns: 1fr !important; min-height: 0 !important; }

  /* ---------- Menu: compact header + 3 items per row ---------- */
  .sidebar {
    display: block !important;
    position: relative !important;
    top: auto !important;
    height: auto !important;
    width: 100% !important;
    flex-direction: initial !important;
    padding: 12px 12px 14px !important;
    border-radius: 0 0 20px 20px;
    box-shadow: 0 8px 24px rgba(120, 90, 50, .18);
  }
  .sidebar img { width: 64px !important; max-width: 64px !important; height: auto; margin: 0 0 10px !important; display: block; }
  .sidebar h3 { display: none; }

  .nav {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px !important;
    margin: 0 !important;
  }
  .nav a {
    display: flex !important;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 44px;
    padding: 6px 4px !important;
    font-size: 12px !important;
    font-weight: 600;
    line-height: 1.25;
    border-radius: 12px !important;
    background: rgba(255, 255, 255, .16);
    border: 1px solid rgba(255, 255, 255, .22);
    color: #fff;
    word-break: break-word;
    -webkit-tap-highlight-color: transparent;
    transition: background .15s ease, transform .1s ease;
  }
  .nav a:active { transform: scale(.97); }
  .nav a.active { background: #fff !important; color: #8a6a45 !important; border-color: #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, .12); }

  .social-links { display: none !important; }
  .hamburger { display: none !important; }

  /* ---------- Top bar ---------- */
  .topbar { height: auto !important; min-height: 52px; padding: 10px 14px !important; gap: 8px; flex-wrap: wrap; }
  .topbar > div { min-width: 0; }
  .welcome-text { font-size: 13px !important; max-width: 60vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .logout-btn { padding: 6px 12px !important; font-size: 12px !important; }

  /* ---------- Content spacing ---------- */
  .main, .container, .main-wrap { padding: 14px !important; }
  .main-wrap > .main { padding: 0 !important; }
  .main-wrap { flex-direction: column !important; align-items: stretch !important; }
  .main, .main-wrap > * { min-width: 0 !important; width: 100%; max-width: 100%; min-height: 0 !important; }
  .chat-panel { max-height: none !important; }
  .chat-header, .chat-controls { flex-wrap: wrap !important; }
  .chat-controls select { max-width: 100%; }
  .chat-controls input[type="text"] { min-width: 0; flex: 1 1 160px; }
  .msg { max-width: 92% !important; }
  .container { flex-direction: column !important; gap: 14px !important; align-items: stretch !important; }
  .page-title h1, .main h1 { font-size: 20px !important; line-height: 1.3; }
  .page-desc, .main p { font-size: 14px; line-height: 1.6; }
  .cards, .grid, .projects-wrap { grid-template-columns: 1fr !important; gap: 12px !important; }
  .card { padding: 16px !important; }

  .calendar-wrap { padding: 12px !important; max-width: 100% !important; width: 100%; }
  .sidebar-right { display: block !important; position: relative !important; top: auto !important; width: 100% !important; max-width: 100% !important; height: auto !important; }

  /* ---------- Calendars (events / meetings / lectures): 7 even columns ---------- */
  .weekdays, .calendar-grid, .days { grid-template-columns: repeat(7, minmax(0, 1fr)) !important; gap: 4px !important; }
  .weekday, .weekdays > * { font-size: 11px !important; padding: 4px 0 !important; text-align: center; }
  .day { min-width: 0; min-height: 58px !important; padding: 4px !important; border-radius: 8px !important; overflow: hidden; }
  .day .date-num, .day .num { font-size: 12px !important; }
  .day .events { display: flex; flex-direction: column; gap: 2px; margin-top: 2px; }
  .event-pill { display: block !important; max-width: 100% !important; font-size: 9.5px !important; padding: 2px 4px !important; border-radius: 5px !important; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .cal-controls, .cal-header { flex-wrap: wrap; gap: 8px; }
  .month-title { font-size: 16px !important; }

  /* ---------- Resources / experts / discussions ---------- */
  .books-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 12px !important; }

  /* ---------- Forms & modals ---------- */
  input, select, textarea { font-size: 16px !important; max-width: 100%; } /* 16px stops iOS zoom-on-focus */
  .modal { width: 94% !important; max-height: 90vh; overflow-y: auto; }
  table { display: block; overflow-x: auto; max-width: 100%; }
  iframe, video { max-width: 100%; }
}

/* Very small phones */
@media (max-width: 360px) {
  .nav { gap: 6px !important; }
  .nav a { font-size: 11px !important; min-height: 40px; }
}
