/* Sleep Impact Calculator - Best-in-Class Enhanced Styling */

/* Tool Container */
.bv-tool-container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 2rem;
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border-radius: 20px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
  margin-bottom: 3rem;
}

/* Tool Header */
.bv-tool-header {
  text-align: center;
  margin-bottom: 3rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid #e2e8f0;
}

.bv-header-content {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 1rem;
}

.bv-tool-title {
  font-size: 2.5rem;
  font-weight: 800;
  color: #1e293b;
  margin-bottom: 1rem;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.bv-tool-description {
  font-size: 1.1rem;
  color: #64748b;
  margin: 0 auto 2rem auto;
  line-height: 1.6;
}

/* Statistics Section */
.bv-tool-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2rem;
  margin-top: 2rem;
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
}

.bv-stat {
  text-align: center;
  padding: 1rem;
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border-radius: 12px;
  border: 1px solid #e2e8f0;
}

.bv-stat-number {
  display: block;
  font-size: 1.8rem;
  font-weight: 800;
  color: #3b82f6;
  line-height: 1;
}

.bv-stat-label {
  display: block;
  font-size: 0.9rem;
  color: #64748b;
  margin-top: 0.5rem;
  font-weight: 500;
}

/* Referral Links Section */
.bv-referrals-section {
  margin: 3rem 0;
  padding: 2rem 0;
  border-top: 1px solid #e2e8f0;
}

/* Tool Footer */
.bv-tool-footer {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid #e2e8f0;
}

.bv-tool-disclaimer {
  background: #f8fafc;
  padding: 1.5rem;
  border-radius: 12px;
  border-left: 4px solid #3b82f6;
}

.bv-tool-disclaimer h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 0.5rem;
}

.bv-tool-disclaimer p {
  color: #64748b;
  font-size: 0.9rem;
  line-height: 1.6;
  margin: 0;
}

