/* DBT Skills Workbook Styles */

@import url('https://fonts.googleapis.com/css2?family=Atkinson+Hyperlegible:wght@400;700&family=Fraunces:opsz,wght@9..144,700&display=swap');

:root {
  --distress-tolerance: #E74C3C;
  --mindfulness: #3498DB;
  --emotion-regulation: #9B59B6;
  --interpersonal-effectiveness: #2ECC71;
}

.subtitle {
  font-size: 0.9em;
  color: #666;
  margin-top: 4px;
  font-weight: normal;
}

/* Progress Summary */
.progress-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.stat-card {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 1.5rem;
  border-radius: 12px;
  text-align: center;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.stat-number {
  font-size: 2.5rem;
  font-weight: bold;
  margin-bottom: 0.5rem;
}

.stat-label {
  font-size: 0.9rem;
  opacity: 0.9;
}

/* Modules Grid */
.modules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
  margin-top: 1rem;
}

.module-card {
  background: white;
  border: 2px solid #eee;
  border-radius: 12px;
  padding: 1.5rem;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.module-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}

.module-card.distress_tolerance {
  border-left: 4px solid var(--distress-tolerance);
}

.module-card.mindfulness {
  border-left: 4px solid var(--mindfulness);
}

.module-card.emotion_regulation {
  border-left: 4px solid var(--emotion-regulation);
}

.module-card.interpersonal_effectiveness {
  border-left: 4px solid var(--interpersonal-effectiveness);
}

.module-icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.module-name {
  font-size: 1.2rem;
  font-weight: bold;
  margin-bottom: 0.5rem;
  color: #333;
}

.module-description {
  font-size: 0.9rem;
  color: #666;
  line-height: 1.4;
  margin-bottom: 1rem;
}

.module-stats {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: #888;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #eee;
}

/* Module Filter */
.module-filter {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 0.5rem 1rem;
  border: 2px solid #ddd;
  background: white;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.9rem;
}

.filter-btn:hover {
  background: #f0f0f0;
}

.filter-btn.active {
  background: #667eea;
  color: white;
  border-color: #667eea;
}

/* Skills List */
.skill-card {
  background: white;
  border: 1px solid #eee;
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1rem;
  cursor: pointer;
  transition: all 0.3s;
}

.skill-card:hover {
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.skill-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  margin-bottom: 0.5rem;
}

.skill-title {
  font-size: 1.2rem;
  font-weight: bold;
  color: #333;
}

.skill-acronym {
  background: #667eea;
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: bold;
}

.skill-description {
  color: #666;
  line-height: 1.5;
  margin-bottom: 1rem;
}

.skill-meta {
  display: flex;
  gap: 1rem;
  font-size: 0.85rem;
  color: #888;
}

.skill-badge {
  background: #f0f0f0;
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
}

/* Modals */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.5);
  animation: fadeIn 0.3s;
}

.modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  background-color: white;
  margin: auto;
  border-radius: 12px;
  width: 90%;
  max-width: 800px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.3s;
}

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

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  border-bottom: 1px solid #eee;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.5rem;
}

.close-btn {
  background: none;
  border: none;
  font-size: 2rem;
  cursor: pointer;
  color: #999;
  line-height: 1;
  padding: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s;
}

.close-btn:hover {
  background: #f0f0f0;
  color: #333;
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

/* Exercise Cards */
.exercise-card {
  background: #f9f9f9;
  border: 1px solid #eee;
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
  cursor: pointer;
  transition: all 0.2s;
}

.exercise-card:hover {
  background: #f0f0f0;
}

.exercise-card.completed {
  background: #e8f5e9;
  border-color: #4caf50;
}

.exercise-title {
  font-weight: bold;
  margin-bottom: 0.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.exercise-type {
  font-size: 0.75rem;
  background: #667eea;
  color: white;
  padding: 0.25rem 0.5rem;
  border-radius: 8px;
}

.completion-badge {
  font-size: 0.75rem;
  background: #4caf50;
  color: white;
  padding: 0.25rem 0.5rem;
  border-radius: 8px;
}

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

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: #333;
}

.form-group input[type="text"],
.form-group input[type="date"],
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
}

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

.form-group input[type="range"] {
  width: calc(100% - 50px);
  margin-right: 10px;
}

.form-actions {
  display: flex;
  gap: 1rem;
  margin-top: 2rem;
}

/* Buttons */
.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}

.btn-primary {
  background: #667eea;
  color: white;
}

.btn-primary:hover {
  background: #5568d3;
}

.btn-secondary {
  background: #e0e0e0;
  color: #333;
}

.btn-secondary:hover {
  background: #d0d0d0;
}

.btn-back {
  background: none;
  border: 1px solid #ddd;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 1rem;
}

.btn-back:hover {
  background: #f0f0f0;
}

/* Key Points List */
.key-points {
  margin: 1rem 0;
}

.key-points ul {
  list-style: none;
  padding: 0;
}

