/* RIOM v1.2.0 — Responsive Architecture (Mobile-First) */

/* Base: Desktop >= 1024px */
.riom-primary-mobile-nav, 
.riom-assistant-menu-sheet { 
  display: none; 
}

.assistant-mobile-tools-trigger {
  display: none;
}

.mobile-only {
  display: none !important;
}

.desktop-only {
  display: flex;
}

@media (max-width: 1024px) {
  .riom-toast-region{right:auto;bottom:max(12px,env(safe-area-inset-bottom));left:50%;width:calc(100% - 24px);max-width:420px;transform:translateX(-50%)}
}

@media (min-width: 1200px) and (max-height: 900px) {
  .app-shell.riom-learning-platform { padding: 12px; gap: 12px; }
  .learning-workspace__shell { padding: var(--learning-workspace-pad-laptop, 20px 24px); }
  .ai-workspace__shell { padding: 0; }
}



/* Tablet (768px - 1279px) */
@media (max-width: 1279px) {
  .app-main {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    display: flex;
    flex-direction: column;
  }

  .riom-sidebar {
    position: fixed;
    top: 0;
    left: -100%;
    width: 320px;
    height: 100dvh;
    z-index: 1500;
    border-radius: 0;
    transition: left 0.3s ease;
  }

  .riom-sidebar.is-open {
    left: 0;
  }

  .riom-sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(7, 24, 48, 0.58);
    z-index: 1400;
    opacity: 0;
    transition: opacity 0.3s ease;
  }
  
  .riom-sidebar-backdrop[hidden] {
    display: none;
  }

  .riom-sidebar-backdrop.is-open {
    opacity: 1;
  }

  .riom-primary-mobile-nav{display:grid;order:-1; 
    grid-template-columns: 1fr 1fr; 
    width: 100%; 
    padding: 4px; 
    border: 1px solid var(--line); 
    border-radius: 14px; 
    background: var(--surface-soft); 
  }
  .riom-primary-mobile-nav button { min-height: 44px; border: 0; border-radius: 10px; background: transparent; color: var(--text-soft); font: inherit; font-size: 1rem; font-weight: 800; cursor: pointer; }
  .riom-primary-mobile-nav button[aria-selected='true'] { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm), inset 0 -3px 0 var(--accent); }
  
  .riom-learning-platform[data-mobile-view='learn'] .ai-workspace, 
  .riom-learning-platform[data-mobile-view='assistant'] .learning-workspace { 
    display: none; 
  }
  
  .learning-workspace, .ai-workspace { display: flex; width: 100%; max-width: none; height: auto; min-height: 0; flex: 1; overflow: hidden; }
  .learning-workspace__shell, .ai-workspace__shell { display: flex; flex-direction: column; width: 100%; height: 100%; padding: 20px; gap: 16px; }
  .ai-workspace__shell { padding: 0; }
  
  .ai-workspace__content-area { flex-direction: column; padding: var(--resource-panel-pad-laptop, 20px 20px); }
  .ai-workspace__header { padding: 20px 20px 14px; }
  .assistant-nav-tabs { padding: 14px 20px 16px; }
  .assistant-navigation-sidebar { display: none; }
  .desktop-only { display: none !important; }
  .mobile-only { display: flex !important; }
  .assistant-mobile-tools-trigger { display: flex !important; width: 100%; min-height: 52px; align-items: center; justify-content: space-between; padding: 0 16px; border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--text); font-weight: 700; font-size: 1rem; cursor: pointer; }
  .riom-user-avatar-btn { width: 44px; height: 44px; min-width: 44px; min-height: 44px; }
  
  /* Sheets interactivos (Tablet / Mobile) */
  body.workspace-context-open { overflow: hidden; }
  .riom-assistant-menu-sheet[aria-hidden='true'] { display: none; }
  .riom-assistant-menu-sheet[aria-hidden='false'] { position: fixed; z-index: 1400; inset: 0; display: grid; align-items: end; }
  .riom-assistant-menu-sheet__backdrop { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: rgba(7, 24, 48, 0.58); }
  
  .riom-assistant-menu-sheet__surface { position: relative; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; width: min(680px, 100%); max-height: min(85dvh, 700px); margin-inline: auto; padding: 18px 16px max(16px, env(safe-area-inset-bottom)); gap: 16px; border-radius: 20px 20px 0 0; background: var(--surface); box-shadow: 0 -16px 48px rgba(7, 24, 48, 0.22); overflow: hidden; }
  .riom-assistant-menu-sheet__surface > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
  .riom-assistant-menu-sheet__surface h2 { margin: 3px 0 0; font-size: 1.2rem; line-height: 1.25; color: var(--primary-strong); }
  .riom-context-sheet__close { display: grid; place-items: center; width: 44px; height: 44px; flex: 0 0 44px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); color: var(--primary); font-size: 1.5rem; cursor: pointer; }
  .riom-assistant-menu-sheet__list { display: grid; gap: 14px; overflow-y: auto; overscroll-behavior: contain; padding-bottom: 8px; }
}

