/**
 * css/components.css  -  Reusable UI components
 *
 * Load order: AFTER layout.css, BEFORE utilities.css
 * Naming: c- prefix (BEM: c-block__element--modifier)
 *
 * Add new shared components here. Page-scoped components
 * (ap-, kb-, etc.) stay in their own pages/modules.
 */

/* ── Badge ───────────────────────────────────────────── */

.c-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: .75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--theme-bg-surface, #f3f4f6);
  color: var(--theme-text-secondary);
}

.c-badge--accent {
  background: rgba(var(--theme-accent-rgb, 1,167,233), .12);
  color: var(--theme-accent);
}

.c-badge--denied {
  background: #fef2f2;
  color: #ef4444;
}

.c-badge--success {
  background: #f0fdf4;
  color: #16a34a;
}

/* ── Icon accent ─────────────────────────────────────── */

.c-icon-accent {
  color: var(--theme-accent);
}

/* ── Section label (icon + text heading) ─────────────── */

.c-section-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: .9rem;
  color: var(--theme-text-primary);
  margin: 20px 0 10px;
}

.c-section-label i {
  color: var(--theme-accent);
}

/* ── Stat card (KPI box) ─────────────────────────────── */
/* Canonical component  -  replaces: .stat-card, .modern-stat-card, .stat-card-large,
   .tlm-stat-card, .admin-stat-card, .fm-kpi-card in all modules.
   Usage: <div class="c-stat-card"> <div class="c-stat-card__value">42</div>
          <div class="c-stat-card__label">Total Sales</div> </div>              */

.c-stat-card {
  position: relative;
  background: var(--theme-bg-card, #fff);
  border: 1px solid var(--theme-border-color, #dee2e6);
  border-radius: 12px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.c-stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,.08);
}

.c-stat-card__icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  margin-bottom: 0.75rem;
  background: rgba(var(--theme-accent-rgb, 1,167,233), .12);
  color: var(--theme-accent);
}

.c-stat-card__label {
  font-size: 0.78rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--theme-text-secondary, #6c757d);
}

.c-stat-card__value {
  font-size: 1.6rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--theme-text-primary, #212529);
  line-height: 1.2;
}

