/* ==========================================================================
   FA Integration Platform – Styles
   ========================================================================== */

:root {
  --color-bg: #f0f2f5;
  --color-surface: #ffffff;
  --color-border: #d1d5db;
  --color-text: #1f2937;
  --color-text-muted: #6b7280;
  --color-primary: #1e40af;
  --color-primary-hover: #1e3a8a;
  --color-success: #059669;
  --color-success-bg: #ecfdf5;
  --color-warning: #d97706;
  --color-warning-bg: #fffbeb;
  --color-danger: #dc2626;
  --color-danger-bg: #fef2f2;
  --color-info: #3b82f6;
  --color-info-bg: #eff6ff;
  --color-source: #4338ca;
  --color-source-bg: #eef2ff;
  --color-not-synced: #b45309;
  --color-not-synced-bg: #fff7ed;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --radius: 8px;
  --radius-sm: 4px;
  --font-mono: "SF Mono", "Fira Code", "Cascadia Code", Consolas, monospace;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu,
    Cantarell, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
}

/* Header */
header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 100;
}

header h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--color-text);
}

.subtitle {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-top: 2px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.timestamp {
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

/* Buttons */
.btn {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--color-primary);
  color: white;
}

.btn-primary:hover {
  background: var(--color-primary-hover);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.btn-primary:disabled {
  background: #b2bec3;
  cursor: not-allowed;
}

/* Main */
main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem 2rem;
}

/* Target Banner */
.target-banner {
  background: #1e3a5f;
  color: white;
  padding: 1.2rem 2rem;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-md);
}

.target-label {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.9;
}

.target-value {
  font-size: 1.5rem;
  font-weight: 700;
  font-family: var(--font-mono);
}

.sync-status {
  margin-left: auto;
  font-size: 0.85rem;
  padding: 0.3rem 0.8rem;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.2);
}

.sync-status.all-synced {
  background: rgba(5, 150, 105, 0.3);
}

.sync-status.pending,
.sync-status.not-synced {
  background: rgba(217, 119, 6, 0.3);
}

/* Tabs */
.tabs {
  display: flex;
  gap: 0;
  margin-bottom: 0;
  border-bottom: 2px solid var(--color-border);
}

.tab {
  padding: 0.75rem 1.5rem;
  border: none;
  background: none;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
}

.tab:hover {
  color: var(--color-primary);
}

.tab.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

/* Tab Content */
.tab-content {
  display: none;
  padding-top: 1.5rem;
}

.tab-content.active {
  display: block;
}

/* Section Header */
.section-header {
  margin-bottom: 1rem;
}

.section-header h2 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.section-header p {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

/* Tables */
.table-container {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead {
  background: #f8f9fa;
}

th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-muted);
  border-bottom: 2px solid var(--color-border);
  white-space: nowrap;
}

td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #f1f2f6;
  font-size: 0.9rem;
  vertical-align: middle;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: #f8f9fa;
}

/* Cell styles */
.fa-number {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.85rem;
}

.repo-name {
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.repo-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-se {
  background: var(--color-source-bg);
  color: var(--color-source);
}
.badge-ca {
  background: var(--color-info-bg);
  color: #1e40af;
}
.badge-ui {
  background: var(--color-success-bg);
  color: #059669;
}
.badge-sa {
  background: var(--color-warning-bg);
  color: #b45309;
}

/* Status badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.6rem;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.status-synced {
  background: var(--color-success-bg);
  color: #059669;
}

.status-pending,
.status-not-synced {
  background: var(--color-not-synced-bg, var(--color-warning-bg));
  color: var(--color-not-synced, #b45309);
}

.status-source {
  background: var(--color-source-bg);
  color: var(--color-source);
}

.status-unknown {
  background: #f1f2f6;
  color: var(--color-text-muted);
}

/* Links */
a {
  color: var(--color-primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.commit-link {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  background: #f1f2f6;
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
}

.pr-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.85rem;
}

.na-text {
  color: var(--color-text-muted);
  font-style: italic;
  font-size: 0.85rem;
}

.not-yet-text {
  color: var(--color-warning);
  font-weight: 600;
  font-size: 0.85rem;
}

.artifact-link {
  display: inline-block;
  max-width: 400px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.82rem;
}

/* Workflow Generate Artifacts Column */
.wf-icon {
  font-size: 1.2rem;
  text-decoration: none;
  cursor: default;
}

a.wf-icon {
  cursor: pointer;
}

.wf-found {
  color: var(--color-text-muted);
}

.wf-success {
  color: #22863a;
  font-weight: 700;
}

.wf-failure {
  color: #cb2431;
  font-weight: 700;
}

.wf-pending {
  color: #dbab09;
}

.wf-trigger-btn {
  background: #0366d6;
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.15s;
}

.wf-trigger-btn:hover {
  background: #0250a3;
}

.wf-retry-btn {
  background: none;
  color: #0366d6;
  border: 1px solid #0366d6;
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 0.85rem;
  cursor: pointer;
  margin-left: 6px;
}

.wf-retry-btn:hover {
  background: #0366d6;
  color: #fff;
}

.timestamp-cell {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  white-space: nowrap;
}

/* Loading */
.loading {
  text-align: center;
  color: var(--color-text-muted);
  padding: 2rem;
  font-style: italic;
}

/* Spinner */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 0.5rem;
  vertical-align: middle;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* History Section */
.history-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.history-controls label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-muted);
}

.history-controls select {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  background: white;
}

#history-container {
  margin-top: 1rem;
}

.history-repo-section {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
  overflow: hidden;
}

.history-repo-header {
  padding: 0.75rem 1rem;
  background: #f8f9fa;
  border-bottom: 1px solid var(--color-border);
  font-weight: 700;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
}

.history-table th {
  background: #fcfcfd;
  font-size: 0.75rem;
}

.history-table td {
  font-size: 0.85rem;
}

/* Error */
.error-message {
  background: var(--color-danger-bg);
  color: var(--color-danger);
  padding: 1rem;
  border-radius: var(--radius);
  text-align: center;
  margin: 1rem 0;
}

/* Footer */
footer {
  text-align: center;
  padding: 2rem;
  color: var(--color-text-muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--color-border);
  margin-top: 3rem;
}

/* Responsive */
@media (max-width: 768px) {
  header {
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem;
  }

  main {
    padding: 1rem;
  }

  .target-banner {
    flex-direction: column;
    gap: 0.5rem;
    text-align: center;
  }

  .sync-status {
    margin-left: 0;
  }

  .tabs {
    overflow-x: auto;
  }

  .tab {
    white-space: nowrap;
    padding: 0.75rem 1rem;
  }
}
