/* ==============================================================================
   DNA AUTO — LAYOUT BASE & ESTRUTURA GERAL
   ============================================================================== */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    min-height: 100dvh;
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
}

/* Reset nativo de botões e campos para preservar tema escuro corporativo */
button {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
    background: transparent;
    border: none;
    cursor: pointer;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

/* ==========================================================================
   REGRA UNIVERSAL DE CONTRASTE PARA CAIXAS DE TEXTO / INPUTS / BOXES:
   - Fundo escuro -> Letra branca (#FFFFFF)
   - Fundo claro/branco -> Letra preta (#0F172A)
   ========================================================================== */

/* 1. Base para campos de digitação */
input, select, textarea {
    font-family: inherit;
    font-size: inherit;
    outline: none;
    box-sizing: border-box;
}

/* 2. Padrão Dark (Fundo Escuro / Padrão Geral do Sistema) */
input, select, textarea,
.ws-dark-box input,
.ws-dark-box textarea,
.ws-dark-box select,
.input-dark,
input.dark-input,
textarea.dark-input,
select.dark-input,
[data-bg="dark"] input,
[data-bg="dark"] textarea {
    color: #FFFFFF;
    -webkit-text-fill-color: #FFFFFF;
    color-scheme: dark;
    caret-color: #00D4FF;
}

input::placeholder, select::placeholder, textarea::placeholder,
.ws-dark-box input::placeholder,
.ws-dark-box textarea::placeholder,
.input-dark::placeholder {
    color: rgba(255, 255, 255, 0.6) !important;
    -webkit-text-fill-color: rgba(255, 255, 255, 0.6) !important;
}

/* Autofill em fundo escuro */
input:-webkit-autofill,
input:-webkit-autofill:hover, 
input:-webkit-autofill:focus,
textarea:-webkit-autofill,
textarea:-webkit-autofill:hover,
textarea:-webkit-autofill:focus,
select:-webkit-autofill,
select:-webkit-autofill:hover,
select:-webkit-autofill:focus {
    -webkit-text-fill-color: #FFFFFF !important;
    -webkit-box-shadow: 0 0 0px 1000px rgba(11, 22, 44, 0.98) inset !important;
    transition: background-color 5000s ease-in-out 0s !important;
    color: #FFFFFF !important;
}

/* 3. REGRA ABSOLUTA PARA CAIXAS DE FUNDO BRANCO OU CLARO: LETRA PRETA OBRIGATÓRIA */
.ws-light-box input,
.ws-light-box textarea,
.ws-light-box select,
.ws-login-card-sheet input,
.ws-login-card-sheet textarea,
.ws-login-input-row input,
.ws-model-dash-card input,
.card-white input,
.bg-white input,
.input-light,
input.light-input,
input.bg-white,
input[style*="background: rgb(255, 255, 255)"],
input[style*="background: #fff"],
input[style*="background: #FFF"],
input[style*="background:#fff"],
input[style*="background:#FFF"],
input[style*="background: white"],
input[style*="background-color: rgb(255, 255, 255)"],
input[style*="background-color: #fff"],
input[style*="background-color: #FFF"],
input[style*="background-color:#fff"],
input[style*="background-color: white"],
textarea[style*="background: #fff"],
textarea[style*="background: white"],
select[style*="background: #fff"],
select[style*="background: white"],
.dna-input-light {
    color: #0F172A !important;
    -webkit-text-fill-color: #0F172A !important;
    caret-color: #0F172A !important;
    color-scheme: light !important;
}

.ws-light-box input::placeholder,
.ws-login-input-row input::placeholder,
.input-light::placeholder,
input.light-input::placeholder,
.dna-input-light::placeholder {
    color: #64748B !important;
    -webkit-text-fill-color: #64748B !important;
}

/* Autofill em fundo claro/branco */
.ws-light-box input:-webkit-autofill,
.ws-login-card-sheet input:-webkit-autofill,
.ws-login-input-row input:-webkit-autofill,
.input-light:-webkit-autofill,
.dna-input-light:-webkit-autofill {
    -webkit-text-fill-color: #0F172A !important;
    -webkit-box-shadow: 0 0 0px 1000px #FFFFFF inset !important;
    color: #0F172A !important;
}


/* Scrollbar estilizada */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
    background: var(--border-highlight);
    border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--brand-primary);
}

