/* ============================================================
   GSB Design System — Gold/Warm Shared Styles
   ============================================================ */

/* --- Google Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Vollkorn:wght@400;600;700&family=Lexend:wght@300;400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

/* --- Custom Properties --- */
:root {
  /* Primary warm tones */
  --earth: #7a5c3a;
  --earth-dark: #5e4528;
  --earth-light: #a07d55;

  /* Gold accents */
  --gold: #d4a93c;
  --gold-light: #e6be4a;

  /* Semantic colors */
  --sage: #4a8f4e;
  --sage-light: #dff0de;
  --brick: #A6503C;
  --brick-light: #FAEAE6;
  --ochre: #C4933F;
  --ochre-light: #FFF8E8;

  /* Surfaces */
  --cream: #ede7df;
  --surface: #ffffff;
  --surface-dark: #2c2520;
  --surface-dark-secondary: #3a332d;
  --border: #c5beb5;
  --border-light: #d9d3cb;

  /* Text */
  --text: #1f2937;
  --text-secondary: #6b7280;
  --text-tertiary: #9ca3af;

  /* Typography */
  --font-heading: 'Vollkorn', Georgia, serif;
  --font-body: 'Lexend', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'IBM Plex Mono', 'Courier New', monospace;

  /* Transitions */
  /* Card shadow */
  --card-shadow: 0 2px 4px rgba(44,32,22,0.08), 0 8px 20px rgba(44,32,22,0.12);

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition: 0.2s ease;
}

/* --- Reset --- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* --- Base --- */
body {
  font-family: var(--font-body);
  color: var(--text);
  background: var(--cream);
  min-height: 100vh;
  font-size: 18px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Page-load fade-in — only when motion is OK */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: no-preference) {
  body.loaded > *:not(.session-bar):not(.overlay) {
    animation: fadeIn 0.4s ease both;
  }
}

/* --- Typography --- */
h1, h2, h3 {
  font-family: var(--font-heading);
  color: var(--text);
  line-height: 1.3;
}

h1 { font-size: 28px; font-weight: 700; }
h2 { font-size: 22px; font-weight: 600; }
h3 { font-size: 18px; font-weight: 600; }

/* --- Gradient Text Utility --- */
.gradient-text {
  background: linear-gradient(135deg, var(--earth) 0%, var(--earth-light) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* --- Container --- */
.container {
  max-width: 1000px;
  width: 100%;
  margin: 0 auto;
  padding: 16px 40px;
}

/* --- Card --- */
.card {
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--card-shadow);
  padding: 24px;
  margin-bottom: 24px;
  border: 1px solid var(--border-light);
}

.card h2 {
  margin-bottom: 16px;
}

/* --- Card Dark (focal card for totals/payouts) --- */
.card-dark {
  background: var(--surface-dark);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  padding: 24px;
  color: #f5f1ed;
}

.card-dark .amount {
  color: var(--gold-light);
  font-family: var(--font-mono);
  font-weight: 700;
}

/* --- Section Header (colored header bar inside cards) --- */
.section-header {
  background: var(--cream);
  border-bottom: 1px solid var(--border-light);
  padding: 12px 24px;
  margin: -24px -24px 20px;
  border-radius: 16px 16px 0 0;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 18px;
}

/* --- Session Bar --- */
.session-bar {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--earth-dark);
  color: white;
  padding: 8px 16px;
  font-size: 14px;
  z-index: 1000;
  align-items: center;
  justify-content: space-between;
}

.session-bar.visible { display: flex; }

.session-bar .operator-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.session-bar .role-badge {
  background: rgba(255, 255, 255, 0.15);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 13px;
  text-transform: capitalize;
}

.session-bar #logoutBtn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: white;
  padding: 4px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  font-family: var(--font-body);
  transition: background var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.session-bar #logoutBtn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.session-bar #adminLink {
  color: rgba(255, 255, 255, 0.9);
  text-decoration: none;
  font-size: 13px;
  padding: 4px 12px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  display: none;
  transition: background var(--transition-fast);
  align-items: center;
  gap: 6px;
}

.session-bar #adminLink:hover {
  background: rgba(255, 255, 255, 0.18);
}

/* --- Button Icons --- */
.btn-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn-icon-sm {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 20px;
  min-height: 48px;
  border: none;
  border-radius: 10px;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), opacity var(--transition), transform 0.1s ease, box-shadow var(--transition);
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, var(--earth) 0%, var(--earth-light) 100%);
  color: white;
  width: 100%;
  box-shadow: 0 4px 12px rgba(154, 124, 90, 0.3);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--earth-dark) 0%, var(--earth) 100%);
  box-shadow: 0 6px 16px rgba(154, 124, 90, 0.4);
}

.btn-secondary {
  background: var(--text-tertiary);
  color: white;
  width: 100%;
}

.btn-secondary:hover:not(:disabled) {
  opacity: 0.85;
}

