/**
 * GawangPinas Seller Portal — components.css
 *
 * Reusable pieces used across the seller pages: buttons, form controls,
 * status badges, tabs, toolbars, statistics, and small data widgets.
 */

/* ==========================================================================
   1. BUTTONS
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--gp-space-2);
  min-height: 42px;
  padding: 0 var(--gp-space-5);
  border: 1px solid transparent;
  border-radius: var(--gp-radius-md);
  background-color: transparent;
  color: var(--gp-text-main);
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color var(--gp-transition-fast),
              border-color var(--gp-transition-fast),
              color var(--gp-transition-fast);
}

.btn:hover {
  text-decoration: none;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled,
.btn[aria-busy="true"] {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background-color: var(--gp-primary);
  border-color: var(--gp-primary);
  color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--gp-primary-hover);
  border-color: var(--gp-primary-hover);
  color: #ffffff;
}

.btn-secondary {
  background-color: var(--gp-surface);
  border-color: var(--gp-border-strong);
  color: var(--gp-text-main);
}

.btn-secondary:hover:not(:disabled) {
  background-color: var(--gp-surface-2);
  color: var(--gp-text-main);
}

.btn-ghost {
  color: var(--gp-text-secondary);
}

.btn-ghost:hover:not(:disabled) {
  background-color: var(--gp-surface-2);
  color: var(--gp-text-main);
}

.btn-outline {
  background-color: var(--gp-surface);
  border-color: var(--gp-primary-border);
  color: var(--gp-primary);
}

.btn-outline:hover:not(:disabled) {
  background-color: var(--gp-primary-light);
  border-color: var(--gp-primary);
}

.btn-danger {
  background-color: var(--gp-danger);
  border-color: var(--gp-danger);
  color: #ffffff;
}

.btn-danger:hover:not(:disabled) {
  background-color: var(--gp-danger-text);
  border-color: var(--gp-danger-text);
  color: #ffffff;
}

.btn-sm {
  min-height: 36px;
  padding: 0 var(--gp-space-3);
  border-radius: var(--gp-radius-sm);
  font-size: 0.875rem;
}

.btn-lg {
  min-height: 48px;
  padding: 0 var(--gp-space-6);
  font-size: 1rem;
}

.btn-block {
  width: 100%;
}

.btn .material-symbols-outlined {
  font-size: 20px;
}

/* Square icon-only button (top bar, table rows, dialogs) */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--gp-border);
  border-radius: var(--gp-radius-md);
  background-color: var(--gp-surface);
  color: var(--gp-text-secondary);
  transition: background-color var(--gp-transition-fast), color var(--gp-transition-fast);
}

.icon-btn:hover {
  background-color: var(--gp-surface-2);
  color: var(--gp-text-main);
}

.icon-btn .material-symbols-outlined {
  font-size: 20px;
}

.topbar-right .icon-btn {
  color: #475569;
  border-color: #cbd5e1;
}

.topbar-right .icon-btn:hover {
  color: #334155;
}

[data-theme="dark"] .topbar-right .icon-btn {
  color: #cbd5e1;
}

.sidebar-user .sb-user-detail {
  flex: 1;
}

.sidebar-user .sidebar-logout {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  margin-left: auto;
  color: rgba(255, 255, 255, 0.68);
  border-radius: var(--gp-radius-md);
}

.sidebar-user .sidebar-logout:hover,
.sidebar-user .sidebar-logout:focus-visible {
  color: #ffffff;
  background-color: rgba(255, 255, 255, 0.08);
}

.sidebar-user .sidebar-logout .material-symbols-outlined {
  font-size: 22px;
}

/* Unread counter on the notification bell */
.count-pill {
  position: absolute;
  top: -4px;
  right: -4px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 4px;
  border: 2px solid var(--topbar-bg);
  border-radius: var(--gp-radius-full);
  background-color: var(--gp-danger);
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 700;
}

/* Account menu avatar button */
.user-avatar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--gp-primary);
  border-radius: var(--gp-radius-full);
  background-color: var(--gp-primary);
  color: #ffffff;
  font-size: 0.9375rem;
  font-weight: 700;
}

/* ==========================================================================
   2. FORM CONTROLS
   ========================================================================== */

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--gp-space-2);
  margin-bottom: var(--gp-space-4);
}

