/* ================================================================
   AdminPro — components.css
   Shared component styles used across ALL pages.
   Loaded universally via layouts/main.php <head>.
   ================================================================ */

/* ── Tables ─────────────────────────────────────────────────────── */
.ap-table-wrap { overflow-x: auto; }

.ap-table {
  width: 100%;
  margin-bottom: 0;
  border-collapse: collapse;
}
.ap-table thead tr {
  background: var(--ap-table-head);
  border-bottom: 1px solid var(--ap-border);
}
.ap-table thead th {
  padding: .75rem 1rem;
  font-size: .75rem;
  font-weight: 700;
  color: var(--ap-text-3);
  text-transform: uppercase;
  letter-spacing: .06em;
  white-space: nowrap;
}
.ap-table tbody tr {
  border-bottom: 1px solid var(--ap-border);
  transition: background .15s;
}
.ap-table tbody tr:hover { background: var(--ap-surface-2); }
.ap-table tbody td {
  padding: .75rem 1rem;
  font-size: .875rem;
  color: var(--ap-text-2);
  vertical-align: middle;
}

/* ── Badges ──────────────────────────────────────────────────────── */
.ap-badge {
  display: inline-flex; align-items: center;
  font-size: .72rem; font-weight: 700;
  padding: .2rem .55rem; border-radius: 20px;
  letter-spacing: .03em; white-space: nowrap;
}
.ap-badge-primary  { background: var(--ap-primary-soft);  color: var(--ap-primary);  }
.ap-badge-success  { background: var(--ap-success-soft);  color: var(--ap-success);  }
.ap-badge-warning  { background: var(--ap-warning-soft);  color: var(--ap-warning);  }
.ap-badge-danger   { background: var(--ap-danger-soft);   color: var(--ap-danger);   }
.ap-badge-info     { background: var(--ap-info-soft);     color: var(--ap-info);     }
.ap-badge-purple   { background: var(--ap-purple-soft);   color: var(--ap-purple);   }
.ap-badge-secondary{ background: var(--ap-border);        color: var(--ap-text-3);   }

