/* Team Scorecard App - Styles */

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --success: #16a34a;
  --warning: #ca8a04;
  --error: #dc2626;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1), 0 4px 6px rgba(0, 0, 0, 0.05);

  /* Status colors */
  --status-on-track: #16a34a;
  --status-on-track-bg: #dcfce7;
  --status-at-risk: #ca8a04;
  --status-at-risk-bg: #fef9c3;
  --status-off-track: #dc2626;
  --status-off-track-bg: #fee2e2;
  --status-completed: #6b7280;
  --status-completed-bg: #f3f4f6;

  /* BSC colors (defaults, can be overridden) */
  --bsc-1: #3B82F6;
  --bsc-2: #10B981;
  --bsc-3: #F59E0B;
  --bsc-4: #8B5CF6;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

/* Container */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem;
}

.container-wide {
  max-width: 1100px;
}

/* Back link */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--gray-500);
  text-decoration: none;
  font-size: 0.9375rem;
  margin-bottom: 1rem;
}

.back-link:hover {
  color: var(--primary);
}

/* Header */
header {
  text-align: center;
  margin-bottom: 2rem;
}

header h1 {
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: 0.5rem;
}

header p {
  color: var(--gray-500);
}

.header-team-name {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--primary);
  margin-top: 0.5rem;
}

/* App Header with Team Selector */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--gray-200);
}

.app-header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--gray-900);
  margin: 0;
}

.team-selector {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.team-selector label {
  font-size: 0.875rem;
  color: var(--gray-600);
}

.team-selector select {
  padding: 0.5rem 2rem 0.5rem 0.75rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 0.9375rem;
  background: white;
  cursor: pointer;
  min-width: 200px;
}

.team-selector select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Tab Navigation */
.tab-nav {
  display: flex;
  gap: 0.25rem;
  background: var(--gray-100);
  padding: 0.25rem;
  border-radius: var(--radius-lg);
  margin-bottom: 1.5rem;
  overflow-x: auto;
}

.tab-btn {
  padding: 0.625rem 1rem;
  background: transparent;
  border: none;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-600);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--gray-800);
  background: var(--gray-200);
}

.tab-btn.active {
  background: white;
  color: var(--gray-900);
  box-shadow: var(--shadow);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Cards */
.card {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1rem;
}

.card h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--gray-700);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.card-header h2 {
  margin-bottom: 0;
}

/* Section Header with Add Button */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.section-header h2 {
  margin-bottom: 0;
}

.section-description {
  color: var(--gray-500);
  font-size: 0.9375rem;
  margin-bottom: 1.5rem;
}

/* Item Cards (consistent pattern for all sections) */
.item-cards {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.item-card {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 1rem;
  position: relative;
}

.item-card:hover {
  border-color: var(--gray-300);
}

.item-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}

.item-card-badges {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.item-card-actions {
  display: flex;
  gap: 0.5rem;
}

.item-card-number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  font-size: 0.875rem;
  font-weight: 600;
  flex-shrink: 0;
}

.item-card-content {
  flex: 1;
}

.item-card-statement {
  font-weight: 500;
  color: var(--gray-800);
  margin-bottom: 0.5rem;
}

.item-card-criteria {
  font-size: 0.9375rem;
  color: var(--gray-600);
  padding-top: 0.5rem;
  border-top: 1px solid var(--gray-200);
  margin-top: 0.5rem;
}

.item-card-criteria-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
  margin-bottom: 0.25rem;
}

/* Item Card with Number */
.item-card-with-number {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 1rem;
}