.key-points li {
  padding: 0.5rem 0;
  padding-left: 1.5rem;
  position: relative;
}

.key-points li:before {
  content: "✓";
  position: absolute;
  left: 0;
  color: #667eea;
  font-weight: bold;
}

/* Checklist */
.checklist-item {
  padding: 0.75rem;
  background: #f9f9f9;
  border-radius: 8px;
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: all 0.2s;
}

.checklist-item:hover {
  background: #f0f0f0;
}

.checklist-item input[type="checkbox"] {
  margin-right: 0.75rem;
}

.checklist-item.checked {
  background: #e8f5e9;
}

/* Progress Bars */
.progress-bar-container {
  margin-bottom: 1.5rem;
}

.progress-bar-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.progress-bar {
  height: 24px;
  background: #f0f0f0;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
  transition: width 0.5s ease;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 0.5rem;
  color: white;
  font-size: 0.85rem;
  font-weight: bold;
}

/* Practice Log Cards */
.log-card {
  background: white;
  border: 1px solid #eee;
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.log-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #eee;
}

.log-date {
  font-weight: bold;
  color: #333;
}

.log-rating {
  background: #667eea;
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.85rem;
}

.log-content {
  color: #666;
  line-height: 1.5;
}

.log-meta {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid #eee;
  font-size: 0.85rem;
  color: #888;
}

/* Welcome Card */
.welcome-card {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.welcome-card h2 {
  color: white;
  margin-bottom: 1rem;
}

.welcome-card p {
  line-height: 1.6;
  opacity: 0.95;
}

/* Responsive */
@media (max-width: 768px) {
  .modules-grid {
    grid-template-columns: 1fr;
  }

  .progress-stats {
    grid-template-columns: 1fr;
  }

  .modal-content {
    width: 95%;
    max-height: 95vh;
  }

  .form-actions {
    flex-direction: column;
  }

  .btn {
    width: 100%;
  }
}

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

.loading:after {
  content: '...';
  animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
  0%, 20% {
    content: '.';
  }
  40% {
    content: '..';
  }
  60%, 100% {
    content: '...';
  }
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: #999;
}

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

/* Toast Notifications */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #333;
  color: white;
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  z-index: 10000;
  opacity: 0;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast-success {
  background: #2e7d32;
}

.toast-error {
  background: #c62828;
}

.toast-icon {
  font-weight: bold;
  font-size: 1.2rem;
}

/* Session Banner */
.session-banner {
  background: linear-gradient(90deg, #667eea, #764ba2);
  color: white;
  padding: 0.75rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

.session-banner-content {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.session-banner-content span:first-child {
  font-size: 0.95rem;
}

.session-banner-content span:last-child {
  font-size: 0.8rem;
  opacity: 0.9;
}

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
}

/* Workbook Navigation */
.workbook-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  margin-bottom: 1rem;
  border-bottom: 1px solid #eee;
}

.workbook-progress {
  font-size: 0.9rem;
  color: #667eea;
  font-weight: 500;
}

.workbook-nav .btn {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
}

/* =========================
   Focus Mode Worksheet Runner
   ========================= */

.focus-runner {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: none;
  background:
    radial-gradient(1100px 820px at 18% -10%, rgba(182, 255, 74, 0.20), transparent 55%),
    radial-gradient(900px 720px at 92% 12%, rgba(255, 77, 109, 0.16), transparent 58%),
    radial-gradient(900px 700px at 50% 112%, rgba(0, 199, 255, 0.12), transparent 62%),
    linear-gradient(180deg, #070a12 0%, #0b1020 100%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.035) 0px, rgba(255, 255, 255, 0.035) 1px, transparent 1px, transparent 7px),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.020) 0px, rgba(255, 255, 255, 0.020) 1px, transparent 1px, transparent 7px);
}

.focus-runner.active {
  display: block;
}

.focus-shell {
  width: min(760px, 100%);
  height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: calc(14px + env(safe-area-inset-top)) calc(14px + env(safe-area-inset-right)) calc(14px + env(safe-area-inset-bottom)) calc(14px + env(safe-area-inset-left));
  font-family: 'Atkinson Hyperlegible', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: rgba(255, 255, 255, 0.92);
}

.focus-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.75rem 0.75rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.10);
  backdrop-filter: blur(10px);
}

.focus-nav-btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(10, 12, 18, 0.35);
  color: rgba(255, 255, 255, 0.92);
  border-radius: 12px;
  padding: 0.55rem 0.75rem;
  font-weight: 700;
  letter-spacing: 0.2px;
  transition: transform 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}

.focus-nav-btn:active {
  transform: translateY(1px);
}

.focus-nav-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.22);
}

.focus-danger {
  border-color: rgba(255, 77, 109, 0.35);
}

.focus-danger:hover {
  background: rgba(255, 77, 109, 0.14);
  border-color: rgba(255, 77, 109, 0.55);
}

