/* ---------------------------------------------------------
   portal.css - Portal do Colaborador — Safe Extintores
   Cores alinhadas ao Sistema SaaS Multitenant
   --------------------------------------------------------- */

:root {
    /* ── Marca Safe Extintores ─────────────────────────── */
    --primary:        #801715;          /* Vermelho Vinho */
    --primary-hover:  #a31c1a;
    --primary-light:  rgba(128,23,21,0.08);
    --primary-border: rgba(128,23,21,0.25);
    --header-bg:      #0f0f0f;          /* Preto — igual ao sistema principal */
    /* ── Semânticas ────────────────────────────────────── */
    --accent:         #ef5350;
    --success:        #2e7d32;
    /* ── Base ──────────────────────────────────────────── */
    --bg-light:       #f4f5f7;
    --text-main:      #1a1a1a;
    --text-soft:      #666;
    --border:         #e4e4e4;
    --glass:          rgba(255,255,255,0.90);
    --shadow:         0 2px 8px rgba(0,0,0,0.07);
    --shadow-md:      0 4px 20px rgba(0,0,0,0.10);
    --radius:         12px;
    --cor-primaria:   #801715;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    /* iOS Safari pode estourar a largura mesmo com overflow no body;
       fixar aqui também garante que nada ultrapasse a largura da tela. */
    overflow-x: hidden;
    max-width: 100%;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-light);
    color: var(--text-main);
    overflow-x: hidden;
    max-width: 100%;
    height: 100vh;
}

.hidden { display: none !important; }

/* Fallback CSS: esconde o splash após 4s mesmo que o JS falhe */
@keyframes _splashAutoHide {
    0%,  90% { opacity: 1; visibility: visible; pointer-events: auto; }
    100%     { opacity: 0; visibility: hidden;  pointer-events: none; }
}
.splash-screen {
    animation: _splashAutoHide 4s ease-out forwards;
}

/* splash screen */
.splash-screen {
    position: fixed;
    inset: 0;
    background: #fff;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.logo-container img {
    width: 200px;
    margin-bottom: 20px;
    animation: fadeIn 0.8s ease;
}

.loader {
    width: 36px;
    height: 36px;
    border: 3px solid #eee;
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* auth container */
.auth-container {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-card {
    background: #fff;
    padding: 40px 30px;
    width: 100%;
    max-width: 400px;
    border-radius: 24px;
    box-shadow: var(--shadow);
    text-align: center;
}

.auth-card h1 { font-size: 1.8rem; margin-bottom: 10px; color: var(--primary); }
.auth-card p { color: var(--text-soft); font-size: 0.9rem; margin-bottom: 30px; }

.form-group { text-align: left; margin-bottom: 20px; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 8px; color: var(--text-soft); }
.form-group input {
    width: 100%;
    padding: 14px;
    border: 1.5px solid #eee;
    border-radius: 12px;
    font-family: inherit;
    font-size: 1rem;
    transition: 0.3s;
}
.form-group input:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 4px var(--primary-light); }

.btn-primary {
    width: 100%;
    padding: 15px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    margin-top: 10px;
    letter-spacing: 0.3px;
}
.btn-primary:hover  { background: var(--primary-hover); }
.btn-primary:active { transform: scale(0.98); }

/* Spinner do botão durante o login */
.btn-primary.is-loading { color: transparent !important; pointer-events: none; position: relative; }
.btn-primary.is-loading::after {
    content: ""; position: absolute; top: 50%; left: 50%; width: 18px; height: 18px;
    margin: -9px 0 0 -9px; border: 2px solid rgba(255,255,255,0.45); border-top-color: #fff;
    border-radius: 50%; animation: btn-spin 0.6s linear infinite;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }

.auth-footer { margin-top: 20px; font-size: 0.8rem; color: #999; }

/* app container */
.app-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg-light);
}

.app-wrapper { flex: 1; overflow-y: auto; padding: 20px; padding-bottom: 100px; }

.app-header {
    background: #fff;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.03);
    position: sticky;
    top: 0;
    z-index: 100;
}

.user-info { display: flex; align-items: center; gap: 12px; }
.avatar {
    width: 44px;
    height: 44px;
    background: var(--primary);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
}

.greeting { font-size: 0.75rem; color: var(--text-soft); }
.user-name { font-size: 1rem; font-weight: 700; color: var(--text-main); }

.btn-icon {
    width: 40px;
    height: 40px;
    border: none;
    background: #f1f3f5;
    border-radius: 12px;
    color: var(--text-soft);
    cursor: pointer;
}

/* bottom navigation */
.bottom-nav {
    position: fixed;
    bottom: 20px;
    left: 20px;
    right: 20px;
    height: 70px;
    background: var(--glass);
    backdrop-filter: blur(10px);
    border-radius: 24px;
    display: flex;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
    border: 1px solid rgba(255,255,255,0.3);
    z-index: 1000;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    border: none;
    background: none;
    color: var(--text-soft);
    cursor: pointer;
    transition: 0.2s;
    flex: 1;
}

