/* ============================================================
 * MZ Cards Component Library
 * Reusable UI component classes built on design tokens.
 * Phase 2 of UI Modernization.
 *
 * This file defines the component layer. No view references
 * these classes yet — they are loaded but unused, so the app
 * appearance is unchanged.
 * ============================================================ */

/* === Button === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  line-height: 1.2;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background var(--transition-base),
              border-color var(--transition-base),
              color var(--transition-base),
              box-shadow var(--transition-base);
  text-decoration: none;
  white-space: nowrap;
}

.btn:disabled, .btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Button variants */
.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}
.btn--primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  text-decoration: none;
}

.btn--secondary { /* same as base .btn */ }

.btn--ghost {
  border-color: transparent;
  background: transparent;
}
.btn--ghost:hover:not(:disabled) {
  background: var(--surface-3);
  text-decoration: none;
}

.btn--danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #ffffff;
}
.btn--danger:hover:not(:disabled) {
  background: var(--danger-text);
  border-color: var(--danger-text);
}

/* Button sizes */
.btn--sm {
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-xs);
}
.btn--xs {
  padding: 2px var(--space-1);
  font-size: var(--text-xs);
}

/* === Icon Button === */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background var(--transition-base), color var(--transition-base);
  text-decoration: none;
}
.btn-icon:hover {
  background: var(--surface-3);
  color: var(--text);
  text-decoration: none;
}
.btn-icon--sm {
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
}

/* === Button Group === */
.btn-group {
  display: inline-flex;
  gap: var(--space-1);
  flex-wrap: wrap;
  align-items: center;
}

/* Segmented control (connected buttons, iOS style) */
.btn-group--segmented {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  gap: 0;
}
.btn-group--segmented .btn,
.btn-group--segmented button {
  border: none;
  border-radius: 0;
  border-right: 1px solid var(--border);
  background: var(--surface);
}
.btn-group--segmented .btn:last-child,
.btn-group--segmented button:last-child {
  border-right: none;
}
.btn-group--segmented .btn.active,
.btn-group--segmented button.active,
.btn-group--segmented button[disabled] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: var(--font-semibold);
}
.btn-group--segmented .btn:hover:not(.active):not(:disabled),
.btn-group--segmented button:hover:not(.active):not(:disabled) {
  background: var(--surface-3);
  text-decoration: none;
}

/* === Badge === */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  line-height: 1.4;
}
.badge--success { background: var(--success-soft); color: var(--success-text); }
.badge--warning { background: var(--warning-soft); color: var(--warning-text); }
.badge--danger  { background: var(--danger-soft);  color: var(--danger-text); }
.badge--info    { background: var(--info-soft);    color: var(--info-text); }
.badge--neutral { background: var(--neutral-soft); color: var(--neutral-text); }
.badge--accent  { background: var(--accent-soft); color: var(--accent); }

/* === Notice / Alert === */
.notice {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  background: var(--success-soft);
  color: var(--success-text);
  font-size: var(--text-sm);
}
.alert {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  background: var(--danger-soft);
  color: var(--danger-text);
  font-size: var(--text-sm);
}

/* === Error Message Block === */
.error-block {
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
  border: 1px solid var(--danger);
  border-left: 3px solid var(--danger);
  border-radius: var(--radius-md);
  background: var(--danger-soft);
  color: var(--danger-text);
}
.error-block h2 {
  font-size: var(--text-sm);
  margin: 0 0 var(--space-2);
}
.error-block ul {
  margin: 0;
  padding-left: var(--space-4);
}
.error-block li {
  margin-bottom: var(--space-1);
}

/* === Card Surface === */
.card-surface {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-base),
              border-color var(--transition-base);
}
.card-surface:hover {
  box-shadow: var(--shadow-md);
}

/* === Toolbar === */
.toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex-wrap: wrap;
}
.toolbar--right { justify-content: flex-end; }
.toolbar--between { justify-content: space-between; }

/* === Empty State === */
.empty-state {
  text-align: center;
  padding: var(--space-8) var(--space-4);
  color: var(--text-subtle);
}
.empty-state__icon {
  font-size: 2rem;
  margin-bottom: var(--space-2);
}
.empty-state__title {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--text-muted);
  margin-bottom: var(--space-1);
}
.empty-state__text {
  font-size: var(--text-sm);
}

/* === Form Field === */
.field {
  margin-bottom: var(--space-4);
}
.field label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-muted);
  margin-bottom: var(--space-1);
}

/* === Breadcrumb === */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-sm);
  color: var(--text-muted);
}
.breadcrumb a {
  color: var(--text-muted);
}
.breadcrumb a:hover {
  color: var(--accent);
  text-decoration: none;
}
.breadcrumb__separator {
  color: var(--text-subtle);
}
.breadcrumb__current {
  color: var(--text);
  font-weight: var(--font-semibold);
}

/* === Text utilities === */
.text-muted { color: var(--text-muted); }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }


/* === Card surface modifiers === */
.card-surface--padded {
  padding: var(--space-3);
  margin-bottom: var(--space-5);
}

/* === Notice auto-hide animation (extracted from layout.html.erb) === */
@keyframes fadeOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(20px); }
}
.notice.hide {
  animation: fadeOut 0.5s ease-out forwards;
}

/* === Command Palette (extracted from layout.html.erb) === */
.command-palette {
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  max-width: 560px;
  width: 90vw;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}
.command-palette::backdrop { background: rgba(0, 0, 0, 0.4); }
.command-palette input {
  width: 100%;
  box-sizing: border-box;
  border: none;
  border-bottom: 1px solid var(--border);
  padding: var(--space-3) var(--space-4);
  font-size: 1em;
  outline: none;
  background: transparent;
  color: inherit;
}
.command-palette ul {
  list-style: none;
  margin: 0;
  padding: var(--space-1);
  max-height: 60vh;
  overflow-y: auto;
}
.command-palette li { margin: 0; }
.command-palette a {
  display: block;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}
.command-palette a.selected,
.command-palette a:hover {
  background: var(--accent-soft);
  color: var(--accent);
}
.command-palette .palette-empty {
  padding: var(--space-3);
  color: var(--text-muted);
}


/* === Utility: section spacing === */
.section-spaced {
  margin-top: var(--space-8);
}

/* === Utility: deck list meta text === */
.deck-list-meta {
  color: var(--text-muted);
  font-size: var(--text-xs);
}


/* === Quick capture (header) === */
.quick-capture {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--surface);
  padding: 2px var(--space-2);
  min-width: 0;
}

.quick-capture .icon {
  color: var(--text-subtle);
  flex-shrink: 0;
}

.quick-capture input {
  border: none;
  background: transparent;
  font-size: var(--text-sm);
  color: var(--text);
  width: 13rem;
  padding: var(--space-1) 0;
}

.quick-capture input:focus {
  outline: none;
}

.quick-capture__status {
  font-size: var(--text-xs);
  color: var(--text-subtle);
  white-space: nowrap;
}

.quick-capture__status--error {
  color: var(--danger);
}

.quick-capture__status a {
  color: var(--accent);
}

@media (max-width: 900px) {
  .quick-capture { display: none; }
}