/* Mobile <= 767 px */
@media (max-width: 767px) {
  html { font-size: 16px; -webkit-text-size-adjust: 100%; }
  html, body { width: 100%; min-width: 0; height: auto; min-height: 100%; overflow-x: clip; overflow-y: auto; }
  body { font-size: 1rem; }
  .app-shell.riom-learning-platform {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 100dvh;
    overflow: visible;
    padding: 8px;
    gap: 12px;
  }
  
  .app-main {
    display: flex;
    flex-direction: column;
    height: auto;
    overflow: visible;
  }
  
  .main-workspace-container {
    display: flex;
    flex-direction: column;
    height: auto;
    overflow: visible;
  }
  
  .learning-workspace, .ai-workspace {
    height: auto;
    overflow: visible;
  }
  
  .learning-workspace__shell, .ai-workspace__shell, .ai-workspace__content-area {
    height: auto;
    overflow: visible;
  }
  
  .riom-app-header__brand strong { display: none; }
  
  .learning-workspace__header { grid-template-columns: 1fr; gap: 10px; }
  .learning-workspace__title { max-width: 100%; font-size: clamp(1.45rem, 7vw, 1.75rem); line-height: 1.2; }
  
  .riom-app-header { height: 64px; min-height: 64px; padding: 0 12px; }
  .riom-app-header__brand img { height: 20px; }
  .riom-app-header__right { gap: 8px; }
  .riom-user-avatar-btn { width: 44px; height: 44px; min-width: 44px; min-height: 44px; font-size: 0.9rem; }
  .riom-user-dropdown-menu { width: min(280px, calc(100vw - 24px)); right: 0; z-index: 1000; }
  .riom-user-dropdown-menu__item { min-height: 44px; }
  
  .riom-mobile-context-trigger { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 48px; background: transparent; border: none; padding: 0 12px; margin-bottom: 8px; cursor: pointer; }
  .riom-mobile-context-trigger__text { font-size: 0.94rem; font-weight: 600; color: var(--text-soft); }
  
  .prompt-block { white-space: pre-wrap; overflow-wrap: anywhere; overflow-x: hidden; font-size: 15px; padding: 16px; }
  .prompt-actions { display: flex; flex-direction: column; width: 100%; gap: 8px; }
  .prompt-actions button { width: 100%; min-height: 48px; }
  
  .quick-actions { display: flex; flex-direction: column; width: 100%; height: auto; min-height: 0; padding: 16px 12px max(16px, env(safe-area-inset-bottom)); gap: 8px; position: relative; bottom: auto; margin-top: 16px; border: none; box-shadow: none; background: transparent; }
  .quick-actions__navs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; }
  .quick-action { width: 100%; min-width: 0 !important; min-height: 48px; }
  .workspace-progress--footer { width: 100%; justify-content: space-between; }
  .history-load-more { width: 100%; min-height: 44px; }

  /* Assessment Overrides */
  .assessment-context-card {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
  }
  .assessment-button {
    width: 100%;
    min-height: 48px;
    white-space: normal;
    height: auto;
  }
  .assessment-view--result .assessment-result-details {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .assessment-view--result .assessment-result-details > div:last-child {
    grid-column: 1 / -1; /* Date wraps to take full width */
  }
}

/* Mobile pequeño */
@media (max-width: 479px) {
  .app-shell.riom-learning-platform { padding: 6px; }
  .riom-sidebar { width: 280px; }
  .quick-action { font-size: 0.84rem; }
  .quick-action svg { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .riom-sidebar, .riom-sidebar-backdrop, .riom-primary-mobile-nav button, .riom-assistant-menu-sheet { transition: none !important; animation: none !important; }
}
