/**
 * Unified Component Styles
 *
 * This file contains reusable component styles used across the site.
 * Import after theme.css and base.css.
 */

/* ==========================================================================
   BUTTONS
   ========================================================================== */

/**
 * Base button styles
 * Usage: <button class="btn btn--primary">Action</button>
 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  border: 2px solid var(--color-border);
  background: transparent;
  color: var(--color-text);
  font-family: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.1s ease;
}

.btn:hover {
  background: color-mix(in srgb, var(--color-primary) 10%, transparent);
  text-decoration: none;
}

/* Primary button - main actions */
.btn--primary {
  padding: var(--space-sm) var(--space-lg);
  border: 3px solid var(--color-text);
  background: var(--color-primary);
  color: var(--color-bg);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.btn--primary:hover {
  transform: translate(-2px, -2px);
  box-shadow: 4px 4px 0 var(--color-text);
  background: var(--color-primary);
}

.btn--primary:active {
  transform: translate(0, 0);
  box-shadow: none;
}

/* Alias: btn-primary (used in admin) */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-lg);
  border: 3px solid var(--color-text);
  background: var(--color-primary);
  color: var(--color-bg);
  font-family: inherit;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.1s ease;
}

.btn-primary:hover {
  transform: translate(-2px, -2px);
  box-shadow: 4px 4px 0 var(--color-text);
  background: var(--color-primary);
  text-decoration: none;
}

.btn-primary:active {
  transform: translate(0, 0);
  box-shadow: none;
}

/* Secondary button - alternative actions */
.btn--secondary,
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  border: 2px solid var(--color-border);
  background: transparent;
  color: var(--color-text);
  font-family: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.1s ease;
}

.btn--secondary:hover,
.btn-secondary:hover {
  background: color-mix(in srgb, var(--color-primary) 10%, transparent);
  text-decoration: none;
}

/* Danger button - destructive actions */
.btn--danger,
.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  border: 2px solid #ff4444;
  background: #ff4444;
  color: white;
  font-family: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.1s ease;
}

.btn--danger:hover,
.btn-danger:hover {
  background: #cc3333;
  border-color: #cc3333;
  text-decoration: none;
}

/* Ghost danger - danger on hover only */
.btn--ghost-danger:hover {
  background: #ff4444;
  border-color: #ff4444;
  color: white;
}

/* Small button - compact actions in tables/lists */
.btn--sm {
  padding: var(--space-xs) var(--space-sm);
}

/* Full width button */
.btn--block {
  width: 100%;
}

/* Action button - small buttons used in tables/lists */
.btn-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-xs) var(--space-sm);
  border: 2px solid var(--color-border);
  background: transparent;
  color: var(--color-text);
  font-family: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.1s ease;
}

.btn-action:hover {
  background: color-mix(in srgb, var(--color-primary) 10%, transparent);
  text-decoration: none;
}

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

.btn-action:disabled:hover {
  background: transparent;
}

.btn-action.primary {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

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

.btn-action.danger {
  border-color: #ff4444;
  color: #ff4444;
}

.btn-action.danger:hover {
  background: #ff4444;
  color: white;
}

/* Logout button */
.btn-logout {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-xs) var(--space-sm);
  border: 2px solid var(--color-border);
  background: transparent;
  color: var(--color-text);
  font-family: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.1s ease;
}

.btn-logout:hover {
  background: #ff4444;
  border-color: #ff4444;
  color: white;
}

/* ==========================================================================
   CARDS
   ========================================================================== */

/**
 * Base card styles
 * Usage: <article class="card">Content</article>
 */
.card {
  padding: var(--space-md);
  border: 2px solid var(--color-border);
  background: var(--color-bg);
}

/* Interactive card - lifts on hover */
.card--interactive {
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease;
}

.card--interactive:hover {
  transform: translateY(-2px);
  box-shadow: 4px 4px 0 var(--color-primary);
}

/* ==========================================================================
   FORMS
   ========================================================================== */

/**
 * Form group - wraps label and input
 * Usage: <div class="form-group"><label>...</label><input>...</div>
 */
.form-group {
  margin-bottom: var(--space-md);
}

.form-group label,
.form-label {
  display: block;
  margin-bottom: var(--space-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-group input,
.form-group textarea,
.form-group select,
.form-input {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  border: 2px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 1rem;
  font-family: inherit;
}

.form-group input:focus-visible,
.form-group textarea:focus-visible,
.form-group select:focus-visible,
.form-input:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-color: var(--color-primary);
  box-shadow: 4px 4px 0 var(--color-primary);
}

.form-group input:focus:not(:focus-visible),
.form-group textarea:focus:not(:focus-visible),
.form-group select:focus:not(:focus-visible),
.form-input:focus:not(:focus-visible) {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 4px 4px 0 var(--color-primary);
}

/* Help text - small hint below inputs */
.form-help,
.help-text {
  color: color-mix(in srgb, var(--color-text) 60%, transparent);
  margin: var(--space-xs) 0 0;
}

/* Monospace input - for slugs, code, URLs */
.form-input--mono {
  font-family: var(--font-mono);
}

/* ==========================================================================
   DATA TABLES (Proper HTML tables)
   ========================================================================== */

/**
 * Admin table - proper HTML table with neo-brutalist styling
 * Usage: <table class="admin-table">...</table>
 */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  border: 3px solid var(--color-border);
  background: var(--color-bg);
}