.btn-success {
  background: linear-gradient(135deg, var(--sage) 0%, #4A6449 100%);
  color: white;
  width: 100%;
  box-shadow: 0 4px 12px rgba(95, 122, 94, 0.3);
}

.btn-success:hover:not(:disabled) {
  background: linear-gradient(135deg, #4A6449 0%, #3D5340 100%);
  box-shadow: 0 6px 16px rgba(95, 122, 94, 0.35);
}

.btn-danger {
  background: linear-gradient(135deg, var(--brick) 0%, #8A3F2E 100%);
  color: white;
  padding: 8px 14px;
  min-height: 36px;
  font-size: 15px;
  box-shadow: 0 4px 12px rgba(166, 80, 60, 0.25);
}

.btn-danger:hover:not(:disabled) {
  background: linear-gradient(135deg, #8A3F2E 0%, #733424 100%);
  box-shadow: 0 6px 16px rgba(166, 80, 60, 0.3);
}

.btn-outline {
  background: var(--surface);
  color: var(--earth);
  border: 2px solid var(--earth);
  width: 100%;
}

.btn-outline:hover:not(:disabled) {
  background: var(--cream);
}

.btn-link {
  background: none;
  border: none;
  color: var(--earth);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  padding: 8px 0;
  font-family: var(--font-body);
  transition: color var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-link:hover {
  color: var(--earth-dark);
}

/* Button used in ps-details, ps-dl-scan as inline (not full-width) */
.buttons .btn-secondary {
  background: var(--surface);
  border: 2px solid var(--border);
  color: var(--text);
  width: auto;
}

.buttons .btn-secondary:hover:not(:disabled) {
  background: var(--cream);
  opacity: 1;
}

.buttons .btn-primary {
  width: auto;
}

.btn-warning {
  background: var(--surface);
  border: 2px solid var(--ochre);
  color: #6B5A1F;
}

.btn-warning:hover:not(:disabled) {
  background: var(--ochre-light);
}

.btn-retry {
  background: linear-gradient(135deg, var(--ochre) 0%, #A67D30 100%);
  color: white;
  margin-right: 8px;
  box-shadow: 0 4px 12px rgba(196, 147, 63, 0.25);
}

.btn-retry:hover:not(:disabled) {
  background: linear-gradient(135deg, #A67D30 0%, #8C6928 100%);
  box-shadow: 0 6px 16px rgba(196, 147, 63, 0.3);
}

.btn-group {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 16px;
}

.buttons {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
}

/* --- Form Elements --- */
.form-group {
  margin-bottom: 16px;
}

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

input, select, textarea {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 18px;
  transition: border-color var(--transition);
  font-family: var(--font-body);
  -webkit-appearance: none;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(44, 32, 22, 0.06) inset;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201, 169, 97, 0.15);
}

input::placeholder, textarea::placeholder {
  color: var(--text-tertiary);
}

select {
  background: var(--surface);
  cursor: pointer;
}

/* --- Status Messages --- */
.status-msg {
  margin-top: 8px;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 15px;
  display: none;
}

.status-msg.error {
  background: var(--brick-light);
  color: var(--brick);
  border: 1px solid #E8C4BC;
  display: block;
}

.status-msg.info {
  background: #F0EDE7;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  display: block;
}

.status-msg.success {
  background: var(--sage-light);
  color: var(--sage);
  border: 1px solid #C2D9C1;
  display: block;
}

/* --- Message (admin page pattern) --- */
.message {
  display: none;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 15px;
  margin-bottom: 16px;
}

.message.visible { display: block; }
.message.error { background: var(--brick-light); color: var(--brick); border: 1px solid #E8C4BC; }
.message.success { background: var(--sage-light); color: var(--sage); border: 1px solid #C2D9C1; }

/* --- Status Badges --- */
.status-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  font-family: var(--font-body);
}

.status-draft { background: var(--ochre-light); color: #6B5A1F; }
.status-completed { background: var(--sage-light); color: var(--sage); }
.status-cancelled { background: var(--brick-light); color: var(--brick); }

/* --- Spinner --- */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* --- Overlay --- */
.overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(44, 32, 22, 0.45);
  z-index: 1100;
  align-items: center;
  justify-content: center;
}

.overlay.active {
  display: flex;
}

.overlay-content {
  background: var(--surface);
  border-radius: 16px;
  padding: 24px;
  max-width: 500px;
  width: calc(100% - 32px);
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 4px 24px rgba(44, 32, 22, 0.2);
}

.overlay-content h3 {
  font-family: var(--font-heading);
  margin-bottom: 16px;
}

/* --- Info Grid --- */
.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.info-item {
  font-size: 16px;
}

.info-item .label {
  color: var(--text-tertiary);
  font-size: 14px;
  margin-bottom: 2px;
}

.info-item .value {
  color: var(--text);
  font-weight: 500;
}

.info-item.full-width {
  grid-column: 1 / -1;
}

/* --- Divider --- */
.divider {
  display: flex;
  align-items: center;
  margin-bottom: 20px;
  color: var(--text-tertiary);
  font-size: 16px;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--border-light);
}

.divider span {
  padding: 0 12px;
}

/* --- Spacing Helpers --- */
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.text-center { text-align: center; }
