/* =============================================================================
   GSMOne Design System — Component Library (extension)
   -----------------------------------------------------------------------------
   Adds the remaining official components on top of gsmone-components.css.
   All built on --ds-* tokens (with fallbacks). WCAG AA, dark-mode, responsive.
   Pairs with gsmone-ui.js for interactive behavior (modal/drawer/tabs/accordion/
   dropdown/tooltip/popover/wizard/confirm).
   ============================================================================= */

/* ===========================================================================
   CHECKBOX & RADIO — custom control, native input kept for a11y
   <label class="ds-check"><input type="checkbox"><span class="ds-check__box"></span> Label</label>
   =========================================================================== */
.ds-check, .ds-radio {
  display: inline-flex; align-items: center; gap: var(--ds-space-2, 8px);
  font-size: var(--ds-text-sm, .875rem); color: var(--ds-text-primary, #111827);
  cursor: pointer; user-select: none;
}
.ds-check input, .ds-radio input { position: absolute; opacity: 0; width: 0; height: 0; }
.ds-check__box, .ds-radio__box {
  width: 18px; height: 18px; flex-shrink: 0;
  border: 1.5px solid var(--ds-border-strong, #d1d5db); background: #fff;
  transition: all .15s var(--ds-ease-standard, cubic-bezier(.2,0,0,1));
  display: inline-flex; align-items: center; justify-content: center;
}
.ds-check__box { border-radius: 5px; }
.ds-radio__box { border-radius: 50%; }
.ds-check__box::after {
  content: ""; width: 10px; height: 10px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M13 4 6 11 3 8' stroke='white' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/contain no-repeat;
  opacity: 0; transform: scale(.6); transition: all .15s;
}
.ds-radio__box::after {
  content: ""; width: 8px; height: 8px; border-radius: 50%; background: #fff;
  opacity: 0; transform: scale(.4); transition: all .15s;
}
.ds-check input:checked + .ds-check__box { background: var(--ds-color-brand, #006994); border-color: var(--ds-color-brand, #006994); }
.ds-check input:checked + .ds-check__box::after { opacity: 1; transform: scale(1); }
.ds-radio input:checked + .ds-radio__box { background: var(--ds-color-brand, #006994); border-color: var(--ds-color-brand, #006994); }
.ds-radio input:checked + .ds-radio__box::after { opacity: 1; transform: scale(1); }
.ds-check input:focus-visible + .ds-check__box,
.ds-radio input:focus-visible + .ds-radio__box { box-shadow: var(--ds-shadow-focus, 0 0 0 3px rgba(0,105,148,.25)); }
.ds-check input:disabled ~ *, .ds-radio input:disabled ~ * { opacity: .5; cursor: not-allowed; }

/* ===========================================================================
   SWITCH — <label class="ds-switch"><input type="checkbox"><span class="ds-switch__track"></span></label>
   =========================================================================== */
.ds-switch { display: inline-flex; align-items: center; gap: var(--ds-space-2, 8px); cursor: pointer; }
.ds-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.ds-switch__track {
  width: 40px; height: 22px; border-radius: 999px; background: var(--ds-color-gray-300, #d1d5db);
  position: relative; transition: background .2s var(--ds-ease-standard, cubic-bezier(.2,0,0,1)); flex-shrink: 0;
}
.ds-switch__track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; box-shadow: var(--ds-shadow-sm, 0 1px 2px rgba(0,0,0,.2));
  transition: transform .2s var(--ds-ease-standard, cubic-bezier(.2,0,0,1));
}
.ds-switch input:checked + .ds-switch__track { background: var(--ds-color-brand, #006994); }
.ds-switch input:checked + .ds-switch__track::after { transform: translateX(18px); }
.ds-switch input:focus-visible + .ds-switch__track { box-shadow: var(--ds-shadow-focus, 0 0 0 3px rgba(0,105,148,.25)); }
.ds-switch input:disabled + .ds-switch__track { opacity: .5; cursor: not-allowed; }

/* ===========================================================================
   EMPTY STATE
   =========================================================================== */
.ds-empty {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: var(--ds-space-3, 12px); padding: var(--ds-space-12, 48px) var(--ds-space-6, 24px);
  color: var(--ds-text-secondary, #6b7280);
}
.ds-empty__icon { width: 48px; height: 48px; color: var(--ds-color-gray-300, #d1d5db); }
.ds-empty__title { font-size: var(--ds-text-lg, 1.125rem); font-weight: 600; color: var(--ds-text-primary, #111827); margin: 0; }
.ds-empty__text { font-size: var(--ds-text-sm, .875rem); max-width: 360px; margin: 0; }

/* ===========================================================================
   LOADING — spinner + dots
   =========================================================================== */
.ds-spinner {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid var(--ds-color-gray-200, #e5e7eb);
  border-top-color: var(--ds-color-brand, #006994);
  animation: ds-spin .7s linear infinite; display: inline-block;
}
.ds-spinner-lg { width: 36px; height: 36px; border-width: 3px; }
@keyframes ds-spin { to { transform: rotate(360deg); } }
.ds-loading-overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.7); z-index: 5; border-radius: inherit;
}

/* ===========================================================================
   SKELETON
   =========================================================================== */
.ds-skeleton {
  display: block; border-radius: var(--ds-radius-sm, 6px);
  background: linear-gradient(90deg, var(--ds-color-gray-100,#f3f4f6) 25%, var(--ds-color-gray-200,#e5e7eb) 37%, var(--ds-color-gray-100,#f3f4f6) 63%);
  background-size: 400% 100%; animation: ds-shimmer 1.4s ease infinite; height: 1em;
}
.ds-skeleton-text { height: .85em; margin-bottom: .5em; }
.ds-skeleton-title { height: 1.4em; width: 50%; margin-bottom: .75em; }
.ds-skeleton-circle { border-radius: 50%; }
@keyframes ds-shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ===========================================================================
   PAGINATION
   =========================================================================== */
.ds-pagination { display: inline-flex; align-items: center; gap: var(--ds-space-1, 4px); }
.ds-pagination a, .ds-pagination span {
  display: inline-flex; align-items: center; justify-content: center; min-width: 36px; height: 36px;
  padding: 0 var(--ds-space-2, 8px); font-size: var(--ds-text-sm, .875rem); font-weight: 500;
  color: var(--ds-text-secondary, #6b7280); border: 1px solid var(--ds-border, #e5e7eb);
  border-radius: var(--ds-radius-sm, 6px); background: #fff; text-decoration: none; transition: all .15s;
}
.ds-pagination a:hover { background: var(--ds-surface-hover, #f9fafb); color: var(--ds-text-primary, #111827); border-color: var(--ds-border-strong, #d1d5db); }
.ds-pagination .is-active { background: var(--ds-color-brand, #006994); border-color: var(--ds-color-brand, #006994); color: #fff; }
.ds-pagination .is-disabled { opacity: .45; pointer-events: none; }

/* ===========================================================================
   SEARCH input (icon + clear)
   =========================================================================== */
.ds-search { position: relative; display: inline-flex; align-items: center; width: 100%; max-width: 360px; }
.ds-search__icon { position: absolute; left: 12px; width: 16px; height: 16px; color: var(--ds-text-tertiary, #9ca3af); pointer-events: none; }
.ds-search input {
  width: 100%; height: var(--ds-input-height, 40px); padding: 0 36px 0 36px;
  font-size: var(--ds-text-sm, .875rem); border: 1px solid var(--ds-border-strong, #d1d5db);
  border-radius: var(--ds-radius-sm, 6px); background: #fff; color: var(--ds-text-primary, #111827); transition: all .15s;
}
.ds-search input:focus { outline: none; border-color: var(--ds-border-focus, #006994); box-shadow: var(--ds-shadow-focus, 0 0 0 3px rgba(0,105,148,.18)); }
.ds-search__clear { position: absolute; right: 8px; width: 22px; height: 22px; border: none; background: transparent; color: var(--ds-text-tertiary,#9ca3af); cursor: pointer; border-radius: 5px; display: none; }
.ds-search.has-value .ds-search__clear { display: inline-flex; align-items: center; justify-content: center; }
.ds-search__clear:hover { background: var(--ds-surface-sunken, #f3f4f6); color: var(--ds-text-primary,#111827); }

/* ===========================================================================
   FILTER BAR
   =========================================================================== */
.ds-filterbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--ds-space-3, 12px);
  padding: var(--ds-space-3, 12px) var(--ds-space-4, 16px);
  background: var(--ds-surface-card, #fff); border: 1px solid var(--ds-border, #e5e7eb);
  border-radius: var(--ds-radius-md, 8px);
}
.ds-filterbar__group { display: flex; align-items: center; gap: var(--ds-space-2, 8px); }
.ds-filterbar__spacer { flex: 1; }
@media (max-width: 767px){ .ds-filterbar { flex-direction: column; align-items: stretch; } .ds-filterbar__spacer { display: none; } }

/* ===========================================================================
   TABS
   =========================================================================== */
.ds-tabs { display: flex; gap: var(--ds-space-1, 4px); border-bottom: 1px solid var(--ds-border, #e5e7eb); }
.ds-tab {
  appearance: none; background: none; border: none; cursor: pointer;
  padding: var(--ds-space-3, 12px) var(--ds-space-4, 16px); font-size: var(--ds-text-sm, .875rem); font-weight: 500;
  color: var(--ds-text-secondary, #6b7280); border-bottom: 2px solid transparent; margin-bottom: -1px; transition: all .15s;
}
.ds-tab:hover { color: var(--ds-text-primary, #111827); }
.ds-tab[aria-selected="true"] { color: var(--ds-color-brand, #006994); border-bottom-color: var(--ds-color-brand, #006994); }
.ds-tab:focus-visible { outline: none; box-shadow: var(--ds-shadow-focus, 0 0 0 3px rgba(0,105,148,.25)); border-radius: 6px; }
.ds-tabpanel { padding-top: var(--ds-space-4, 16px); }
.ds-tabpanel[hidden] { display: none; }

/* ===========================================================================
   ACCORDION
   =========================================================================== */
.ds-accordion { border: 1px solid var(--ds-border, #e5e7eb); border-radius: var(--ds-radius-md, 8px); overflow: hidden; }
.ds-accordion__item + .ds-accordion__item { border-top: 1px solid var(--ds-border, #e5e7eb); }
.ds-accordion__trigger {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: var(--ds-space-4, 16px); background: #fff; border: none; cursor: pointer; text-align: left;
  font-size: var(--ds-text-sm, .875rem); font-weight: 600; color: var(--ds-text-primary, #111827); transition: background .15s;
}
.ds-accordion__trigger:hover { background: var(--ds-surface-hover, #f9fafb); }
.ds-accordion__trigger:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--ds-color-brand, #006994); }
.ds-accordion__chev { width: 16px; height: 16px; color: var(--ds-text-tertiary,#9ca3af); transition: transform .2s; flex-shrink: 0; }
.ds-accordion__trigger[aria-expanded="true"] .ds-accordion__chev { transform: rotate(180deg); }
.ds-accordion__panel { padding: 0 var(--ds-space-4, 16px) var(--ds-space-4, 16px); font-size: var(--ds-text-sm, .875rem); color: var(--ds-text-secondary, #6b7280); }
.ds-accordion__panel[hidden] { display: none; }

/* ===========================================================================
   WIZARD (stepper)
   =========================================================================== */
.ds-wizard { display: flex; align-items: center; gap: var(--ds-space-2, 8px); }
.ds-wizard__step { display: flex; align-items: center; gap: var(--ds-space-2, 8px); flex: 1; }
.ds-wizard__dot {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0; display: inline-flex;
  align-items: center; justify-content: center; font-size: .75rem; font-weight: 600;
  background: var(--ds-color-gray-100, #f3f4f6); color: var(--ds-text-secondary, #6b7280); border: 2px solid var(--ds-border, #e5e7eb);
}
.ds-wizard__label { font-size: var(--ds-text-sm, .875rem); color: var(--ds-text-secondary, #6b7280); white-space: nowrap; }
.ds-wizard__line { flex: 1; height: 2px; background: var(--ds-border, #e5e7eb); }
.ds-wizard__step.is-active .ds-wizard__dot { background: var(--ds-color-brand, #006994); border-color: var(--ds-color-brand, #006994); color: #fff; }
.ds-wizard__step.is-active .ds-wizard__label { color: var(--ds-text-primary, #111827); font-weight: 600; }
.ds-wizard__step.is-done .ds-wizard__dot { background: var(--ds-color-success, #10b981); border-color: var(--ds-color-success, #10b981); color: #fff; }
@media (max-width: 767px){ .ds-wizard__label { display: none; } }

/* ===========================================================================
   DROPDOWN / CONTEXT MENU (positioned by JS)
   =========================================================================== */
.ds-menu {
  position: absolute; min-width: 180px; padding: var(--ds-space-1, 4px);
  background: var(--ds-surface-card, #fff); border: 1px solid var(--ds-border, #e5e7eb);
  border-radius: var(--ds-radius-md, 8px); box-shadow: var(--ds-shadow-lg, 0 12px 24px rgba(17,24,39,.10));
  z-index: var(--ds-z-dropdown, 1000); opacity: 0; transform: translateY(-4px);
  transition: opacity .12s, transform .12s; pointer-events: none;
}
.ds-menu.is-open { opacity: 1; transform: none; pointer-events: auto; }
.ds-menu__item {
  display: flex; align-items: center; gap: var(--ds-space-2, 8px); width: 100%;
  padding: var(--ds-space-2, 8px) var(--ds-space-3, 12px); font-size: var(--ds-text-sm, .875rem);
  color: var(--ds-text-primary, #111827); background: none; border: none; border-radius: var(--ds-radius-sm, 6px);
  cursor: pointer; text-align: left; text-decoration: none; transition: background .12s;
}
.ds-menu__item:hover, .ds-menu__item:focus { background: var(--ds-surface-sunken, #f3f4f6); outline: none; }
.ds-menu__item.is-danger { color: var(--ds-color-danger-text, #b91c1c); }
.ds-menu__sep { height: 1px; background: var(--ds-border, #e5e7eb); margin: var(--ds-space-1, 4px) 0; }

/* ===========================================================================
   TOOLTIP & POPOVER (positioned by JS)
   =========================================================================== */
.ds-tooltip {
  position: absolute; z-index: var(--ds-z-tooltip, 1500); max-width: 240px;
  padding: 6px 10px; font-size: var(--ds-text-xs, .75rem); line-height: 1.4;
  color: #fff; background: var(--ds-color-gray-900, #111827); border-radius: var(--ds-radius-sm, 6px);
  box-shadow: var(--ds-shadow-md, 0 4px 8px rgba(0,0,0,.15)); opacity: 0; transition: opacity .12s; pointer-events: none;
}
.ds-tooltip.is-open { opacity: 1; }
.ds-popover {
  position: absolute; z-index: var(--ds-z-tooltip, 1500); min-width: 220px; max-width: 320px;
  padding: var(--ds-space-4, 16px); font-size: var(--ds-text-sm, .875rem);
  background: var(--ds-surface-card, #fff); color: var(--ds-text-primary, #111827);
  border: 1px solid var(--ds-border, #e5e7eb); border-radius: var(--ds-radius-md, 8px);
  box-shadow: var(--ds-shadow-lg, 0 12px 24px rgba(17,24,39,.12)); opacity: 0; transform: translateY(-4px);
  transition: opacity .12s, transform .12s; pointer-events: none;
}
.ds-popover.is-open { opacity: 1; transform: none; pointer-events: auto; }

/* ===========================================================================
   DRAWER (side panel)
   =========================================================================== */
.ds-drawer-backdrop {
  position: fixed; inset: 0; background: var(--ds-modal-backdrop, rgba(17,24,39,.45));
  z-index: var(--ds-z-modal, 1300); opacity: 0; transition: opacity .25s; pointer-events: none;
}
.ds-drawer-backdrop.is-open { opacity: 1; pointer-events: auto; }
.ds-drawer {
  position: fixed; top: 0; bottom: 0; right: 0; width: 420px; max-width: 92vw;
  background: var(--ds-surface-card, #fff); z-index: calc(var(--ds-z-modal, 1300) + 1);
  box-shadow: var(--ds-shadow-xl, 0 24px 48px rgba(17,24,39,.18));
  transform: translateX(100%); transition: transform .28s var(--ds-ease-emphasized, cubic-bezier(.3,0,0,1));
  display: flex; flex-direction: column;
}
.ds-drawer.is-open { transform: none; }
.ds-drawer--left { right: auto; left: 0; transform: translateX(-100%); }
.ds-drawer__header { display: flex; align-items: center; justify-content: space-between; padding: var(--ds-space-5, 20px); border-bottom: 1px solid var(--ds-border, #e5e7eb); }
.ds-drawer__title { font-size: var(--ds-text-lg, 1.125rem); font-weight: 600; margin: 0; }
.ds-drawer__body { flex: 1; overflow: auto; padding: var(--ds-space-5, 20px); }
.ds-drawer__footer { display: flex; gap: var(--ds-space-3, 12px); justify-content: flex-end; padding: var(--ds-space-4, 16px) var(--ds-space-5, 20px); border-top: 1px solid var(--ds-border, #e5e7eb); }
@media (max-width: 767px){ .ds-drawer { width: 100vw; max-width: 100vw; } }

/* ===========================================================================
   CONFIRMATION DIALOG (compact modal variant) — used by ui.confirm()
   =========================================================================== */
.ds-confirm { width: 400px; max-width: 100%; text-align: left; }
.ds-confirm__icon { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin-bottom: var(--ds-space-3, 12px); }
.ds-confirm__icon.is-danger { background: var(--ds-color-danger-subtle, #fee2e2); color: var(--ds-color-danger-hover, #dc2626); }
.ds-confirm__icon.is-warning { background: var(--ds-color-warning-subtle, #fffbeb); color: var(--ds-color-warning-hover, #d97706); }
.ds-confirm__title { font-size: var(--ds-text-lg, 1.125rem); font-weight: 600; margin: 0 0 var(--ds-space-2, 8px); }
.ds-confirm__msg { font-size: var(--ds-text-sm, .875rem); color: var(--ds-text-secondary, #6b7280); margin: 0 0 var(--ds-space-5, 20px); line-height: 1.5; }

/* ===========================================================================
   DARK MODE overrides (shared)
   =========================================================================== */
.dark-mode .ds-check__box, .dark-mode .ds-radio__box { background: #1e293b; border-color: #475569; }
.dark-mode .ds-switch__track { background: #475569; }
.dark-mode .ds-pagination a, .dark-mode .ds-pagination span { background: #1e293b; border-color: #334155; color: #cbd5e1; }
.dark-mode .ds-search input, .dark-mode .ds-filterbar { background: #1e293b; border-color: #334155; color: #f1f5f9; }
.dark-mode .ds-menu, .dark-mode .ds-popover, .dark-mode .ds-drawer { background: #1e293b; border-color: #334155; color: #f1f5f9; }
.dark-mode .ds-menu__item { color: #f1f5f9; }
.dark-mode .ds-menu__item:hover, .dark-mode .ds-menu__item:focus { background: #334155; }
.dark-mode .ds-accordion, .dark-mode .ds-accordion__trigger { background: #1e293b; border-color: #334155; color: #f1f5f9; }
.dark-mode .ds-empty__title { color: #f1f5f9; }

@media (prefers-reduced-motion: reduce) {
  .ds-skeleton, .ds-spinner { animation-duration: .01ms; }
  .ds-drawer { transition: none; }
}