.nav-item.active { color: var(--primary); }
.nav-item .material-symbols-outlined { font-size: 24px; transition: transform 0.2s; }
.nav-item.active .material-symbols-outlined { font-variation-settings: 'FILL' 1; transform: scale(1.1); }
.nav-item span { font-size: 0.65rem; font-weight: 600; }

/* cards */
.app-content { padding: 20px; }

.section-title { font-size: 1.2rem; font-weight: 700; margin-bottom: 20px; color: var(--text-main); }

.card {
    background: #fff;
    border-radius: 20px;
    padding: 20px;
    margin-bottom: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.02);
    border: 1px solid #f0f0f0;
}

/* Specific Section Styles Injected via JS later */

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVIDADE COMPLETA — Portal do Colaborador
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Mobile pequeno (≤ 480px) ─────────────────────────────────────────────── */
@media (max-width: 480px) {
    .auth-card {
        padding: 30px 20px;
        border-radius: 0;
        min-height: 100dvh;
        max-width: 100%;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }
    .bottom-nav {
        left: 0;
        right: 0;
        bottom: 0;
        border-radius: 0;
        border: none;
        border-top: 1.5px solid #eee;
        height: 60px;
    }
    .app-wrapper { padding: 12px; padding-bottom: 80px; }
    .nav-item span { font-size: 0.6rem; }
    .app-header { padding: 14px 16px; }
    .avatar { width: 38px; height: 38px; font-size: 0.95rem; }
    .user-name { font-size: 0.9rem; }
    .card { padding: 16px; border-radius: 16px; }
    .section-title { font-size: 1.05rem; }

    /* ── Conteúdo do portal (inline-styled) cabe na tela ──────────────── */
    /* Nada pode estourar a largura da tela */
    #portal-content { max-width: 100%; overflow-x: hidden; }
    /* min-width:0 permite que itens de flex/grid encolham (some o overflow) */
    #portal-content *,
    #portal-content .ponto-marcacao-col { min-width: 0; }
    /* Grids de 2 colunas → 1 coluna no celular */
    .portal-cards-grid { grid-template-columns: 1fr !important; }
    /* Espelho de ponto (4 colunas) → 2x2 */
    #portal-ponto-espelho { grid-template-columns: 1fr 1fr !important; }
    /* Quebra de palavras longas (nomes, e-mails) evita estouro */
    #portal-content { word-break: break-word; overflow-wrap: anywhere; }
}

/* ── Tablet (481px – 1024px) ──────────────────────────────────────────────── */
@media (min-width: 481px) and (max-width: 1024px) {
    body { background: var(--bg-light); }
    .app-container {
        max-width: 600px;
        margin: 0 auto;
        box-shadow: 0 0 40px rgba(0,0,0,0.08);
    }
    .auth-container { background: #e8edf5; }
    .auth-card {
        max-width: 440px;
        border-radius: 28px;
        padding: 44px 36px;
    }
    .bottom-nav {
        left: 30px;
        right: 30px;
        bottom: 24px;
        max-width: 540px;
        margin: 0 auto;
    }
    .app-wrapper { padding: 24px; padding-bottom: 110px; }
    .card { border-radius: 20px; }
}

/* ── Desktop (> 1024px) ───────────────────────────────────────────────────── */
@media (min-width: 1025px) {
    body {
        background: var(--bg-light);
        min-height: 100vh;
        display: block;
        align-items: unset;
        justify-content: unset;
    }
    .splash-screen {
        max-width: 460px;
        left: 50%;
        transform: translateX(-50%);
        border-radius: 24px;
        overflow: hidden;
    }
    .app-container {
        max-width: 100%;
        width: 100%;
        height: auto;
        min-height: 100vh;
        border-radius: 0;
        box-shadow: none;
        overflow: visible;
    }
    .auth-container {
        background: var(--bg-light);
        padding: 20px;
        height: 100vh;
    }
    .auth-card {
        border-radius: 24px;
        max-width: 420px;
        box-shadow: var(--shadow);
    }
    .card { border-radius: 20px; }
    .btn-primary:hover { opacity: 0.9; transform: translateY(-1px); box-shadow: 0 6px 20px rgba(21,101,192,0.25); }
}

/* ═══════════════════════════════════════════════════════════════════
   PORTAL TOPBAR — padrão do Sistema SaaS (header preto + borda vinho)
   ═══════════════════════════════════════════════════════════════════ */
#portal-topbar {
    background: #fff;
    border-bottom: 3px solid var(--primary);
    padding: 0 20px;
    height: 54px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 200;
    gap: 12px;
}