/* ── Pagination ──────────────────────────────────────────────────── */
.ap-page-btn {
  min-width: 32px; height: 32px; padding: 0 .5rem;
  border: 1.5px solid var(--ap-border);
  background: var(--ap-surface); border-radius: var(--radius-sm);
  font-size: .84rem; font-weight: 500; color: var(--ap-text-2);
  cursor: pointer; transition: var(--transition);
  display: inline-flex; align-items: center; justify-content: center;
}
.ap-page-btn:hover:not(:disabled)  { border-color: var(--ap-primary); color: var(--ap-primary); }
.ap-page-btn.is-active             { background: var(--ap-primary); border-color: var(--ap-primary); color: #fff; }
.ap-page-btn:disabled              { opacity: .4; cursor: not-allowed; }

/* ── Period / Tab Buttons ────────────────────────────────────────── */
.ap-period-tabs { display: flex; gap: .5rem; flex-wrap: wrap; }
.ap-period-btn {
  padding: .4rem .9rem; border-radius: var(--radius-md);
  border: 1.5px solid var(--ap-border);
  background: var(--ap-surface); color: var(--ap-text-2);
  font-size: .84rem; font-weight: 500; cursor: pointer; transition: var(--transition);
}
.ap-period-btn:hover    { border-color: var(--ap-primary); color: var(--ap-primary); }
.ap-period-btn.is-active{ background: var(--ap-primary); border-color: var(--ap-primary); color: #fff; }

/* ── Underline Tabs ──────────────────────────────────────────────── */
.ap-tabs-underline { display: flex; gap: 0; border-bottom: 2px solid var(--ap-border); margin-bottom: 1.25rem; flex-wrap: wrap; }
.ap-tab-ul {
  padding: .65rem 1.1rem; border: none; background: none;
  font-size: .875rem; font-weight: 500; color: var(--ap-text-3);
  cursor: pointer; border-bottom: 2px solid transparent;
  margin-bottom: -2px; transition: var(--transition); white-space: nowrap;
}
.ap-tab-ul:hover     { color: var(--ap-primary); }
.ap-tab-ul.is-active { color: var(--ap-primary); border-bottom-color: var(--ap-primary); font-weight: 600; }

.ap-tab-count {
  display: inline-block; padding: .1rem .45rem;
  background: var(--ap-surface-2); border-radius: .25rem;
  font-size: .72rem; color: var(--ap-text-3); margin-left: .4rem; font-weight: 600;
}

/* ── Dropdown Menu ───────────────────────────────────────────────── */
.ap-dropdown-menu {
  position: absolute; right: 0; top: calc(100% + .5rem);
  background: var(--ap-surface); border: 1px solid var(--ap-border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  z-index: 1050; overflow: hidden;
}
.ap-dropdown-header {
  padding: .6rem 1rem; font-size: .78rem;
  color: var(--ap-text-3); font-weight: 500;
  border-bottom: 1px solid var(--ap-border);
}
.ap-dropdown-item {
  display: flex; align-items: center; gap: .6rem;
  padding: .55rem 1rem; font-size: .875rem; font-weight: 500;
  color: var(--ap-text-2); text-decoration: none; transition: var(--transition);
  cursor: pointer; white-space: nowrap;
}
.ap-dropdown-item:hover   { background: var(--ap-surface-2); color: var(--ap-text-1); }
.ap-dropdown-item.is-danger { color: var(--ap-danger); }
.ap-dropdown-item.is-danger:hover { background: var(--ap-danger-soft); }
.ap-dropdown-divider { height: 1px; background: var(--ap-border); margin: .25rem 0; }

/* ── Toasts ──────────────────────────────────────────────────────── */
#ap-toasts {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  display: flex; flex-direction: column; gap: .6rem;
  z-index: 9999;
}
.ap-toast {
  display: flex; align-items: flex-start; gap: .75rem;
  min-width: 280px; max-width: 380px;
  background: var(--ap-surface); border: 1px solid var(--ap-border);
  border-radius: var(--radius-lg); padding: .85rem 1rem;
  box-shadow: var(--shadow-lg);
  animation: toastIn .3s cubic-bezier(.4,0,.2,1);
}
@keyframes toastIn {
  from { opacity:0; transform:translateX(110%); }
  to   { opacity:1; transform:translateX(0); }
}
.ap-toast-success { border-left: 3px solid var(--ap-success); }
.ap-toast-warning { border-left: 3px solid var(--ap-warning); }
.ap-toast-danger  { border-left: 3px solid var(--ap-danger);  }
.ap-toast-info    { border-left: 3px solid var(--ap-info);    }
.ap-toast-icon    { font-size: 1.1rem; flex-shrink: 0; margin-top: .1rem; }
.ap-toast-success .ap-toast-icon { color: var(--ap-success); }
.ap-toast-warning .ap-toast-icon { color: var(--ap-warning); }
.ap-toast-danger  .ap-toast-icon { color: var(--ap-danger);  }
.ap-toast-info    .ap-toast-icon { color: var(--ap-info);    }
.ap-toast-content { flex: 1; min-width: 0; }
.ap-toast-title   { font-size: .84rem; font-weight: 700; color: var(--ap-text-1); margin-bottom: .15rem; }
.ap-toast-msg     { font-size: .82rem; color: var(--ap-text-3); }
.ap-toast-close   {
  background: none; border: none; cursor: pointer;
  color: var(--ap-text-4); font-size: 1rem; padding: 0;
  flex-shrink: 0; transition: var(--transition);
}
.ap-toast-close:hover { color: var(--ap-text-1); }

/* ── Modals ──────────────────────────────────────────────────────── */
.ap-modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 2000; display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity .22s ease;
}
.ap-modal-backdrop.is-open { opacity: 1; pointer-events: all; }
/* Base .ap-modal — no transform/display to avoid breaking overlay-pattern modals */
.ap-modal {
  background: var(--ap-surface-1, var(--ap-surface, #fff)); border: 1px solid var(--ap-border);
  border-radius: var(--radius-xl, 16px); box-shadow: 0 24px 64px rgba(0,0,0,.4);
  width: 100%; max-width: 560px; max-height: 90vh;
  overflow: hidden;
}
/* Scale animation only when nested inside backdrop */
.ap-modal-backdrop .ap-modal {
  display: flex; flex-direction: column;
  transform: translateY(16px) scale(.98);
  transition: transform .22s cubic-bezier(.4,0,.2,1);
}
.ap-modal-backdrop.is-open .ap-modal { transform: translateY(0) scale(1); }
.ap-modal-sm { max-width: 400px; }
.ap-modal-lg { max-width: 740px; }
.ap-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--ap-border); flex-shrink: 0;
}
.ap-modal-title { font-size: 1rem; font-weight: 700; color: var(--ap-text-1); }
.ap-modal-close {
  width: 30px; height: 30px; border: none; background: var(--ap-surface-2);
  border-radius: var(--radius-sm); cursor: pointer; font-size: 1rem;
  color: var(--ap-text-3); display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
}
.ap-modal-close:hover { background: var(--ap-danger-soft); color: var(--ap-danger); }
.ap-modal-body   { flex: 1; overflow-y: auto; padding: 1.35rem; }
.ap-modal-footer {
  padding: .85rem 1.25rem; border-top: 1px solid var(--ap-border);
  display: flex; gap: .6rem; justify-content: flex-end; flex-shrink: 0;
  background: var(--ap-surface-2);
}

/* ── Breadcrumb ──────────────────────────────────────────────────── */
.ap-breadcrumb {
  display: flex; align-items: center; gap: .4rem;
  font-size: .8125rem; color: var(--ap-text-3); margin-bottom: .4rem;
}
.ap-breadcrumb a { color: var(--ap-text-3); text-decoration: none; transition: var(--transition); }
.ap-breadcrumb a:hover { color: var(--ap-primary); }
.ap-breadcrumb .sep     { color: var(--ap-text-4); }
.ap-breadcrumb .current { color: var(--ap-text-2); font-weight: 500; }

/* ── Progress bars ───────────────────────────────────────────────── */
.ap-progress { height: 6px; background: var(--ap-border); border-radius: 10px; overflow: hidden; }
.ap-progress-fill { height: 100%; border-radius: 10px; transition: width .6s ease; }

/* ── Product cards ───────────────────────────────────────────────── */
.ap-product-card {
  border: 1px solid var(--ap-border); border-radius: 8px;
  overflow: hidden; background: var(--ap-surface); transition: box-shadow .2s ease;
}
.ap-product-card:hover { box-shadow: var(--shadow-md); }
.ap-product-image {
  width: 100%; height: 180px;
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 48px;
}
.ap-product-body { padding: 16px; }
.ap-product-name { font-weight: 600; font-size: .875rem; margin-bottom: 4px; color: var(--ap-text-1); }
.ap-product-meta { font-size: .75rem; color: var(--ap-text-3); margin-bottom: 8px; }
.ap-product-price{ font-size: 1rem; font-weight: 700; color: var(--ap-primary); margin-bottom: 8px; }
.ap-product-rating{ font-size: .75rem; color: #ffc107; margin-bottom: 8px; }
.ap-stock-bar { width:100%; height:6px; background:var(--ap-border); border-radius:3px; overflow:hidden; margin-bottom:8px; }
.ap-stock-fill { height:100%; background:var(--ap-success); transition: background .2s; }
.ap-stock-fill.low { background: var(--ap-warning); }
.ap-stock-fill.out { background: var(--ap-danger);  }
.ap-product-actions { display:flex; gap:6px; margin-top:12px; border-top:1px solid var(--ap-border); padding-top:12px; }

/* ── Quick Nav Tiles ─────────────────────────────────────────────── */
.qnav-tile {
  display: flex; align-items: center; gap: .875rem;
  padding: 1.1rem 1.25rem;
  background: var(--ap-surface); border: 1.5px solid var(--ap-border);
  border-radius: var(--radius-lg); text-decoration: none;
  transition: var(--transition); color: var(--ap-text-1);
}
.qnav-tile:hover {
  border-color: var(--ap-primary); box-shadow: 0 4px 16px var(--ap-primary-soft);
  color: var(--ap-text-1); transform: translateY(-2px);
}
.qnav-icon {
  width: 42px; height: 42px; border-radius: var(--radius-md); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 1.2rem;
}
.qnav-label { font-size: .9rem; font-weight: 700; }
.qnav-desc  { font-size: .8rem; color: var(--ap-text-3); margin-top: .1rem; }

/* ── Activity feed ───────────────────────────────────────────────── */
.act-item {
  display: flex; gap: .875rem;
  padding: .8rem 0; border-bottom: 1px solid var(--ap-border-2);
}
.act-item:last-child { border-bottom: none; }
.act-icon {
  width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 1rem;
}
.act-title { font-size: .875rem; font-weight: 600; color: var(--ap-text-1); }
.act-sub   { font-size: .8125rem; color: var(--ap-text-3); margin-top: .1rem; }
.act-time  { font-size: .75rem; color: var(--ap-text-4); margin-top: .2rem; }

/* ── Health dots ─────────────────────────────────────────────────── */
.health-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: .6rem 0; border-bottom: 1px solid var(--ap-border-2);
}
.health-item:last-child  { border-bottom: none; }
.health-label {
  font-size: .9rem; font-weight: 500; color: var(--ap-text-2);
  display: flex; align-items: center; gap: .6rem;
}
.health-status { font-size: .8125rem; font-weight: 700; }
.health-dot    { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* ── Tabs: generic containers ────────────────────────────────────── */
.ap-tabs-container {
  display: flex; gap: 16px;
  border-bottom: 2px solid var(--ap-border); margin-bottom: 24px;
}
.ap-tab-btn {
  padding: 12px 0; border: none; background: none; cursor: pointer;
  font-size: .875rem; font-weight: 500; color: var(--ap-text-2);
  border-bottom: 2px solid transparent; margin-bottom: -2px;
}
.ap-tab-btn.is-active { color: var(--ap-primary); border-bottom-color: var(--ap-primary); }

/* ── Date select ─────────────────────────────────────────────────── */
.date-select {
  appearance: none; background: var(--ap-surface); border: 1.5px solid var(--ap-border);
  border-radius: var(--radius-md); padding: .5rem 2.2rem .5rem .9rem;
  font-size: .9rem; font-weight: 500; color: var(--ap-text-1); font-family: inherit;
  cursor: pointer; outline: none; transition: var(--transition);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%236b7280' d='M7.247 11.14L2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .6rem center; background-size: 11px;
}
.date-select:focus { border-color: var(--ap-primary); box-shadow: 0 0 0 3px var(--ap-primary-soft); }

/* ── Goal ring SVG ───────────────────────────────────────────────── */
.goal-ring        { transform: rotate(-90deg); }
.goal-ring-bg     { fill: none; stroke: var(--ap-border); stroke-width: 8; }
.goal-ring-fill   { fill: none; stroke-width: 8; stroke-linecap: round; transition: stroke-dashoffset .8s ease; }
