/*
 * Components
 * Lozenges, buttons, cards, forms, tables, toasts, modals.
 * All driven by design tokens. No hardcoded colours.
 */

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-100);
    padding: var(--space-075) var(--space-200);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-medium);
    line-height: var(--line-height-default);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast);
    white-space: nowrap;
}
.btn:focus-visible { outline-offset: 2px; }
.btn svg { width: 1em; height: 1em; flex-shrink: 0; }

.btn-primary {
    background: var(--brand-primary);
    color: var(--text-inverse);
}
.btn-primary:hover { background: var(--brand-primary-hover); }
.btn-primary:active { background: var(--brand-primary-pressed); }

.btn-default {
    background: var(--surface-base);
    color: var(--text-primary);
    border-color: var(--border-default);
}
.btn-default:hover { background: var(--surface-hovered); }

.btn-danger {
    background: var(--status-danger-bg);
    color: var(--status-danger-bold);
    border-color: var(--status-danger);
}
.btn-danger:hover { background: var(--status-danger); color: var(--text-inverse); }

.btn-sm { padding: var(--space-050) var(--space-150); font-size: var(--font-size-sm); }
.btn-lg { padding: var(--space-150) var(--space-300); font-size: var(--font-size-md); }

/* ===== LOZENGES (status badges) ===== */
.lozenge {
    display: inline-flex;
    align-items: center;
    padding: 0.0625rem var(--space-100);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    text-transform: uppercase;
    letter-spacing: 0.02em;
    border-radius: var(--radius-md);
    line-height: 1.6;
    white-space: nowrap;
}
.lozenge--success { background: var(--status-success-bg); color: var(--status-success-bold); }
.lozenge--warning { background: var(--status-warning-bg); color: var(--status-warning-bold); }
.lozenge--danger  { background: var(--status-danger-bg);  color: var(--status-danger-bold); }
.lozenge--info    { background: var(--status-info-bg);    color: var(--status-info-bold); }
.lozenge--neutral { background: var(--status-neutral-bg); color: var(--status-neutral); }
.lozenge--discovery { background: var(--status-discovery-bg); color: var(--status-discovery); }

/* ===== METRIC CARDS ===== */
.metric-card {
    background: var(--surface-base);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: var(--space-300);
    min-width: 0;
}
.metric-value {
    font-size: var(--font-size-2xl);
    font-weight: var(--font-weight-bold);
    color: var(--text-primary);
    line-height: var(--line-height-tight);
}
.metric-label {
    font-size: var(--font-size-sm);
    color: var(--text-subtlest);
    margin-top: var(--space-050);
}
.metric-trend {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    margin-top: var(--space-100);
}
.metric-trend--up { color: var(--status-success); }
.metric-trend--down { color: var(--status-danger); }

/* ===== CARDS ===== */
.card {
    background: var(--surface-base);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: var(--space-300);
}
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-200);
}
.card-title {
    font-size: var(--font-size-md);
    font-weight: var(--font-weight-medium);
}

/* ===== FORMS ===== */
.form-group {
    margin-bottom: var(--space-250);
}
.form-label {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: var(--text-secondary);
    margin-bottom: var(--space-075);
}
.form-input,
.form-select,
.form-textarea {
    display: block;
    width: 100%;
    padding: var(--space-100) var(--space-150);
    font-size: var(--font-size-base);
    color: var(--text-primary);
    background: var(--surface-base);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--border-focused);
    box-shadow: 0 0 0 1px var(--border-focused);
    outline: none;
}
.form-textarea { resize: vertical; min-height: 5rem; }
.form-hint { font-size: var(--font-size-sm); color: var(--text-subtlest); margin-top: var(--space-050); }
.form-error { font-size: var(--font-size-sm); color: var(--status-danger); margin-top: var(--space-050); }

/* ===== DATA TABLES ===== */
.data-table { width: 100%; }
.data-table th {
    text-align: left;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: var(--text-subtlest);
    padding: var(--space-100) var(--space-150);
    border-bottom: 2px solid var(--border-default);
    white-space: nowrap;
}
.data-table td {
    padding: var(--space-150);
    border-bottom: 1px solid var(--border-default);
    vertical-align: middle;
}
.data-table tr:hover td {
    background: var(--surface-hovered);
}
.data-table .text-right { text-align: right; }

/* ===== TOAST NOTIFICATIONS ===== */
.toast-container {
    position: fixed;
    top: var(--space-200);
    right: var(--space-200);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: var(--space-100);
    pointer-events: none;
}
.toast {
    pointer-events: auto;
    padding: var(--space-150) var(--space-250);
    border-radius: var(--radius-lg);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-medium);
    box-shadow: var(--shadow-overlay);
    animation: toast-in 300ms ease-out;
    max-width: 24rem;
}
.toast--success { background: var(--status-success-bg); color: var(--status-success-bold); border-left: 3px solid var(--status-success); }
.toast--error   { background: var(--status-danger-bg);  color: var(--status-danger-bold);  border-left: 3px solid var(--status-danger); }
.toast--info    { background: var(--status-info-bg);    color: var(--status-info-bold);    border-left: 3px solid var(--status-info); }
.toast--warning { background: var(--status-warning-bg); color: var(--status-warning-bold); border-left: 3px solid var(--status-warning); }

@keyframes toast-in {
    from { opacity: 0; transform: translateY(-0.5rem); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ===== MODAL ===== */
.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: var(--z-modal);
    align-items: center;
    justify-content: center;
}
.modal-backdrop.active { display: flex; }
.modal {
    background: var(--surface-overlay);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-modal);
    width: 90%;
    max-width: 32rem;
    max-height: 90vh;
    overflow-y: auto;
    padding: var(--space-400);
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-300);
}
.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-subtlest);
    padding: var(--space-050);
    border-radius: var(--radius-sm);
}
.modal-close:hover { color: var(--text-primary); background: var(--surface-hovered); }

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: var(--space-800) var(--space-400);
    color: var(--text-subtlest);
}
.empty-state p { margin-top: var(--space-100); }

/* ===== COUNT BADGE (sidebar) ===== */
.count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 var(--space-075);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    background: var(--status-danger);
    color: var(--text-inverse);
    border-radius: 10rem;
}
