/* ==========================================================================
   pages/strategy.css — Strategy Studio page-specific styles
   Conformité Guide Migration V8
   FIX (2026-02):
   - drawer push compatibility (no overflow-x leak)
   - safe min-height if context bar hidden
   - z-index: never above drawer (drawer z-index=1600)
   ========================================================================== */

/* --------------------------------------------------------------------------
   Page Layout
   -------------------------------------------------------------------------- */

.strategy-page{
  /* context bar may be hidden => fallback 0 */
  min-height: calc(100vh - var(--header-h) - var(--context-bar-h, 0px) - 4rem);

  /* safety: never allow horizontal overflow at page level */
  overflow-x: hidden;
}

.strategy-page.is-loading{
  opacity: 0.7;
  pointer-events: none;
}

/* Allow children to shrink in flex/grid without overflow */
.strategy-page :is(
  .editor-layout,
  .editor-section,
  .registry-layout,
  .registry-card,
  .effective-detail,
  .effective-detail .kv,
  .diff-view
){
  min-width: 0;
  max-width: 100%;
}

/* --------------------------------------------------------------------------
   Floating Actions Bar
   -------------------------------------------------------------------------- */

.floating-actions{
  position: fixed;
  bottom: var(--space-lg);
  right: var(--space-lg);
  display: flex;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-md);

  /* IMPORTANT: must stay below drawer */
  z-index: 200;
}

@media (max-width: 640px){
  .floating-actions{
    bottom: var(--space-md);
    right: var(--space-md);
    left: var(--space-md);
    justify-content: center;
  }
}

/* --------------------------------------------------------------------------
   Editor Layout
   -------------------------------------------------------------------------- */

.editor-layout{
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.editor-section{
  background: var(--bg-soft);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  min-width: 0;
}

.editor-section h3{ margin: 0; }
.editor-section h4{ margin: 0; }

/* --------------------------------------------------------------------------
   Registry Layout
   -------------------------------------------------------------------------- */

.registry-layout{
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.registry-card{
  transition: transform var(--transition-base), box-shadow var(--transition-base);
  position: relative; /* needed for ::after badge positioning */
  min-width: 0;
}

.registry-card:hover{
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.registry-card.is-deprecated{
  opacity: 0.6;
}

.registry-card.is-deprecated::after{
  content: "DEPRECATED";
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  font-size: var(--text-xs);
  padding: 0.15rem 0.5rem;
  background: var(--color-warning);
  color: #000;
  border-radius: var(--radius-full);
  font-weight: 700;
}

/* --------------------------------------------------------------------------
   Effective Table
   -------------------------------------------------------------------------- */

.effective-table{
  width: 100%;
  max-width: 100%;
}

.effective-row{
  cursor: pointer;
  transition: background var(--transition-base);
}

.effective-row:hover{
  background: var(--bg-hover);
}

.effective-row.is-expanded{
  background: var(--bg-soft);
}

.effective-detail-row{
  background: var(--surface-3);
}

.effective-detail{
  border-left: 3px solid var(--color-accent);
  min-width: 0;
}

.effective-detail .kv{
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 0.35rem 1rem;
  min-width: 0;
}

.effective-detail .kv dt{
  font-weight: 600;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.effective-detail .kv dd{
  margin: 0;
  min-width: 0;
}

/* --------------------------------------------------------------------------
   Drawer/Modal Form
   -------------------------------------------------------------------------- */

.drawer-form{
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
}

.drawer-form .form-group{
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.drawer-form .form-label{
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-muted);
}

.drawer-form .form-label .text-danger{
  color: var(--color-danger);
}

.drawer-form input[readonly]{
  opacity: 0.7;
  cursor: not-allowed;
}

.drawer-form details summary{
  color: var(--text-muted);
  font-size: var(--text-sm);
  padding: var(--space-sm) 0;
}

.drawer-form details summary:hover{
  color: var(--color-text);
}

/* --------------------------------------------------------------------------
   Simulation List
   -------------------------------------------------------------------------- */

.is-selected{
  background: rgba(79,156,255,0.08) !important;
  border-left: 3px solid var(--color-accent);
}

/* --------------------------------------------------------------------------
   Form Helpers
   -------------------------------------------------------------------------- */

.w-full{ width: 100%; }

/* --------------------------------------------------------------------------
   Responsive Adjustments
   -------------------------------------------------------------------------- */

@media (max-width: 768px){
  .effective-table th:nth-child(3),
  .effective-table td:nth-child(3){
    display: none; /* Hide condition column on mobile */
  }

  .effective-table th:nth-child(5),
  .effective-table td:nth-child(5){
    display: none; /* Hide budget column on mobile */
  }
}

/* --------------------------------------------------------------------------
   Pro Mode Indicator
   -------------------------------------------------------------------------- */

.strategy-page[data-mode="pro"] .floating-actions{
  border-color: var(--color-accent);
}

.strategy-page[data-mode="pro"]::before{
  content: "PRO";
  position: fixed;
  top: calc(var(--header-h) + var(--context-bar-h, 0px) + var(--space-sm));
  right: var(--space-md);
  font-size: var(--text-xs);
  padding: 0.2rem 0.5rem;
  background: var(--gradient-primary);
  color: #fff;
  border-radius: var(--radius-full);
  font-weight: 700;

  /* Below drawer */
  z-index: 200;
}

/* --------------------------------------------------------------------------
   Loading States
   -------------------------------------------------------------------------- */

/* Make sure the overlay works: parent must be positioned */
.strategy-page .tab-panel{
  position: relative;
  min-width: 0;
}

.strategy-page .tab-panel.is-loading::after{
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.30);
  border-radius: inherit;
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   Lint Errors Display
   -------------------------------------------------------------------------- */

.lint-errors{
  margin-top: var(--space-md);
  padding: var(--space-md);
  background: rgba(239,68,68,0.08);
  border: 1px solid rgba(239,68,68,0.25);
  border-radius: var(--radius-lg);
  min-width: 0;
}

.lint-errors h4{
  margin: 0 0 var(--space-sm) 0;
  color: var(--color-danger);
  font-size: var(--text-sm);
}

.lint-errors ul{
  margin: 0;
  padding-left: 1.5rem;
  font-size: var(--text-sm);
}

.lint-errors li{
  margin-bottom: 0.25rem;
}

/* --------------------------------------------------------------------------
   Diff View (future)
   -------------------------------------------------------------------------- */

.diff-view{
  font-family: var(--font-mono, monospace);
  font-size: var(--text-sm);
  background: var(--surface-3);
  border-radius: var(--radius-md);
  padding: var(--space-md);

  /* scroll local only */
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
}

.diff-view .diff-add{
  background: rgba(34,197,94,0.15);
  color: var(--color-success);
}

.diff-view .diff-remove{
  background: rgba(239,68,68,0.15);
  color: var(--color-danger);
}