/* Sleep Calculator Variables */
:root {
  --sleep-primary: #3b82f6;
  --sleep-primary-hover: #2563eb;
  --sleep-accent: #ec4899;
  --sleep-danger: #ef4444;
  --sleep-danger-hover: #dc2626;
  --sleep-warning: #f59e0b;
  --sleep-success: #22c55e;
  --sleep-bg: #f1f5f9;
  --sleep-card: #ffffff;
  --sleep-text: #1e293b;
  --sleep-text-secondary: #64748b;
  --sleep-border: #e2e8f0;
  --sleep-input-bg: #f8fafc;
  --sleep-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

/* Wrapper & Layout */
.bv-sleep-wrapper {
  max-width: 100%;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.bv-sleep-card {
  background: var(--sleep-card);
  border-radius: 16px;
  padding: 24px;
  border: 1px solid var(--sleep-border);
  box-shadow: var(--sleep-shadow);
  transition: background 0.3s, border 0.3s;
}

.bv-sleep-panel h2 {
  font-size: 1.4rem;
  margin-bottom: 16px;
  color: var(--sleep-primary);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.bv-icon {
  font-size: 1.5rem;
}

/* Form Styling */
.bv-sleep-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.bv-sleep-form-group {
  display: flex;
  flex-direction: column;
  margin-bottom: 16px;
}

.bv-sleep-form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 0.9rem;
  color: var(--sleep-text);
}

.bv-sleep-form-group input,
.bv-sleep-select {
  width: 100%;
  padding: 12px;
  font-size: 1rem;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  border: 1px solid var(--sleep-border);
  background-color: var(--sleep-input-bg);
  color: var(--sleep-text);
  border-radius: 8px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.bv-sleep-form-group input:focus,
.bv-sleep-select:focus {
  outline: none;
  border-color: var(--sleep-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.bv-sleep-form-group input:hover,
.bv-sleep-select:hover {
  border-color: #94a3b8;
}

.bv-sleep-inline-group {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
}

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

.bv-sleep-input-with-unit {
  position: relative;
  display: flex;
  align-items: center;
}

.bv-sleep-input-with-unit input {
  padding-right: 50px;
}

.bv-sleep-input-with-unit span {
  position: absolute;
  right: 12px;
  color: var(--sleep-text-secondary);
  font-size: 0.9rem;
  pointer-events: none;
}

.bv-sleep-form-group input.is-invalid,
.bv-sleep-select.is-invalid {
  border-color: var(--sleep-danger);
}

.bv-error-msg {
  color: var(--sleep-danger);
  font-size: 0.8rem;
  height: 1em;
  display: block;
  margin-top: 4px;
}

.bv-sleep-settings-info {
  font-size: 0.8rem;
  color: var(--sleep-text-secondary);
  margin-top: 8px;
  text-align: center;
}

/* Buttons */
.bv-sleep-buttons-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.bv-sleep-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-grow: 1;
  padding: 12px 16px;
  font-size: 1rem;
  font-weight: 600;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

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

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

.bv-sleep-btn-secondary {
  background: transparent;
  color: var(--sleep-primary);
  border-color: var(--sleep-primary);
}

.bv-sleep-btn-secondary:hover {
  background: var(--sleep-primary);
  color: white;
}

.bv-sleep-btn-danger {
  background: var(--sleep-danger);
  color: white;
  border-color: var(--sleep-danger);
}

.bv-sleep-btn-danger:hover {
  background: var(--sleep-danger-hover);
  border-color: var(--sleep-danger-hover);
}

.bv-sleep-btn-calculate {
  width: 100%;
  font-size: 1.1rem;
  padding: 14px;
  margin-bottom: 16px;
  background: linear-gradient(135deg, var(--sleep-primary), var(--sleep-accent));
  color: white;
  border: none;
}

.bv-sleep-btn-calculate:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(59, 130, 246, 0.3);
}

/* Entries List */
.bv-sleep-entries-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.bv-sleep-entries-list:empty::after {
  content: "No entries yet. Click 'Add Entry' to start tracking.";
  display: block;
  text-align: center;
  color: var(--sleep-text-secondary);
  font-style: italic;
  padding: 2rem;
  background: var(--sleep-bg);
  border-radius: 8px;
  margin: 1rem 0;
}

.bv-sleep-entries-list li {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.05), rgba(139, 92, 246, 0.05));
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-left: 4px solid var(--sleep-primary);
  transition: all 0.3s ease;
}

.bv-sleep-entries-list li:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.bv-sleep-entries-list li[data-substance="alcohol"] {
  border-left-color: var(--sleep-accent);
  background: linear-gradient(135deg, rgba(236, 72, 153, 0.05), rgba(244, 114, 182, 0.05));
}

.bv-sleep-entry-details {
  font-size: 0.95rem;
}

.bv-sleep-entry-details strong {
  font-weight: 600;
  color: var(--sleep-text);
}

.bv-sleep-entry-details span {
  color: var(--sleep-text-secondary);
  font-size: 0.85rem;
  display: block;
  margin-top: 2px;
}

.bv-sleep-entry-actions {
  display: flex;
  gap: 4px;
}

.bv-sleep-entry-actions button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  color: var(--sleep-text-secondary);
  border-radius: 4px;
  transition: all 0.2s ease;
  font-size: 1.1rem;
}

.bv-sleep-entry-actions button:hover {
  color: var(--sleep-primary);
  background: rgba(59, 130, 246, 0.1);
}

.bv-sleep-entry-actions button.delete:hover {
  color: var(--sleep-danger);
  background: rgba(239, 68, 68, 0.1);
}

/* Gauges System */
.bv-sleep-gauges-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 24px;
}

.bv-sleep-gauge {
  background: var(--sleep-bg);
  padding: 16px;
  border-radius: 12px;
  border: 1px solid var(--sleep-border);
}

.bv-sleep-gauge-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 0.9rem;
  font-weight: 600;
}

.bv-sleep-gauge-label strong {
  color: var(--sleep-primary);
  font-weight: 700;
}

.bv-sleep-gauge-track {
  height: 12px;
  background: #e2e8f0;
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}

.bv-sleep-gauge-bar {
  height: 100%;
  width: 0;
  border-radius: 6px;
  transition: width 1s ease-in-out;
}