.focus-title {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.focus-exercise-title {
  font-family: 'Fraunces', ui-serif, Georgia, serif;
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.focus-skill-title {
  font-size: 0.88rem;
  color: rgba(255, 255, 255, 0.75);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.focus-progress {
  margin-top: 0.75rem;
  padding: 0.75rem 0.85rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.10);
}

.focus-progress-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: baseline;
}

.focus-step-label {
  font-weight: 700;
  letter-spacing: 0.2px;
}

.focus-time-estimate {
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.72);
}

.focus-progress-bar {
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 0.6rem;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.10);
}

.focus-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, rgba(182, 255, 74, 0.95), rgba(0, 199, 255, 0.85));
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12) inset;
  transition: width 0.25s ease;
}

.focus-main {
  flex: 1;
  overflow: auto;
  padding: 0.9rem 0 1rem 0;
}

.focus-card {
  border-radius: 18px;
  background: rgba(246, 241, 232, 0.96);
  color: #0b1020;
  border: 1px solid rgba(255, 255, 255, 0.40);
  box-shadow:
    0 14px 40px rgba(0, 0, 0, 0.35),
    0 0 0 1px rgba(0, 0, 0, 0.06) inset;
  padding: 1.1rem;
}

.focus-question-label {
  font-family: 'Fraunces', ui-serif, Georgia, serif;
  font-size: 1.35rem;
  line-height: 1.15;
  margin: 0 0 0.75rem 0;
}

.focus-instructions {
  padding: 0.75rem 0.85rem;
  border-radius: 14px;
  background: rgba(182, 255, 74, 0.16);
  border: 1px solid rgba(11, 16, 32, 0.18);
  color: rgba(11, 16, 32, 0.82);
  margin-bottom: 0.85rem;
  font-size: 0.98rem;
}

.focus-help {
  padding: 0.75rem 0.85rem;
  border-radius: 14px;
  background: rgba(11, 16, 32, 0.06);
  border: 1px dashed rgba(11, 16, 32, 0.18);
  color: rgba(11, 16, 32, 0.78);
  margin-bottom: 0.85rem;
}

.focus-examples,
.focus-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

.focus-chip {
  appearance: none;
  border: 1px solid rgba(11, 16, 32, 0.18);
  background: rgba(255, 255, 255, 0.75);
  color: rgba(11, 16, 32, 0.88);
  border-radius: 999px;
  padding: 0.5rem 0.75rem;
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1;
  transition: transform 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}

.focus-chip:hover {
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(11, 16, 32, 0.28);
}

.focus-chip:active {
  transform: translateY(1px);
}

.focus-chip.focus-chip-example {
  border-style: dashed;
  font-weight: 600;
}

.focus-input input[type="text"],
.focus-input textarea {
  width: 100%;
  font-size: 1.05rem;
  padding: 0.9rem 0.9rem;
  border-radius: 14px;
  border: 1px solid rgba(11, 16, 32, 0.20);
  background: rgba(255, 255, 255, 0.90);
  color: #0b1020;
  outline: none;
}

.focus-input textarea {
  min-height: 140px;
  resize: vertical;
  line-height: 1.45;
}

.focus-input input[type="text"]:focus,
.focus-input textarea:focus {
  border-color: rgba(11, 16, 32, 0.45);
  box-shadow: 0 0 0 4px rgba(182, 255, 74, 0.24);
}

.focus-checklist {
  display: grid;
  gap: 0.6rem;
}

.focus-checklist label {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.85rem 0.85rem;
  border-radius: 14px;
  border: 1px solid rgba(11, 16, 32, 0.14);
  background: rgba(255, 255, 255, 0.78);
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.focus-checklist label:hover {
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(11, 16, 32, 0.22);
}

.focus-checklist input[type="checkbox"] {
  margin-top: 0.15rem;
}

.focus-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  padding-top: 0.75rem;
}

.focus-actions .btn {
  width: 100%;
}

.focus-complete {
  margin-top: 1rem;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.10);
  padding: 1.1rem;
}

.focus-complete-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 800;
  letter-spacing: 0.2px;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: rgba(182, 255, 74, 0.16);
  border: 1px solid rgba(182, 255, 74, 0.28);
}

.focus-complete-title {
  margin-top: 0.8rem;
  font-family: 'Fraunces', ui-serif, Georgia, serif;
  font-size: 1.6rem;
  line-height: 1.1;
}

.focus-complete-subtitle {
  margin-top: 0.4rem;
  color: rgba(255, 255, 255, 0.76);
}

.focus-complete-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  margin-top: 1rem;
}

@media (min-width: 520px) {
  .focus-complete-actions {
    grid-template-columns: 1fr 1fr;
  }
}

.workbook-nav .btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

@media (max-width: 480px) {
  .session-banner {
    flex-direction: column;
    gap: 0.75rem;
    text-align: center;
  }

  .workbook-nav {
    flex-direction: column;
    gap: 0.75rem;
  }

  .workbook-progress {
    order: -1;
  }
}