.c-stat-card__sub {
  font-size: 0.8rem;
  color: var(--theme-text-secondary, #6c757d);
  margin-top: 2px;
}

/* Admin-only lock badge  -  drop this inside any .c-stat-card whose PHP is
   wrapped in <?php if (isGlobalAdmin()): ?>. Non-admins never get the card
   in the DOM at all; this badge just signals to the admin that the figure
   is restricted from other roles.
   Usage: <span class="c-stat-card__lock" title="Ορατό μόνο σε Admin">
            <i class="fas fa-lock"></i></span>                            */
.c-stat-card__lock {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--theme-bg-surface, #f3f4f6);
  color: var(--theme-text-secondary, #6c757d);
  font-size: 0.68rem;
  cursor: default;
}

/* Semantic color modifiers */
.c-stat-card--positive .c-stat-card__value { color: var(--theme-success, #198754); }
.c-stat-card--negative .c-stat-card__value { color: var(--theme-danger, #dc3545); }
.c-stat-card--warning  .c-stat-card__value { color: var(--theme-warning, #fd7e14); }
.c-stat-card--info     .c-stat-card__value { color: var(--theme-info, #0d6efd); }

/* Mobile: shrink so stat rows don't dominate the screen and bury content below them */
@media (max-width: 768px) {
  .c-stat-card {
    padding: 0.75rem;
    gap: 0.15rem;
  }

  .c-stat-card__icon {
    width: 32px;
    height: 32px;
    font-size: 0.9rem;
    margin-bottom: 0.4rem;
  }

  .c-stat-card__lock {
    top: 0.4rem;
    right: 0.4rem;
    width: 18px;
    height: 18px;
    font-size: 0.6rem;
  }

  .c-stat-card__label {
    font-size: 0.68rem;
  }

  .c-stat-card__value {
    font-size: 1.15rem;
  }
}

/* ── Customer search result card ─────────────────────── */
/* Canonical component  -  rendered by js/core/customer-search-card.js.
   Replaces ad-hoc customer row markup in Cashier, Repairhub, Inventory,
   Finance customer-search dropdowns/lists. Style here only; the JS module
   controls structure/fields. */

.c-customer-result {
  padding: 2px 0;
  line-height: 1.4;
}

.c-customer-result__name {
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 600;
  color: var(--theme-text-primary);
}

.c-customer-result__icon {
  opacity: .6;
  font-size: .85em;
}

.c-customer-result__icon--business {
  opacity: 1;
  color: var(--theme-accent);
}

.c-customer-result__badge {
  color: var(--theme-accent);
  font-size: .85em;
  font-weight: 500;
}

.c-customer-result__subtitle {
  font-size: .85em;
  color: var(--theme-accent);
}

.c-customer-result__contact,
.c-customer-result__meta {
  font-size: .8em;
  color: var(--theme-text-muted, #6c757d);
}

.c-customer-result__parent {
  font-size: .8em;
  color: var(--theme-accent);
}

/* ── Page header ─────────────────────────────────────── */
/* Canonical component  -  replaces local .page-header in customers.css,
   inventory/pages.css, goals/shared.css, tlm/tlm.css.
   Usage: <div class="c-page-header">
            <div class="c-page-header__title"><h1>...</h1></div>
            <div class="c-page-header__actions"><!-- buttons --></div>
          </div>                                                                 */

.c-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

.c-page-header__title h1,
.c-page-header__title h2 {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--theme-text-primary);
}

.c-page-header__title p {
  margin: 4px 0 0;
  font-size: .85rem;
  color: var(--theme-text-muted);
}

.c-page-header__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── Store selector ─────────────────────────────────── */
/* Global store context dropdown in the top navbar.
   Usage: <div class="c-store-selector">
            <i class="fas fa-store c-store-selector__icon"></i>
            <select id="storeSelector" class="c-store-selector__select">...</select>
          </div>                                                                 */

.c-store-selector {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-right: 12px;
}

/* =====================================================
   NOTIFICATION BELL  (.c-notif-bell)
   ===================================================== */
.c-notif-bell {
  position: relative;
  display: inline-block;
  margin-right: 8px;
}

.c-notif-bell__btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 8px;
  color: var(--theme-text-secondary, #666);
  font-size: 1rem;
  position: relative;
  transition: background 0.15s;
}
.c-notif-bell__btn:hover { background: var(--theme-hover, rgba(0,0,0,0.06)); }

.c-notif-bell__badge {
  position: absolute;
  top: 2px;
  right: 2px;
  background: #dc3545;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  border-radius: 50%;
  min-width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  padding: 0 3px;
}

.c-notif-bell__panel {
  /* Panel lives at body level (outside backdrop-filter context).
     Desktop: fixed dropdown anchored near top-right bell.
     Mobile override below. */
  position: fixed;
  top: 58px;
  right: 20px;
  width: 320px;
  max-height: 420px;
  overflow-y: auto;
  background: var(--theme-card-bg, #fff);
  border: 1px solid var(--theme-border, #e0e0e0);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.14);
  z-index: 9999;
}

.c-notif-bell__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--theme-border, #e0e0e0);
  font-weight: 600;
  font-size: 0.9rem;
}

.c-notif-bell__back {
  display: none; /* only visible on mobile full-screen view */
}

.c-notif-bell__mark-all {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.78rem;
  color: var(--theme-accent, #0d6efd);
  padding: 2px 6px;
  border-radius: 4px;
}
.c-notif-bell__mark-all:hover { background: var(--theme-hover, rgba(0,0,0,0.05)); }

.c-notif-bell__empty {
  padding: 16px;
  text-align: center;
  color: var(--theme-text-muted, #888);
  font-size: 0.85rem;
}

.c-notif-bell__item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--theme-border, #e0e0e0);
  border-left: 3px solid transparent;
  transition: background 0.12s;
}
.c-notif-bell__item:last-child { border-bottom: none; }
.c-notif-bell__item--upcoming { border-left-color: #0d6efd; background: rgba(13,110,253,0.04); }
.c-notif-bell__item--overdue  { border-left-color: #dc3545; background: rgba(220,53,69,0.04); }
.c-notif-bell__item--pool     { border-left-color: #28a745; background: rgba(40,167,69,0.04); cursor: pointer; }
.c-notif-bell__item--pool:hover { background: rgba(40,167,69,0.09); }
.c-notif-bell__item--comment  { border-left-color: #3b82f6; background: rgba(59,130,246,0.04); }
.c-notif-bell__item--lead     { border-left-color: #16a34a; background: rgba(22,163,74,0.04); cursor: pointer; }
.c-notif-bell__item--lead:hover { background: rgba(22,163,74,0.09); }
.c-notif-bell__item--clickable { cursor: pointer; }
.c-notif-bell__item--clickable:hover { filter: brightness(0.96); }
.c-notif-bell__item--read { opacity: 0.6; }

.c-notif-bell__item-body { flex: 1; min-width: 0; }
.c-notif-bell__item-title { font-weight: 600; font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.c-notif-bell__item-text { font-size: 0.8rem; color: var(--theme-text-muted, #888); margin-top: 2px; }

.c-notif-bell__item-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.c-notif-bell__item-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 3px 5px;
  border-radius: 4px;
  font-size: 0.75rem;
  color: var(--theme-text-muted, #888);
}
.c-notif-bell__item-btn:hover { background: var(--theme-hover, rgba(0,0,0,0.08)); color: var(--theme-text, #333); }

/* Drag handle (visible on mobile bottom drawer) */
.c-notif-bell__handle {
  display: none;
  width: 36px;
  height: 4px;
  background: var(--theme-border, #d0d0d0);
  border-radius: 2px;
  margin: 10px auto 2px;
}

/* Backdrop overlay */
.c-notif-bell__overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 9998;
  transition: opacity 0.2s;
}

/* Mobile: full-screen view, slides in from the right like a navigation push */
@media (max-width: 768px) {
  .c-notif-bell__handle { display: none; } /* replaced by the explicit back button in the header */

  .c-notif-bell__back {
    display: block;
    background: none;
    border: none;
    padding: 4px;
    margin-right: 4px;
    font-size: 1.1rem;
    color: var(--theme-text, #1a1a1a);
    cursor: pointer;
  }

  .c-notif-bell__panel {
    position: fixed;
    inset: 0;
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: 100vh;
    border-radius: 0;
    border: none;
    box-shadow: none;
    z-index: 10000;
    transform: translateX(100%);
    transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
    /* u-hidden is removed by JS before open; visibility+transform do the hiding */
    display: flex;
    flex-direction: column;
    visibility: hidden;
    pointer-events: none;
  }

  .c-notif-bell__panel.c-notif-bell__panel--open {
    transform: translateX(0);
    visibility: visible;
    pointer-events: auto;
  }

  /* The notifList inside should scroll, not the whole panel */
  .c-notif-bell__panel #notifList {
    overflow-y: auto;
    flex: 1;
    overscroll-behavior: contain;
  }

  .c-notif-bell__header {
    position: sticky;
    top: 0;
    padding-top: calc(10px + env(safe-area-inset-top, 0px));
    background: var(--theme-card-bg, #fff);
    border-radius: 0;
    z-index: 1;
    flex-shrink: 0;
  }

  /* Overlay should sit above mobile nav */
  .c-notif-bell__overlay {
    z-index: 9998;
  }
}

/* =====================================================
   RECURRING TASK BADGES & UI
   ===================================================== */
.task-recurring-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  color: #0d6efd;
  margin-left: 4px;
  opacity: 0.8;
}

.recurring-nav-item {
  position: relative;
}
.recurring-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-accent, #0d6efd);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  border-radius: 10px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: auto;
  flex: 0 0 auto;
  line-height: 1;
}

#recurringOptionsPanel,
#poolRecurringOptionsPanel {
  background: var(--theme-hover, rgba(0,0,0,0.03));
  border: 1px solid var(--theme-border, #e0e0e0);
  border-radius: 8px;
  padding: 12px;
  margin-top: 4px;
}

.c-store-selector__icon {
  font-size: 0.8rem;
  color: var(--theme-text-muted);
}

.c-store-selector__select {
  background: var(--theme-surface, #fff);
  color: var(--theme-text, #333);
  border: 1px solid var(--theme-border, #ddd);
  border-radius: var(--theme-radius-sm, 6px);
  padding: 4px 24px 4px 8px;
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
  appearance: auto;
  min-width: 80px;
  transition: border-color 0.15s ease;
}

.c-store-selector__select:hover {
  border-color: var(--theme-accent, #6c5ce7);
}

.c-store-selector__select:focus {
  outline: none;
  border-color: var(--theme-accent, #6c5ce7);
  box-shadow: 0 0 0 2px rgba(108, 92, 231, 0.15);
}

/* ── App Launch Overlay ─────────────────────────────────────────────────────
   Full-screen branded overlay shown while navigating to an app.
   Eliminates the blank-screen gap between portal click and app load.
   Triggered by launchApp() in index.php.
─────────────────────────────────────────────────────────────────────────── */
.c-app-launch {
  position: fixed;
  inset: 0;
  z-index: 99990;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  background: var(--theme-bg, #f5f3ef);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.c-app-launch--open {
  opacity: 1;
  pointer-events: auto;
}

.c-app-launch__icon {
  font-size: 4rem;
  background: linear-gradient(135deg, var(--theme-accent, #6366f1), var(--theme-accent-2, #06b6d4));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: c-app-launch-pulse 1.2s ease-in-out infinite;
}

.c-app-launch__name {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--theme-text, #1a1a2e);
  letter-spacing: 0.01em;
}

.c-app-launch__spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--theme-border, #e0ddd8);
  border-top-color: var(--theme-accent, #6366f1);
  border-radius: 50%;
  animation: c-app-launch-spin 0.7s linear infinite;
}

@keyframes c-app-launch-spin {
  to { transform: rotate(360deg); }
}

@keyframes c-app-launch-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.65; }
}

/* ── Portal Dashboard ─────────────────────────────────
   Group section with heading + card grid.
   Cards: c-portal-card + variant modifier (--ops/sales/mgmt/tools)
─────────────────────────────────────────────────────────────────── */

.c-portal-group {
  margin-bottom: 2rem;
}

.c-portal-group__label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--theme-text-muted, #888);
  margin: 0 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--theme-border-color, rgba(0,0,0,0.07));
}

.c-portal-group__label i {
  font-size: 0.75rem;
  color: var(--theme-accent, #01a7e9);
}

.c-portal-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 1rem 1.1rem;
  border-radius: 14px;
  background: var(--theme-bg-card, #fff);
  border: 1px solid var(--theme-border-color, rgba(0,0,0,0.07));
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.c-portal-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.10);
  border-color: var(--theme-accent, #01a7e9);
}

.c-portal-card:active {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.c-portal-card__head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.c-portal-card__icon-wrap {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
  /* default (ops) */
  background: rgba(245, 166, 35, 0.12);
  color: var(--brand-primary, #f5a623);
}

.c-portal-card--sales .c-portal-card__icon-wrap {
  background: rgba(16, 185, 129, 0.12);
  color: #10b981;
}

.c-portal-card--mgmt .c-portal-card__icon-wrap {
  background: rgba(99, 102, 241, 0.12);
  color: #6366f1;
}

.c-portal-card--tools .c-portal-card__icon-wrap {
  background: rgba(139, 92, 246, 0.12);
  color: #8b5cf6;
}

.c-portal-card__title-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.c-portal-card__name {
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--theme-text-primary, #212529);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.c-portal-card__stat-pill {
  display: inline-flex;
  align-items: center;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 20px;
  background: var(--theme-border-color, rgba(0,0,0,0.06));
  color: var(--theme-text-muted, #888);
  width: fit-content;
}

.c-portal-card__stat-pill--active {
  background: rgba(245, 166, 35, 0.14);
  color: var(--brand-primary, #e6950a);
}

.c-portal-card__desc {
  font-size: 0.77rem;
  color: var(--theme-text-muted, #888);
  margin: 0;
  line-height: 1.45;
  flex: 1;
}

.c-portal-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 8px;
  border-top: 1px solid var(--theme-border-color, rgba(0,0,0,0.06));
  margin-top: auto;
}

.c-portal-card__cta {
  font-size: 0.77rem;
  font-weight: 600;
  color: var(--theme-accent, #01a7e9);
}

.c-portal-card__arrow {
  font-size: 0.7rem;
  color: var(--theme-text-muted, #aaa);
  transition: transform 0.18s ease;
}

.c-portal-card:hover .c-portal-card__arrow {
  transform: translateX(3px);
  color: var(--theme-accent, #01a7e9);
}

/* dark-mode tweaks for portal cards */
[data-theme="dark"] .c-portal-card {
  background: var(--theme-bg-card);
}

[data-theme="dark"] .c-portal-card:hover {
  box-shadow: 0 6px 20px rgba(0,0,0,0.35), 0 0 0 1px rgba(255,255,255,0.04);
}

[data-theme="dark"] .c-portal-card:active {
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

[data-theme="dark"] .c-portal-card__stat-pill--active {
  background: rgba(245, 166, 35, 0.18);
  color: #f5a623;
}

/* ── Portal Edit Mode ─────────────────────────────────────────────────────
   Classes for the layout editor: toolbar, action bar, drag handles,
   card/group edit overlays, card edit panel, group rename popup.
──────────────────────────────────────────────────────────────────────────── */

/* Toolbar row: sits above the groups and holds the "Organise" toggle */
.c-portal-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

/* Toggle button */
.c-portal-edit-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 5px 14px;
  border-radius: 20px;
  border: 1px solid var(--theme-border-color, rgba(0,0,0,0.12));
  background: var(--theme-bg-card, #fff);
  color: var(--theme-text-secondary, #666);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.c-portal-edit-toggle:hover,
.c-portal-edit-toggle--active {
  background: var(--theme-accent, #01a7e9);
  border-color: var(--theme-accent, #01a7e9);
  color: #fff;
}

/* Edit action bar (shown when edit mode is active) */
.c-portal-edit-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 14px;
  margin-bottom: 16px;
  border-radius: 10px;
  background: var(--theme-bg-surface, #f8f9fa);
  border: 1px dashed var(--theme-accent, #01a7e9);
}

.c-portal-edit-bar__scope {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.c-portal-edit-bar__scope-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--theme-text-muted, #888);
}

.c-portal-edit-bar__scope-opt {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--theme-text-secondary, #555);
}
.c-portal-edit-bar__scope-opt input[type="radio"] {
  accent-color: var(--theme-accent, #01a7e9);
}

.c-portal-edit-bar__actions {
  display: flex;
  gap: 6px;
  margin-left: auto;
}

/* Edit controls: hidden by default; shown in edit mode via body class */
.c-portal-edit-control {
  display: none;
}
.portal-edit-mode .c-portal-edit-control {
  display: flex;
}

/* Group header: aligns drag handle + title + action buttons */
.c-portal-group__header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.c-portal-group__header .c-portal-group__label {
  flex: 1;
  margin: 0;
}

/* Group drag handle */
.c-portal-group-drag {
  align-items: center;
  justify-content: center;
  width: 24px;
  cursor: grab;
  color: var(--theme-text-muted, #aaa);
  font-size: 0.85rem;
  flex-shrink: 0;
}
.c-portal-group-drag:active { cursor: grabbing; }

/* Group action buttons (pencil / trash) */
.c-portal-group-actions {
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.c-portal-group-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  font-size: 0.75rem;
  color: var(--theme-text-muted, #888);
  transition: background 0.15s, color 0.15s;
}
.c-portal-group-action-btn:hover { background: var(--theme-hover, rgba(0,0,0,0.07)); color: var(--theme-text-primary); }
.c-portal-group-action-btn--danger:hover { background: rgba(220,53,69,0.1); color: #dc3545; }

/* Ghost while dragging a group */
.c-portal-group--ghost { opacity: 0.4; }

/* Card edit overlay: drag handle + pencil, floats over the card top-right */
.c-portal-card-edit-overlay {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 10;
  align-items: center;
  gap: 4px;
}

/* Ensure the card has position:relative for the overlay to anchor correctly */
.portal-edit-mode .c-portal-card {
  position: relative;
  cursor: default;
}

.c-portal-card-drag {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: var(--theme-bg-surface, rgba(0,0,0,0.05));
  color: var(--theme-text-muted, #888);
  cursor: grab;
  font-size: 0.8rem;
}
.c-portal-card-drag:active { cursor: grabbing; }

.c-portal-card-edit-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 6px;
  background: var(--theme-accent, #01a7e9);
  color: #fff;
  cursor: pointer;
  font-size: 0.72rem;
  transition: opacity 0.15s;
}
.c-portal-card-edit-btn:hover { opacity: 0.85; }

/* Ghost while dragging a card */
.c-portal-card--ghost { opacity: 0.35; outline: 2px dashed var(--theme-accent, #01a7e9); border-radius: 14px; }

/* ── Card edit panel (right-side drawer) ─────────────────────────────── */
.c-portal-edit-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 300px;
  max-width: 90vw;
  z-index: 1050;
  background: var(--theme-bg-card, #fff);
  border-left: 1px solid var(--theme-border-color, #dee2e6);
  box-shadow: -4px 0 24px rgba(0,0,0,0.12);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.25s ease;
}
.c-portal-edit-panel.u-hidden { display: none; }

.c-portal-edit-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--theme-border-color, #dee2e6);
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--theme-text-primary);
  flex-shrink: 0;
}

.c-portal-edit-panel__close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--theme-text-muted, #888);
  font-size: 0.9rem;
  padding: 4px 6px;
  border-radius: 6px;
}
.c-portal-edit-panel__close:hover { background: var(--theme-hover, rgba(0,0,0,0.07)); }

.c-portal-edit-panel__body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.c-portal-edit-panel__label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--theme-text-muted, #888);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: block;
  margin-bottom: 5px;
}

.c-portal-edit-panel__footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 4px;
}

/* ── Group rename popup ───────────────────────────────────────────────── */
.c-portal-group-edit-popup {
  position: absolute;
  z-index: 1040;
  width: 284px;
  background: var(--theme-bg-card, #fff);
  border: 1px solid var(--theme-border-color, #dee2e6);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  padding: 14px;
}
.c-portal-group-edit-popup.u-hidden { display: none; }

/* ── Icon picker grid ────────────────────────────────────────────────── */
.c-portal-icon-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.c-portal-icon-btn {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: 1px solid var(--theme-border-color, #dee2e6);
  background: transparent;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--theme-text-secondary, #555);
  transition: background 0.12s, border-color 0.12s;
}
.c-portal-icon-btn:hover { background: var(--theme-hover, rgba(0,0,0,0.06)); }
.c-portal-icon-btn--active {
  background: rgba(var(--theme-accent-rgb, 1,167,233), 0.15);
  border-color: var(--theme-accent, #01a7e9);
  color: var(--theme-accent, #01a7e9);
}

/* Dashed border around groups while in edit mode */
.portal-edit-mode .c-portal-group {
  border: 1.5px dashed var(--theme-border-color, rgba(0,0,0,0.15));
  border-radius: 12px;
  padding: 12px 12px 4px;
  margin-bottom: 1rem;
}

/* Suppress hover effects on portal cards in edit mode */
.portal-edit-mode .c-portal-card:hover {
  transform: none !important;
  box-shadow: none !important;
}

/* Mobile: card panel slides up from bottom */
@media (max-width: 576px) {
  .c-portal-edit-panel {
    top: auto;
    width: 100%;
    max-width: 100%;
    border-left: none;
    border-top: 1px solid var(--theme-border-color, #dee2e6);
    border-radius: 16px 16px 0 0;
    max-height: 70vh;
  }
  .c-portal-group-edit-popup {
    width: calc(100vw - 24px);
    left: 12px !important;
  }
}

/* ─── Timeline (serial/entity movement history) ─────────────────────────── */
.c-timeline {
  position: relative;
  padding-left: 28px;
  margin: 0;
}

.c-timeline__item {
  position: relative;
  padding-bottom: 20px;
  border-left: 2px solid var(--theme-border-color, #dee2e6);
  padding-left: 20px;
  margin-left: 6px;
}

.c-timeline__item:last-child {
  border-left-color: transparent;
  padding-bottom: 0;
}

.c-timeline__dot {
  position: absolute;
  left: -9px;
  top: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .6rem;
  color: #fff;
  background: var(--theme-text-muted, #6c757d);
}

.c-timeline__dot--in { background: var(--theme-success, #28a745); }
.c-timeline__dot--sold { background: var(--theme-accent, #007bff); }
.c-timeline__dot--sold-unconfirmed { background: var(--theme-warning, #ffc107); }
.c-timeline__dot--refunded { background: var(--theme-warning, #ffc107); }
.c-timeline__dot--out { background: var(--theme-danger, #dc3545); }
.c-timeline__dot--assembly { background: var(--theme-info, #17a2b8); }

.c-timeline__title {
  font-weight: 600;
  color: var(--theme-text-primary);
}

.c-timeline__meta {
  font-size: .8rem;
  color: var(--theme-text-muted);
}

/* ─────────────────────────────────────────────────────────
   c-app-modal  -  Global application modal (AppModal.js)
   Use AppModal.open({...})  -  never write a modal from scratch.
   ───────────────────────────────────────────────────────── */

.c-app-modal-dialog { margin: 1.75rem auto; width: calc(100% - 2rem); }
.c-app-modal-dialog.c-app-modal--sm { max-width: 440px; }
.c-app-modal-dialog.c-app-modal--md { max-width: 600px; }
.c-app-modal-dialog.c-app-modal--lg { max-width: 800px; }
.c-app-modal-dialog.c-app-modal--xl { max-width: 1060px; }

.c-app-modal-content {
  border: none;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
}

.c-app-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--theme-border-color);
  background: var(--theme-bg-surface);
  gap: .75rem;
  flex-shrink: 0;
}

.c-app-modal-title-wrap {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem;
  flex: 1;
  min-width: 0;
}

.c-app-modal-icon {
  font-size: 1rem;
  color: var(--theme-accent);
  flex-shrink: 0;
}

.c-app-modal-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--theme-text-primary);
  line-height: 1.3;
  flex: 1;
}

.c-app-modal-subtitle {
  width: 100%;
  margin: .15rem 0 0;
  font-size: .8rem;
  color: var(--theme-text-muted);
}

.c-app-modal-close {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: none;
  background: transparent;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--theme-text-muted);
  cursor: pointer;
  font-size: .85rem;
  transition: background .15s, color .15s;
}

.c-app-modal-close:hover {
  background: rgba(0, 0, 0, .07);
  color: var(--theme-text-primary);
}

[data-theme="dark"] .c-app-modal-close:hover {
  background: rgba(255, 255, 255, .08);
}

.c-app-modal-body {
  padding: 1.25rem;
  background: var(--theme-bg-card);
  overflow-y: auto;
}

.c-app-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: .5rem;
  padding: .875rem 1.25rem;
  border-top: 1px solid var(--theme-border-color);
  background: var(--theme-bg-card);
}

@media (max-width: 576px) {
  .c-app-modal-dialog { margin: .5rem auto; }
}

/* c-app-modal: icon colour variants (for confirm/alert type colouring) */
.c-app-modal-icon.text-danger  { color: #dc3545 !important; }
.c-app-modal-icon.text-warning { color: #e6a817 !important; }
.c-app-modal-icon.text-success { color: #28a745 !important; }
.c-app-modal-icon.text-info    { color: #17a2b8 !important; }

/* ── Every modal is full screen on phones ───────────────
   Applies globally to every Bootstrap .modal-dialog (including AppModal.js's
   .c-app-modal-dialog, which carries .modal-dialog too) - no per-modal opt-in
   needed. New modals get this automatically; don't add a modifier class.
   !important is deliberate: this must always win over module-local modal-sizing
   systems (e.g. inventory/assets/css/shared.css's compound .modal-dialog.modal-lg
   selectors), regardless of load order. */
@media (max-width: 768px) {
  .modal-dialog {
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100% !important;
    max-height: 100vh !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .modal-dialog .modal-content {
    height: 100% !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
    border: none !important;
  }

  .modal-dialog .modal-body {
    overflow-y: auto;
    max-height: none !important;
  }

  /* Full-screen modals sit flush against the top edge, so their header must
     clear the device status bar / notch / Dynamic Island itself - unlike the
     desktop centered dialog, which always has margin above it regardless. */
  .modal-dialog .modal-header,
  .modal-dialog .c-app-modal-header {
    padding-top: calc(1rem + env(safe-area-inset-top, 0px)) !important;
  }

  /* Footer buttons: on desktop these sit side-by-side sized to their own text
     (fine - there's room). On a narrow phone a short "Ακύρωση" next to a long
     "Διαχείριση στις Παραγγελίες" wraps unevenly - one tiny pill floating next
     to one near-full-width bar. Stack full-width instead; reversed so the
     primary action (always last in DOM, see AppModal.confirm) lands on top,
     matching the standard mobile sheet convention of the "safe"/cancel action
     sitting closest to the thumb at the bottom. */
  .modal-dialog .modal-footer,
  .modal-dialog .c-app-modal-footer {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .modal-dialog .modal-footer > *,
  .modal-dialog .c-app-modal-footer > * {
    width: 100%;
    margin: 0 !important;
  }
}

/* c-app-modal: async spinner shown via AppModal.spinner() / AppModal.setBody() */
.c-app-modal-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 1.25rem;
  gap: .75rem;
}
.c-app-modal-spinner::before {
  content: '';
  display: block;
  width: 2rem;
  height: 2rem;
  border: 3px solid var(--theme-border-color, #dee2e6);
  border-top-color: var(--theme-accent);
  border-radius: 50%;
  animation: c-modal-spin .7s linear infinite;
  flex-shrink: 0;
}
@keyframes c-modal-spin {
  to { transform: rotate(360deg); }
}
.c-app-modal-spinner-text {
  margin: 0;
  font-size: .85rem;
  color: var(--theme-text-muted);
}

/* ─────────────────────────────────────────────────────────
   c-list-*  -  Shared list-view chrome (js/core/list-view.js)
   Empty state, loading skeleton, pagination. Item/card/row
   templates stay per-module - only this surrounding chrome
   is shared.
   ───────────────────────────────────────────────────────── */

.c-list-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 3rem 1.5rem;
  gap: .5rem;
}

.c-list-empty-icon {
  width: 3.5rem;
  height: 3.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--theme-bg-surface);
  color: var(--theme-text-muted);
  font-size: 1.4rem;
  margin-bottom: .5rem;
}

.c-list-empty--error .c-list-empty-icon {
  color: #dc3545;
  background: rgba(220, 53, 69, .1);
}

.c-list-empty--success .c-list-empty-icon {
  color: #198754;
  background: rgba(25, 135, 84, .1);
}

.c-list-empty-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--theme-text-primary);
}

.c-list-empty-message {
  margin: 0;
  font-size: .875rem;
  color: var(--theme-text-muted);
  max-width: 32rem;
}

.c-list-empty-action {
  margin-top: .5rem;
}

/* c-list-empty--compact: a short empty message nested inside an already-small
   section (e.g. one folder's empty task list) - no icon badge, tighter padding. */
.c-list-empty--compact {
  padding: 1.5rem 1rem;
}

.c-list-empty--compact .c-list-empty-icon {
  width: auto;
  height: auto;
  background: none;
  font-size: 1.6rem;
  margin-bottom: .25rem;
}

.c-list-empty--compact .c-list-empty-message {
  max-width: none;
}

/* c-list-loading: skeleton rows shown while a list is fetching */
.c-list-loading {
  display: flex;
  flex-direction: column;
  gap: .75rem;
  padding: .5rem 0;
}

.c-list-skeleton-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1rem;
  border-radius: 10px;
  background: var(--theme-bg-surface);
}

.c-list-skeleton-bar {
  display: block;
  height: .75rem;
  border-radius: 4px;
  flex: 1;
  background: linear-gradient(90deg, var(--theme-border-color) 25%, var(--theme-bg-card) 50%, var(--theme-border-color) 75%);
  background-size: 200% 100%;
  animation: c-list-skeleton-shimmer 1.4s ease-in-out infinite;
}

.c-list-skeleton-bar--avatar {
  flex: 0 0 2.25rem;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
}

.c-list-skeleton-bar--sm {
  flex: 0 0 4rem;
}

/* c-list-loading--grid: skeleton cards for modules whose real content renders
   as a card grid (Customers etc.), not a list of rows. */
.c-list-loading--grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.c-list-skeleton-card {
  background: var(--theme-bg-card);
  border: 1px solid var(--theme-card-border, var(--theme-border-color));
  border-radius: 16px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.c-list-skeleton-card-header {
  display: flex;
  gap: .75rem;
  margin-bottom: .25rem;
}

.c-list-skeleton-card-lines {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  justify-content: center;
}

.c-list-skeleton-bar--w75 { width: 75%; flex: 0 0 auto; }
.c-list-skeleton-bar--w50 { width: 50%; flex: 0 0 auto; }

@keyframes c-list-skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .c-list-skeleton-bar { animation: none; }
}

/* c-list-pagination */
.c-list-pagination {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .35rem;
  padding: 1rem 0 .25rem;
}

.c-list-pagination .page-link {
  color: var(--theme-text-primary);
  background: var(--theme-bg-card);
  border-color: var(--theme-border-color);
}

.c-list-pagination .page-item.active .page-link {
  background: var(--theme-accent);
  border-color: var(--theme-accent);
  color: #fff;
}

.c-list-pagination .page-item.disabled .page-link {
  color: var(--theme-text-muted);
  background: var(--theme-bg-surface);
}

.c-list-pagination-info {
  font-size: .8rem;
  color: var(--theme-text-muted);
}
