/*
 * GLOBAL THEME ENGINE — RST GSM
 * ------------------------------------------------------------------
 * Regras GLOBAIS e de baixo risco que consomem as variáveis --theme-*
 * definidas dinamicamente por includes/helpers/theme_engine.php
 * (renderGlobalThemeStyleBlock).
 *
 * Este arquivo NÃO sobrescreve nenhum sistema de design existente
 * (--uds-*, --ads-*, --auth-*) — essas pontes já ficam no <style> inline
 * gerado pelo PHP. Aqui ficam apenas:
 *   1) o "background ambiente" global (gradients leves, sem imagens);
 *   2) baseline para elementos genéricos usando :where() (especificidade
 *      zero — qualquer outra regra existente sempre vence, então isto
 *      nunca quebra nada que já tenha estilo);
 *   3) classes utilitárias opcionais citadas no pedido (.card, .modal,
 *      .alert, .badge, .pagination, .tabs) para quem ainda não usa um
 *      design system específico;
 *   4) toques globais de identidade (seleção de texto, foco, scrollbar).
 *
 * Performance: só gradients/CSS variables, sem imagens pesadas, sem JS.
 */

/* ===================================================================
   1) BACKGROUND AMBIENTE GLOBAL
   =================================================================== */
body {
    position: relative;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-color: var(--theme-bg, #f6f7fb);
    background-image:
        radial-gradient(1100px 620px at 10% -10%, color-mix(in srgb, var(--theme-primary, #6366f1) 16%, transparent), transparent 60%),
        radial-gradient(900px 560px at 110% 0%, color-mix(in srgb, var(--theme-accent, #8b5cf6) 14%, transparent), transparent 62%),
        radial-gradient(1000px 680px at 50% 115%, color-mix(in srgb, var(--theme-secondary, #6366f1) 10%, transparent), transparent 65%);
    background-repeat: no-repeat;
    transition: background-color 0.25s ease;
}

/* Grid extremamente sutil, só no modo escuro (assinatura "SaaS premium"). */
body::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    opacity: 0;
    background-image:
        linear-gradient(color-mix(in srgb, var(--theme-primary, #38bdf8) 6%, transparent) 1px, transparent 1px),
        linear-gradient(90deg, color-mix(in srgb, var(--theme-primary, #38bdf8) 6%, transparent) 1px, transparent 1px);
    background-size: 42px 42px, 42px 42px;
    mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 40%, transparent 90%);
    -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 40%, transparent 90%);
}

.dark body::after {
    opacity: 1;
}

/* ===================================================================
   2) IDENTIDADE GLOBAL: seleção, foco, scrollbar
   =================================================================== */
::selection {
    background: color-mix(in srgb, var(--theme-primary, #6366f1) 55%, transparent);
    color: #fff;
}

:where(a, button, input, select, textarea, [tabindex]):focus-visible {
    outline: 2px solid color-mix(in srgb, var(--theme-primary, #6366f1) 70%, transparent);
    outline-offset: 2px;
}

/* ===================================================================
   3) BASELINE GENÉRICO (especificidade zero — nunca sobrescreve nada
      que já tenha classe/estilo próprio; serve só de fallback coerente)
   =================================================================== */
:where(button:not([class])),
:where(input[type="submit"]:not([class])),
:where(input[type="button"]:not([class])) {
    background: var(--theme-primary, #6366f1);
    color: #fff;
    border: 1px solid transparent;
    border-radius: 0.6rem;
    padding: 0.55rem 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.15s ease;
}
:where(button:not([class])):hover,
:where(input[type="submit"]:not([class])):hover,
:where(input[type="button"]:not([class])):hover {
    background: var(--theme-primary-hover, #4f46e5);
}

:where(input:not([class]), select:not([class]), textarea:not([class])) {
    background: var(--theme-surface, #fff);
    color: var(--theme-text, #0f172a);
    border: 1px solid var(--theme-border, #e2e8f0);
    border-radius: 0.55rem;
    padding: 0.5rem 0.75rem;
}

:where(table:not([class])) {
    border-collapse: collapse;
    width: 100%;
    background: var(--theme-surface, #fff);
    color: var(--theme-text, #0f172a);
}
:where(table:not([class])) :where(th, td) {
    border-bottom: 1px solid var(--theme-border, #e2e8f0);
    padding: 0.6rem 0.75rem;
    text-align: left;
}
:where(table:not([class])) :where(tbody tr:hover) {
    background: var(--theme-surface-hover, #f8fafc);
}

/* ===================================================================
   4) CLASSES UTILITÁRIAS OPCIONAIS (opt-in) — item 10 do pedido
   =================================================================== */
.theme-card {
    background: var(--theme-card, #fff);
    border: 1px solid var(--theme-border, #e2e8f0);
    border-radius: 1rem;
    box-shadow: var(--theme-shadow, 0 10px 25px rgba(15, 23, 42, 0.08));
    color: var(--theme-text, #0f172a);
}

.theme-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    background: color-mix(in srgb, var(--theme-primary, #6366f1) 14%, transparent);
    color: var(--theme-primary, #6366f1);
}
.theme-badge--success { background: color-mix(in srgb, var(--theme-success, #10b981) 16%, transparent); color: var(--theme-success, #10b981); }
.theme-badge--warning { background: color-mix(in srgb, var(--theme-warning, #f59e0b) 16%, transparent); color: var(--theme-warning, #f59e0b); }
.theme-badge--danger { background: color-mix(in srgb, var(--theme-danger, #ef4444) 16%, transparent); color: var(--theme-danger, #ef4444); }
.theme-badge--info { background: color-mix(in srgb, var(--theme-info, #3b82f6) 16%, transparent); color: var(--theme-info, #3b82f6); }

.theme-alert {
    display: flex;
    gap: 0.6rem;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    border: 1px solid var(--theme-border, #e2e8f0);
    background: var(--theme-surface-hover, #f8fafc);
    color: var(--theme-text, #0f172a);
}

.theme-modal-backdrop {
    background: rgba(0, 0, 0, 0.6);
}
.theme-modal {
    background: var(--theme-surface, #fff);
    border: 1px solid var(--theme-border, #e2e8f0);
    border-radius: 1rem;
    box-shadow: var(--theme-shadow, 0 20px 45px rgba(0, 0, 0, 0.25));
    color: var(--theme-text, #0f172a);
}

.theme-pagination a,
.theme-pagination button {
    border: 1px solid var(--theme-border, #e2e8f0);
    background: var(--theme-surface, #fff);
    color: var(--theme-text, #0f172a);
    border-radius: 0.5rem;
    padding: 0.35rem 0.7rem;
}
.theme-pagination a.active,
.theme-pagination button.active {
    background: var(--theme-primary, #6366f1);
    border-color: var(--theme-primary, #6366f1);
    color: #fff;
}

.theme-tabs {
    display: flex;
    gap: 0.25rem;
    border-bottom: 1px solid var(--theme-border, #e2e8f0);
}
.theme-tabs a,
.theme-tabs button {
    padding: 0.6rem 1rem;
    color: var(--theme-text-muted, #64748b);
    border-bottom: 2px solid transparent;
}
.theme-tabs a.active,
.theme-tabs button.active {
    color: var(--theme-primary, #6366f1);
    border-bottom-color: var(--theme-primary, #6366f1);
}

/* ===================================================================
   5) SERVICES GRID — imagens (Tailwind preflight height:auto colapsa)
   =================================================================== */
.svc-grid-group .aspect-square,
.svc-grid-group .svc-card-thumb {
    position: relative !important;
    width: 100% !important;
    aspect-ratio: 1 / 1;
    min-height: 72px;
}
.svc-grid-group .aspect-square > img,
.svc-grid-group .svc-card-thumb__img,
.svc-grid-group .svc-card-thumb > img {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    object-fit: contain !important;
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
}

/* Lista com grupos: thumbs fixas — NÃO usar height:100% solto (colapsa img) */
.svc-list-group .w-12.h-12 {
    position: relative;
    flex-shrink: 0;
}
.svc-list-group .w-12.h-12 > img {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    object-fit: contain !important;
    display: block !important;
}

/* Navbar / shell: reforço de identidade nos hovers e ícones ativos */
.uds-nav a:hover,
.uds-nav button:hover,
.uds-sidebar a:hover,
.uds-sidebar .active,
.uds-nav__link.is-active,
.uds-nav__item.is-active {
    color: var(--theme-primary, #4f46e5);
}
.uds-btn--primary,
.btn-primary.uds-compat,
.uds-nav__cta {
    background: var(--theme-gradient, linear-gradient(135deg, #4f46e5, #4338ca)) !important;
    color: #fff !important;
    border-color: transparent !important;
}

/* ===================================================================
   6) PERFORMANCE / ACESSIBILIDADE
   =================================================================== */
@media (prefers-reduced-motion: reduce) {
    body::before,
    body::after {
        transition: none !important;
    }
}