/* Lado esquerdo: logo + nome da empresa */
#topbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

#topbar-logo {
    height: 30px;
    object-fit: contain;
    display: block;
}

#topbar-company-name {
    color: rgba(255,255,255,0.92);
    font-weight: 700;
    font-size: 0.875rem;
    letter-spacing: 0.2px;
    white-space: nowrap;
}

/* Lado direito: avatar + nome + logout */
#topbar-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

#topbar-user-info {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 0.825rem;
    font-weight: 600;
    color: rgba(255,255,255,0.85);
}

#topbar-user-info .topbar-avatar {
    width: 30px;
    height: 30px;
    background: var(--primary);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 800;
    flex-shrink: 0;
    border: 2px solid rgba(255,255,255,0.15);
}

#btn-portal-logout {
    display: flex;
    align-items: center;
    gap: 5px;
    background: #fff1f1;
    color: var(--primary);
    border: 1px solid var(--primary-border);
    border-radius: 8px;
    padding: 6px 12px;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.78rem;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}
#btn-portal-logout:hover {
    background: var(--primary);
    color: #fff;
}
#btn-portal-logout .material-symbols-outlined { font-size: 15px; }

/* ═══════════════════════════════════════════════════════════════════
   PORTAL CONTENT WRAPPER
   ═══════════════════════════════════════════════════════════════════ */
#portal-content {
    padding: 24px;
    max-width: 1300px;
    margin: 0 auto;
    /* É um item flex de .app-container (column). Sem min-width:0 o item flex
       usa min-width:auto e se recusa a encolher abaixo da largura do conteúdo,
       vazando para a direita no celular. */
    min-width: 0;
    width: 100%;
}

/* .app-container é flex column; impede que qualquer item ultrapasse a tela. */
.app-container { max-width: 100%; overflow-x: hidden; }

/* ═══════════════════════════════════════════════════════════════════
   PORTAL TABS  (espelha o sistema interno)
   ═══════════════════════════════════════════════════════════════════ */
.subaba-portal-conteudo { display: none; }
.subaba-portal-conteudo.ativo { display: block; }

.sidebar-sub-navegacao { scrollbar-width: none; }
.sidebar-sub-navegacao::-webkit-scrollbar { display: none; }

.tab-btn {
    background: none;
    border: none;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    color: #777;
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.15s, background 0.15s;
    /* Mantém o tamanho natural (ícone + texto lado a lado). Sem isto, o
       min-width:0 do conteúdo deixava o botão encolher e o ícone sobrepunha
       o texto; a barra de abas deve rolar na horizontal, não comprimir. */
    flex-shrink: 0;
}

/* Garante o ícone ao lado do texto, nunca por cima. */
.tab-btn .material-symbols-outlined { flex-shrink: 0; }

.tab-btn:hover { color: #222; background: #fafafa; }

.tab-btn.ativo {
    color: var(--primary);
    font-weight: 700;
    background: transparent;
    border-bottom: 3px solid var(--primary);
}

/* ═══════════════════════════════════════════════════════════════════
   COMPONENTES DE FORMULÁRIO  (espelha o sistema interno)
   ═══════════════════════════════════════════════════════════════════ */
.painel-acoes {
    background: #fafafa;
    border: 1px solid #eaeaea;
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.campo-form {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.campo-form label {
    font-size: 0.78rem;
    font-weight: 600;
    color: #666;
}

.campo-form input,
.campo-form select {
    padding: 8px 10px;
    border: 1.5px solid #e0e0e0;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.875rem;
    color: #333;
    background: #fff;
    transition: border-color 0.2s;
}

.campo-form input:focus,
.campo-form select:focus {
    outline: none;
    border-color: #505050;
}

.btn-registrar {
    background: #2e7d32;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 10px 20px;
    font-family: inherit;
    font-weight: 700;
    font-size: 0.875rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background 0.15s;
}

.btn-registrar:hover { background: #1b5e20; }

.btn-cancelar {
    background: #f5f5f5;
    color: #666;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 10px 20px;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-cancelar:hover { background: #ebebeb; }

.btn-acao {
    background: #f0f0f0;
    color: #505050;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 8px 14px;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.8rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background 0.15s;
}

.btn-acao:hover { background: #e4e4e4; }

/* ═══════════════════════════════════════════════════════════════════
   RESPONSIVIDADE PORTAL
   ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
    #portal-content { padding: 16px; }

    /* Força colunas da dashboard para coluna única */
    #portal-content #portal-dash > div[style*="grid-template-columns: minmax"] {
        grid-template-columns: 1fr !important;
    }
    #portal-content #portal-ponto > div[style*="grid-template-columns: auto"] {
        grid-template-columns: 1fr !important;
    }
    #portal-content #portal-ferias > div[style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }
    #portal-content #portal-dados > div[style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }
}