/* Estrutura Principal */
#app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    min-height: 100dvh;
    width: 100%;
    max-width: 100vw;
    overflow: hidden;
    position: relative;
}

/* Barra Superior Global */
.top-navbar {
    height: 64px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 100;
    flex-shrink: 0;
}

.brand-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.brand-logo-icon {
    width: 38px;
    height: 38px;
    background: #0A0F16;
    border: 1px solid rgba(255, 210, 28, 0.45);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 16px var(--brand-glow);
}

.brand-text-block h1 {
    font-size: 18px;
    font-weight: 900;
    letter-spacing: 0.5px;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 4px;
}

.brand-text-block p {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Indicador de Rede ao Vivo no Header */
.network-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
}

.pulse-dot {
    width: 8px;
    height: 8px;
    background: var(--proof-level-4);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--proof-level-4);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); opacity: 0.8; }
    50% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(0.95); opacity: 0.8; }
}

/* Seletor de Perfil / Acessos Rápidos no Topo Estilo TOTVS */
.nav-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.top-user-session-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.top-user-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.top-user-shortname {
    display: none;
}

.top-logout-btn {
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.35);
    color: #fca5a5;
    padding: 6px 12px;
    font-size: 11px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    white-space: nowrap;
}

.top-logout-btn:hover {
    background: rgba(239, 68, 68, 0.25);
    color: #ffffff;
    border-color: #ef4444;
}

.profile-quick-bar {
    display: flex;
    align-items: center;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 3px;
    gap: 2px;
}

.profile-pill-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.profile-pill-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.profile-pill-btn.active {
    background: var(--bg-surface);
    color: var(--brand-cyan);
    border-color: var(--border-highlight);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.profile-pill-btn svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
}

/* Corpo Principal (Sidebar + Conteúdo) */
.main-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
    min-width: 0;
}

/* Sidebar de Navegação Corporativa TOTVS */
.sidebar {
    width: 270px;
    background: #0d121f;
    border-right: 1px solid rgba(255, 255, 255, 0.07);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    flex-shrink: 0;
    overflow-y: auto;
    transition: var(--transition-normal);
}

.sidebar-brand-badge {
    padding: 14px 20px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-brand-badge .env-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.6px;
    color: var(--brand-primary);
    text-transform: uppercase;
    background: rgba(255, 210, 28, 0.1);
    border: 1px solid rgba(255, 210, 28, 0.3);
    padding: 2px 8px;
    border-radius: 4px;
}

.sidebar-brand-badge .sys-version {
    font-size: 10px;
    color: var(--text-dim);
    font-family: var(--font-mono);
}

.nav-module-group {
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.nav-section-title {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: #64748b;
    font-weight: 700;
    padding: 10px 20px 4px;
    display: flex;
    align-items: center;
    gap: 7px;
}

.nav-section-title svg {
    width: 12px;
    height: 12px;
    stroke: #64748b;
}

.nav-menu {
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 18px;
    color: #94a3b8;
    font-size: 12.5px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    border-left: 2px solid transparent;
    user-select: none;
    position: relative;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.04);
    color: #f8fafc;
}

.nav-item.active {
    background: rgba(255, 255, 255, 0.06);
    color: #ffffff;
    border-left-color: #FFD21C;
    font-weight: 600;
}

.nav-svg-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    stroke: currentColor;
    opacity: 0.85;
    transition: opacity 0.15s ease;
}

.nav-item:hover .nav-svg-icon {
    opacity: 1;
}

.nav-item.active .nav-svg-icon {
    stroke: #FFD21C;
    opacity: 1;
}

/* Submenu Discreto para Oficinas & Carros */
.nav-sub-menu {
    list-style: none;
    margin: 2px 0 6px;
    padding: 0 0 0 34px;
    border-left: 1px solid rgba(255, 255, 255, 0.06);
    margin-left: 26px;
}

.nav-sub-item {
    padding: 6px 12px;
    font-size: 11.5px;
    color: #64748b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.15s ease;
    border-radius: 4px;
    margin-bottom: 2px;
}

.nav-sub-item:hover {
    color: #cbd5e1;
    background: rgba(255, 255, 255, 0.03);
}

