/*
 * This is a manifest file that'll be compiled into application.css.
 */

/* ===========================
   Dictation — Application Styles
   =========================== */

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

:root {
  --color-primary: #4f46e5;
  --color-primary-hover: #4338ca;
  --color-primary-light: #eef2ff;
  --color-danger: #dc2626;
  --color-success: #16a34a;
  --color-success-light: #dcfce7;
  --color-danger-light: #fee2e2;
  --color-text: #111827;
  --color-text-muted: #6b7280;
  --color-border: #e5e7eb;
  --color-bg: #f9fafb;
  --color-white: #ffffff;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
}

/* ===========================
   Flash messages
   =========================== */

.flash {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 16px;
}

.flash--notice {
  background: var(--color-success-light);
  color: var(--color-success);
  border: 1px solid #bbf7d0;
}

.flash--alert {
  background: var(--color-danger-light);
  color: var(--color-danger);
  border: 1px solid #fecaca;
}

/* ===========================
   Buttons
   =========================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  font-size: 15px;
  font-weight: 500;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  line-height: 1;
}

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

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

.btn--ghost {
  background: transparent;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}

.btn--ghost:hover {
  background: var(--color-border);
  color: var(--color-text);
}

.btn--full {
  width: 100%;
}

.btn--sm {
  padding: 6px 12px;
  font-size: 13px;
}

/* ===========================
   Auth page (login)
   =========================== */

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-md);
}

.auth-header {
  text-align: center;
  margin-bottom: 32px;
}

.auth-logo {
  font-size: 28px;
  font-weight: 700;
  color: var(--color-primary);
  letter-spacing: -0.5px;
}

.auth-subtitle {
  margin-top: 4px;
  color: var(--color-text-muted);
  font-size: 14px;
}

.auth-form .form-group {
  margin-bottom: 20px;
}

.auth-form label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--color-text);
}

.auth-form input[type="email"],
.auth-form input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 15px;
  color: var(--color-text);
  background: var(--color-white);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.auth-form input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.auth-form .btn--primary {
  margin-top: 8px;
}

/* ===========================
   App shell (sidebar layout)
   =========================== */

.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ===========================
   Sidebar
   =========================== */

.app-sidebar {
  width: 240px;
  min-height: 100vh;
  height: 100vh;
  position: sticky;
  top: 0;
  background: var(--color-white);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  transition: width 0.2s ease;
  z-index: 20;
}

.app-sidebar--collapsed {
  width: 64px;
}

.app-sidebar__brand {
  height: 60px;
  display: flex;
  align-items: center;
  padding: 0 20px;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
  overflow: hidden;
  white-space: nowrap;
}

.app-sidebar__brand-text {
  font-size: 18px;
  font-weight: 700;
  color: var(--color-primary);
  letter-spacing: -0.3px;
  opacity: 1;
  transition: opacity 0.15s ease;
}

.app-sidebar--collapsed .app-sidebar__brand-text {
  opacity: 0;
}

.app-sidebar__nav {
  list-style: none;
  padding: 12px 8px;
  flex: 1;
  overflow: hidden;
}

.app-sidebar__nav li + li {
  margin-top: 2px;
}

.app-sidebar__link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--color-text-muted);
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
  overflow: hidden;
}

.app-sidebar__link:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

.app-sidebar__link--active {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.app-sidebar__icon {
  flex-shrink: 0;
}

.app-sidebar__label {
  font-size: 14px;
  font-weight: 500;
  opacity: 1;
  transition: opacity 0.15s ease;
}

.app-sidebar--collapsed .app-sidebar__label {
  opacity: 0;
}

.app-sidebar__toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 48px;
  border: none;
  border-top: 1px solid var(--color-border);
  background: transparent;
  cursor: pointer;
  color: var(--color-text-muted);
  transition: background 0.15s ease, color 0.15s ease;
  flex-shrink: 0;
}

.app-sidebar__toggle:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

.app-sidebar__toggle-icon--collapse {
  display: none;
}

.app-sidebar--collapsed .app-sidebar__toggle-icon--expand {
  display: none;
}

.app-sidebar--collapsed .app-sidebar__toggle-icon--collapse {
  display: block;
}

/* ===========================
   App content area
   =========================== */

.app-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.app-header {
  background: var(--color-white);
  border-bottom: 1px solid var(--color-border);
  padding: 0 24px;
  height: 60px;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: var(--shadow);
  flex-shrink: 0;
}

