/* ==========================================================================
   custom.css — Prolicences Shared Styles (DRY)
   Extracted from repeated <style> blocks across all portal & admin pages.
   Include AFTER portal.css (and admin.css for admin pages).
   ========================================================================== */

/* ──────────────────────────────────────────────────────────────────────────
   1. ACTIVE STATE UTILITIES
   Previously copy-pasted in: orders, settings, tickets, invoices, profile,
   checkout, cart, shop, register, login, order-detail, thank-you, ticket-new
   ────────────────────────────────────────────────────────────────────────── */
.cat-chip.active { border-color: var(--pl-primary); color: #fff; background: var(--pl-primary); }
.cat-chip.active .chip-count { background: rgba(255,255,255,0.3); }

.step.active { color: #059669; }
.step.active .step-num { border-color: #059669; background: #059669; color: #fff; }

.pay-method-tab.active { border-color: #059669; background: #f0fdf4; }
.pay-method-tab.active .radio-dot { border-color: #059669; }
.pay-method-tab.active .radio-dot::after { content: ''; width: 10px; height: 10px; border-radius: 50%; background: #059669; }
.pay-method-panel.active { display: block; }

.method-tab.active { border-color: var(--pl-primary); background: var(--pl-primary-light); box-shadow: 0 2px 8px rgba(37,99,235,0.12); }
.payment-panel.active { display: block; }

.dc-filter-tab.active { background: var(--pl-primary); color: #fff; border-color: var(--pl-primary); }

.license-status.active { background: #ecfdf5; color: #059669; }


/* ──────────────────────────────────────────────────────────────────────────
   2. TOGGLE SWITCH COMPONENT
   Previously in: settings.php (duplicated twice), admin-settings.php
   ────────────────────────────────────────────────────────────────────────── */
.pl-toggle { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.pl-toggle input { opacity: 0; width: 0; height: 0; }
.pl-toggle .toggle-slider { position: absolute; cursor: pointer; inset: 0; background: #d1d5db; border-radius: 24px; transition: background 0.2s; }
.pl-toggle .toggle-slider::before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: transform 0.2s; }
.pl-toggle input:checked + .toggle-slider { background: var(--pl-primary, #2563eb); }
.pl-toggle input:checked + .toggle-slider::before { transform: translateX(20px); }


/* ──────────────────────────────────────────────────────────────────────────
   3. NOTIFICATION ROW (Settings)
   ────────────────────────────────────────────────────────────────────────── */
.notif-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--pl-border); }
.notif-row:last-child { border-bottom: none; }
.notif-row .notif-info { flex: 1; }


/* ──────────────────────────────────────────────────────────────────────────
   4. CART ITEM STYLES
   Previously in: cart.php (duplicated twice within same file)
   ────────────────────────────────────────────────────────────────────────── */
.cart-item { display: flex; align-items: center; gap: 20px; padding: 20px 24px; border-bottom: 1px solid var(--pl-border); transition: background 0.15s; }
.cart-item:last-child { border-bottom: none; }
.cart-item:hover { background: #f8fafc; }
.cart-item-img { width: 64px; height: 64px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 28px; flex-shrink: 0; }
.cart-item-img.blue { background: var(--pl-primary-light); color: var(--pl-primary); }
.cart-item-img.orange { background: #fff7ed; color: #f59e0b; }

.order-item-icon.blue { background: #eff6ff; color: #2563eb; }
.order-item-icon.orange { background: #fff7ed; color: #f59e0b; }


/* ──────────────────────────────────────────────────────────────────────────
   5. USERS TABLE & AVATARS
   Previously in: yeslicense-users.php, b2b-users.php, api-users.php
   ────────────────────────────────────────────────────────────────────────── */
.settings-section { margin-bottom: 24px; }
.settings-section-title {
  font-size: 16px; font-weight: 700; color: var(--pl-text, #1e293b);
  margin-bottom: 16px; display: flex; align-items: center; gap: 8px;
}
.settings-section-title i { color: #2563eb; }

.users-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; padding: 14px 18px;
  border-bottom: 1px solid var(--pl-border, #e5e7eb);
}
.users-count { font-size: 13px; color: var(--pl-text-muted, #64748b); font-weight: 600; }
.users-count strong { color: var(--pl-text, #1e293b); font-weight: 800; }

.users-table { width: 100%; border-collapse: collapse; }
.users-table th {
  padding: 11px 16px; text-align: left; font-weight: 700;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
  color: #94a3b8; background: #f8fafc; border-bottom: 1px solid var(--pl-border, #e5e7eb);
}
.users-table td { padding: 14px 16px; font-size: 13px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.users-table tr:last-child td { border-bottom: none; }

.user-cell { display: flex; align-items: center; gap: 10px; }
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  color: #fff; font-weight: 800; font-size: 13px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.user-avatar.blue   { background: linear-gradient(135deg, #2563eb, #3b82f6); }
.user-avatar.green  { background: linear-gradient(135deg, #059669, #10b981); }
.user-avatar.purple { background: linear-gradient(135deg, #6366f1, #8b5cf6); }
.user-avatar.orange { background: linear-gradient(135deg, #f59e0b, #fbbf24); }
.user-avatar.red    { background: linear-gradient(135deg, #ef4444, #f87171); }
.user-avatar.gray   { background: linear-gradient(135deg, #64748b, #94a3b8); }

.user-name { font-weight: 700; color: var(--pl-text, #1e293b); font-size: 13px; line-height: 1.3; }
.user-name .me-badge {
  display: inline-block; margin-left: 6px; padding: 1px 7px;
  border-radius: 20px; font-size: 10px; font-weight: 700; vertical-align: middle;
}
.user-email { font-size: 11.5px; color: #94a3b8; }

.status-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 20px;
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px;
}
.status-badge.active   { background: #dcfce7; color: #15803d; }
.status-badge.invited  { background: #fef3c7; color: #a16207; }
.status-badge.disabled { background: #fee2e2; color: #b91c1c; }

.role-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px;
}
.role-badge.admin    { background: #ede9fe; color: #6d28d9; }
.role-badge.finance  { background: #dcfce7; color: #15803d; }
.role-badge.employee { background: #dbeafe; color: #1e40af; }

.rights-pills { display: flex; flex-wrap: wrap; gap: 4px; max-width: 280px; }
.right-pill {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 7px; border-radius: 5px;
  font-size: 10.5px; font-weight: 600;
  background: #f1f5f9; color: #475569;
}

.row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.row-btn {
  background: #fff; border: 1px solid var(--pl-border, #e5e7eb);
  border-radius: 6px; padding: 5px 10px; font-size: 11px; font-weight: 600;
  color: #64748b; cursor: pointer; display: inline-flex; align-items: center; gap: 4px;
  transition: all 0.15s;
}
.row-btn:hover { background: #f8fafc; border-color: #2563eb; color: #2563eb; }
.row-btn.danger:hover { border-color: #ef4444; color: #ef4444; background: #fef2f2; }


/* ──────────────────────────────────────────────────────────────────────────
   6. INVITE MODAL
   Previously in: yeslicense-users.php, b2b-users.php, api-users.php
   ────────────────────────────────────────────────────────────────────────── */
.invite-modal {
  display: none; position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.55); backdrop-filter: blur(4px);
  z-index: 1050; align-items: center; justify-content: center; padding: 20px;
}
.invite-modal.open { display: flex; }


/* ──────────────────────────────────────────────────────────────────────────
   7. CREDENTIAL DISPLAY & COPY
   Previously in: settings.php, api-admin.php, api-users.php
   ────────────────────────────────────────────────────────────────────────── */
.pl-credential-value {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; background: #f8fafc; border: 1px solid var(--pl-border);
  border-radius: 8px;
}
.pl-credential-value .credential-text {
  flex: 1; font-family: 'SF Mono', SFMono-Regular, Consolas, monospace;
  font-size: 13px; color: var(--pl-text); word-break: break-all;
}
.pl-credential-value .credential-btn {
  background: none; border: none; cursor: pointer; padding: 4px;
  color: var(--pl-text-muted); transition: color 0.15s;
}
.pl-credential-value .credential-btn:hover { color: var(--pl-primary); }


/* ──────────────────────────────────────────────────────────────────────────
   8. FILTER CHIPS (tickets, orders)
   ────────────────────────────────────────────────────────────────────────── */
.filter-chip {
  padding: 6px 16px; border-radius: 20px; border: 1.5px solid var(--pl-border);
  background: #fff; font-size: 12px; font-weight: 600; color: var(--pl-text-muted);
  cursor: pointer; transition: all 0.2s;
}
.filter-chip:hover { border-color: var(--pl-primary); color: var(--pl-primary); }
.filter-chip.active { background: var(--pl-primary); color: #fff; border-color: var(--pl-primary); }


/* ──────────────────────────────────────────────────────────────────────────
   9. MOBILE — DESKTOP-ONLY MESSAGE
   CSS for the .mobile-desktop-only-msg component.
   The HTML lives in partials/mobile-warning.php.
   ────────────────────────────────────────────────────────────────────────── */
.mobile-desktop-only-msg { display: none; }

@media (max-width: 768px) {
  .mobile-desktop-only-msg {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    text-align: center; padding: 60px 24px; min-height: 60vh;
  }
  .mobile-desktop-only-msg .desktop-only-icon {
    width: 80px; height: 80px; border-radius: 50%;
    background: linear-gradient(135deg, #eff6ff, #dbeafe);
    display: flex; align-items: center; justify-content: center;
    font-size: 36px; color: #2563eb; margin-bottom: 20px;
    border: 2px solid #93c5fd;
  }
  .mobile-desktop-only-msg h2 { font-size: 20px; font-weight: 800; color: #1e293b; margin: 0 0 8px; }
  .mobile-desktop-only-msg p  { font-size: 14px; color: #64748b; margin: 0 0 6px; max-width: 320px; }
  .mobile-desktop-only-msg .desktop-only-sub { font-size: 13px; color: #94a3b8; margin-bottom: 24px; }
  .mobile-desktop-only-msg .desktop-only-hint {
    display: inline-flex; align-items: center; gap: 8px; padding: 12px 20px;
    background: #f0f9ff; border: 1.5px solid #bae6fd; border-radius: 12px;
    font-size: 13px; color: #0369a1; font-weight: 600;
  }
  .mobile-desktop-only-msg .desktop-only-hint i { font-size: 18px; }

  /* When mobile-warning is present, hide the rest of the portal content */
  .portal-content.desktop-only-page > *:not(.mobile-desktop-only-msg) { display: none !important; }
}


/* ──────────────────────────────────────────────────────────────────────────
   10. MOBILE — TABLE CARD LAYOUT
   Common responsive table transform used in: dashboard, orders, tickets,
   thank-you, invoices, downloads
   ────────────────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .pl-table-mobile thead { display: none; }
  .pl-table-mobile tbody tr {
    display: flex; flex-wrap: wrap; align-items: center;
    padding: 14px 16px; gap: 6px 12px;
    border-bottom: 1px solid var(--pl-border, #e2e8f0);
  }
  .pl-table-mobile tbody td {
    display: inline-flex; align-items: center; border: none; padding: 0; font-size: 13px;
  }
  .pl-table-mobile tbody td:first-child {
    flex: 0 0 100%; margin-bottom: 4px;
    display: flex; align-items: baseline; gap: 10px;
  }
  .pl-table-mobile tbody td:first-child br { display: none; }
}

@media (max-width: 480px) {
  .pl-table-mobile tbody tr { padding: 12px 14px; }
}
@media (max-width: 390px) {
  .pl-table-mobile tbody tr { padding: 10px 12px; gap: 4px 8px; }
}


/* ──────────────────────────────────────────────────────────────────────────
   11. TOAST NOTIFICATION (dynamic)
   Unified toast used via showToast() in app.js.
   ────────────────────────────────────────────────────────────────────────── */
.pl-toast-dynamic {
  position: fixed; bottom: 24px; right: 24px; padding: 12px 20px;
  color: #fff; border-radius: 10px; font-size: 14px; font-weight: 600;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15); z-index: 9999;
  display: flex; align-items: center; gap: 8px;
  animation: plToastSlideUp 0.3s ease;
  transition: opacity 0.3s;
}
.pl-toast-dynamic.success { background: #059669; }
.pl-toast-dynamic.error   { background: #dc2626; }
.pl-toast-dynamic.warning { background: #d97706; }
.pl-toast-dynamic.info    { background: #2563eb; }

@keyframes plToastSlideUp {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}


/* ──────────────────────────────────────────────────────────────────────────
   12. SPIN ANIMATION (used in wallet crypto verify, loading states)
   ────────────────────────────────────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
.spin { display: inline-block; animation: spin 0.8s linear infinite; }


/* ──────────────────────────────────────────────────────────────────────────
   13. ADMIN — COMMON COMPONENTS
   Previously in: admin.php, admin-api.php, admin-orders.php, etc.
   ────────────────────────────────────────────────────────────────────────── */

/* Admin stat grid */
.admin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; margin-bottom: 24px; }
.admin-stat { background: #fff; border: 1px solid var(--pl-border); border-radius: var(--pl-radius); padding: 20px; display: flex; align-items: center; gap: 14px; }
.admin-stat-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 22px; color: #fff; flex-shrink: 0; }
.admin-stat-icon.blue   { background: #2563eb; }
.admin-stat-icon.green  { background: #10b981; }
.admin-stat-icon.purple { background: #a855f7; }
.admin-stat-icon.orange { background: #f59e0b; }
.admin-stat-icon.red    { background: #ef4444; }
.admin-stat h3 { font-size: 24px; font-weight: 800; margin: 0; }
.admin-stat p  { font-size: 13px; color: var(--pl-text-muted); margin: 0; }

/* Admin tabs */
.nav-tabs-admin { display: flex; gap: 4px; border-bottom: 2px solid var(--pl-border); margin-bottom: 20px; }
.nav-tab-admin { padding: 10px 20px; font-size: 14px; font-weight: 600; color: var(--pl-text-muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all 0.2s; }
.nav-tab-admin:hover { color: var(--pl-primary); }
.nav-tab-admin.active { color: var(--pl-primary); border-bottom-color: var(--pl-primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Stat grid (smaller variant — admin-api) */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat-box { background: #fff; border: 1.5px solid var(--pl-border); border-radius: 12px; padding: 16px; text-align: center; }
.stat-value { font-size: 24px; font-weight: 800; line-height: 1.1; }
.stat-label { font-size: 11px; color: #64748b; font-weight: 600; margin-top: 4px; text-transform: uppercase; letter-spacing: 0.5px; }

/* Period tabs */
.period-tabs { display: flex; gap: 2px; background: #f1f5f9; border-radius: 8px; padding: 3px; }
.period-tab { padding: 6px 14px; border-radius: 6px; font-size: 12px; font-weight: 700; cursor: pointer; color: #64748b; transition: all 0.15s; border: none; background: transparent; }
.period-tab:hover { color: var(--pl-primary); }
.period-tab.active { background: #fff; color: var(--pl-primary); box-shadow: 0 1px 3px rgba(0,0,0,0.1); }

/* Reseller avatar (admin) */
.reseller-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--pl-primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0; }

/* Editable fields (admin) */
.editable-field { padding: 6px 10px; border: 1.5px solid var(--pl-border); border-radius: 8px; font-size: 14px; width: 100%; background: #fff; transition: border-color 0.2s; }
.editable-field:focus { outline: none; border-color: var(--pl-primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }

/* Price group badges */
.pg-badge { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 10px; font-weight: 700; letter-spacing: 0.3px; text-transform: uppercase; }
.pg-grp1 { background: #f3e8ff; color: #7c3aed; }
.pg-grp2 { background: #dbeafe; color: #1e40af; }
.pg-grp3 { background: #dcfce7; color: #16a34a; }

/* License type badges */
.type-badge { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 10px; font-weight: 700; letter-spacing: 0.3px; }
.type-retail { background: #dbeafe; color: #1e40af; }
.type-volume { background: #fef3c7; color: #b45309; }
.type-oem    { background: #f3e8ff; color: #7c3aed; }
.type-bind   { background: #fce7f3; color: #be185d; }

/* Detail stats (admin client detail) */
.detail-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--pl-border); background: #fafbfc; }
.detail-stat { text-align: center; }
.detail-stat-val { font-size: 18px; font-weight: 800; }
.detail-stat-lbl { font-size: 10px; color: #64748b; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }

/* Expandable product rows (admin-api) */
.product-row { cursor: pointer; transition: background 0.1s; }
.product-row:hover { background: #f0f7ff !important; }
.product-row.expanded { background: #eff6ff !important; }
.product-row .chevron { transition: transform 0.2s; font-size: 12px; color: #94a3b8; }
.product-row.expanded .chevron { transform: rotate(180deg); color: var(--pl-primary); }
.product-breakdown { display: none; }
.product-breakdown td { padding: 8px 12px 8px 24px !important; background: #f8fafc; border-bottom: 1px solid #e2e8f0 !important; }
.product-breakdown .sub-table { width: 100%; border-collapse: collapse; margin: 8px 0; }
.product-breakdown .sub-table th { padding: 10px 16px; font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 700; color: #94a3b8; background: #f1f5f9; border-bottom: 1px solid #e2e8f0; }
.product-breakdown .sub-table td { padding: 12px 16px; font-size: 13px; border-bottom: 1px solid #f1f5f9; background: transparent; }
.inv-current  { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 10px; font-weight: 700; background: #dcfce7; color: #16a34a; margin-left: 6px; }
.inv-depleted { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 10px; font-weight: 700; background: #fef2f2; color: #ef4444; margin-left: 6px; }
.inv-name   { font-weight: 600; color: #1e293b; }
.inv-detail { font-size: 11px; color: #94a3b8; margin-top: 2px; }
.inv-bar      { height: 4px; border-radius: 2px; background: #e2e8f0; margin-top: 4px; width: 120px; }
.inv-bar-fill { height: 100%; border-radius: 2px; background: #059669; }
.inv-bar-fill.low      { background: #f59e0b; }
.inv-bar-fill.depleted { background: #ef4444; }

/* ──────────────────────────────────────────────────────────────────────────
   16. ADMIN RESPONSIVE
   ────────────────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .period-tabs { flex-wrap: wrap; }
  .admin-table th:nth-child(n+3), .admin-table td:nth-child(n+3) { font-size: 11px; }
}
@media (max-width: 576px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .detail-stats { grid-template-columns: repeat(2, 1fr); }
}
