/* ==========================================================================
   Rosas Weyh · Design System
   Tokens e primitivos visuais derivados das telas de referência.
   Acento de marca/navegação = azul; ações de criar/confirmar = verde.
   ========================================================================== */

:root {
    /* Neutros (slate) */
    --c-bg: #f4f6fb;
    --c-surface: #ffffff;
    --c-surface-2: #f8fafc;
    --c-border: #e6eaf1;
    --c-border-strong: #d4dae5;

    --c-text: #0f172a;
    --c-text-soft: #475569;
    --c-text-muted: #7a8699;

    /* Azul de marca / navegação / informação */
    --c-brand: #2563eb;
    --c-brand-hover: #1d4ed8;
    --c-brand-soft: #eef4ff;
    --c-brand-strong: #1e3a8a;

    /* Verde de ação (criar / confirmar) */
    --c-action: #16a34a;
    --c-action-hover: #15803d;
    --c-action-soft: #ecfdf3;

    /* Estados semânticos */
    --c-success: #16a34a;
    --c-success-soft: #eefbf3;
    --c-info: #2563eb;
    --c-info-soft: #eef4ff;
    --c-warning: #b45309;
    --c-warning-soft: #fff7ed;
    --c-danger: #dc2626;
    --c-danger-soft: #fef2f2;

    /* Raios (regra de forma: controles 8px, cartões 14px, pílula) */
    --r-control: 8px;
    --r-card: 14px;
    --r-pill: 999px;

    /* Sombras tingidas no tom do fundo (nunca preto puro) */
    --sh-sm: 0 1px 2px rgba(15, 23, 42, .05);
    --sh-md: 0 1px 3px rgba(15, 23, 42, .06), 0 4px 12px rgba(15, 23, 42, .05);
    --sh-lg: 0 12px 32px rgba(15, 23, 42, .12), 0 2px 8px rgba(15, 23, 42, .06);
    --sh-focus: 0 0 0 3px rgba(37, 99, 235, .22);

    /* Tipografia */
    --font: "Segoe UI", system-ui, -apple-system, "Roboto", "Helvetica Neue", Arial, sans-serif;

    --sidebar-w: 268px;

    color-scheme: light;
}

/* ---- Reset leve ---------------------------------------------------------- */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    font-family: var(--font);
    background: var(--c-bg);
    color: var(--c-text);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
    margin: 0;
    color: var(--c-text);
    font-weight: 700;
    letter-spacing: -0.01em;
}

a {
    color: var(--c-brand);
    text-decoration: none;
}

button {
    font-family: inherit;
}

/* Ícone padrão (sobrescrito por contextos mais específicos: .btn svg, etc.) */
.ico { width: 20px; height: 20px; display: inline-block; vertical-align: middle; flex: none; }