.app-header__inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.app-header__nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-header__user {
  font-size: 14px;
  color: var(--color-text-muted);
}

.app-main {
  flex: 1;
  padding: 32px 24px;
}

/* ===========================
   Instructions panel
   =========================== */

.instructions-panel {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.instructions-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
}

.instructions-toolbar__title {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text);
}

.panel-footer {
  display: flex;
  justify-content: flex-end;
  padding: 12px 20px;
  border-top: 1px solid var(--color-border);
}

.search-form {
  flex: 1;
  max-width: 360px;
}

.search-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--color-text);
  background: var(--color-bg);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
  background: var(--color-white);
}

/* ===========================
   Data table
   =========================== */

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

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table thead th {
  text-align: left;
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}

.data-table tbody tr {
  border-bottom: 1px solid var(--color-border);
}

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

.data-table tbody tr:hover {
  background: var(--color-bg);
}

.data-table td {
  padding: 14px 16px;
  color: var(--color-text);
  vertical-align: top;
}

.td--name {
  font-weight: 500;
}

.td--description {
  color: var(--color-text-muted);
  max-width: 320px;
}

.td--date {
  white-space: nowrap;
  color: var(--color-text-muted);
}

/* ===========================
   Badges
   =========================== */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.badge--processing {
  background: #fef9c3;
  color: #854d0e;
}

.badge--processed {
  background: var(--color-success-light);
  color: var(--color-success);
}

.badge--transcription_error {
  background: var(--color-danger-light);
  color: var(--color-danger);
}

/* ===========================
   Pagination
   =========================== */

.pagination {
  display: flex;
  justify-content: center;
  padding: 16px;
  border-top: 1px solid var(--color-border);
}

.pagy {
  display: flex;
  align-items: center;
  gap: 4px;
  list-style: none;
}

.pagy a,
.pagy span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  color: var(--color-text-muted);
  border: 1px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.pagy a:hover {
  background: var(--color-bg);
  border-color: var(--color-border);
  color: var(--color-text);
}

.pagy .current {
  background: var(--color-primary);
  color: var(--color-white);
  border-color: var(--color-primary);
}

.pagy .disabled {
  opacity: 0.4;
  cursor: default;
}

/* ===========================
   Empty state
   =========================== */

.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 14px;
}

/* ===========================
   New instruction page
   =========================== */

.page-header {
  margin-bottom: 24px;
}

.page-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--color-text);
}

.form-card {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 32px;
  max-width: 640px;
  box-shadow: var(--shadow);
}

.form-group {
  margin-bottom: 24px;
}

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--color-text);
}

.form-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 15px;
  color: var(--color-text);
  background: var(--color-white);
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

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

.form-hint {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-bottom: 6px;
}

.form-file {
  display: block;
  width: 100%;
  font-size: 14px;
  color: var(--color-text);
  padding: 8px 0;
}

.file-preview {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px;
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  margin-bottom: 10px;
}

.file-preview__image {
  max-height: 64px;
  max-width: 160px;
  object-fit: contain;
  border-radius: 4px;
}

.file-preview__hint {
  font-size: 12px;
  color: var(--color-text-muted);
  margin: 0;
}

.form-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 16px;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 8px;
}

.field-error {
  display: block;
  margin-top: 4px;
  font-size: 13px;
  color: var(--color-danger);
}

.form-input--error {
  border-color: var(--color-danger);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

.form-file--error {
  outline: 2px solid var(--color-danger);
  border-radius: var(--radius);
}

.error-list {
  margin-top: 8px;
  padding-left: 20px;
}

.error-list li {
  font-size: 14px;
  margin-top: 4px;
}

/* ===========================
   Table link
   =========================== */

.th--actions,
.td--actions {
  text-align: right;
  white-space: nowrap;
}

.inline-code {
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 13px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 2px 6px;
  color: var(--color-text);
}

.form-input--mono {
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 14px;
}

.form-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-checkbox {
  width: 16px;
  height: 16px;
  accent-color: var(--color-primary);
  cursor: pointer;
}

.form-label--inline {
  margin-bottom: 0;
  cursor: pointer;
}

.page-header--with-actions {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
}

.detail-block-section {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--color-border);
}

.detail-block-section__label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin-bottom: 8px;
}

.code-block {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--color-text);
  overflow-x: auto;
}

.table-link {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 500;
}

.table-link:hover {
  text-decoration: underline;
}

/* ===========================
   Instruction show page
   =========================== */

.show-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}

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

