/* ============================================
   CMS Hospital Star Rankings Calculator
   Premium Modern Design
   ============================================ */

:root {
  --primary-blue: #003366;
  --primary-light: #1a5399;
  --accent-gold: #d4af37;
  --bg-gradient-start: #0a1628;
  --bg-gradient-end: #1a2a4a;
  --card-bg: rgba(255, 255, 255, 0.05);
  --card-border: rgba(255, 255, 255, 0.1);
  --text-primary: #ffffff;
  --text-secondary: #a0b3c6;
  --success-green: #22c55e;
  --warning-orange: #f59e0b;
  --error-red: #ef4444;
  --star-gold: #fbbf24;
  --star-empty: #374151;
}

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


html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
  min-height: 100vh;
  color: var(--text-primary);
  line-height: 1.6;
}

/* Header */
.header {
  background: rgba(0, 51, 102, 0.8);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--card-border);
  padding: 1.5rem 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

/* Custom Searchable Dropdown */
.hospital-selector {
  min-width: 300px;
}

.hospital-search-container {
  position: relative;
  width: 100%;
}

.hospital-search-container input {
  width: 100%;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 0.5rem 1rem 0.5rem 2.5rem;
  /* Space for icon */
  color: var(--text-primary);
  font-size: 0.9rem;
  transition: all 0.2s ease;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="white" viewBox="0 0 16 16" opacity="0.5"><path d="M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z"/></svg>');
  background-repeat: no-repeat;
  background-position: 10px center;
}

.hospital-search-container input:focus {
  outline: none;
  border-color: var(--accent-gold);
  background-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.2);
}

