/* ═══════════════════════════════════════════════════════
   Grupo Orizonti — Design System
   ═══════════════════════════════════════════════════════ */

/* ── Tokens ─────────────────────────────────────────────── */
:root {
    /* Brand */
    --brand: #547264;
    --brand-dark: #40574c;
    --brand-muted: #6d8f80;
    --brand-subtle: #e8efec;
    --cream: #cdc9a6;
    --cream-light: #e8e5d6;
    --cream-dark: #b0ab87;

    /* Surfaces */
    --bg: #f7f5f0;
    --surface: #ffffff;
    --surface-alt: #f0ede6;

    /* Borders */
    --border: #e0dbd1;
    --border-focus: #547264;

    /* Text */
    --text: #2c3e32;
    --text-muted: #7a8b81;
    --text-on-brand: #e8e5d6;

    /* Feedback */
    --error: #c0392b;
    --error-bg: #fdf2f2;
    --error-border: rgba(192, 57, 43, 0.25);

    /* Radii */
    --radius-sm: 0.375rem;
    --radius-md: 0.625rem;
    --radius-lg: 1rem;
    --radius-xl: 1.375rem;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgb(0 0 0 / 0.07);
    --shadow-md: 0 4px 14px rgb(0 0 0 / 0.08);

    /* Motion */
    --transition: 150ms ease;

    /* Typography */
    --font: 'Nunito', system-ui, sans-serif;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-md: 0.9375rem;
    --font-size-lg: 1.125rem;
}

/* ── Dark mode ───────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
    html:not([data-theme="light"]) {
        --bg: #1b1e1b;
        --surface: #242724;
        --surface-alt: #2c302b;
        --border: #3a3f38;
        --text: #dfe0da;
        --text-muted: #8c9689;
        --brand-subtle: #1f2e27;
        --error-bg: #2d1a1a;
        --error-border: rgba(192, 57, 43, 0.35);
        --shadow-sm: 0 1px 3px rgb(0 0 0 / 0.25);
        --shadow-md: 0 4px 14px rgb(0 0 0 / 0.35);
    }
}

html[data-theme="dark"] {
    --bg: #1b1e1b;
    --surface: #242724;
    --surface-alt: #2c302b;
    --border: #3a3f38;
    --text: #dfe0da;
    --text-muted: #8c9689;
    --brand-subtle: #1f2e27;
    --error-bg: #2d1a1a;
    --error-border: rgba(192, 57, 43, 0.35);
    --shadow-sm: 0 1px 3px rgb(0 0 0 / 0.25);
    --shadow-md: 0 4px 14px rgb(0 0 0 / 0.35);
}

/* ── Scrollbars (global thin style) ─────────────────────── */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

*::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

*::-webkit-scrollbar-track {
    background: transparent;
}

*::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

*::-webkit-scrollbar-button {
    display: none;
}

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

html,
body {
    height: 100%;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: var(--font-size-md);
    -webkit-font-smoothing: antialiased;
}


/* ── Shared button utilities ─────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.45rem 1rem;
    border: none;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: var(--font-size-sm);
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
    white-space: nowrap;
    text-decoration: none;
}

.btn--primary {
    background: var(--brand);
    color: var(--text-on-brand);
}

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

.btn--secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn--secondary:hover {
    background: var(--surface-alt);
}

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

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

.btn--danger {
    background: var(--error-bg);
    color: var(--error);
    border: 1px solid var(--error-border);
}

.btn--danger:hover {
    filter: brightness(1.15);
}

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

.btn:disabled:hover {
    filter: none;
}

.btn--sm {
    padding: 0.3rem 0.65rem;
    font-size: var(--font-size-xs);
}

/* ── Generic form fields ─────────────────────────────── */
.form-field {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    margin-bottom: 0.875rem;
}

.form-field label {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-muted);
}

.form-hint {
    font-weight: 400;
    font-size: var(--font-size-xs);
}

.form-field input[type="text"],
.form-field input[type="file"] {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.45rem 0.875rem;
    font: inherit;
    font-size: var(--font-size-sm);
    color: var(--text);
    background: var(--bg);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-field input[type="text"]:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: var(--border);
    color: var(--text-muted);
}

.form-field input[type="text"]:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(84, 114, 100, 0.12);
}

.form-field input[type="file"] {
    padding: 0.35rem 0.5rem;
    cursor: pointer;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
}

.text-muted {
    color: var(--text-muted);
    font-size: var(--font-size-sm);
    margin: 0;
}

/* Ensure popover backdrop visibility is controlled by CSS class, not only JS inline style */
.px-popover-backdrop--visible {
    visibility: visible !important;
}

/* Increase default built-in popover card width */
.px-popover-card {
    max-width: min(44ch, calc(100vw - 1rem)) !important;
}