/*
  modals.css — Nium Portal Modal & Drawer System
  ────────────────────────────────────────────────
  Link after tokens.css and typography.css.

  <link rel="stylesheet" href="modals.css">

  THREE SHELL TYPES:

  1. Full modal (.modal-overlay + .modal-box)
     Centered overlay. For multi-field forms, confirmations, detail views.
     Radius: --radius-xl (16px)

  2. Side drawer (.drawer-overlay + .drawer-panel)
     Slides in from the right. For multi-step flows, issue card, move funds.
     Radius: --radius-xl (16px) on left corners only

  3. Lightweight panel (.panel-overlay + .panel-box)
     Smaller centered modal. For confirmations, env switch, notifications.
     Radius: --radius-lg (12px)

  CANONICAL PATTERNS:

  Full modal:
    <div class="modal-overlay" id="myModalOverlay">
      <div class="modal-box">
        <div class="modal-header">
          <h2 class="modal-title">Title</h2>
          <button class="modal-close" onclick="...">✕</button>
        </div>
        <div class="modal-body">...</div>
        <div class="modal-footer">
          <button class="btn-secondary">Cancel</button>
          <button class="btn-primary">Confirm</button>
        </div>
      </div>
    </div>

  Side drawer:
    <div class="drawer-overlay" id="myDrawerOverlay">
      <div class="drawer-panel">
        <div class="drawer-header">
          <h2 class="drawer-title">Title</h2>
          <button class="drawer-close" onclick="...">✕</button>
        </div>
        <div class="drawer-body">...</div>
        <div class="drawer-footer">...</div>
      </div>
    </div>

  Lightweight panel:
    <div class="panel-overlay" id="myPanelOverlay">
      <div class="panel-box">
        <p class="panel-title">Confirm action</p>
        <p class="panel-body">...</p>
        <div class="panel-footer">...</div>
      </div>
    </div>
*/

/* ══════════════════════════════════════════════════════
   SHARED OVERLAY BASE
══════════════════════════════════════════════════════ */

.modal-overlay,
.drawer-overlay,
.panel-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--color-overlay);
}

.modal-overlay.is-open,
.drawer-overlay.is-open,
.panel-overlay.is-open { display: flex; }

/* Center modal and panel; drawer aligns right */
.modal-overlay,
.panel-overlay {
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.drawer-overlay {
  align-items: stretch;
  justify-content: flex-end;
}

/* ══════════════════════════════════════════════════════
   1. FULL MODAL
══════════════════════════════════════════════════════ */

.modal-box {
  background: var(--color-bg-primary);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.18);
  animation: modal-in 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-box--wide  { max-width: 720px; }
.modal-box--narrow { max-width: 400px; }

@keyframes modal-in {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 28px 20px;
  flex-shrink: 0;
}

.modal-title {
  font-size: var(--text-modal-title-size, 20px);
  font-weight: var(--text-modal-title-weight, 500);
  color: var(--color-text-primary);
  margin: 0;
}

.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--color-text-tertiary);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  transition: background 0.1s, color 0.1s;
  flex-shrink: 0;
}
.modal-close:hover { background: var(--color-bg-secondary); color: var(--color-text-primary); }

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 0 28px 24px;
}

.modal-divider {
  border: none;
  border-top: 0.5px solid var(--color-border-tertiary);
  margin: 0 28px;
}

.modal-section-label {
  font-size: var(--text-overline-size, 11px);
  font-weight: var(--text-overline-weight, 600);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-tertiary);
  margin-bottom: 14px;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 28px 24px;
  border-top: 0.5px solid var(--color-border-tertiary);
  flex-shrink: 0;
}

/* ══════════════════════════════════════════════════════
   2. SIDE DRAWER
══════════════════════════════════════════════════════ */

.drawer-panel {
  background: var(--color-bg-primary);
  width: 480px;
  max-width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--radius-xl) 0 0 var(--radius-xl);
  box-shadow: -4px 0 40px rgba(0,0,0,0.18);
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.drawer-overlay.is-open .drawer-panel { transform: translateX(0); }

.drawer-panel--wide { width: 560px; }

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 0.5px solid var(--color-border-tertiary);
  flex-shrink: 0;
}

.drawer-title {
  font-size: var(--text-modal-title-size, 20px);
  font-weight: var(--text-modal-title-weight, 500);
  color: var(--color-text-primary);
  margin: 0;
}

.drawer-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--color-text-tertiary);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  transition: background 0.1s, color 0.1s;
  flex-shrink: 0;
}
.drawer-close:hover { background: var(--color-bg-secondary); color: var(--color-text-primary); }

/* Step indicator (multi-step drawers) */
.drawer-steps {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 12px 24px;
  border-bottom: 0.5px solid var(--color-border-tertiary);
  flex-shrink: 0;
}

.drawer-step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--text-caption-size, 12px);
  color: var(--color-text-tertiary);
}

.drawer-step__dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--color-border-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.drawer-step--active .drawer-step__dot {
  border-color: var(--color-brand-navy);
  background: var(--color-brand-navy);
  color: var(--color-brand-navy-text);
}

.drawer-step--done .drawer-step__dot {
  border-color: var(--color-success-dot);
  background: var(--color-success-dot);
  color: #fff;
}

.drawer-step__connector {
  flex: 1;
  height: 1px;
  background: var(--color-border-primary);
  margin: 0 8px;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.drawer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 16px 24px;
  border-top: 0.5px solid var(--color-border-tertiary);
  flex-shrink: 0;
}

.drawer-footer--end { justify-content: flex-end; }

/* Drawer field spacing */
.drawer-field {
  margin-bottom: 20px;
}
.drawer-field:last-child { margin-bottom: 0; }

/* ══════════════════════════════════════════════════════
   3. LIGHTWEIGHT PANEL
══════════════════════════════════════════════════════ */

.panel-box {
  background: var(--color-bg-primary);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 360px;
  padding: 24px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.14);
  animation: panel-in 0.15s ease-out;
}

@keyframes panel-in {
  from { opacity: 0; transform: scale(0.97); }
  to   { opacity: 1; transform: scale(1); }
}

.panel-title {
  font-size: var(--text-section-title-size, 16px);
  font-weight: var(--text-section-title-weight, 500);
  color: var(--color-text-primary);
  margin-bottom: 8px;
}

.panel-body {
  font-size: var(--text-small-size, 13px);
  color: var(--color-text-secondary);
  line-height: var(--text-line-height-base, 1.5);
  margin-bottom: 20px;
}

.panel-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

/* ══════════════════════════════════════════════════════
   FLOATING PANELS (notifications, profile, search)
══════════════════════════════════════════════════════ */

/* These are positioned relative to the topbar, not centered overlays */

.floating-panel {
  position: fixed;
  background: var(--color-bg-primary);
  border: 0.5px solid var(--color-border-primary);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0,0,0,0.14);
  z-index: 900;
  overflow: hidden;
}

.floating-panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 0.5px solid var(--color-border-tertiary);
}

.floating-panel-title {
  font-size: var(--text-section-title-size, 16px);
  font-weight: var(--text-section-title-weight, 500);
  color: var(--color-text-primary);
  flex: 1;
}

.floating-panel-body {
  overflow-y: auto;
  max-height: 480px;
}