.nav-sub-item.active {
    color: #FFD21C;
    background: rgba(255, 210, 28, 0.08);
    font-weight: 600;
}

.nav-sub-count {
    font-size: 10px;
    color: #475569;
    font-family: var(--font-mono);
}

.nav-sub-item.active .nav-sub-count {
    color: #FFD21C;
}

.nav-badge {
    margin-left: auto;
    background: rgba(255, 255, 255, 0.06);
    color: #94a3b8;
    font-size: 10px;
    font-weight: 500;
    padding: 1px 6px;
    border-radius: 3px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.nav-badge.warning,
.nav-badge.success,
.nav-badge.primary {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.08);
    color: #94a3b8;
}

/* Rodapé Corporativo de Sessão do Usuário */
.sidebar-user-session {
    padding: 14px 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(0, 0, 0, 0.25);
}

.user-session-card {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-session-avatar {
    width: 34px;
    height: 34px;
    border-radius: 6px;
    background: linear-gradient(135deg, #1e293b, #0f172a);
    border: 1px solid rgba(255, 255, 255, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.user-session-avatar svg {
    width: 18px;
    height: 18px;
    stroke: var(--brand-cyan);
}

.user-session-info {
    flex: 1;
    min-width: 0;
}

.user-session-name {
    font-size: 12px;
    font-weight: 700;
    color: #f8fafc;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-session-role {
    font-size: 11px;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 4px;
}

.user-session-role .status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #10b981;
    display: inline-block;
}

/* Área de Conteúdo Central */
.content-viewport {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 24px 32px 60px;
    background: var(--bg-main);
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

/* Cabeçalho de Tela */
.view-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.view-header-title h2 {
    font-size: 22px;
    font-weight: 800;
    color: var(--text-highlight);
    letter-spacing: -0.5px;
}

.view-header-title p {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Responsividade Mobile */
.mobile-menu-btn {
    display: none;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 24px;
    cursor: pointer;
    padding: 6px;
    line-height: 1;
}

/* Backdrop escuro ao abrir sidebar no celular */
.sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 998;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.sidebar-backdrop.active {
    display: block;
    opacity: 1;
}

@media (max-width: 900px) {
    .top-navbar {
        height: 52px;
        padding: 0 10px;
        gap: 6px;
    }

    .brand-wrapper {
        gap: 8px;
    }

    .brand-logo-icon {
        width: 30px;
        height: 30px;
        font-size: 14px;
    }

    .brand-text-block h1 {
        font-size: 14px;
        letter-spacing: 0.3px;
    }

    .brand-text-block p {
        display: none !important;
    }

    .top-user-fullname {
        display: none !important;
    }

    .top-user-shortname {
        display: inline !important;
        font-size: 11px;
    }

    .top-user-badge {
        padding: 4px 8px;
        font-size: 11px;
        gap: 4px;
    }

    .top-logout-btn {
        padding: 5px 8px;
        font-size: 10.5px;
    }

    /* Oculta os botões de perfil do topo no celular para não esmagar a tela */
    .profile-quick-bar {
        display: none !important;
    }

    .network-pill {
        display: none !important;
    }

    .mobile-menu-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 32px;
        height: 32px;
        font-size: 18px;
    }

    .sidebar {
        position: fixed;
        left: -290px;
        top: 52px;
        bottom: 0;
        width: 280px;
        z-index: 999;
        transition: left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: none;
    }

    .sidebar.open {
        left: 0;
        box-shadow: 10px 0 35px rgba(0, 0, 0, 0.85);
    }

    .content-viewport {
        padding: 12px 10px 115px !important;
        width: 100%;
        max-width: 100vw;
        box-sizing: border-box;
        overflow-x: hidden;
    }

    .view-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        margin-bottom: 14px;
    }

    .view-header-title h2 {
        font-size: 18px;
        line-height: 1.25;
    }

    .view-header-title p {
        font-size: 11.5px;
        line-height: 1.4;
    }
}

@media (max-width: 480px) {
    .top-navbar {
        padding: 0 8px;
    }

    .top-user-shortname {
        display: none !important;
    }

    .top-user-badge {
        padding: 4px 6px;
    }

    .top-logout-label {
        display: none !important;
    }

    .top-logout-btn {
        padding: 5px 6px;
    }
}
