/* ============================================
   Sellout Performance Tracking — Mobile-First CSS
   Base: 320px+  |  Breakpoint: 768px+
   ============================================ */

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --color-primary: #2563eb;
  --color-primary-dark: #1d4ed8;
  --color-danger: #dc2626;
  --color-danger-dark: #b91c1c;
  --color-secondary: #6b7280;
  --color-secondary-dark: #4b5563;
  --color-success: #16a34a;
  --color-warning: #d97706;
  --color-error: #dc2626;
  --color-info: #2563eb;
  --color-bg: #f3f4f6;
  --color-surface: #ffffff;
  --color-text: #1f2937;
  --color-text-light: #6b7280;
  --color-border: #e5e7eb;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.06);
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

/* --- Container --- */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}

/* --- Header / Navigation --- */
.header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 12px 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.header__title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--color-primary);
  white-space: nowrap;
}

.header__role {
  font-size: 0.75rem;
  color: var(--color-text-light);
  background: var(--color-bg);
  padding: 2px 10px;
  border-radius: 12px;
}

.header__back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.875rem;
  color: var(--color-primary);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius);
}

.header__back:hover {
  background: var(--color-bg);
}

/* --- Page Section --- */
.page-section {
  padding: 16px 0;
}

.page-section__title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 12px;
}

/* --- KPI Cards --- */
.kpi-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.kpi-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  border-left: 4px solid var(--color-border);
}

.kpi-card--green  { border-left-color: var(--color-success); }
.kpi-card--yellow { border-left-color: var(--color-warning); }
.kpi-card--red    { border-left-color: var(--color-error); }
.kpi-card--total  { border-left-color: var(--color-primary); background: #eff6ff; }

.kpi-card__category {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-light);
  margin-bottom: 4px;
}

.kpi-card__achievement {
  font-size: 1.5rem;
  font-weight: 700;
}

.kpi-card__achievement--green  { color: var(--color-success); }
.kpi-card__achievement--yellow { color: var(--color-warning); }
.kpi-card__achievement--red    { color: var(--color-error); }

.kpi-card__details {
  display: flex;
  gap: 16px;
  margin-top: 8px;
  font-size: 0.875rem;
  color: var(--color-text-light);
}

.kpi-card__detail-label {
  font-size: 0.75rem;
  color: var(--color-text-light);
}

.kpi-card__detail-value {
  font-weight: 600;
  color: var(--color-text);
}

/* --- Progress Bars --- */
.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--color-bg);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 8px;
}

.progress-bar__fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease;
}

.progress-bar__fill--green  { background: var(--color-success); }
.progress-bar__fill--yellow { background: var(--color-warning); }
.progress-bar__fill--red    { background: var(--color-error); }

.progress-bar__label {
  font-size: 0.75rem;
  color: var(--color-text-light);
  margin-top: 2px;
  text-align: right;
}

/* --- Tables --- */
.table-wrapper {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background: var(--color-surface);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  white-space: nowrap;
}

.data-table th,
.data-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

.data-table th {
  background: var(--color-bg);
  font-weight: 600;
  color: var(--color-text);
  position: sticky;
  top: 0;
}

.data-table tbody tr:nth-child(even) {
  background: #f9fafb;
}

.data-table tbody tr:hover {
  background: #eff6ff;
}

.data-table tbody tr.clickable {
  cursor: pointer;
}

/* --- Forms --- */
.upload-form {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}

.upload-form__title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 12px;
}

.form-group {
  margin-bottom: 12px;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 4px;
  color: var(--color-text);
}

.form-group input[type="text"],
.form-group input[type="file"],
.form-group select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  background: var(--color-surface);
  color: var(--color-text);
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 0.875rem;
  font-weight: 500;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn--primary {
  background: var(--color-primary);
  color: #fff;
}
.btn--primary:hover { background: var(--color-primary-dark); }

.btn--danger {
  background: var(--color-danger);
  color: #fff;
}
.btn--danger:hover { background: var(--color-danger-dark); }

.btn--secondary {
  background: var(--color-bg);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}
.btn--secondary:hover { background: var(--color-border); }

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* --- Loading Indicator --- */
.loading {
  display: none;
}

.loading.active {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  color: var(--color-text-light);
}

.loading__spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --- Notifications --- */
.notification {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: notifyIn 0.3s ease, notifyOut 0.3s ease 3.7s forwards;
  max-width: calc(100% - 32px);
}

.notification--success {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.notification--error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.notification--info {
  background: #dbeafe;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

@keyframes notifyIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-12px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes notifyOut {
  from { opacity: 1; transform: translateX(-50%) translateY(0); }
  to   { opacity: 0; transform: translateX(-50%) translateY(-12px); }
}

/* --- Modal / Dialog --- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 500;
  align-items: center;
  justify-content: center;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 24px;
  width: 90%;
  max-width: 400px;
}

.modal__title {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.modal__body {
  font-size: 0.875rem;
  color: var(--color-text-light);
  margin-bottom: 20px;
}

.modal__actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* --- Filter Controls --- */
.filter-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.filter-group select,
.filter-group input[type="text"] {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  background: var(--color-surface);
  color: var(--color-text);
}

.filter-group select:focus,
.filter-group input[type="text"]:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* --- Role Selection (Landing Page) --- */
.role-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 400px;
  margin: 0 auto;
}

.role-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.role-card:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md);
}

.role-card__title {
  font-weight: 600;
  font-size: 1rem;
}

.role-card__desc {
  font-size: 0.8rem;
  color: var(--color-text-light);
}

/* --- Empty / No Data State --- */
.empty-state {
  text-align: center;
  padding: 40px 16px;
  color: var(--color-text-light);
}

.empty-state__message {
  font-size: 1rem;
  margin-top: 8px;
}

/* --- Utility Classes --- */
.text-center { text-align: center; }
.text-right  { text-align: right; }

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.p-1  { padding: 8px; }
.p-2  { padding: 16px; }

.hidden { display: none !important; }

/* --- Desktop Breakpoint (768px+) --- */
@media (min-width: 768px) {
  .container {
    padding: 0 24px;
  }

  .header__title {
    font-size: 1.25rem;
  }

  /* KPI cards: 2-3 column grid */
  .kpi-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
  }

  /* Tables: no scroll needed, full width */
  .data-table {
    white-space: normal;
  }

  /* Filter controls: inline row */
  .filter-group {
    flex-direction: row;
    align-items: flex-end;
  }

  .filter-group select,
  .filter-group input[type="text"] {
    width: auto;
    min-width: 180px;
  }

  /* Role grid: horizontal */
  .role-grid {
    flex-direction: row;
    max-width: none;
    justify-content: center;
  }

  .role-card {
    flex: 1;
    max-width: 260px;
    flex-direction: column;
    text-align: center;
  }

  /* Upload forms: side by side */
  .upload-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }

  /* Modal slightly wider */
  .modal {
    width: 440px;
  }

  .page-section {
    padding: 24px 0;
  }
}