.admin-table thead {
  background: color-mix(in srgb, var(--color-primary) 10%, transparent);
}

.admin-table th {
  padding: var(--space-md);
  text-align: left;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border-bottom: 2px solid var(--color-border);
  white-space: nowrap;
}

.admin-table td {
  padding: var(--space-md);
  border-bottom: 1px dashed var(--color-border);
  vertical-align: middle;
}

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

.admin-table tbody tr:hover {
  background: color-mix(in srgb, var(--color-primary) 5%, transparent);
}

/* Cell content truncation */
.admin-table .cell-truncate {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Cell width hints */
.admin-table .col-title {
  width: 40%;
  min-width: 200px;
}

.admin-table .col-slug {
  width: 25%;
  min-width: 150px;
}

.admin-table .col-date {
  width: 15%;
  min-width: 100px;
  white-space: nowrap;
}

.admin-table .col-status {
  width: 10%;
  min-width: 100px;
  white-space: nowrap;
}

.admin-table .col-actions {
  width: auto;
  min-width: 120px;
  white-space: nowrap;
  text-align: right;
}

/* Actions cell alignment */
.admin-table td:last-child {
  text-align: right;
}

.admin-table th:last-child {
  text-align: right;
}

/* Table wrapper for horizontal scroll on mobile */
.table-wrapper {
  width: 100%;
  overflow-x: auto;
  border: 3px solid var(--color-border);
}

.table-wrapper .admin-table {
  border: none;
  min-width: 600px;
}

/* ==========================================================================
   LIST ITEMS
   ========================================================================== */

/**
 * Item list - bordered list with rows
 * Usage: <div class="item-list"><div class="item-row">...</div></div>
 */
.item-list {
  border: 2px solid var(--color-border);
}

.item-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md);
  border-bottom: 1px dashed var(--color-border);
}

.item-row:last-child {
  border-bottom: none;
}

/* Clickable item row */
.item-row--link {
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: background 0.1s ease;
}

.item-row--link:hover {
  background: color-mix(in srgb, var(--color-primary) 10%, transparent);
  text-decoration: none;
}

.item-row .item-title {
  font-weight: 600;
  color: var(--color-text);
}

.item-row .item-date {
  color: color-mix(in srgb, var(--color-text) 60%, transparent);
}

/* ==========================================================================
   DIALOGS
   ========================================================================== */

/**
 * Dialog - modal overlay with content
 * Usage: <div class="dialog-overlay"><div class="dialog">...</div></div>
 *
 * IMPORTANT: Use the [hidden] attribute to hide dialogs.
 */
.dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

/* Critical: Ensure hidden attribute works with flexbox */
.dialog-overlay[hidden] {
  display: none !important;
}

.dialog {
  background: var(--color-bg);
  border: 3px solid var(--color-border);
  padding: var(--space-xl);
  max-width: 500px;
  width: 90%;
}

.dialog__title {
  margin: 0 0 var(--space-md);
}

.dialog__content {
  margin: 0 0 var(--space-lg);
}

.dialog__actions {
  display: flex;
  gap: var(--space-sm);
  justify-content: flex-end;
}

/* ==========================================================================
   TEXT UTILITIES
   ========================================================================== */

/* Meta text - secondary info like dates, slugs */
.meta {
  color: color-mix(in srgb, var(--color-text) 60%, transparent);
}

/* Title in lists/tables */
.title {
  font-weight: 600;
}

.title a {
  color: var(--color-text);
  text-decoration: none;
}

.title a:hover {
  color: var(--color-primary);
}

/* Untitled/placeholder state */
.untitled {
  font-style: italic;
  color: color-mix(in srgb, var(--color-text) 50%, transparent);
}

/* Monospace text */
.mono {
  font-family: var(--font-mono);
}

/* ==========================================================================
   STATUS INDICATORS
   ========================================================================== */

/**
 * Status dot - small circular indicator
 * Usage: <span class="status-dot status-dot--active"></span>
 */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--color-text) 30%, transparent);
}

.status-dot--active,
.status-dot.visited {
  background: #22c55e;
}

.status-dot--warning {
  background: #f59e0b;
}

.status-dot--danger {
  background: #ff4444;
}

/* Status badge with text */
.status {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
}

/* ==========================================================================
   ACTION GROUPS
   ========================================================================== */

/**
 * Actions - group of action buttons
 * Usage: <div class="actions"><button class="btn btn--sm">...</button></div>
 */
.actions {
  display: flex;
  gap: var(--space-xs);
}

/* ==========================================================================
   STATE CLASSES
   ========================================================================== */

/* Loading state */
.loading {
  padding: var(--space-xl);
  text-align: center;
  color: color-mix(in srgb, var(--color-text) 50%, transparent);
  font-style: italic;
}

/* Empty state */
.empty {
  padding: var(--space-xl);
  text-align: center;
  color: color-mix(in srgb, var(--color-text) 50%, transparent);
  font-style: italic;
}

/* Error message */
.error {
  background: #ff4444;
  color: white;
  padding: var(--space-sm) var(--space-md);
  margin-bottom: var(--space-md);
  font-weight: 500;
}

/* Hidden utility */
.hidden {
  display: none !important;
}

/* ==========================================================================
   LAYOUT UTILITIES
   ========================================================================== */

/* Center content */
.text-center {
  text-align: center;
}

/* Grid utilities */
.grid {
  display: grid;
  gap: var(--space-lg);
}
