/**
 * GoldLedger UI Components
 * Segmented pills, keypad triggers, form controls, cards, badges
 */

/* Header Bar */
.app-header {
  height: 64px;
  padding: 0 16px;
  padding-top: var(--safe-top);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(17, 24, 39, 0.96);
  border-bottom: 1px solid var(--border-muted);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 90;
  position: sticky;
  top: 0;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon-box {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
  border: 1px solid var(--gold-500);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px rgba(245, 158, 11, 0.2);
  overflow: hidden;
}

.brand-icon-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand-titles {
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.brand-subtitle {
  font-size: 0.72rem;
  color: var(--gold-400);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cashier-badge-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-muted);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  color: var(--text-primary);
  font-family: var(--font-arabic);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 38px;
}

.cashier-badge-btn:hover {
  border-color: var(--gold-500);
  background: var(--bg-card-hover);
}

.cashier-badge-btn:active {
  transform: scale(0.96);
}

.cashier-avatar-mini {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--gold-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--text-on-gold);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--color-inflow);
  box-shadow: 0 0 6px var(--color-inflow);
  transition: background-color 0.3s ease;
}

.status-dot.offline {
  background-color: var(--color-warning);
  box-shadow: 0 0 6px var(--color-warning);
}

.header-icon-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border-muted);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 1.1rem;
}

.header-icon-btn:hover {
  color: var(--gold-400);
  border-color: var(--gold-500);
}

/* Card Container */
.gold-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-muted);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}

.gold-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(245, 158, 11, 0.4), transparent);
}

.section-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Segmented Thumb-Touch Pills (min-height: 48px) */
.pill-grid {
  display: grid;
  gap: 8px;
  width: 100%;
}

.pill-grid-4 {
  grid-template-columns: repeat(4, 1fr);
}

.pill-grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

.pill-grid-2 {
  grid-template-columns: repeat(2, 1fr);
}

.thumb-pill {
  min-height: var(--pill-height);
  padding: 8px 10px;
  background: var(--bg-pill);
  border: 1.5px solid var(--border-muted);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-family: var(--font-arabic);
  font-size: 0.88rem;
  font-weight: 700;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-align: center;
  gap: 2px;
  position: relative;
}

.thumb-pill .pill-icon {
  font-size: 1.15rem;
}

.thumb-pill:hover {
  background: var(--bg-card-hover);
  border-color: rgba(245, 158, 11, 0.3);
  color: var(--text-primary);
}

.thumb-pill:active {
  transform: scale(0.96);
}

.thumb-pill.selected {
  background: var(--bg-pill-selected);
  border-color: var(--gold-400);
  color: var(--text-on-gold);
  box-shadow: var(--shadow-gold);
  font-weight: 800;
}

.thumb-pill.selected .pill-icon {
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4));
}

/* Category-specific accent badges */
.thumb-pill[data-category="بيع ذهب"].selected {
  background: linear-gradient(135deg, #059669 0%, #10b981 50%, #34d399 100%);
  color: #064e3b;
  border-color: #6ee7b7;
}

.thumb-pill[data-category="شراء كسر"].selected {
  background: linear-gradient(135deg, #d97706 0%, #f59e0b 50%, #fbbf24 100%);
  color: #78350f;
  border-color: #fde68a;
}

.thumb-pill[data-category="مصروفات"].selected {
  background: linear-gradient(135deg, #dc2626 0%, #ef4444 50%, #f87171 100%);
  color: #450a0a;
  border-color: #fca5a5;
}

.thumb-pill[data-category="إيداع صندوق"].selected {
  background: linear-gradient(135deg, #2563eb 0%, #3b82f6 50%, #60a5fa 100%);
  color: #172554;
  border-color: #93c5fd;
}

/* Form Controls & Inputs */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.input-container {
  position: relative;
  display: flex;
  align-items: center;
}

.text-center {
  text-align: center !important;
}

.gold-input {
  width: 100%;
  height: var(--input-height);
  background: var(--bg-input);
  border: 1.5px solid var(--border-muted);
  border-radius: var(--radius-md);
  padding: 0 16px;
  color: var(--text-primary);
  font-family: var(--font-arabic);
  font-size: 1.05rem;
  font-weight: 600;
  text-align: center; /* Center all input text */
  transition: all 0.2s ease;
  outline: none;
}

.gold-input:focus {
  border-color: var(--gold-500);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2);
  background: #111827;
}

.gold-input.font-digits {
  font-size: 1.35rem;
  font-weight: 700;
  text-align: center; /* Center numeric digits */
  letter-spacing: 0.04em;
}

.input-container .gold-input {
  padding-left: 60px; /* Ample breathing room for unit badge */
  padding-right: 60px;
}

.input-unit-badge {
  position: absolute;
  left: 12px;
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--gold-300);
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.25);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  pointer-events: none;
  user-select: none;
  line-height: 1;
}

.header-date-pill {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--gold-300);
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.25);
  padding: 5px 10px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Quick Increments Bar */
.quick-chips-row {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.chip-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-muted);
  color: var(--text-secondary);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.chip-btn:hover {
  border-color: var(--gold-500);
  color: var(--text-primary);
}

.chip-btn:active {
  transform: scale(0.94);
  background: var(--gold-900);
}

/* Price Per Gram Indicator */
.calc-badge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(245, 158, 11, 0.08);
  border: 1px dashed rgba(245, 158, 11, 0.3);
  border-radius: var(--radius-md);
  margin-top: 8px;
  font-size: 0.82rem;
  color: var(--gold-200);
}

.calc-rate {
  font-weight: 800;
  color: var(--gold-400);
  font-size: 0.95rem;
}

/* Primary Action Submit Button */
.btn-submit-action {
  width: 100%;
  height: var(--btn-height);
  min-height: var(--btn-height);
  border-radius: var(--radius-lg);
  border: none;
  background: var(--gold-gradient);
  color: var(--text-on-gold);
  font-family: var(--font-arabic);
  font-size: 1.1rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-gold-lg);
  margin-top: 8px;
  position: relative;
  overflow: hidden;
}

.btn-submit-action::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 60%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.35), transparent);
  animation: goldShimmer 3s infinite;
}

@keyframes goldShimmer {
  0% { left: -100%; }
  40% { left: 140%; }
  100% { left: 140%; }
}

.btn-submit-action:active:not(:disabled) {
  transform: scale(0.98);
  box-shadow: var(--shadow-gold);
}

.btn-submit-action:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  filter: grayscale(0.4);
}

/* Spinner during loading state locks */
.spinner {
  width: 22px;
  height: 22px;
  border: 3px solid rgba(17, 24, 39, 0.2);
  border-top-color: #111827;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 2.5rem;
  margin-bottom: 8px;
  opacity: 0.6;
}