.form-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--gp-text-secondary);
}

.form-label .req {
  margin-left: 2px;
  color: var(--gp-danger);
}

.form-input,
.form-select,
.form-textarea,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="tel"],
input[type="url"],
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 14px;
  border: 1px solid var(--gp-border-strong);
  border-radius: var(--gp-radius-sm);
  background-color: var(--gp-surface);
  color: var(--gp-text-main);
  font-size: 0.9375rem;
  transition: border-color var(--gp-transition-fast);
}

.form-textarea,
textarea {
  min-height: 100px;
  resize: vertical;
  line-height: 1.5;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus,
input:focus,
select:focus,
textarea:focus {
  border-color: var(--gp-primary);
}

.form-input::placeholder,
.form-textarea::placeholder,
textarea::placeholder {
  color: var(--gp-text-faint);
}

.form-input:disabled,
.form-select:disabled,
.form-textarea:disabled {
  background-color: var(--gp-surface-2);
  color: var(--gp-text-muted);
}

.form-hint {
  font-size: 0.8125rem;
  color: var(--gp-text-muted);
  line-height: 1.5;
}

.form-error {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--gp-danger-text);
}

/* Marks a field the server or the browser rejected */
.has-error .form-input,
.has-error .form-select,
.has-error .form-textarea {
  border-color: var(--gp-danger);
}

/* Checkboxes stay square; the label is part of the hit area */
.form-check {
  display: flex;
  align-items: flex-start;
  gap: var(--gp-space-2);
  font-size: 0.875rem;
  color: var(--gp-text-main);
  cursor: pointer;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
  width: 18px;
  height: 18px;
  min-height: 0;
  margin-top: 2px;
  accent-color: var(--gp-primary);
  cursor: pointer;
}

/* Search field with a leading icon */
.input-with-icon {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-icon .material-symbols-outlined {
  position: absolute;
  left: 12px;
  font-size: 20px;
  color: var(--gp-text-muted);
  pointer-events: none;
}

.input-with-icon input {
  padding-left: 42px;
}

/* Row of bulk price tiers (up to three per product) */
.tier-builder {
  display: flex;
  flex-direction: column;
  gap: var(--gp-space-2);
  padding: var(--gp-space-4);
  border: 1px solid var(--gp-border);
  border-radius: var(--gp-radius-sm);
  background-color: var(--gp-surface-2);
}

.tier-head,
.tier-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--gp-space-3);
}

.tier-head {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--gp-text-muted);
}

@media (max-width: 640px) {
  .tier-head,
  .tier-row {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Multi-column form layout */
.form-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 0 var(--gp-space-4);
}

.col-12 { grid-column: span 12; }
.col-10 { grid-column: span 10; }
.col-8  { grid-column: span 8; }
.col-6  { grid-column: span 6; }
.col-4  { grid-column: span 4; }
.col-3  { grid-column: span 3; }
.col-2  { grid-column: span 2; }

/* ==========================================================================
   2b. FORM ACTIONS
   The submit row that closes a form. ModularAdmin right-aligns its actions,
   same as the admin shell.
   ========================================================================== */

.form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: var(--gp-space-2);
  margin-top: var(--gp-space-5);
}

/* A hint that belongs to the action row drops onto its own line under the
   buttons instead of squeezing in beside them. */
.form-actions .form-hint {
  flex-basis: 100%;
  margin: 0;
  text-align: right;
}

/* ==========================================================================
   3. STATUS BADGES
   Tone classes only: green for finished, amber for waiting,
   red for a problem, blue for information, grey for inactive.
   ========================================================================== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--gp-space-1);
  padding: 3px 10px;
  border: 1px solid transparent;
  border-radius: var(--gp-radius-xs);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}

.badge-success {
  background-color: var(--gp-success-bg);
  border-color: var(--gp-success-border);
  color: var(--gp-success-text);
}

.badge-warning {
  background-color: var(--gp-warning-bg);
  border-color: var(--gp-warning-border);
  color: var(--gp-warning-text);
}

.badge-danger {
  background-color: var(--gp-danger-bg);
  border-color: var(--gp-danger-border);
  color: var(--gp-danger-text);
}

.badge-info {
  background-color: var(--gp-info-bg);
  border-color: var(--gp-info-border);
  color: var(--gp-info-text);
}

.badge-neutral {
  background-color: var(--gp-surface-2);
  border-color: var(--gp-border);
  color: var(--gp-text-secondary);
}

.badge-accent {
  background-color: var(--gp-primary-light);
  border-color: var(--gp-primary-border);
  color: var(--gp-primary-active);
}

/* Small colour dot that marks stock level */
.stock-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: var(--gp-radius-full);
  background-color: var(--gp-border-strong);
}

