/* ============================================================
   WP Inventory POS — Admin Stylesheet
   Matches Firmtechcloud plugin visual language (support-center)
   ============================================================ */

/* ── CSS Variables ────────────────────────────────────────── */
:root {
  --wpip-primary:       #3B82F6;
  --wpip-primary-dark:  #1D4ED8;
  --wpip-success:       #10B981;
  --wpip-warning:       #F5A623;
  --wpip-danger:        #EF4444;
  --wpip-purple:        #8B5CF6;
  --wpip-bg:            #F8FAFC;
  --wpip-card-bg:       #FFFFFF;
  --wpip-border:        #E2E8F0;
  --wpip-border-light:  #F1F5F9;
  --wpip-text:          #111827;
  --wpip-text-muted:    #6B7280;
  --wpip-text-light:    #9CA3AF;
  --wpip-shadow:        0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --wpip-shadow-md:     0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
  --wpip-shadow-lg:     0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
  --wpip-radius:        10px;
  --wpip-radius-sm:     6px;
  --wpip-radius-lg:     14px;
}

/* ── Layout ───────────────────────────────────────────────── */
.wpip-wrap {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 4px 32px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--wpip-text);
}

/* ── Page Header ──────────────────────────────────────────── */
.wpip-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 20px 0 16px;
  flex-wrap: wrap;
  gap: 12px;
}
.wpip-page-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 22px;
  font-weight: 700;
  color: var(--wpip-text);
  margin: 0 !important;
}
.wpip-page-icon {
  font-size: 24px;
  line-height: 1;
}
.wpip-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ── Select ───────────────────────────────────────────────── */
.wpip-select {
  padding: 7px 12px;
  border: 1px solid var(--wpip-border);
  border-radius: var(--wpip-radius-sm);
  background: #fff;
  font-size: 13px;
  color: var(--wpip-text);
  cursor: pointer;
  outline: none;
  transition: border-color .15s;
}
.wpip-select:focus { border-color: var(--wpip-primary); }

/* ── POS Button ───────────────────────────────────────────── */
.wpip-btn-pos {
  background: linear-gradient(135deg, var(--wpip-primary), var(--wpip-primary-dark)) !important;
  border: none !important;
  border-radius: var(--wpip-radius-sm) !important;
  padding: 8px 16px !important;
  font-weight: 600 !important;
  letter-spacing: .3px;
  box-shadow: 0 2px 8px rgba(59,130,246,.3) !important;
  transition: transform .1s, box-shadow .1s !important;
}
.wpip-btn-pos:hover {
  transform: translateY(-1px) !important;
  box-shadow: 0 4px 12px rgba(59,130,246,.4) !important;
}

/* ── Admin Nav Tabs ───────────────────────────────────────── */
.wpip-admin-nav {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--wpip-border);
  margin-bottom: 24px;
}
.wpip-admin-nav-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  background: none;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--wpip-text-muted);
  border-radius: var(--wpip-radius-sm) var(--wpip-radius-sm) 0 0;
  transition: color .15s, border-color .15s, background .15s;
}
.wpip-admin-nav-item:hover {
  color: var(--wpip-primary);
  background: rgba(59,130,246,.05);
}
.wpip-admin-nav-item.active {
  color: var(--wpip-primary);
  border-bottom-color: var(--wpip-primary);
  font-weight: 600;
}

/* ── Views ────────────────────────────────────────────────── */
.wpip-admin-view { display: none; }
.wpip-admin-view.active { display: block; }

/* ── KPI Stat Cards ───────────────────────────────────────── */
.wpip-stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 8px;
}
.wpip-stat-card {
  background: var(--wpip-card-bg);
  border: 1px solid var(--wpip-border);
  border-radius: var(--wpip-radius);
  padding: 20px 20px 16px;
  box-shadow: var(--wpip-shadow);
  transition: transform .15s, box-shadow .15s;
  position: relative;
  overflow: hidden;
}
.wpip-stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--wpip-primary), var(--wpip-purple));
  opacity: 0;
  transition: opacity .2s;
}
.wpip-stat-card:hover { transform: translateY(-2px); box-shadow: var(--wpip-shadow-md); }
.wpip-stat-card:hover::before { opacity: 1; }
.wpip-stat-card-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--wpip-text-muted);
  text-transform: uppercase;
  letter-spacing: .6px;
  margin-bottom: 8px;
}
.wpip-stat-card-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--wpip-text);
  line-height: 1.1;
  margin-bottom: 6px;
  letter-spacing: -.5px;
}
.wpip-stat-card-delta {
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 3px;
}
.wpip-stat-card-delta.up   { color: var(--wpip-success); }
.wpip-stat-card-delta.down { color: var(--wpip-danger); }
.wpip-stat-card-delta.neutral { color: var(--wpip-text-muted); }
.wpip-stat-card-sub {
  font-size: 12px;
  color: var(--wpip-text-muted);
  margin-top: 4px;
}