.show-stack {
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.detail-card {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
}

.detail-card.detail-card--collapsible {
  padding: 0;
}

.detail-card__title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--color-border);
}

.detail-card--collapsible {
  padding: 0;
}

.detail-card__summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 28px;
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text);
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s ease;
}

.detail-card__summary::-webkit-details-marker { display: none; }

.detail-card__summary::after {
  content: "";
  display: inline-block;
  width: 16px;
  height: 16px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: contain;
  transition: transform 0.2s ease;
}

details[open] > .detail-card__summary::after {
  transform: rotate(180deg);
}

details[open] > .detail-card__summary {
  border-bottom-color: var(--color-border);
}

.detail-card__body {
  padding: 24px 28px;
}

.detail-card__footer {
  padding: 20px 28px;
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: flex-end;
}

/* ===========================
   Collapsible sub-section
   =========================== */

.collapsible-section {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  margin-bottom: 20px;
  overflow: hidden;
}

.collapsible-section__summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
  cursor: pointer;
  user-select: none;
  background: var(--color-bg);
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s ease;
}

.collapsible-section__summary::-webkit-details-marker { display: none; }

.collapsible-section__summary::after {
  content: "";
  display: inline-block;
  width: 14px;
  height: 14px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: contain;
  transition: transform 0.2s ease;
}

details[open] > .collapsible-section__summary::after {
  transform: rotate(180deg);
}

details[open] > .collapsible-section__summary {
  border-bottom-color: var(--color-border);
}

.collapsible-section__body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.collapsible-section__empty {
  font-size: 14px;
  color: var(--color-text-muted);
}

.collapsible-section__count {
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-muted);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 1px 8px;
  margin-left: auto;
  margin-right: 8px;
}

.collapsible-section--nested {
  margin-top: 16px;
  margin-bottom: 0;
}

/* ===========================
   Checkbox row
   =========================== */

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 14px;
}

.checkbox-row__label {
  flex: 1;
  font-weight: 500;
  color: var(--color-text);
}

/* ===========================
   Transform result
   =========================== */

.transform-result {
  display: block;
  width: 100%;
  padding: 16px;
  margin-top: 1px;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-bg);
  border: none;
  border-top: 1px solid var(--color-border);
  border-radius: 0 0 var(--radius) var(--radius);
  resize: vertical;
  min-height: 200px;
  outline: none;
}

.detail-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.detail-list__row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 8px;
  font-size: 14px;
}

.detail-list__row dt {
  font-weight: 500;
  color: var(--color-text-muted);
}

.detail-list__row dd {
  color: var(--color-text);
  word-break: break-word;
}

.detail-list__inline-group {
  display: flex;
  gap: 32px;
  flex-wrap: wrap;
}

.detail-list__inline-group .detail-list__row {
  flex: 1 1 auto;
  grid-template-columns: auto;
  min-width: 120px;
}

@media (max-width: 600px) {
  .detail-list__inline-group {
    flex-direction: column;
    gap: 14px;
  }
}

.transcription-meta {
  margin-bottom: 16px;
}

.transcription-meta__label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin-bottom: 2px;
}

.transcription-meta__value {
  font-size: 15px;
  font-weight: 500;
  color: var(--color-text);
}

.transcription-status-message {
  font-size: 14px;
  color: var(--color-text-muted);
  margin-bottom: 16px;
  line-height: 1.6;
}

.transcription-status-message--error {
  color: var(--color-danger);
}

.transcription-status-message--success {
  color: var(--color-success);
}

.error-box {
  background: var(--color-danger-light);
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 13px;
  color: var(--color-danger);
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

.transcribed-text-box {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.transcribed-text-box--unsaved {
  border-color: var(--color-danger);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

.transcribed-text-box__toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}

.transcribed-text-box__unsaved {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-danger);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.transcribed-text-box__content {
  display: block;
  width: 100%;
  padding: 16px;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--color-text);
  background: var(--color-white);
  max-height: 400px;
  overflow-y: auto;
  border: none;
  resize: vertical;
  outline: none;
}

.transcribed-text-box__save-bar {
  display: flex;
  justify-content: flex-end;
  padding: 10px 12px;
  border-top: 1px solid var(--color-border);
  background: var(--color-bg);
}

/* ===========================
   React component: StatusWidget
   =========================== */

.status-widget {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.status-widget__title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin-bottom: 8px;
}

.status-widget__value {
  font-size: 18px;
  font-weight: 600;
  color: var(--color-text);
}

.status-widget__meta {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-top: 4px;
}