.stock-dot.is-ok { background-color: var(--gp-success); }
.stock-dot.is-low { background-color: var(--gp-warning); }
.stock-dot.is-out { background-color: var(--gp-danger); }

/* ==========================================================================
   4. TABS AND TOOLBARS
   ========================================================================== */

.tabs {
  display: flex;
  align-items: center;
  gap: var(--gp-space-2);
  margin-bottom: var(--gp-space-5);
  border-bottom: 1px solid var(--gp-border);
  overflow-x: auto;
}

.tab {
  padding: var(--gp-space-3) var(--gp-space-5);
  border: none;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--gp-text-muted);
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
  transition: color var(--gp-transition-fast), border-color var(--gp-transition-fast);
}

.tab:hover {
  color: var(--gp-text-main);
}

.tab.is-active {
  border-bottom-color: var(--gp-primary);
  color: var(--gp-primary-active);
  font-weight: 600;
}

.tab-count {
  margin-left: var(--gp-space-1);
  color: var(--gp-text-muted);
  font-weight: 600;
}

/* Filters and search above a table or list */
.toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--gp-space-3);
  margin-bottom: var(--gp-space-4);
}

.toolbar .grow {
  flex: 1;
  min-width: 200px;
}

.toolbar label {
  font-size: 0.875rem;
  color: var(--gp-text-muted);
}

/* The generic form rules make inputs full width; inside a toolbar they sit
   side by side with the search box instead. */
.toolbar .form-select,
.toolbar .form-input {
  width: auto;
  min-width: 180px;
}

/* Two dates side by side, as one filter */
.date-range {
  display: flex;
  align-items: center;
  gap: var(--gp-space-2);
  font-size: 0.875rem;
  color: var(--gp-text-muted);
}

.date-range .form-input {
  min-width: 150px;
}

/* Small heading inside a panel body */
.panel-subtitle {
  margin: var(--gp-space-5) 0 var(--gp-space-2);
  font-size: 1rem;
  font-weight: 600;
  color: var(--gp-text-main);
}

.panel-subtitle:first-child {
  margin-top: 0;
}

.address-block {
  line-height: 1.6;
  color: var(--gp-text-secondary);
}

/* ==========================================================================
   5. STATISTICS
   ========================================================================== */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--gp-space-4);
  margin-bottom: var(--gp-space-6);
}

/* Pages with four metrics sit in a single row on desktop. */
.stat-grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

/* ModularAdmin statistic widget: leading icon, the figure and its label, then
   a hairline progress bar. The hint is pushed to the foot so cards of mixed
   content still line up across the row. */
.stat {
  display: flex;
  flex-direction: column;
  padding: var(--gp-space-5);
  border: none;
  border-radius: var(--gp-radius-md);
  background-color: var(--gp-surface);
  box-shadow: var(--gp-shadow-card);
}

.stat-main {
  display: flex;
  align-items: center;
  gap: var(--gp-space-3);
}

.stat-icon {
  flex-shrink: 0;
  width: 40px;
  text-align: center;
  font-size: 26px;
  color: var(--gp-text-faint);
}

.stat-text {
  min-width: 0;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.25;
  color: var(--gp-text-main);
  font-feature-settings: var(--gp-tabular-nums);
  font-variant-numeric: tabular-nums;
}

.stat-label {
  margin-top: 2px;
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--gp-text-muted);
}

.stat-progress {
  height: 3px;
  margin-top: var(--gp-space-3);
  background-color: var(--gp-surface-3);
}

.stat-progress-fill {
  display: block;
  height: 100%;
  background-color: var(--gp-primary);
}

.stat-hint {
  margin-top: auto;
  padding-top: var(--gp-space-3);
  font-size: 0.8125rem;
  color: var(--gp-text-muted);
}

