/* Emotions Log — app-specific styles (tokens from css/theme.css) */

.emotions-app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.emotions-app #main-content {
  flex: 1;
  padding: 0;
}

/* Header */
.emotions-header {
  padding: 0 0 0.75rem;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 0.75rem;
}

.emotions-header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.emotions-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.emotions-icon {
  font-size: 1.75rem;
  line-height: 1;
  flex-shrink: 0;
}

.emotions-header h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-primary);
  letter-spacing: -0.02em;
}

.emotions-header .subtitle {
  margin: 0.15rem 0 0;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.emotions-header .theme-toggle {
  position: static;
  flex-shrink: 0;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 0.35rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 0.3rem;
  margin-bottom: 1rem;
}

.tab {
  flex: 1;
  padding: 0.7rem 0.5rem;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  min-height: var(--min-touch);
}

.tab:hover {
  color: var(--color-text);
  background: var(--color-surface-hover);
}

.tab:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

.tab.active {
  background: var(--color-primary);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

/* Views */
.view { display: none; }
.view.active { display: block; }
.view[hidden] { display: none !important; }

/* List toolbar */
.list-toolbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.list-toolbar input[type="search"],
.list-toolbar select,
input[type="text"],
input[type="datetime-local"],
input[type="search"],
textarea,
select {
  width: 100%;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface-raised);
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--color-text);
  margin-bottom: 0;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.list-toolbar input[type="search"] {
  grid-column: 1 / -1;
}

.list-toolbar select {
  min-width: 8.5rem;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--color-teal);
  box-shadow: var(--focus-ring);
}

input[aria-invalid="true"],
select[aria-invalid="true"] {
  border-color: var(--color-danger);
  box-shadow: 0 0 0 3px var(--color-danger-light);
}

/* Entry cards */
.entries-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.entries-list > li {
  margin: 0;
  padding: 0;
}

.entry-card {
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-teal);
  border-radius: var(--radius);
  padding: 1rem 1rem 1rem 0.9rem;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}

.entry-card:hover,
.entry-card:focus-visible {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
  border-color: var(--color-teal);
  outline: none;
}

.entry-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}

.entry-emotion {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-text);
  margin: 0;
}

.entry-datetime {
  display: block;
  font-size: 0.78rem;
  color: var(--color-text-muted);
  margin-top: 0.15rem;
}

.strength-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.5rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.strength-1 { background: var(--color-teal-dark); }
.strength-2 { background: var(--color-teal); }
.strength-3 { background: var(--color-accent); color: var(--color-text); }
.strength-4 { background: var(--color-secondary); }
.strength-5 { background: var(--color-primary); }

.entry-card.strength-1 { border-left-color: var(--color-teal-dark); }
.entry-card.strength-2 { border-left-color: var(--color-teal); }
.entry-card.strength-3 { border-left-color: var(--color-accent); }
.entry-card.strength-4 { border-left-color: var(--color-secondary); }
.entry-card.strength-5 { border-left-color: var(--color-primary); }

.entry-preview {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--color-text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.empty-state {
  text-align: center;
  padding: 3rem 1.25rem;
  color: var(--color-text-muted);
  background: var(--color-bg);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-lg);
  line-height: 1.6;
}

/* Form */
.field-group {
  border: none;
  margin: 0 0 1rem;
  padding: 1rem;
  background: var(--color-bg);
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
}

.field-group legend {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-primary);
  margin-bottom: 0.75rem;
  padding: 0;
}

label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--color-text);
}

.field-hint {
  margin: 0.35rem 0 0.75rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  line-height: 1.4;
}

.field-error {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  color: var(--color-danger);
  font-weight: 600;
}

.required-mark {
  color: var(--color-danger);
}

.emotion-custom-panel {
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.85rem;
  margin: 0.5rem 0 0.85rem;
}

.emotion-custom-row {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}

.emotion-custom-row input {
  flex: 1;
}

.emotion-custom-row .btn {
  flex-shrink: 0;
}

textarea {
  resize: vertical;
  min-height: 4.5rem;
  margin-bottom: 0.75rem;
}

input:not([type="range"]),
select,
textarea {
  margin-bottom: 0.75rem;
}

.strength-output {
  display: block;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 0.25rem;
}

