/* ============================================
   SAP Health Check Dashboard — Styles
   Premium dark mode with glassmorphism
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ── CSS Custom Properties ── */
:root {
  /* Brand Colors */
  --brand-verde-1: #007853;
  --brand-verde-2: #00aa42;
  --brand-verde-3: #76bc21;
  --brand-verde-4: #c2d500;
  --brand-aguamarina: #00af9a;

  /* Theme Backgrounds: Clean Light Theme */
  --bg-primary: #f1f5f9;
  --bg-secondary: #e2e8f0;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-card-hover: rgba(255, 255, 255, 1);
  --bg-glass: rgba(255, 255, 255, 0.6);
  --border-glass: rgba(0, 0, 0, 0.06);
  --border-hover: rgba(0, 170, 66, 0.3);

  --text-primary: #1e293b;
  --text-secondary: #475569;
  --text-muted: #64748b;

  /* Semantic UI Colors mapped to Brand where possible */
  --accent-green: var(--brand-verde-2);
  --accent-green-glow: rgba(0, 170, 66, 0.15);
  --accent-blue: var(--brand-aguamarina);
  --accent-blue-glow: rgba(0, 175, 154, 0.15);
  
  --accent-amber: #f59e0b;
  --accent-amber-glow: rgba(245, 158, 11, 0.15);
  --accent-red: #ef4444;
  --accent-red-glow: rgba(239, 68, 68, 0.15);
  --accent-purple: var(--brand-verde-3);
  --accent-purple-glow: rgba(118, 188, 33, 0.15);
  --accent-gray: #64748b;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
  --shadow-glow-green: 0 4px 14px var(--accent-green-glow);
  --shadow-glow-red: 0 4px 14px var(--accent-red-glow);
  --shadow-glow-amber: 0 4px 14px var(--accent-amber-glow);

  --transition-fast: 0.15s ease;
  --transition-base: 0.25s ease;
  --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

/* Animated background gradient */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(0, 170, 66, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(0, 175, 154, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 50%, rgba(118, 188, 33, 0.05) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
  animation: bgShift 20s ease-in-out infinite alternate;
}

@keyframes bgShift {
  0%   { opacity: 0.6; }
  50%  { opacity: 1;   }
  100% { opacity: 0.7; }
}

/* ── Layout ── */
.app-container {
  position: relative;
  z-index: 1;
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px 32px;
}

/* ── Header ── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 28px;
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-xl);
  margin-bottom: 24px;
  animation: slideDown 0.6s var(--transition-slow);
}

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

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-logo {
  height: 48px;
  width: auto;
  max-width: 140px;
  object-fit: contain;
  border-radius: 4px; /* Optional slight rounding if logo has sharp background */
}

.header-title {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.header-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 2px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.header-badge .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-green);
  animation: pulse 2s ease-in-out infinite;
}

.header-badge .dot.offline {
  background: var(--accent-red);
  animation: none;
}

@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 var(--accent-green-glow); }
  50%      { opacity: 0.7; box-shadow: 0 0 0 6px transparent; }
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  transition: all var(--transition-base);
}

.btn-primary {
  background: linear-gradient(135deg, var(--brand-verde-2), var(--brand-verde-1));
  color: white;
  box-shadow: 0 4px 12px rgba(0, 170, 66, 0.3);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0, 170, 66, 0.4);
}

.btn-primary:active {
  transform: translateY(0);
}

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

/* Secondary Button (PDF/Email) */
.btn-secondary {
  background: white;
  color: var(--text-primary);
  border: 1px solid var(--border-light);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--accent-green);
  color: var(--accent-green);
}

.btn i {
  width: 18px;
}

.btn-icon {
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  color: var(--text-secondary);
  padding: 10px;
  border-radius: var(--radius-md);
}

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

/* ── Score Panel ── */
.score-panel {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 24px;
  margin-bottom: 24px;
  animation: fadeUp 0.6s var(--transition-slow) 0.1s both;
}

