/* Path: css/components.css */

/* Cards Layout */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: clamp(.85rem, 3vw, 1.5rem);
  box-shadow: var(--shadow);
  border: 1px solid var(--border-color);
}

.card h2 {
  font-size: 1.25rem;
  margin-bottom: 1.25rem;
  color: var(--primary-color);
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.5rem;
}

/* Forms Layout */
button, input, select {
  font-family: inherit;
}

@media (pointer: coarse) {
  .btn-lang, .tab-btn, input:not([type="checkbox"], [type="radio"]), select {
    min-block-size: 44px;
  }
}

.form-group {
  display: flex;
  flex-direction: column;
  margin-bottom: 1rem;
}

.form-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
}

@media (min-width: 480px) {
  .form-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

label {
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 0.35rem;
  color: var(--text-dark);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.25rem;
}

input, select {
  min-inline-size: 0;
  max-inline-size: 100%;
  padding: 0.65rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s ease;
}

input:focus, select:focus {
  border-color: var(--primary-color);
}

.section-divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 1.5rem 0 1rem 0;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: bold;
  text-transform: uppercase;
}

.section-divider::before, .section-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px dashed var(--border-color);
}

.section-divider:not(:empty)::before {
  margin-right: .5em;
}

.section-divider:not(:empty)::after {
  margin-left: .5em;
}

/* Buttons UI */
.btn {
  display: inline-block;
  padding: 0.75rem 1.25rem;
  border: none;
  border-radius: 4px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: background-color 0.15s ease;
  width: 100%;
}

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

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

.btn-secondary {
  background-color: #edf2f7;
  color: var(--text-dark);
}

.btn-danger {
  background-color: #fed7d7;
  color: #c53030;
}

.btn-danger:hover {
  background-color: #feb2b2;
}

.btn-lang {
  background: none;
  border: 1px solid var(--border-color);
  padding: 0.35rem 0.75rem;
  cursor: pointer;
  font-weight: bold;
  border-radius: 4px;
}

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

/* Info Icon Buttons */
.info-btn {
  background: none;
  border: none;
  color: var(--primary-color);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0.1rem 0.3rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.info-btn:hover {
  background-color: #ebf8ff;
  color: var(--primary-hover);
}

/* Badges UI */
.badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  font-weight: bold;
  border-radius: 12px;
  color: white;
}

.badge-normal { background-color: var(--normal-color); }
.badge-warning { background-color: var(--warning-color); }
.badge-critical { background-color: var(--critical-color); }

/* Results Component */
.results-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.25rem;
  background-color: var(--bg-color);
  padding: 0.75rem;
  border-radius: 4px;
  font-size: 0.9rem;
}

.meta-column p {
  margin-bottom: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.metric-result {
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  margin-bottom: 1rem;
  overflow: hidden;
}

.metric-header {
  background-color: var(--bg-color);
  padding: 0.75rem 1rem;
  font-weight: bold;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
}

.metric-body {
  padding: 1rem;
}

.metric-description {
  font-size: 0.85rem;
  margin-top: 0.5rem;
  color: var(--text-muted);
}

.placeholder-text {
  color: var(--text-muted);
  text-align: center;
  padding: 3rem 1rem;
  font-style: italic;
}

/* Alert banner */
.alert-banner {
  display: flex;
  align-items: flex-start;
  background-color: #fffaf0;
  border: 1px solid #feebc8;
  border-left: 4px solid var(--warning-color);
  padding: 1rem;
  border-radius: 4px;
  margin-bottom: 1.25rem;
}

.alert-icon {
  margin-right: 0.75rem;
  font-size: 1.25rem;
}

.alert-text strong {
  display: block;
  color: #c05621;
}

.alert-text p {
  font-size: 0.85rem;
  color: #7b341e;
}

/* History Component */
.history-section {
  grid-column: 1 / -1;
}

.table-container {
  overflow-x: auto;
  margin-bottom: 1rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

th, td {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

th {
  background-color: var(--bg-color);
  font-weight: 600;
}

#btn-clear-history {
  width: auto;
}

/* Cohort Tabs Navigation */
.cohort-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 0.25rem;
}

.tab-btn {
  background: none;
  border: none;
  padding: 0.5rem 0.75rem;
  font-weight: bold;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--text-muted);
  position: relative;
  transition: color 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
}

@media (min-width: 600px) {
  .tab-btn {
    padding: 0.6rem 1.2rem;
    font-size: 0.95rem;
  }
}

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

.tab-btn.active {
  color: var(--primary-color);
}

.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -0.4rem;
  left: 0;
  width: 100%;
  height: 3px;
  background-color: var(--primary-color);
  border-radius: 2px 2px 0 0;
}

.tab-info-btn {
  font-size: 0.75rem;
  opacity: 0.5;
  transition: opacity 0.15s ease, transform 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.1rem;
}

.tab-info-btn:hover {
  opacity: 1;
  transform: scale(1.1);
}

.hidden-group {
  display: none !important;
}

/* Namespaced Modal UI Container */
.modal {
  position: fixed;
  z-index: 2000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: opacity 0.15s ease;
}

.modal.hidden {
  display: none !important;
  opacity: 0;
}

.modal-content {
  background-color: var(--card-bg);
  padding: 1.75rem;
  border-radius: var(--radius);
  max-width: 500px;
  width: 90%;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
  position: relative;
  border: 1px solid var(--border-color);
  animation: modalSlideUp 0.2s ease-out;
}

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

.modal-close {
  position: absolute;
  top: 0.75rem;
  right: 1rem;
  font-size: 1.6rem;
  font-weight: bold;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text-dark);
}

.modal-title-text {
  font-size: 1.2rem;
  color: var(--primary-color);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-color);
}

.modal-body {
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text-dark);
}

.modal-body strong {
  color: var(--text-dark);
}

.modal-body code {
  background-color: var(--bg-color);
  padding: 0.15rem 0.35rem;
  border-radius: 3px;
  font-family: monospace;
  font-size: 0.85rem;
}

.modal-body ol, .modal-body ul {
  margin-left: 1.25rem;
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}

.modal-body li {
  margin-bottom: 0.35rem;
}

/* Growth Curve Analytics Section */
.chart-section {
  grid-column: 1 / -1;
  margin-bottom: 1.5rem;
}

.chart-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: .75rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.5rem;
}

.chart-section-header h2 {
  margin-bottom: 0;
  border-bottom: none;
  padding-bottom: 0;
}

.chart-selector-container select {
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  background-color: var(--card-bg);
  font-weight: 600;
  color: var(--text-dark);
}

.chart-viewport {
  position: relative;
  height: clamp(15rem, 55dvh, 23.75rem);
  width: 100%;
}