/* ==========================================================================
   8. TIMELINE
   Used for product history, order progress, and review replies.
   ========================================================================== */

.timeline {
  display: flex;
  flex-direction: column;
  gap: var(--gp-space-4);
  padding-left: var(--gp-space-5);
  list-style: none;
}

.tl-item {
  position: relative;
  font-size: 0.875rem;
}

.tl-item::before {
  content: "";
  position: absolute;
  left: calc(-1 * var(--gp-space-5) + 1px);
  top: 6px;
  width: 9px;
  height: 9px;
  border: 2px solid var(--gp-border-strong);
  border-radius: var(--gp-radius-full);
  background-color: var(--gp-surface);
}

.tl-item.is-done::before {
  border-color: var(--gp-primary);
  background-color: var(--gp-primary);
}

.tl-item.is-current::before {
  border-color: var(--gp-primary);
  background-color: var(--gp-surface);
}

.tl-item.is-cancelled::before {
  border-color: var(--gp-danger);
  background-color: var(--gp-danger);
}

.tl-label {
  font-weight: 600;
  color: var(--gp-text-main);
}

.tl-note {
  margin-top: 2px;
  color: var(--gp-text-secondary);
}

.tl-time {
  margin-top: 2px;
  font-size: 0.8125rem;
  color: var(--gp-text-muted);
}

/* Rating stars (reviews) */
.stars {
  display: inline-flex;
  gap: 2px;
  color: #b45309; /* 4.8:1 on white, readable for small text */
}

.stars .material-symbols-outlined {
  font-size: 18px;
}

.stars .is-off {
  color: var(--gp-border-strong);
}

/* Rounded avatar / initial chip used in lists */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: var(--gp-radius-full);
  background-color: var(--gp-surface-2);
  border: 1px solid var(--gp-border);
  color: var(--gp-text-secondary);
  font-size: 0.875rem;
  font-weight: 700;
}

/* ==========================================================================
   6. LIST ROWS
   A compact list of records inside a panel: title, small second line,
   and an optional action on the right.
   ========================================================================== */

.list-rows {
  display: flex;
  flex-direction: column;
}

.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gp-space-4);
  padding: 13px var(--gp-space-5);
  border-bottom: 1px solid var(--gp-border);
}

.list-row:last-child {
  border-bottom: none;
}

/* If list-rows is placed inside a panel-body that already provides horizontal padding, reset row gutter */
.panel-body:not(.panel-body-flush) > .list-rows .list-row {
  padding-left: 0;
  padding-right: 0;
}

.list-row-main {
  min-width: 0;
}

.list-row-title {
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--gp-text-main);
}

.list-row-sub {
  margin-top: 2px;
  font-size: 0.8125rem;
  color: var(--gp-text-muted);
}

.list-row-actions {
  display: flex;
  align-items: center;
  gap: var(--gp-space-2);
  flex-shrink: 0;
}

@media (max-width: 640px) {
  .list-row {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--gp-space-2);
    padding-left: var(--gp-space-4);
    padding-right: var(--gp-space-4);
  }

  .panel-body:not(.panel-body-flush) > .list-rows .list-row {
    padding-left: 0;
    padding-right: 0;
  }
}

/* ==========================================================================
   7. CHARTS
   ========================================================================== */

.chart-box {
  width: 100%;
}

.chart-svg {
  display: block;
  width: 100%;
  overflow: visible;
}

.chart-placeholder,
.chart-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--gp-space-2);
  min-height: 200px;
  padding: var(--gp-space-5);
  border: 1px dashed var(--gp-border-strong);
  border-radius: var(--gp-radius-sm);
  color: var(--gp-text-muted);
  text-align: center;
  font-size: 0.875rem;
}

.chart-placeholder .material-symbols-outlined {
  font-size: 30px;
  color: var(--gp-text-faint);
}

@media (max-width: 992px) {
  .stat-grid,
  .stat-grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .col-10,
  .col-8,
  .col-6,
  .col-4,
  .col-3,
  .col-2 {
    grid-column: span 12;
  }

  .stat-grid,
  .stat-grid-4 {
    grid-template-columns: minmax(0, 1fr);
  }
}