@keyframes fadeUp {
  from { transform: translateY(16px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

.score-circle-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-xl);
  padding: 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  position: relative;
  overflow: hidden;
}

.score-circle-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius-xl);
  background: radial-gradient(circle at 50% 0%, rgba(0, 170, 66, 0.08) 0%, transparent 60%);
  pointer-events: none;
}

.score-circle {
  position: relative;
  width: 160px;
  height: 160px;
}

.score-circle svg {
  transform: rotate(-90deg);
  width: 100%;
  height: 100%;
}

.score-circle .track {
  fill: none;
  stroke: rgba(0,0,0,0.06);
  stroke-width: 10;
}

.score-circle .progress {
  fill: none;
  stroke-width: 10;
  stroke-linecap: round;
  stroke-dasharray: 440;
  stroke-dashoffset: 440;
  transition: stroke-dashoffset 1.5s cubic-bezier(0.4, 0, 0.2, 1),
              stroke 0.5s ease;
  filter: drop-shadow(0 0 8px var(--accent-green-glow));
}

.score-value {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.score-value .number {
  font-size: 2.8rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
}

.score-value .percent {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
}

.score-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
  text-align: center;
}

/* Summary Cards in Score Panel */
.score-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.summary-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}

.summary-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.summary-card.ok::before { background: var(--accent-green); }
.summary-card.warning::before { background: var(--accent-amber); }
.summary-card.error::before { background: var(--accent-red); }
.summary-card.pending::before { background: var(--accent-gray); }

.summary-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-hover);
  box-shadow: var(--shadow-md);
}

.summary-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.summary-card.ok .summary-icon       { background: rgba(0, 170, 66, 0.15); color: var(--accent-green); }
.summary-card.warning .summary-icon   { background: rgba(245, 158, 11, 0.15); color: var(--accent-amber); }
.summary-card.error .summary-icon     { background: rgba(239, 68, 68, 0.15); color: var(--accent-red); }
.summary-card.pending .summary-icon   { background: rgba(107, 114, 128, 0.15); color: var(--accent-gray); }

.summary-number {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
}

.summary-card.ok .summary-number      { color: var(--accent-green); }
.summary-card.warning .summary-number  { color: var(--accent-amber); }
.summary-card.error .summary-number    { color: var(--accent-red); }
.summary-card.pending .summary-number  { color: var(--accent-gray); }

.summary-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── Category Tabs ── */
.category-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  padding: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(20px);
  overflow-x: auto;
  animation: fadeUp 0.6s var(--transition-slow) 0.2s both;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  transition: all var(--transition-base);
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--text-primary);
  background: var(--bg-glass);
}

.tab-btn.active {
  color: var(--accent-green);
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
  border-color: var(--accent-green);
}

.tab-btn .tab-count {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: rgba(0,0,0,0.06);
  font-weight: 600;
}

/* ── Check Cards Grid ── */
.checks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  animation: fadeUp 0.6s var(--transition-slow) 0.3s both;
}

.check-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  transition: all var(--transition-base);
  cursor: default;
  position: relative;
  overflow: hidden;
}

.check-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.check-card::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 4px;
  height: 100%;
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
  transition: background var(--transition-base);
}

.check-card[data-status="OK"]::after      { background: var(--accent-green); }
.check-card[data-status="WARNING"]::after  { background: var(--accent-amber); }
.check-card[data-status="ERROR"]::after    { background: var(--accent-red); }
.check-card[data-status="PENDING"]::after  { background: var(--accent-gray); }
.check-card[data-status="LOADING"]::after  { background: var(--accent-blue); animation: shimmer 1.5s infinite; }

@keyframes shimmer {
  0%   { opacity: 0.4; }
  50%  { opacity: 1; }
  100% { opacity: 0.4; }
}