/* Status Badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
}

.status-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.status-on_track,
.status-on-track {
  background: var(--status-on-track-bg);
  color: var(--status-on-track);
}

.status-on_track::before,
.status-on-track::before {
  background: var(--status-on-track);
}

.status-at_risk,
.status-at-risk {
  background: var(--status-at-risk-bg);
  color: var(--status-at-risk);
}

.status-at_risk::before,
.status-at-risk::before {
  background: var(--status-at-risk);
}

.status-off_track,
.status-off-track {
  background: var(--status-off-track-bg);
  color: var(--status-off-track);
}

.status-off_track::before,
.status-off-track::before {
  background: var(--status-off-track);
}

.status-completed {
  background: var(--status-completed-bg);
  color: var(--status-completed);
}

.status-completed::before {
  background: var(--status-completed);
}

/* BSC Designation Badges */
.bsc-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius);
  font-size: 0.75rem;
  font-weight: 500;
  background: var(--gray-100);
  color: var(--gray-600);
}

.bsc-badge[data-color] {
  background: color-mix(in srgb, var(--badge-color) 15%, white);
  color: var(--badge-color);
}

/* Forms */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--gray-700);
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group textarea {
  min-height: 100px;
  resize: vertical;
}

.form-group .hint {
  font-size: 0.875rem;
  color: var(--gray-500);
  margin-top: 0.25rem;
}

/* Form Row (inline fields) */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-row-3 {
  grid-template-columns: 1fr 1fr 1fr;
}

/* Inline Form Fields */
.inline-form {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
}

.inline-form .form-group {
  flex: 1;
  margin-bottom: 0;
}

.inline-form .form-group.small {
  flex: 0 0 120px;
}

/* Edit Form (inline editing) */
.edit-form {
  background: white;
  border: 2px solid var(--primary);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}

.edit-form-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.edit-form-title {
  font-weight: 600;
  color: var(--gray-800);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-primary:disabled {
  background: var(--gray-300);
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--gray-100);
  color: var(--gray-700);
}

.btn-secondary:hover {
  background: var(--gray-200);
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-success:hover {
  background: #15803d;
}

.btn-danger {
  background: var(--error);
  color: white;
}

.btn-danger:hover {
  background: #b91c1c;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--gray-300);
  color: var(--gray-700);
}

.btn-outline:hover {
  background: var(--gray-50);
}

.btn-ghost {
  background: transparent;
  color: var(--gray-500);
  padding: 0.5rem;
}

.btn-ghost:hover {
  background: var(--gray-100);
  color: var(--gray-700);
}

.btn-small {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

.btn-icon {
  padding: 0.5rem;
  width: 32px;
  height: 32px;
}

.btn-block {
  width: 100%;
}

/* Button groups */
.btn-group {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
}

.btn-group-right {
  justify-content: flex-end;
}

.btn-group-between {
  justify-content: space-between;
}

/* Team selection - scrollable list */
.existing-teams-section {
  margin-top: 0;
}

.team-filter-input {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 1rem;
  margin-bottom: 0.5rem;
}

.team-filter-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.team-list-container {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  background: var(--gray-50);
}

.team-list {
  display: flex;
  flex-direction: column;
}

.team-list-item {
  padding: 0.75rem 1rem;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--gray-200);
  cursor: pointer;
  font-size: 0.9375rem;
  text-align: left;
  transition: background 0.15s;
}

.team-list-item:last-child {
  border-bottom: none;
}

.team-list-item:hover {
  background: var(--gray-100);
}

.team-list-item.selected {
  background: var(--primary);
  color: white;
}

.team-list-item.selected:hover {
  background: var(--primary-hover);
}

.team-list-empty {
  padding: 1rem;
  text-align: center;
  color: var(--gray-500);
  font-style: italic;
}

/* Divider */
.divider {
  display: flex;
  align-items: center;
  margin: 1.5rem 0;
  color: var(--gray-400);
  font-size: 0.875rem;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--gray-200);
}

.divider span {
  padding: 0 1rem;
}

/* Status Select Dropdown */
.status-select {
  padding: 0.375rem 0.5rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 0.8125rem;
  background: white;
  cursor: pointer;
  min-width: 100px;
}

.status-select:focus {
  outline: none;
  border-color: var(--primary);
}

/* Metrics Display */
.metric-values {
  display: flex;
  gap: 1.5rem;
  margin-top: 0.5rem;
}