/* ---- Tipos de texto ------------------------------------------------------ */
.text-muted { color: var(--c-text-muted); }
.text-soft { color: var(--c-text-soft); }
.text-strong { font-weight: 600; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.numeric { font-variant-numeric: tabular-nums; }

/* ==========================================================================
   Botões
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border: 1px solid transparent;
    border-radius: var(--r-control);
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    transition: background-color .16s ease, border-color .16s ease, box-shadow .16s ease, transform .06s ease;
    white-space: nowrap;
    user-select: none;
}

.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--sh-focus); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.btn svg { width: 18px; height: 18px; flex: none; }

/* Ação principal (criar / confirmar) = verde */
.btn-action {
    background: var(--c-action);
    color: #fff;
    box-shadow: var(--sh-sm);
}
.btn-action:hover:not(:disabled) { background: var(--c-action-hover); }

/* Ação de marca / envio / busca = azul */
.btn-primary {
    background: var(--c-brand);
    color: #fff;
    box-shadow: var(--sh-sm);
}
.btn-primary:hover:not(:disabled) { background: var(--c-brand-hover); }

/* Secundário / neutro */
.btn-secondary {
    background: var(--c-surface);
    color: var(--c-text-soft);
    border-color: var(--c-border-strong);
}
.btn-secondary:hover:not(:disabled) { background: var(--c-surface-2); color: var(--c-text); }

/* Perigo */
.btn-danger {
    background: var(--c-danger);
    color: #fff;
}
.btn-danger:hover:not(:disabled) { background: #b91c1c; }

.btn-ghost {
    background: transparent;
    color: var(--c-text-soft);
    border-color: transparent;
}
.btn-ghost:hover:not(:disabled) { background: var(--c-surface-2); color: var(--c-text); }

.btn-outline-danger {
    background: var(--c-surface);
    color: var(--c-danger);
    border-color: #f4c9c9;
}
.btn-outline-danger:hover:not(:disabled) { background: var(--c-danger-soft); border-color: #f0b4b4; }

.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn-block { width: 100%; }

/* Botão-ícone (ações de tabela: ver, editar, receber) */
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: 1px solid var(--c-border);
    border-radius: var(--r-control);
    background: var(--c-surface);
    color: var(--c-text-soft);
    cursor: pointer;
    transition: background-color .16s ease, color .16s ease, border-color .16s ease, transform .06s ease;
}
.icon-btn:hover:not(:disabled) { background: var(--c-brand-soft); color: var(--c-brand); border-color: #cfe0ff; }
.icon-btn:active { transform: translateY(1px); }
.icon-btn:focus-visible { outline: none; box-shadow: var(--sh-focus); }
.icon-btn:disabled { opacity: .45; cursor: not-allowed; }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.danger:hover:not(:disabled) { background: var(--c-danger-soft); color: var(--c-danger); border-color: #fecaca; }
.icon-btn.action:hover:not(:disabled) { background: var(--c-action-soft); color: var(--c-action); border-color: #bbf7d0; }

/* ==========================================================================
   Cartões / superfícies
   ========================================================================== */
.card {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--r-card);
    box-shadow: var(--sh-sm);
}

.card-pad { padding: 22px 24px; }

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 24px;
    border-bottom: 1px solid var(--c-border);
}

.card-title {
    font-size: 17px;
    font-weight: 700;
}

/* ==========================================================================
   Formulários
   ========================================================================== */
.field { display: flex; flex-direction: column; gap: 7px; }

.label {
    font-size: 13px;
    font-weight: 600;
    color: var(--c-text-soft);
}
.label .req { color: var(--c-danger); margin-left: 2px; }

.control {
    width: 100%;
    height: 44px;
    padding: 0 14px;
    border: 1px solid var(--c-border-strong);
    border-radius: var(--r-control);
    background: var(--c-surface);
    color: var(--c-text);
    font-size: 14px;
    transition: border-color .16s ease, box-shadow .16s ease;
}
textarea.control { height: auto; padding: 12px 14px; resize: vertical; min-height: 84px; line-height: 1.5; }
select.control { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%237a8699' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 40px; }

.control::placeholder { color: var(--c-text-muted); }
.control:hover { border-color: var(--c-border-strong); }
.control:focus { outline: none; border-color: var(--c-brand); box-shadow: var(--sh-focus); }
.control:disabled { background: var(--c-surface-2); color: var(--c-text-muted); cursor: not-allowed; }
.control.invalid, .control.modified.invalid { border-color: var(--c-danger); }

.field-error {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12.5px;
    color: var(--c-danger);
}

/* Campo com ícone (busca) */
.input-icon { position: relative; }
.input-icon svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--c-text-muted); pointer-events: none; }
.input-icon .control { padding-left: 42px; }
.input-icon.trailing svg { left: auto; right: 14px; }
.input-icon.trailing .control { padding-left: 14px; padding-right: 42px; }

/* Toggle (switch de oferta) */
.switch { position: relative; display: inline-flex; width: 44px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
    position: absolute;
    inset: 0;
    background: #cbd5e1;
    border-radius: var(--r-pill);
    transition: background-color .18s ease;
    cursor: pointer;
}
.switch .track::before {
    content: "";
    position: absolute;
    height: 18px; width: 18px;
    left: 3px; top: 3px;
    background: #fff;
    border-radius: 50%;
    box-shadow: var(--sh-sm);
    transition: transform .18s ease;
}
.switch input:checked + .track { background: var(--c-brand); }
.switch input:checked + .track::before { transform: translateX(20px); }
.switch input:focus-visible + .track { box-shadow: var(--sh-focus); }
.switch input:disabled + .track { opacity: .5; cursor: not-allowed; }

/* ==========================================================================
   Badges
   ========================================================================== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: var(--r-pill);
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
}
.badge-info { background: var(--c-info-soft); color: var(--c-info); }
.badge-success { background: var(--c-success-soft); color: var(--c-success); }
.badge-danger { background: var(--c-danger-soft); color: var(--c-danger); }
.badge-warning { background: var(--c-warning-soft); color: var(--c-warning); }
.badge-neutral { background: var(--c-surface-2); color: var(--c-text-soft); border: 1px solid var(--c-border); }

.tag {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: 6px;
    font-size: 11.5px;
    font-weight: 600;
    background: var(--c-warning-soft);
    color: var(--c-warning);
    border: 1px solid #fed7aa;
}

/* ==========================================================================
   Tabelas
   ========================================================================== */
.table-wrap { width: 100%; overflow-x: auto; }

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.table thead th {
    text-align: left;
    padding: 14px 18px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--c-text-soft);
    background: var(--c-surface-2);
    border-bottom: 1px solid var(--c-border);
    white-space: nowrap;
}
.table tbody td {
    padding: 15px 18px;
    border-bottom: 1px solid var(--c-border);
    color: var(--c-text);
    vertical-align: middle;
}
.table tbody tr { transition: background-color .12s ease; }
.table tbody tr:hover { background: #fafbfe; }
.table tbody tr:last-child td { border-bottom: none; }
.table .col-actions { text-align: right; white-space: nowrap; }
.table .actions { display: inline-flex; gap: 8px; justify-content: flex-end; }

/* ==========================================================================
   Utilidades de layout
   ========================================================================== */
.stack { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.gap-4 { gap: 4px; } .gap-8 { gap: 8px; } .gap-12 { gap: 12px; }
.gap-16 { gap: 16px; } .gap-20 { gap: 20px; } .gap-24 { gap: 24px; }
.grow { flex: 1 1 auto; min-width: 0; }
.mt-4 { margin-top: 4px; } .mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.inline-block { display: inline-block; }

/* ==========================================================================
   Boot screen (antes do Blazor carregar)
   ========================================================================== */
.boot-screen {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 22px;
    background: var(--c-bg);
}
.boot-mark { display: flex; align-items: center; gap: 14px; }
.boot-logo {
    width: 52px; height: 52px;
    display: grid; place-items: center;
    border-radius: 14px;
    background: linear-gradient(135deg, #2563eb, #1e3a8a);
    color: #fff; font-weight: 800; font-size: 20px;
    box-shadow: var(--sh-md);
}
.boot-name { font-size: 24px; font-weight: 800; letter-spacing: -.02em; color: var(--c-brand-strong); }
.boot-spinner {
    width: 34px; height: 34px;
    border: 3px solid #dbe4f3;
    border-top-color: var(--c-brand);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
.boot-hint { color: var(--c-text-muted); font-size: 14px; margin: 0; }

@keyframes spin { to { transform: rotate(360deg); } }

/* Erro do Blazor */
#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    padding: 12px 20px;
    background: #fff4e5;
    border-top: 1px solid #fed7aa;
    color: #7c2d12;
    box-shadow: 0 -2px 12px rgba(0,0,0,.08);
    z-index: 1200;
}
#blazor-error-ui .reload { margin-left: 12px; font-weight: 600; }
#blazor-error-ui .dismiss { cursor: pointer; float: right; }

/* ==========================================================================
   Acessibilidade / movimento reduzido
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
    }
}