.strength-input input[type="range"] {
  width: 100%;
  margin: 0.35rem 0;
  accent-color: var(--color-primary);
}

.strength-scale {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

/* Buttons — base styles from css/theme.css; app-specific variants below */

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
  padding-bottom: 0.5rem;
}

.form-actions .btn-primary {
  flex: 1;
  min-width: 8rem;
}

.btn-link {
  background: none;
  border: none;
  color: var(--color-primary);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  padding: 0.5rem;
  min-height: var(--min-touch);
}

.btn-icon {
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 0.5rem;
  min-width: var(--min-touch);
  min-height: var(--min-touch);
  border-radius: var(--radius-sm);
}

/* Detail dialog */
.detail-dialog {
  border: none;
  border-radius: var(--radius-lg);
  padding: 0;
  max-width: calc(100vw - 2rem);
  width: 100%;
  max-height: calc(100dvh - 2rem);
  background: var(--color-surface);
  box-shadow: var(--shadow);
}

.detail-dialog::backdrop {
  background: var(--color-overlay);
}

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.15rem;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-raised);
}

.detail-header h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-text);
}

.detail-content {
  padding: 1.15rem;
  overflow-y: auto;
  max-height: calc(100dvh - 12rem);
}

.detail-section {
  margin-bottom: 1rem;
  padding: 0.85rem;
  background: var(--color-bg);
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
}

.detail-section h3 {
  margin: 0 0 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-primary);
}

.detail-section p {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.5;
  white-space: pre-wrap;
  color: var(--color-text);
}

.detail-section.hidden-consequences {
  background: var(--color-danger-light);
  border-left: 3px solid var(--color-danger);
}

.detail-actions {
  display: flex;
  gap: 0.5rem;
  padding: 1rem 1.15rem;
  border-top: 1px solid var(--color-border);
}

.detail-actions .btn {
  flex: 1;
}

/* Footer */
.footer {
  text-align: center;
  padding: 1.25rem 0 0.5rem;
  margin-top: auto;
  border-top: 1px solid var(--color-border);
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.footer p {
  margin: 0 0 0.35rem;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
}

/* Reports */
.report-toolbar {
  margin-bottom: 1rem;
  padding: 1rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.65rem;
  margin-bottom: 1.25rem;
  list-style: none;
  padding: 0;
}

.stat-card {
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem 0.75rem;
  text-align: center;
}

.stat-value {
  display: block;
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--color-primary);
  line-height: 1.2;
}

.stat-label {
  display: block;
  font-size: 0.72rem;
  color: var(--color-text-muted);
  margin-top: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.report-section {
  margin-bottom: 1.5rem;
}

.report-heading {
  margin: 0 0 0.65rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-text);
}

.insights-list {
  margin: 0;
  padding: 0 0 0 1.1rem;
  color: var(--color-text);
  line-height: 1.5;
}

.chart-card {
  margin: 0;
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem;
}

.chart-card figcaption {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-bottom: 0.75rem;
}

.bar-chart {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.bar-row {
  display: grid;
  grid-template-columns: 5.5rem 1fr 2rem;
  align-items: center;
  gap: 0.5rem;
}

.bar-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--color-text);
}

.bar-track {
  height: 1.2rem;
  background: var(--color-bg);
  border-radius: 4px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: 4px;
  min-width: 2px;
  transition: width 0.3s ease;
}

.bar-fill.strength-1 { background: var(--color-teal-dark); }
.bar-fill.strength-2 { background: var(--color-teal); }
.bar-fill.strength-3 { background: var(--color-accent); }
.bar-fill.strength-4 { background: var(--color-secondary); }
.bar-fill.strength-5 { background: var(--color-primary); }

.bar-value {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--color-text-muted);
  text-align: right;
}

.table-wrap {
  overflow-x: auto;
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.report-table th,
.report-table td {
  padding: 0.65rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

.report-table th {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  background: var(--color-bg);
}

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

.hidden {
  display: none !important;
}

@media (min-width: 480px) {
  .emotions-header h1 {
    font-size: 1.45rem;
  }

  .tab {
    font-size: 0.92rem;
  }

  .stat-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media print {
  .skip-link,
  .tabs,
  .footer,
  .theme-toggle {
    display: none !important;
  }

  .view[hidden] {
    display: none !important;
  }

  #reports-view {
    display: block !important;
  }
}