.dropdown-list {
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  margin-top: 0.5rem;
  background: rgba(10, 22, 40, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  max-height: 300px;
  overflow-y: auto;
  z-index: 1000;
  display: none;
  /* Hidden by default */
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

.dropdown-list.show {
  display: block;
}

.dropdown-item {
  padding: 0.75rem 1rem;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  transition: background 0.2s;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

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

.dropdown-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  padding-left: 1.25rem;
}

.dropdown-item strong {
  color: var(--accent-gold);
}

.logo {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo-icon {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--accent-gold), #c9a227);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.logo-text h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.logo-text p {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

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

/* Intro Section */
.intro {
  text-align: center;
  margin-bottom: 3rem;
}

.intro h2 {
  font-size: 2rem;
  margin-bottom: 1rem;
  background: linear-gradient(135deg, var(--text-primary), var(--accent-gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.intro p {
  color: var(--text-secondary);
  max-width: 700px;
  margin: 0 auto;
}

/* Grid Layout */
.main-grid {
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: 2rem;
}

@media (max-width: 1100px) {
  .main-grid {
    grid-template-columns: 1fr;
  }
}

/* Cards */
.card {
  background: var(--card-bg);
  backdrop-filter: blur(20px);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  overflow: hidden;
}

/* Measure Groups */
.measure-section {
  margin-bottom: 1rem;
}

.measure-header {
  background: rgba(255, 255, 255, 0.03);
  padding: 1rem 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background 0.2s ease;
  border-bottom: 1px solid var(--card-border);
}

.measure-header:hover {
  background: rgba(255, 255, 255, 0.06);
}

.measure-header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.measure-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.measure-icon.mortality {
  background: linear-gradient(135deg, #dc2626, #991b1b);
}

.measure-icon.safety {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
}

.measure-icon.readmission {
  background: linear-gradient(135deg, #7c3aed, #5b21b6);
}

.measure-icon.experience {
  background: linear-gradient(135deg, #059669, #047857);
}

.measure-icon.care {
  background: linear-gradient(135deg, #d97706, #b45309);
}

.measure-title h3 {
  font-size: 0.95rem;
  font-weight: 600;
}

.measure-title p {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.measure-badge {
  background: rgba(255, 255, 255, 0.1);
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.chevron {
  transition: transform 0.3s ease;
}

.measure-header.expanded .chevron {
  transform: rotate(180deg);
}

.measure-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease;
}

.measure-content.expanded {
  max-height: 2000px;
}

.measure-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  padding: 1.5rem;
}

/* Input Fields */
.input-group {
  position: relative;
}

.input-group label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.input-group input {
  width: 100%;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  color: var(--text-primary);
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.input-group input:focus {
  outline: none;
  border-color: var(--accent-gold);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.2);
}

.input-group input::placeholder {
  color: #4b5563;
}

.input-hint {
  font-size: 0.65rem;
  color: #6b7280;
  margin-top: 0.25rem;
}

/* Calculate Button */
.calculate-btn {
  width: 100%;
  background: linear-gradient(135deg, var(--accent-gold), #c9a227);
  border: none;
  border-radius: 12px;
  padding: 1.25rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary-blue);
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 1.5rem;
}

.calculate-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(212, 175, 55, 0.3);
}

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

/* Results Panel */
.results-panel {
  position: sticky;
  top: 100px;
}

.results-card {
  padding: 2rem;
}

.results-header {
  text-align: center;
  margin-bottom: 2rem;
}

.results-header h3 {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
}

.results-header p {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* Star Display */
.star-display {
  text-align: center;
  padding: 2rem 0;
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--card-border);
}

.stars-container {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.star {
  font-size: 2.5rem;
  color: var(--star-empty);
  transition: all 0.3s ease;
}

.star.active {
  color: var(--star-gold);
  animation: starPop 0.4s ease-out;
}

@keyframes starPop {
  0% {
    transform: scale(0);
  }

  50% {
    transform: scale(1.2);
  }

  100% {
    transform: scale(1);
  }
}

.star-label {
  font-size: 1.5rem;
  font-weight: 700;
  margin-top: 0.5rem;
}

.star-label.pending {
  color: var(--text-secondary);
  font-size: 1rem;
}

/* Eligibility Status */
.eligibility {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1.5rem;
}

.eligibility-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.eligibility-status {
  font-weight: 600;
  font-size: 0.9rem;
}

.eligibility-status.eligible {
  color: var(--success-green);
}

.eligibility-status.ineligible {
  color: var(--error-red);
}

.eligibility-status.pending {
  color: var(--text-secondary);
}

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

/* Group Scores */
.group-scores h4 {
  font-size: 0.85rem;
  margin-bottom: 1rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.score-item {
  margin-bottom: 1rem;
}

.score-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  margin-bottom: 0.5rem;
}

.score-bar {
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  overflow: hidden;
}

.score-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease-out;
  background: linear-gradient(90deg, var(--primary-light), var(--accent-gold));
}

.score-fill.negative {
  background: linear-gradient(90deg, var(--error-red), var(--warning-orange));
}

/* Summary Score */
.summary-score {
  background: linear-gradient(135deg, rgba(212, 175, 55, 0.1), rgba(212, 175, 55, 0.05));
  border: 1px solid rgba(212, 175, 55, 0.3);
  border-radius: 12px;
  padding: 1.5rem;
  text-align: center;
  margin-top: 1.5rem;
}

.summary-score h4 {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.summary-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent-gold);
}

/* Footnote */
.footnote {
  margin-top: 2rem;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  font-size: 0.7rem;
  color: #6b7280;
  text-align: center;
}

/* Loading State */
.loading {
  text-align: center;
  padding: 2rem;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--card-border);
  border-top-color: var(--accent-gold);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1rem;
}

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

/* Responsive */
@media (max-width: 768px) {
  .header-content {
    flex-direction: column;
    gap: 1rem;
  }

  .container {
    padding: 1rem;
  }

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

  .intro h2 {
    font-size: 1.5rem;
  }
}

/* Top Hospitals Section */
.top-hospitals-section {
  margin-top: 4rem;
  margin-bottom: 2rem;
}

.section-header {
  text-align: center;
  margin-bottom: 2rem;
}

.section-header h2 {
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, var(--text-primary), var(--accent-gold));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.table-card {
  background: rgba(10, 22, 40, 0.6);
}

.table-container {
  overflow-x: auto;
}

.hospitals-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.hospitals-table th {
  text-align: left;
  padding: 1rem 1.5rem;
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.75rem;
  border-bottom: 1px solid var(--card-border);
}

.hospitals-table td {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.hospitals-table tr:last-child td {
  border-bottom: none;
}

.hospitals-table tr:hover td {
  background: rgba(255, 255, 255, 0.03);
}

.rating-badge {
  background: rgba(251, 191, 36, 0.15);
  color: var(--star-gold);
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.load-btn-sm {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--text-primary);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.2s;
}

.load-btn-sm:hover {
  background: var(--accent-gold);
  color: var(--primary-blue);
  border-color: var(--accent-gold);
}