/* ============================================================
   Design System — shared primitives for the Blazor WebApp.

   Loaded after wwwroot/css/app.css (which defines the tokens
   --accent-primary, --surface-elevated, --border-subtle, etc.).
   Page-scoped .razor.css files keep only genuinely local
   overrides on top of these globals.
   ============================================================ */

/* ---------- Page layout wrapper ---------- */

.page-content {
    width: 100%;
    margin: 0;
    padding: 1rem 0 2.5rem 0;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    box-sizing: border-box;
}

.page-content *,
.page-content *::before,
.page-content *::after {
    box-sizing: border-box;
}

/* ---------- Page header ---------- */

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 0.25rem 0;
}

.page-header__kicker {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.3rem 0.75rem 0.3rem 0.6rem;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--accent-primary);
    background: rgba(45, 125, 70, 0.1);
    border-radius: 999px;
    margin-bottom: 0.85rem;
    width: fit-content;
}

.page-header__kicker::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-primary);
    flex-shrink: 0;
}

.page-header__text h1 {
    font-size: 2.15rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 0.5rem 0;
    line-height: 1.1;
    letter-spacing: -0.01em;
}

.page-header__subtitle {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin: 0;
    max-width: 70ch;
}

/* ---------- Card ---------- */

.card {
    background: var(--surface-elevated);
    border: 1px solid #DCDDD8;
    border-radius: 14px;
    box-shadow: 0 1px 3px rgba(26, 35, 50, 0.04), 0 4px 16px rgba(26, 35, 50, 0.06);
}

.card--filter {
    padding: 1.75rem 2rem;
}

.card--table {
    padding: 0;
    overflow: hidden;
}

.card + .card {
    margin-top: 0;
}

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.7rem 1.25rem;
    border: 1px solid transparent;
    border-radius: 999px;
    font-size: 0.925rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.05s;
    font-family: inherit;
    line-height: 1.2;
}

.btn:active {
    transform: translateY(1px);
}

.btn svg {
    width: 16px;
    height: 16px;
}

.btn-primary {
    background: var(--accent-primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-primary-hover);
    box-shadow: 0 4px 10px rgba(45, 125, 70, 0.25);
}

.btn-outline {
    background: var(--surface-elevated);
    color: var(--text-primary);
    border: 1px solid #C9CBC4;
}

.btn-outline:hover {
    background: #F4F5F1;
    border-color: #9DA197;
    box-shadow: 0 2px 6px rgba(26, 35, 50, 0.08);
}

.btn-danger {
    background: #DC2626;
    color: #fff;
}

.btn-danger:hover {
    background: #B91C1C;
    box-shadow: 0 4px 10px rgba(220, 38, 38, 0.25);
}

.btn-sm {
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
}

.btn-lg {
    padding: 0.8rem 1.5rem;
    font-size: 1rem;
}

.btn-icon {
    padding: 0.5rem;
}

/* ---------- Form controls ---------- */

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.form-grid--compact {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    min-width: 0;
}

.form-label {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-secondary);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.form-control {
    padding: 0.7rem 0.95rem;
    border: 1px solid #C9CBC4;
    border-radius: 10px;
    font-size: 0.95rem;
    font-family: inherit;
    background: var(--surface-elevated);
    color: var(--text-primary);
    transition: border-color 0.15s, box-shadow 0.15s;
    width: 100%;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 4px rgba(45, 125, 70, 0.12);
}

.form-select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    cursor: pointer;
    padding-right: 2.5rem;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'><path d='M1 1.5L6 6.5L11 1.5' stroke='%236B7280' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'/></svg>");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 12px 8px;
}

.form-stack {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.form-hint {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-top: 0.15rem;
}

.form-actions {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

/* ---------- Filter strip (used on report pages) ---------- */

.filter-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    min-width: 0;
}

.filter-group--full {
    grid-column: 1 / -1;
}

.filter-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
}

.filter-actions {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

/* ---------- Data table ---------- */

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

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead th {
    background: #f7fafc;
    padding: 0.85rem 0.9rem;
    text-align: left;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 2px solid var(--border-subtle);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 1;
}

.data-table tbody td {
    padding: 0.75rem 0.9rem;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 0.9rem;
    color: var(--text-primary);
    white-space: nowrap;
}

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

.data-table tbody tr:hover {
    background: #f7fafc;
}

.data-table .numeric {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.data-table .empty-state {
    text-align: center;
    padding: 2.5rem 1rem !important;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.sort-link {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    font: inherit;
    color: inherit;
    text-transform: inherit;
    letter-spacing: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.sort-link:hover {
    color: var(--accent-primary);
}

.sort-link:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
    border-radius: 4px;
}

.sort-link span {
    font-size: 0.7rem;
}

.pager-wrapper {
    display: flex;
    justify-content: flex-end;
}

/* ---------- Alerts ---------- */

.alert {
    padding: 0.85rem 1rem;
    border-radius: 8px;
    font-size: 0.925rem;
    line-height: 1.4;
    border: 1px solid transparent;
}

.alert-info {
    background: #EFF6FF;
    color: #1E3A8A;
    border-color: #BFDBFE;
}

.alert-warning {
    background: #FFFBEB;
    color: #92400E;
    border-color: #FDE68A;
}

.alert-error {
    background: #FEF2F2;
    color: #991B1B;
    border-color: #FECACA;
}

/* ---------- Responsive breakpoints ---------- */

@media (max-width: 1100px) {
    .filter-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 900px) {
    .page-header__text h1 {
        font-size: 1.5rem;
    }
}

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

    .filter-actions .btn,
    .form-actions .btn {
        flex: 1;
    }
}

/* ---------- Status pills ---------- */

.status-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.status-pill--active {
    background: rgba(45, 125, 70, 0.12);
    color: var(--accent-primary);
}

.status-pill--inactive {
    background: rgba(26, 35, 50, 0.06);
    color: var(--text-secondary);
}

/* ---------- Segmented toggle (2-3 way pill switch) ---------- */

.segmented-toggle {
    display: inline-flex;
    gap: 0;
    padding: 0.25rem;
    border-radius: 999px;
    background: #f7fafc;
    border: 1px solid var(--border-subtle);
    width: fit-content;
}

.segmented-toggle__btn {
    background: transparent;
    border: none;
    padding: 0.5rem 1.1rem;
    border-radius: 999px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.segmented-toggle__btn:hover:not(.is-active) {
    color: var(--text-primary);
}

.segmented-toggle__btn.is-active {
    background: var(--surface-elevated);
    color: var(--text-primary);
    box-shadow: 0 1px 3px rgba(26, 35, 50, 0.08);
}

/* ---------- Toggle switch (on/off slider) ---------- */

.toggle-switch__row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-switch__slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 22px;
}

.toggle-switch__slider::before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-switch__slider {
    background-color: var(--accent-primary);
}

.toggle-switch input:checked + .toggle-switch__slider::before {
    transform: translateX(18px);
}

/* ---------- HTML editor (Quill / raw textarea) ---------- */

.html-editor-quill {
    height: 240px;
}

.html-editor-textarea {
    width: 100%;
    height: 240px;
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 0.85rem;
}

.html-editor-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 0.5rem;
}