/* ── Charts ───────────────────────────────────────────────── */
.wpip-charts-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}
.wpip-chart-card {
  background: var(--wpip-card-bg);
  border: 1px solid var(--wpip-border);
  border-radius: var(--wpip-radius);
  padding: 20px;
  box-shadow: var(--wpip-shadow);
}
.wpip-chart-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--wpip-text);
  margin-bottom: 16px;
}
.wpip-chart-wrap {
  position: relative;
  height: 200px;
}
.wpip-chart-wrap canvas { max-height: 100%; }

/* ── Generic Card ─────────────────────────────────────────── */
.wpip-card {
  background: var(--wpip-card-bg);
  border: 1px solid var(--wpip-border);
  border-radius: var(--wpip-radius);
  padding: 20px 24px;
  box-shadow: var(--wpip-shadow);
  margin-bottom: 16px;
}
.wpip-card h2, .wpip-card h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--wpip-text);
  margin: 0 0 16px;
  padding: 0;
}
.wpip-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.wpip-card-header h3 { margin: 0; }
.wpip-link {
  font-size: 12.5px;
  color: var(--wpip-primary);
  text-decoration: none;
  font-weight: 500;
}
.wpip-link:hover { text-decoration: underline; }

/* ── Tables ───────────────────────────────────────────────── */
.wpip-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.wpip-table thead th {
  padding: 10px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--wpip-text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  border-bottom: 2px solid var(--wpip-border);
  background: var(--wpip-bg);
}
.wpip-table tbody td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--wpip-border-light);
  color: var(--wpip-text);
  vertical-align: middle;
}
.wpip-table tbody tr:last-child td { border-bottom: none; }
.wpip-table tbody tr:hover td { background: rgba(59,130,246,.03); }