.metric-value {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.metric-value-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
}

.metric-value-number {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--gray-800);
}

.metric-value-target {
  color: var(--gray-600);
}

/* AI Refinement */
.ai-suggestion {
  background: rgba(37, 99, 235, 0.05);
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  padding: 1rem;
  margin-top: 1rem;
}

.ai-suggestion-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.ai-suggestion-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--primary);
}

.comparison {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1rem;
}

.comparison-side {
  padding: 1rem;
  border-radius: var(--radius);
}

.comparison-original {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
}

.comparison-suggested {
  background: rgba(37, 99, 235, 0.05);
  border: 1px solid var(--primary);
}

.comparison-side h4 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
  margin-bottom: 0.5rem;
}

.comparison-side p {
  font-size: 0.9375rem;
}

.feedback {
  margin-top: 1rem;
  padding: 0.75rem;
  background: var(--gray-50);
  border-radius: var(--radius);
  font-size: 0.875rem;
  color: var(--gray-600);
}

.feedback strong {
  color: var(--gray-700);
}

/* Loading spinner */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.loading-content {
  text-align: center;
}

.loading-content p {
  margin-top: 1rem;
  color: var(--gray-600);
}

/* Alert messages */
.alert {
  padding: 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

.alert-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--error);
}

.alert-success {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: var(--success);
}

.alert-warning {
  background: #fefce8;
  border: 1px solid #fde68a;
  color: var(--warning);
}

/* Hide/show */
.hidden {
  display: none !important;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--gray-500);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 0.5rem;
}

.empty-state p {
  margin-bottom: 1.5rem;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 1.125rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--gray-400);
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover {
  color: var(--gray-600);
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--gray-200);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* Admin Table */
.admin-table {
  width: 100%;
  border-collapse: collapse;
}

.admin-table th,
.admin-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--gray-200);
}

.admin-table th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
  font-weight: 600;
  background: var(--gray-50);
}

.admin-table tbody tr:hover {
  background: var(--gray-50);
}

.admin-table .actions {
  display: flex;
  gap: 0.5rem;
}

/* Color Preview */
.color-preview {
  width: 24px;
  height: 24px;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: white;
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
  text-align: center;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
}

.stat-label {
  font-size: 0.875rem;
  color: var(--gray-500);
  margin-top: 0.25rem;
}

/* Landing Page Cards */
.landing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-top: 2rem;
}

.landing-card {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  text-decoration: none;
  color: inherit;
  transition: transform 0.2s, box-shadow 0.2s;
  display: block;
}

.landing-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.landing-card-icon {
  font-size: 2.5rem;
  margin-bottom: 1rem;
}

.landing-card h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.landing-card p {
  color: var(--gray-500);
  font-size: 0.9375rem;
}

/* Print styles */
@media print {
  body {
    background: white;
  }

  .container {
    max-width: 100%;
    padding: 0;
  }

  .btn,
  .tab-nav,
  .team-selector,
  .back-link {
    display: none !important;
  }

  .card {
    box-shadow: none;
    border: 1px solid var(--gray-200);
    break-inside: avoid;
  }

  .item-card {
    break-inside: avoid;
  }
}

/* Responsive */
@media (max-width: 768px) {
  .container {
    padding: 1rem;
  }

  .app-header {
    flex-direction: column;
    gap: 1rem;
    align-items: flex-start;
  }

  .team-selector {
    width: 100%;
  }

  .team-selector select {
    flex: 1;
  }

  .tab-nav {
    padding: 0.25rem;
  }

  .tab-btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
  }

  .form-row,
  .form-row-3 {
    grid-template-columns: 1fr;
  }

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

  .btn-group {
    flex-direction: column;
  }

  .item-card-with-number {
    grid-template-columns: 1fr;
  }

  .item-card-number {
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
  }

  .item-card-with-number .item-card-content {
    padding-left: 2.5rem;
  }
}