.check-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.check-card-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.check-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.check-card[data-status="OK"] .check-icon       { background: rgba(0, 170, 66, 0.12); color: var(--accent-green); }
.check-card[data-status="WARNING"] .check-icon   { background: rgba(245, 158, 11, 0.12); color: var(--accent-amber); }
.check-card[data-status="ERROR"] .check-icon     { background: rgba(239, 68, 68, 0.12); color: var(--accent-red); }
.check-card[data-status="PENDING"] .check-icon   { background: rgba(107, 114, 128, 0.12); color: var(--accent-gray); }
.check-card[data-status="LOADING"] .check-icon   { background: rgba(0, 175, 154, 0.12); color: var(--accent-blue); }

.check-name {
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.3;
}

.check-transaction {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
  font-family: 'Inter', monospace;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.status-badge.ok      { background: rgba(0, 170, 66, 0.12); color: var(--accent-green); }
.status-badge.warning  { background: rgba(245, 158, 11, 0.12); color: var(--accent-amber); }
.status-badge.error    { background: rgba(239, 68, 68, 0.12); color: var(--accent-red); }
.status-badge.pending  { background: rgba(107, 114, 128, 0.12); color: var(--accent-gray); }
.status-badge.loading  { background: rgba(0, 175, 154, 0.12); color: var(--accent-blue); }

.check-detail {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.check-detail-data {
  margin-top: 12px;
  padding: 12px 16px;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.check-detail-data .data-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px solid rgba(0,0,0,0.04);
}

.check-detail-data .data-row:last-child {
  border-bottom: none;
}

.check-detail-data .data-label {
  color: var(--text-muted);
  font-weight: 500;
}

.check-detail-data .data-value {
  color: var(--text-primary);
  font-weight: 600;
  font-family: 'Inter', monospace;
}

/* ── History Timeline ── */
.history-section {
  margin-top: 32px;
  animation: fadeUp 0.6s var(--transition-slow) 0.4s both;
}

.section-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-title .icon {
  color: var(--accent-blue);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.history-item:hover {
  border-color: var(--border-hover);
}

.history-time {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: 'Inter', monospace;
  min-width: 140px;
}

.history-score {
  font-size: 0.85rem;
  font-weight: 700;
  min-width: 50px;
}

.history-score.good { color: var(--accent-green); }
.history-score.mid  { color: var(--accent-amber); }
.history-score.bad  { color: var(--accent-red); }

.history-summary {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* ── Loading & Empty States ── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-base);
}

.loading-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(0,0,0,0.05);
  border-top-color: var(--brand-verde-2);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.card-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(0,0,0,0.1);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

/* ── Toast Notifications ── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 14px 20px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-glass);
  box-shadow: var(--shadow-lg);
  font-size: 0.82rem;
  color: var(--text-primary);
  animation: toastIn 0.3s ease;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 380px;
}

.toast.success { border-left: 4px solid var(--accent-green); }
.toast.error   { border-left: 4px solid var(--accent-red); }
.toast.info    { border-left: 4px solid var(--accent-blue); }

@keyframes toastIn {
  from { transform: translateX(100px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* ── Timer bar ── */
.timer-bar {
  height: 3px;
  background: rgba(0,0,0,0.06);
  border-radius: 2px;
  margin-top: 12px;
  overflow: hidden;
}

.timer-bar .progress {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-green), var(--accent-blue));
  border-radius: 2px;
  width: 0%;
  transition: width 1s linear;
}

/* ── Responsive ── */
@media (max-width: 1200px) {
  .score-summary {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 960px) {
  .score-panel {
    grid-template-columns: 1fr;
  }
  .score-summary {
    grid-template-columns: repeat(4, 1fr);
  }
  .checks-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  }
}

@media (max-width: 640px) {
  .app-container {
    padding: 16px;
  }
  .header {
    flex-direction: column;
    gap: 16px;
    align-items: flex-start;
  }
  .score-summary {
    grid-template-columns: repeat(2, 1fr);
  }
  .checks-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Feather icon sizing ── */
.feather {
  width: 18px;
  height: 18px;
  stroke-width: 2;
}

.check-icon .feather {
  width: 20px;
  height: 20px;
}

.summary-icon .feather {
  width: 22px;
  height: 22px;
}