/* ── Status Badges ────────────────────────────────────────── */
.wpip-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .3px;
}
.wpip-badge-success { background: #D1FAE5; color: #065F46; }
.wpip-badge-warning { background: #FEF3C7; color: #92400E; }
.wpip-badge-danger  { background: #FEE2E2; color: #991B1B; }
.wpip-badge-info    { background: #DBEAFE; color: #1E40AF; }
.wpip-badge-neutral { background: #F1F5F9; color: #475569; }

/* ── Loading Spinner ──────────────────────────────────────── */
.wpip-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}
.wpip-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--wpip-border);
  border-top-color: var(--wpip-primary);
  border-radius: 50%;
  animation: wpip-spin 0.7s linear infinite;
}
.wpip-spinner-large {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: wpip-spin 0.7s linear infinite;
  margin: 20px auto 0;
}
@keyframes wpip-spin { to { transform: rotate(360deg); } }

/* ── License Page ─────────────────────────────────────────── */
.wpip-license-wrap { max-width: 780px; }
.wpip-license-status-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 24px;
  border-radius: var(--wpip-radius);
  margin-bottom: 20px;
  border: 1px solid;
}
.wpip-lic-valid   { background: #ECFDF5; border-color: #6EE7B7; }
.wpip-lic-invalid { background: #FFF7ED; border-color: #FCD34D; }
.wpip-lic-status-icon  { font-size: 36px; line-height: 1; flex-shrink: 0; }
.wpip-lic-status-info  { flex: 1; }
.wpip-lic-status-title { font-size: 15px; font-weight: 700; color: var(--wpip-text); margin-bottom: 4px; }
.wpip-lic-status-sub   { font-size: 13px; color: var(--wpip-text-muted); }
.wpip-lic-version      { font-size: 12px; color: var(--wpip-text-muted); font-weight: 600; }
.wpip-card-support     { background: linear-gradient(135deg, #EFF6FF, #F0FDF4); }
.wpip-license-gate {
  text-align: center;
  padding: 80px 40px;
  max-width: 480px;
  margin: 60px auto;
  background: #fff;
  border: 1px solid var(--wpip-border);
  border-radius: var(--wpip-radius-lg);
  box-shadow: var(--wpip-shadow-lg);
}
.wpip-license-gate-icon { font-size: 56px; margin-bottom: 16px; }

/* ── POS Loading Screen ───────────────────────────────────── */
#wpip-pos-root {
  position: fixed;
  inset: 32px 0 0 0; /* below WP admin bar */
  background: #0F172A;
  z-index: 9000;
}
.wpip-pos-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #fff;
}
.wpip-pos-loading-logo { font-size: 64px; margin-bottom: 16px; }
.wpip-pos-loading-text { font-size: 16px; font-weight: 500; opacity: .8; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 1200px) {
  .wpip-charts-row { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 782px) {
  .wpip-stat-cards  { grid-template-columns: 1fr 1fr; }
  .wpip-charts-row  { grid-template-columns: 1fr; }
  .wpip-page-header { flex-direction: column; align-items: flex-start; }
  .wpip-admin-nav   { overflow-x: auto; }
  #wpip-pos-root    { inset: 46px 0 0 0; } /* mobile WP bar height */
}
@media (max-width: 480px) {
  .wpip-stat-cards { grid-template-columns: 1fr; }
}

/* ═══════════════════════════════════════════════════════════
   WPIP MODAL SYSTEM — used by all admin CRUD pages
   (was previously only in pos.css; duplicated here so the
   admin pages load properly without pos.css being enqueued)
═══════════════════════════════════════════════════════════ */
.wpip-modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.55); z-index: 100000;
  align-items: center; justify-content: center;
  padding: 20px;
}
.wpip-modal-overlay.open { display: flex; }
.wpip-modal {
  background: #fff; border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  width: 100%; max-width: 600px; max-height: 90vh;
  overflow-y: auto; padding: 28px 32px;
  position: relative; animation: wpip-modal-in .15s ease;
}
@keyframes wpip-modal-in {
  from { opacity:0; transform:scale(.96) translateY(8px); }
  to   { opacity:1; transform:scale(1)  translateY(0);    }
}
.wpip-modal-lg  { max-width: 860px; }
.wpip-modal-sm  { max-width: 420px; }
.wpip-modal h2  { margin: 0 0 20px; font-size: 17px; font-weight: 700; color: #111; }
.wpip-modal-close {
  position: absolute; top: 16px; right: 16px;
  background: none; border: none; cursor: pointer;
  font-size: 20px; color: #6B7280; line-height: 1;
  width: 32px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  transition: background .14s;
}
.wpip-modal-close:hover { background: #F3F4F6; }
.wpip-modal-actions {
  display: flex; gap: 10px; margin-top: 24px;
  padding-top: 20px; border-top: 1px solid #E5E7EB;
  justify-content: flex-end;
}
.wpip-modal table.form-table th {
  width: 140px; padding: 8px 16px 8px 0;
  font-weight: 600; color: #374151; font-size: 13px;
}
.wpip-modal table.form-table td { padding: 6px 0; }
.wpip-modal .large-text, .wpip-modal .regular-text { width: 100%; }
.wpip-modal textarea { width: 100%; min-height: 80px; }

/* Inline notice inside modal */
.wpip-modal-notice {
  padding: 10px 14px; border-radius: 8px;
  margin-bottom: 16px; font-size: 13px; display: none;
}
.wpip-modal-notice.error   { background: #FEE2E2; color: #991B1B; }
.wpip-modal-notice.success { background: #D1FAE5; color: #065F46; }

/* ── POS Terminal (jQuery-based replacement for broken React SPA) ── */
.wpip-pos-wrap {
  display: grid;
  grid-template-columns: 1fr 380px;
  height: calc(100vh - 60px);
  gap: 0; background: #0F172A;
}
.wpip-pos-products-col {
  display: flex; flex-direction: column;
  background: #1E293B; overflow: hidden;
}
.wpip-pos-topbar {
  padding: 12px 16px; background: #0F172A;
  display: flex; gap: 10px; align-items: center;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.wpip-pos-topbar input[type=text] {
  flex: 1; background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.15); border-radius: 8px;
  color: #fff; padding: 8px 14px; font-size: 14px;
}
.wpip-pos-topbar input::placeholder { color: rgba(255,255,255,.4); }
.wpip-pos-topbar select {
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.15); border-radius: 8px;
  color: #fff; padding: 8px 10px; font-size: 13px;
}
.wpip-pos-grid {
  flex: 1; overflow-y: auto; padding: 14px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px,1fr));
  gap: 12px; align-content: start;
}
.wpip-pos-product-card {
  background: #293548; border-radius: 10px;
  padding: 14px; cursor: pointer; text-align: center;
  border: 2px solid transparent; transition: border .14s, background .14s;
}
.wpip-pos-product-card:hover { border-color: #3B82F6; background: #304060; }
.wpip-pos-product-card.out  { opacity: .45; cursor: not-allowed; }
.wpip-pos-product-card .thumb {
  font-size: 32px; margin-bottom: 8px;
}
.wpip-pos-product-card .name {
  font-size: 12px; font-weight: 600; color: #E2E8F0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.wpip-pos-product-card .price {
  font-size: 14px; color: #3B82F6; font-weight: 700; margin-top: 4px;
}
.wpip-pos-product-card .stock {
  font-size: 11px; color: #64748B; margin-top: 2px;
}

/* Cart column */
.wpip-pos-cart-col {
  display: flex; flex-direction: column;
  background: #1E293B; border-left: 1px solid rgba(255,255,255,.08);
}
.wpip-pos-cart-header {
  padding: 14px 16px; font-size: 13px; font-weight: 700;
  color: #94A3B8; text-transform: uppercase; letter-spacing: .5px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex; justify-content: space-between; align-items: center;
}
.wpip-pos-cart-items { flex: 1; overflow-y: auto; padding: 8px 0; }
.wpip-pos-cart-item {
  padding: 10px 16px; display: flex; align-items: center;
  gap: 10px; border-bottom: 1px solid rgba(255,255,255,.05);
}
.wpip-pos-cart-item .ci-name {
  flex: 1; font-size: 13px; color: #E2E8F0; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.wpip-pos-cart-item .ci-qty {
  display: flex; align-items: center; gap: 6px;
}
.wpip-pos-cart-item .ci-qty button {
  width: 24px; height: 24px; border-radius: 6px;
  background: rgba(255,255,255,.1); border: none; color: #fff;
  cursor: pointer; font-size: 14px; display: flex;
  align-items: center; justify-content: center;
}
.wpip-pos-cart-item .ci-qty span {
  font-size: 14px; font-weight: 600; color: #fff; min-width: 24px; text-align: center;
}
.wpip-pos-cart-item .ci-total {
  font-size: 13px; font-weight: 600; color: #3B82F6; min-width: 70px; text-align: right;
}
.wpip-pos-cart-item .ci-remove {
  background: none; border: none; color: #EF4444; cursor: pointer; font-size: 16px;
}
.wpip-pos-cart-empty {
  padding: 40px 16px; text-align: center; color: #475569; font-size: 13px;
}
.wpip-pos-cart-totals {
  padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.08);
}
.wpip-pos-cart-totals .row {
  display: flex; justify-content: space-between;
  font-size: 13px; color: #94A3B8; margin-bottom: 6px;
}
.wpip-pos-cart-totals .row.total {
  font-size: 17px; font-weight: 700; color: #fff; margin-top: 8px;
}
.wpip-pos-cart-actions {
  padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.08);
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.wpip-pos-btn {
  padding: 11px; border-radius: 8px; border: none; font-weight: 600;
  font-size: 13px; cursor: pointer; transition: opacity .14s;
}
.wpip-pos-btn:hover { opacity: .85; }
.wpip-pos-btn-primary { background: #3B82F6; color: #fff; }
.wpip-pos-btn-danger  { background: #EF4444; color: #fff; }
.wpip-pos-btn-outline {
  background: transparent; border: 1px solid rgba(255,255,255,.2); color: #fff;
}
.wpip-pos-btn-full { grid-column: 1 / -1; }

/* Payment modal */
.wpip-pay-method-row {
  display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap;
}
.wpip-pay-method-btn {
  padding: 8px 16px; border-radius: 8px; border: 2px solid #E5E7EB;
  background: #fff; cursor: pointer; font-weight: 600; font-size: 13px;
  transition: border-color .14s, background .14s;
}
.wpip-pay-method-btn.active {
  border-color: #3B82F6; background: #EFF6FF; color: #1D4ED8;
}
.wpip-pay-summary {
  background: #F8FAFC; border-radius: 8px; padding: 14px; margin-bottom: 14px;
}
.wpip-pay-summary .row {
  display: flex; justify-content: space-between;
  font-size: 13px; color: #6B7280; margin-bottom: 6px;
}
.wpip-pay-summary .row.total {
  font-size: 17px; font-weight: 700; color: #111; margin-top: 8px;
}
.wpip-change-display {
  background: #D1FAE5; border-radius: 8px; padding: 12px 16px;
  display: none; margin-top: 10px;
}
.wpip-change-display .amount {
  font-size: 22px; font-weight: 700; color: #065F46;
}

/* Receipt */
.wpip-receipt { font-family: monospace; font-size: 12px; line-height: 1.6; max-width: 320px; margin: 0 auto; }
.wpip-receipt .r-header { text-align: center; margin-bottom: 10px; }
.wpip-receipt .r-divider { border-top: 1px dashed #ccc; margin: 8px 0; }
.wpip-receipt .r-row { display: flex; justify-content: space-between; }
.wpip-receipt .r-total { font-weight: 700; font-size: 14px; }

/* ── POS in consolidated shortcode context ───────────────────────────────── */
/* When POS loads inside [wpip_dashboard], use the panel height instead of  */
/* 100vh so it doesn't overflow the page.                                    */
.wpip-pos-consolidated {
    height: calc(100vh - 120px);
    min-height: 500px;
    border-radius: 10px;
    overflow: hidden;
}
