/* TT24_MCE_BATCH4B3B2_V1 -- "چرخه‌های خروج" (exit-cycle history/actions) UI.
   Additive only: every selector below is scoped under .tt24-ec-* / .tt24-ec-open-history-btn, new
   classes introduced by this batch -- nothing here overrides an existing component's own rules.
   Logical (inline/block) properties are used throughout instead of left/right so the layout is
   correct under the project's single dir="rtl" document without a separate [dir="rtl"] branch. */

.tt24-ec-open-history-btn {
  margin-inline-start: 8px;
}

.tt24-ec-empty {
  padding: 24px 12px;
  text-align: center;
}

.tt24-ec-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.tt24-ec-card {
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 12px;
  padding: 14px 16px;
  background: var(--card-bg, #fff);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tt24-ec-card.tt24-ec-active {
  border-color: var(--gold, #c9a227);
  box-shadow: 0 0 0 1px var(--gold, #c9a227) inset;
}

.tt24-ec-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.tt24-ec-card-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--muted-fg, #475569);
}

.tt24-ec-card-stages {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tt24-ec-transport {
  font-size: 13px;
  padding-block-start: 4px;
}

.tt24-ec-card-slips-head,
.tt24-ec-card-invoices-head {
  font-weight: 600;
  font-size: 13px;
  margin-block-start: 6px;
}

.tt24-ec-slips {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tt24-ec-slip-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 8px;
  font-size: 13px;
}

.tt24-ec-slip-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-inline-start: auto;
}

.tt24-ec-slip-actions button {
  white-space: nowrap;
}

.tt24-ec-invoice-row {
  font-size: 13px;
  padding: 4px 0;
}

.tt24-ec-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-block-start: 6px;
  padding-block-start: 10px;
  border-block-start: 1px dashed var(--line, #e2e8f0);
}

/* Accessible, touch-friendly targets: every interactive element this feature adds gets at least a
   44x44 hit area on touch/narrow viewports, and a clearly visible keyboard-focus ring everywhere
   (desktop mouse users are unaffected since :focus-visible only fires for keyboard/programmatic
   focus in modern browsers). */
.tt24-ec-open-history-btn:focus-visible,
.tt24-ec-card-actions button:focus-visible,
.tt24-ec-card-stages button:focus-visible,
.tt24-ec-slip-actions button:focus-visible {
  outline: 2px solid var(--gold, #c9a227);
  outline-offset: 2px;
}

@media (max-width: 768px) {
  .tt24-ec-card {
    padding: 12px;
  }
  .tt24-ec-card-actions button,
  .tt24-ec-slip-actions button {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding-inline: 12px;
  }
  .tt24-ec-slip-row {
    flex-direction: column;
    align-items: stretch;
  }
  .tt24-ec-slip-actions {
    margin-inline-start: 0;
    justify-content: flex-end;
  }
}

/* The shared modal's own .modal-b already scrolls internally on mobile (app.css's existing
   bottom-sheet rules); this only ensures a long cycle list never forces the dialog itself to grow
   past the viewport on a short/landscape phone screen. */
@media (max-width: 768px) and (max-height: 480px) {
  .tt24-ec-list {
    max-height: 60vh;
    overflow-y: auto;
  }
}

/* MCE4B-F25: the shared modal dialog can programmatically receive focus (tabindex="-1" fallback
   when a modal has no other focusable content) -- give that an intentional, visible ring instead
   of the default browser outline landing at an odd spot. */
.modal:focus-visible {
  outline: 2px solid var(--gold, #c9a227);
  outline-offset: -2px;
}

@media (prefers-reduced-motion: reduce) {
  /* app.css already disables *,*::before,*::after transitions/animations globally; this is a
     defensive no-op restatement scoped to this feature's own classes in case a future change adds
     a transition here without revisiting this rule. */
  .tt24-ec-card,
  .tt24-ec-slip-row {
    transition: none !important;
    animation: none !important;
  }
}

/* TT24_PATCH9_O15_EXIT_TYPE_CARDS_V1 -- the exit-type selection modal's four-choice radiogroup
   (window._openLoadingPermitExitType), rendered as four selectable cards instead of a plain stacked
   radio list. Each card is a real <label> wrapping a real <input type="radio"> (never a click-only
   div), so the entire card is the click target and every native radio keyboard/AT behavior (Tab
   into the group, arrow-key cycling, Space to select) works unmodified. Selected/hover/focus-visible/
   disabled/validation states are all supported; logical (inline/block) properties are used
   throughout so this is correct under the project's single dir="rtl" document without a separate
   [dir="rtl"] branch, matching every other rule in this file. */
.tt24-ec-type-label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--muted-fg, #475569);
  margin-block-end: 8px;
}

.tt24-ec-type-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(140px, 1fr));
  gap: 10px;
}

.tt24-ec-type-card {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1.5px solid var(--line, #e2e8f0);
  border-radius: 12px;
  padding: 12px 14px;
  background: var(--card-bg, #fff);
  cursor: pointer;
  user-select: none;
}

.tt24-ec-type-card:hover {
  border-color: var(--gold, #c9a227);
}

.tt24-ec-type-card.is-selected {
  border-color: var(--gold, #c9a227);
  box-shadow: 0 0 0 1px var(--gold, #c9a227) inset;
  background: color-mix(in srgb, var(--gold, #c9a227) 6%, var(--card-bg, #fff));
}

.tt24-ec-type-radio {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin-block-start: 2px;
  accent-color: var(--gold, #c9a227);
}

/* Touch-friendly hit area on narrow/touch viewports, matching this file's own established
   44x44-minimum convention for every interactive element this feature adds. */
@media (max-width: 768px) {
  .tt24-ec-type-radio {
    width: 20px;
    height: 20px;
  }
  /* TT24_PATCH9_O15_MOBILE_RADIO_WIDTH_FIX_V1: real-device/mobile-viewport reproduction found this
     radio rendered as an enormous ~290x48px box, collapsing the card body text to near-zero width and
     wrapping it into an unreadable vertical ladder of characters. Root cause: app.css's own
     "body.tt24-internal-shell .modal:not(.file-modal):not(.s39b-internal-modal) input{width:100%
     !important;...}" mobile rule (unrelated to this feature -- it exists to make ordinary text/number
     modal inputs full-width on narrow screens) also matches this radio, since a plain modal() dialog
     is neither .file-modal nor .s39b-internal-modal. Its specificity+!important beats the plain
     ".tt24-ec-type-radio{width:20px}" rule above, and even beats app.css's own dedicated
     "input[type=radio]{width:auto!important}" reset (lower specificity than the modal-scoped rule).
     Equal-specificity selectors were tried first, but several of this project's own runtime-injected
     mobile <style> tags (tt24-s39i-unified-internal-mobile-style etc., appended to the document well
     after every static <link> stylesheet including this file) carry the SAME rule and always land
     later in cascade order regardless of this file's own <link> position -- so an equal-specificity
     tie always resolved in their favor, not this file's. Using the modal wrapper's own "#modal-bg" id
     (set by the shared modal() helper in app.js) instead gives this rule strictly higher specificity
     than any class-only selector, which wins unconditionally rather than depending on load order,
     without touching the shared app.css rule that many unrelated modals still depend on. */
  #modal-bg .tt24-ec-type-card input.tt24-ec-type-radio {
    width: 20px !important;
    max-width: 20px !important;
    height: 20px !important;
    min-height: auto !important;
  }
  .tt24-ec-type-card {
    min-height: 44px;
  }
}

.tt24-ec-type-card-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.tt24-ec-type-card-title {
  font-weight: 700;
  font-size: 13.5px;
  color: var(--navy, #0f2547);
}

.tt24-ec-type-card-desc {
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--muted-fg, #475569);
}

/* TT24_PATCH9_O15_RADIO_FOCUS_NOTE_V1: app.css already applies a project-wide focus-visible ring to
   every <input> ("input:focus-visible{outline:none!important;box-shadow:0 0 0 4px var(--tt24-primary-100)
   !important}"), so this radio already gets a clearly visible indicator without any rule here -- an
   outline declared on .tt24-ec-type-radio itself would be dead code (the !important above always wins).
   This only adds the complementary whole-card highlight, via :has(), so the selected card's border also
   picks up the focus state, not just the small radio dot. */
.tt24-ec-type-card:has(.tt24-ec-type-radio:focus-visible) {
  border-color: var(--gold, #c9a227);
}

.tt24-ec-type-radio:disabled {
  cursor: not-allowed;
}

.tt24-ec-type-card:has(.tt24-ec-type-radio:disabled) {
  opacity: .5;
  cursor: not-allowed;
}

/* Validation state for the dependent percentage/explanation fields shown below the card grid (the
   radiogroup itself always has a value -- "definitive" is checked by default -- so it has no
   invalid state of its own; this targets the fields whose own requiredness depends on the selected
   card, matching the toast this project already shows alongside it). */
#ec-explain.is-invalid,
#ec-pct.is-invalid {
  border-color: #b91c1c !important;
  box-shadow: 0 0 0 1px #b91c1c inset;
}

@media (max-width: 480px) {
  .tt24-ec-type-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tt24-ec-type-card {
    transition: none !important;
    animation: none !important;
  }
}
