/* styles.css — Strategy Center · Live Beta */

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

:root {
  --bg: #0a0a0b;
  --bg-card: #141416;
  --bg-card-hover: #1a1a1e;
  --bg-header: #111115;
  --border: #2a2a30;
  --border-light: #333340;
  --text: #e4e4e7;
  --text-muted: #8b8b96;
  --text-dim: #5c5c66;
  --accent: #3b82f6;
  --accent-glow: rgba(59, 130, 246, 0.15);
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --danger-glow: rgba(239, 68, 68, 0.12);
  --info: #06b6d4;
  --live-red: #ff3b30;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.4);
}

html {
  font-size: 14px;
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ---------------------------------------------------------------
 * LIVE BANNER
 * --------------------------------------------------------------- */
.live-banner {
  background: linear-gradient(135deg, #1a0a0a, #1f1015);
  border-bottom: 2px solid var(--live-red);
  color: #fca5a5;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 0.92rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.live-banner .banner-icon {
  font-size: 1.1rem;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.live-banner .banner-text {
  flex: 1;
  min-width: 200px;
}

.live-banner .banner-link {
  color: var(--info);
  text-decoration: none;
  padding: 4px 12px;
  border: 1px solid var(--info);
  border-radius: var(--radius);
  font-size: 0.85rem;
  transition: background 0.2s;
}

.live-banner .banner-link:hover {
  background: rgba(6, 182, 212, 0.1);
}

.banner-close {
  background: none;
  border: none;
  color: #fca5a5;
  cursor: pointer;
  font-size: 1.1rem;
  padding: 2px 8px;
  border-radius: 4px;
}

.banner-close:hover {
  background: rgba(255,255,255,0.08);
}

/* ---------------------------------------------------------------
 * GLOBAL LOADER
 * --------------------------------------------------------------- */
.global-loader {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.9rem;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ---------------------------------------------------------------
 * ERROR CONTAINER
 * --------------------------------------------------------------- */
.error-container {
  padding: 12px 20px;
}

.error-box {
  background: #1a0d0d;
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  padding: 16px 20px;
}

.error-box h3 {
  color: var(--danger);
  font-size: 1rem;
  margin-bottom: 8px;
}

.error-box ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.error-box li {
  color: #fca5a5;
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.retry-btn {
  background: var(--danger);
  color: #fff;
  border: none;
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 0.8rem;
  cursor: pointer;
}

.retry-btn:hover {
  background: #dc2626;
}

/* ---------------------------------------------------------------
 * MAIN CONTAINER
 * --------------------------------------------------------------- */
.main-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 20px 40px;
}

/* ---------------------------------------------------------------
 * HEADER
 * --------------------------------------------------------------- */
.app-header {
  padding: 28px 0 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.app-header h1 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}

.beta-tag {
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 4px;
}

/* ---------------------------------------------------------------
 * PERIOD BAR
 * --------------------------------------------------------------- */
.period-section {
  margin-bottom: 20px;
}

.period-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  flex-wrap: wrap;
}

.period-dates {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.period-label {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.85rem;
}

.period-range {
  color: var(--accent);
  font-weight: 600;
  font-size: 0.95rem;
}

.period-anchor {
  color: var(--text-dim);
  font-size: 0.8rem;
}

.period-buttons {
  display: flex;
  gap: 6px;
}

.period-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
}

.period-btn:hover {
  border-color: var(--accent);
  color: var(--text);
}

.period-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ---------------------------------------------------------------
 * STORE SELECTOR
 * --------------------------------------------------------------- */
.store-selector-section {
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.store-selector-section label {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.88rem;
}

.store-selector-section select {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 7px 12px;
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
  outline: none;
}

.store-selector-section select:focus {
  border-color: var(--accent);
}

/* ---------------------------------------------------------------
 * FUNCTION PANELS
 * --------------------------------------------------------------- */
.function-panel {
  margin-bottom: 24px;
}

.function-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.function-content {
  min-height: 80px;
}

.placeholder-msg {
  color: var(--text-dim);
  text-align: center;
  padding: 40px 20px;
  font-size: 0.92rem;
}

.empty-msg {
  color: var(--text-dim);
  text-align: center;
  padding: 20px;
  font-size: 0.88rem;
}

/* ---------------------------------------------------------------
 * BREADCRUMB
 * --------------------------------------------------------------- */
.breadcrumb {
  font-size: 0.88rem;
  margin-bottom: 10px;
  color: var(--text-muted);
}

.crumb-label {
  color: var(--accent);
  font-weight: 600;
}

.crumb-arrow {
  margin: 0 6px;
  color: var(--text-dim);
}

.crumb-store, .crumb-section {
  font-weight: 600;
  color: var(--text);
}

/* ---------------------------------------------------------------
 * SCOPE NOTICES
 * --------------------------------------------------------------- */
.scope-notice {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.scope-note-listing {
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid var(--warning);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 0.82rem;
  color: var(--warning);
  margin-bottom: 12px;
}

.scope-warning {
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid var(--warning);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 0.82rem;
  color: var(--warning);
  margin-bottom: 12px;
}

/* ---------------------------------------------------------------
 * BACK BUTTONS
 * --------------------------------------------------------------- */
.back-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  margin-bottom: 12px;
  transition: all 0.15s;
}

.back-btn:hover {
  border-color: var(--accent);
  color: var(--text);
}

/* ---------------------------------------------------------------
 * TABLE
 * --------------------------------------------------------------- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.table-wrap-sm {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

.data-table thead {
  background: var(--bg-header);
  position: sticky;
  top: 0;
}

.data-table th {
  text-align: left;
  padding: 10px 12px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
  border-bottom: 2px solid var(--border);
}

.data-table th.num {
  text-align: right;
}

.data-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
}

.data-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.data-table tbody tr:hover {
  background: var(--bg-card-hover);
}

.clickable-row {
  cursor: pointer;
  transition: background 0.12s;
}

.store-cell {
  font-weight: 600;
}

.title-cell {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------------------------------------------------------------
 * ADS TABLE SPECIFICS
 * --------------------------------------------------------------- */
.ads-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.status-on {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.status-off {
  background: rgba(139, 139, 150, 0.12);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.status-recently-off {
  background: rgba(245, 158, 11, 0.12);
  color: var(--warning);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.listing-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.listing-sku {
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 0.78rem;
  color: var(--accent);
}

.listing-title-sm {
  font-size: 0.78rem;
  color: var(--text-muted);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.img-cell img {
  border-radius: 4px;
  object-fit: cover;
  background: var(--bg);
}

.reason-cell {
  max-width: 180px;
  white-space: normal;
  font-size: 0.8rem;
}

.change-cell {
  max-width: 150px;
  white-space: normal;
  font-size: 0.8rem;
}

.next-cell {
  color: var(--text-dim);
  font-style: italic;
  font-size: 0.8rem;
}

/* ---------------------------------------------------------------
 * ADS HISTORY PANEL
 * --------------------------------------------------------------- */
.ads-history-panel {
  margin-top: 16px;
  animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.ads-history-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.history-header h4 {
  font-size: 1rem;
  color: var(--text);
}

.close-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}

.close-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text);
}

.history-section {
  margin-bottom: 20px;
}

.history-section h5 {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-weight: 600;
}

.ads-history-table td,
.ads-history-table th {
  font-size: 0.8rem;
}

.missing-day {
  background: rgba(245, 158, 11, 0.04);
}

.missing-label {
  color: var(--warning);
  font-style: italic;
  font-size: 0.8rem;
}

.missing-note {
  margin-top: 8px;
  font-size: 0.78rem;
  color: var(--warning);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}

.summary-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.summary-label {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.summary-value {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------
 * RULE SUGGESTION BOX
 * --------------------------------------------------------------- */
.rule-suggestion-box {
  margin-top: 20px;
  background: rgba(59, 130, 246, 0.04);
  border: 1px dashed var(--accent);
  border-radius: var(--radius);
  padding: 14px 18px;
}

.rule-suggestion-box h4 {
  font-size: 0.9rem;
  color: var(--accent);
  margin-bottom: 6px;
}

.rule-draft-text {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ---------------------------------------------------------------
 * FOOTER
 * --------------------------------------------------------------- */
.app-footer {
  margin-top: 40px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-dim);
  font-size: 0.78rem;
}

.app-footer code {
  background: var(--bg-card);
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 0.76rem;
}

.footer-note {
  margin-top: 4px;
  font-size: 0.74rem;
  color: var(--text-dim);
}

/* ---------------------------------------------------------------
 * RESPONSIVE
 * --------------------------------------------------------------- */
@media (max-width: 768px) {
  .main-container {
    padding: 0 12px 30px;
  }

  .period-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .period-buttons {
    width: 100%;
  }

  .period-btn {
    flex: 1;
    text-align: center;
  }

  .data-table {
    font-size: 0.78rem;
  }

  .data-table th,
  .data-table td {
    padding: 7px 8px;
  }

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

  .app-header h1 {
    font-size: 1.3rem;
  }
}

@media (max-width: 480px) {
  .live-banner {
    padding: 8px 12px;
    font-size: 0.8rem;
  }

  .summary-grid {
    grid-template-columns: 1fr 1fr;
  }
}