.bv-sleep-gauge-bar-caffeine {
  background: linear-gradient(90deg, var(--sleep-primary), #60a5fa);
}

.bv-sleep-gauge-bar-alcohol {
  background: linear-gradient(90deg, var(--sleep-accent), #f472b6);
}

/* Chart Container */
.bv-sleep-chart-container {
  position: relative;
  height: 300px;
  width: 100%;
  margin: 24px 0;
  padding: 16px;
  background: white;
  border-radius: 12px;
  border: 1px solid var(--sleep-border);
}

#impact-chart {
  width: 100% !important;
  height: 100% !important;
}

/* Recommendations */
.bv-sleep-recommendations {
  margin-top: 20px;
}

.bv-sleep-recommendations:empty {
  display: none;
}

.bv-sleep-recommendations ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.bv-sleep-recommendations li {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 500;
}

.bv-sleep-recommendations li.success {
  background: rgba(34, 197, 94, 0.1);
  color: #166534;
  border-left: 4px solid var(--sleep-success);
}

.bv-sleep-recommendations li.warn {
  background: rgba(245, 158, 11, 0.1);
  color: #92400e;
  border-left: 4px solid var(--sleep-warning);
}

.bv-sleep-recommendations li.danger {
  background: rgba(239, 68, 68, 0.1);
  color: #991b1b;
  border-left: 4px solid var(--sleep-danger);
}

.bv-sleep-recommendations .bv-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
}

/* Modal Styling */
.bv-sleep-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
  z-index: 1000;
}

.bv-sleep-modal-overlay.visible {
  opacity: 1;
  visibility: visible;
}

.bv-sleep-modal-content {
  background: var(--sleep-card);
  padding: 24px;
  border-radius: 16px;
  width: 90%;
  max-width: 500px;
  position: relative;
  transform: translateY(-20px);
  transition: transform 0.3s;
  max-height: 90vh;
  overflow-y: auto;
}

.bv-sleep-modal-overlay.visible .bv-sleep-modal-content {
  transform: translateY(0);
}

.bv-sleep-modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  font-size: 24px;
  color: var(--sleep-text-secondary);
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.bv-sleep-modal-close:hover {
  background: rgba(239, 68, 68, 0.1);
  color: var(--sleep-danger);
}

.bv-sleep-modal-content h2 {
  color: var(--sleep-primary);
  margin-bottom: 20px;
  font-size: 1.5rem;
}

.bv-sleep-modal-form .bv-sleep-form-group {
  margin-bottom: 16px;
}

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

  .bv-tool-title {
    font-size: 1.8rem;
  }

  .bv-tool-stats {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .bv-sleep-wrapper {
    gap: 16px;
  }

  .bv-sleep-card {
    padding: 16px;
  }

  .bv-sleep-form-grid {
    grid-template-columns: 1fr;
  }

  .bv-sleep-inline-group {
    flex-direction: column;
    gap: 0;
  }

  .bv-sleep-buttons-row {
    flex-direction: column;
  }

  .bv-sleep-btn {
    flex-grow: 0;
  }

  .bv-sleep-entries-list li {
    flex-direction: column;
    gap: 8px;
    text-align: center;
  }

  .bv-sleep-chart-container {
    height: 250px;
    padding: 12px;
  }

  .bv-sleep-gauges-container {
    gap: 12px;
  }
}

@media (max-width: 480px) {
  .bv-tool-container {
    margin: 0.5rem;
    padding: 1rem;
  }

  .bv-sleep-card {
    padding: 12px;
  }

  .bv-sleep-modal-content {
    padding: 16px;
    margin: 16px;
  }

  .bv-tool-stats {
    gap: 0.5rem;
  }
}

/* Animations */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.bv-sleep-entries-list li {
  animation: fadeInUp 0.3s ease;
}

/* Print Styles */
@media print {
  .bv-sleep-buttons-row,
  .bv-sleep-btn-calculate,
  .bv-sleep-modal-overlay {
    display: none !important;
  }
}

/* High Contrast Support */
@media (prefers-contrast: high) {
  :root {
    --sleep-border: #000000;
    --sleep-text: #000000;
  }

  .bv-sleep-card {
    border: 2px solid var(--sleep-border);
  }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  .bv-sleep-btn,
  .bv-sleep-gauge-bar,
  .bv-sleep-form-group input,
  .bv-sleep-select,
  .bv-sleep-entries-list li {
    transition: none;
  }

  .bv-sleep-modal-overlay,
  .bv-sleep-modal-content {
    transition: none;
  }

  .bv-sleep-entries-list li {
    animation: none;
  }
}