/* =========================================================================
   Escala de Enfermagem - UPA Noroeste
   Folha de estilo principal (mobile-first, responsiva e moderna).
   Estrategia: estilos base pensados para o celular; media queries ampliam
   o layout para tablets e desktops.
   ========================================================================= */

/* ----- Tokens de design (cores, espacamentos, tipografia) ----- */
:root {
    --cor-primaria: #0d9488;        /* teal 600 */
    --cor-primaria-escura: #0f766e; /* teal 700 */
    --cor-primaria-clara: #ccfbf1;  /* teal 100 */
    --cor-secundaria: #6366f1;      /* indigo 500 */
    --cor-fundo: #f1f5f9;           /* slate 100 */
    --cor-superficie: #ffffff;
    --cor-texto: #0f172a;           /* slate 900 */
    --cor-texto-suave: #64748b;     /* slate 500 */
    --cor-borda: #e2e8f0;           /* slate 200 */

    --ok: #16a34a;
    --ok-bg: #dcfce7;
    --erro: #dc2626;
    --erro-bg: #fee2e2;
    --aviso: #d97706;
    --aviso-bg: #fef3c7;
    --info: #2563eb;
    --info-bg: #dbeafe;

    --raio: 14px;
    --raio-sm: 10px;
    --sombra: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
    --sombra-md: 0 4px 16px rgba(15, 23, 42, .10);
    --transicao: .18s ease;

    --header-altura: 56px;
    --nav-altura: 64px;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
    background: var(--cor-fundo);
    color: var(--cor-texto);
    line-height: 1.5;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--cor-primaria-escura); text-decoration: none; }

/* ===================== Layout autenticado (app) ===================== */

.app-header {
    position: sticky;
    top: 0;
    z-index: 30;
    height: var(--header-altura);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    padding: 0 1rem;
    background: var(--cor-primaria);
    color: #fff;
    box-shadow: var(--sombra-md);
}
.app-header .marca {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-weight: 700;
    font-size: 1rem;
    color: #fff;
    text-decoration: none;
    min-width: 0;
    overflow: hidden;
}
.app-header .marca span {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.app-header .marca-logo {
    display: block;
    width: 32px;
    height: 32px;
    object-fit: contain;
    border-radius: 8px;
    flex: 0 0 auto;
    background: rgba(255, 255, 255, .12);
}
.app-header .usuario {
    display: flex;
    align-items: center;
    gap: .6rem;
    font-size: .85rem;
}
.app-header .usuario a { color: #fff; opacity: .9; }

.app-main {
    max-width: 1024px;
    margin: 0 auto;
    padding: 1rem;
    padding-bottom: calc(var(--nav-altura) + 1.5rem); /* espaco p/ nav inferior */
}

/* ----- Navegacao inferior (mobile) ----- */
.bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 30;
    height: var(--nav-altura);
    display: flex;
    background: var(--cor-superficie);
    border-top: 1px solid var(--cor-borda);
    box-shadow: 0 -2px 12px rgba(15,23,42,.06);
}
.bottom-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-size: .68rem;
    color: var(--cor-texto-suave);
    transition: color var(--transicao);
}
.bottom-nav a .ico { font-size: 1.25rem; line-height: 1; }
.bottom-nav a.ativo { color: var(--cor-primaria-escura); font-weight: 600; }

/* ===================== Componentes ===================== */

.card {
    background: var(--cor-superficie);
    border: 1px solid var(--cor-borda);
    border-radius: var(--raio);
    box-shadow: var(--sombra);
    padding: 1rem;
    margin-bottom: 1rem;
}
.card h2, .card h3 { font-size: 1.05rem; margin-bottom: .25rem; }

.titulo-pagina {
    font-size: 1.35rem;
    font-weight: 700;
    margin-bottom: 1rem;
}
.subtitulo { color: var(--cor-texto-suave); font-size: .9rem; }

/* ----- Botoes ----- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .7rem 1.1rem;
    font-size: .95rem;
    font-weight: 600;
    border: 1px solid transparent;
    border-radius: var(--raio-sm);
    cursor: pointer;
    transition: background var(--transicao), transform var(--transicao), box-shadow var(--transicao);
    background: var(--cor-superficie);
    color: var(--cor-texto);
    min-height: 44px; /* alvo de toque confortavel */
}
.btn:active { transform: scale(.98); }
.btn-primario { background: var(--cor-primaria); color: #fff; }
.btn-primario:hover { background: var(--cor-primaria-escura); }
.btn-secundario { background: var(--cor-primaria-clara); color: var(--cor-primaria-escura); }
.btn-perigo { background: var(--erro); color: #fff; }
.btn-contorno { border-color: var(--cor-borda); background: #fff; }
.btn-bloco { width: 100%; }
.btn-sm { padding: .45rem .7rem; min-height: 36px; font-size: .85rem; }

/* ----- Formularios ----- */
.campo { margin-bottom: 1rem; }
.campo label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .35rem; }
.campo input, .campo select, .campo textarea {
    width: 100%;
    padding: .7rem .8rem;
    font-size: 1rem;
    border: 1px solid var(--cor-borda);
    border-radius: var(--raio-sm);
    background: #fff;
    color: var(--cor-texto);
    transition: border-color var(--transicao), box-shadow var(--transicao);
}
.campo input:focus, .campo select:focus, .campo textarea:focus {
    outline: none;
    border-color: var(--cor-primaria);
    box-shadow: 0 0 0 3px var(--cor-primaria-clara);
}
.campo .erro-msg { color: var(--erro); font-size: .8rem; margin-top: .3rem; }
.campo input.invalido, .campo select.invalido { border-color: var(--erro); }

/* ----- Alertas / flash ----- */
.alerta {
    padding: .75rem 1rem;
    border-radius: var(--raio-sm);
    margin-bottom: 1rem;
    font-size: .9rem;
    border: 1px solid transparent;
}
.alerta-sucesso { background: var(--ok-bg); color: #166534; border-color: #bbf7d0; }
.alerta-erro { background: var(--erro-bg); color: #991b1b; border-color: #fecaca; }
.alerta-aviso { background: var(--aviso-bg); color: #92400e; border-color: #fde68a; }
.alerta-info { background: var(--info-bg); color: #1e40af; border-color: #bfdbfe; }

/* ----- Badges de status/ocorrencia ----- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    padding: .2rem .55rem;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 700;
    white-space: nowrap;
}
.badge-presente { background: var(--ok-bg); color: #166534; }
.badge-folga    { background: var(--info-bg); color: #1e40af; }
.badge-falta    { background: var(--erro-bg); color: #991b1b; }
.badge-troca    { background: #f3e8ff; color: #6b21a8; }
.badge-extra    { background: var(--aviso-bg); color: #92400e; }
.badge-licenca  { background: #e2e8f0; color: #334155; }
.badge-fixo     { background: #cffafe; color: #155e75; }
.badge-neutro   { background: #e2e8f0; color: #334155; }

/* ===================== Pagina de login ===================== */
.auth-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.25rem;
    background:
        radial-gradient(1200px 600px at 10% -10%, rgba(13,148,136,.25), transparent),
        radial-gradient(900px 500px at 100% 0%, rgba(99,102,241,.18), transparent),
        var(--cor-fundo);
}
.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--cor-superficie);
    border-radius: 20px;
    box-shadow: var(--sombra-md);
    padding: 1.75rem 1.5rem;
}
.auth-card .marca-login {
    text-align: center;
    margin-bottom: 1.25rem;
}
.auth-card .marca-login-logo {
    display: block;
    width: 92px;
    height: 92px;
    margin: 0 auto .75rem;
    object-fit: contain;
    border-radius: 16px;
}
.auth-card h1 { font-size: 1.2rem; }
.auth-card .subtitulo { margin-bottom: 1.25rem; }

/* ===================== Tabela de escala ===================== */
.escala-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: .6rem;
    align-items: flex-end;
    margin-bottom: 1rem;
}
.escala-toolbar .campo { margin-bottom: 0; flex: 1 1 140px; }

.turno-bloco { margin-bottom: 1.25rem; }
.turno-cabecalho {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    padding: .6rem .9rem;
    border-radius: var(--raio-sm) var(--raio-sm) 0 0;
    color: #fff;
    font-weight: 700;
}
.turno-diurno .turno-cabecalho { background: linear-gradient(135deg, #f59e0b, #f97316); }
.turno-noturno .turno-cabecalho { background: linear-gradient(135deg, #4338ca, #1e3a8a); }
.turno-cabecalho .contagem { font-size: .8rem; font-weight: 600; opacity: .95; }

.categoria-titulo {
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--cor-texto-suave);
    font-weight: 700;
    padding: .6rem .9rem .2rem;
}

/* Cada profissional vira um "cartao-linha" (otimo para toque no celular) */
.prof-lista {
    background: var(--cor-superficie);
    border: 1px solid var(--cor-borda);
    border-top: none;
}
.prof-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .7rem .9rem;
    border-top: 1px solid var(--cor-borda);
}
.prof-item:first-child { border-top: none; }
.prof-ordem {
    flex: 0 0 auto;
    width: 26px; height: 26px;
    display: grid; place-items: center;
    background: var(--cor-fundo);
    border-radius: 8px;
    font-size: .8rem;
    font-weight: 700;
    color: var(--cor-texto-suave);
}
.prof-info { flex: 1 1 auto; min-width: 0; }
.prof-nome { font-weight: 600; font-size: .95rem; }
.prof-detalhe { font-size: .78rem; color: var(--cor-texto-suave); }
.prof-acao { flex: 0 0 auto; }

/* ----- Modal ----- */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(15,23,42,.5);
    display: none;
    align-items: flex-end;
    justify-content: center;
    z-index: 50;
}
.modal-overlay.aberto { display: flex; }
.modal {
    width: 100%;
    max-width: 480px;
    background: #fff;
    border-radius: 18px 18px 0 0;
    padding: 1.25rem;
    max-height: 90vh;
    overflow-y: auto;
    animation: subir .2s ease;
}
@keyframes subir { from { transform: translateY(40px); opacity: .5; } to { transform: translateY(0); opacity: 1; } }
.modal-cabecalho { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.modal-cabecalho h3 { font-size: 1.05rem; }
.modal-fechar { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--cor-texto-suave); line-height: 1; }

/* ----- Dashboard cards ----- */
.grid-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: .75rem;
    margin-bottom: 1rem;
}
.metric {
    background: var(--cor-superficie);
    border: 1px solid var(--cor-borda);
    border-radius: var(--raio);
    padding: 1rem;
    box-shadow: var(--sombra);
}
.metric .num { font-size: 1.7rem; font-weight: 800; color: var(--cor-primaria-escura); }
.metric .rotulo { font-size: .8rem; color: var(--cor-texto-suave); }

.atalhos { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem; }
.atalho {
    display: flex; flex-direction: column; gap: .35rem;
    padding: 1rem;
    background: var(--cor-superficie);
    border: 1px solid var(--cor-borda);
    border-radius: var(--raio);
    box-shadow: var(--sombra);
    transition: transform var(--transicao), box-shadow var(--transicao);
}
.atalho:active { transform: scale(.98); }
.atalho .ico { font-size: 1.5rem; }
.atalho .titulo { font-weight: 700; font-size: .95rem; color: var(--cor-texto); }
.atalho .desc { font-size: .78rem; color: var(--cor-texto-suave); }

/* ----- Lista de profissionais (cadastro) ----- */
.lista-prof .prof-item { background: #fff; border-radius: 0; }
.filtro-busca { margin-bottom: 1rem; }

.vazio {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--cor-texto-suave);
}
.vazio .ico { font-size: 2.5rem; display: block; margin-bottom: .5rem; }

/* ----- Utilitarios ----- */
.flex { display: flex; }
.flex-entre { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.gap { gap: .5rem; }
.mt { margin-top: 1rem; }
.mb { margin-bottom: 1rem; }
.text-suave { color: var(--cor-texto-suave); }
.text-centro { text-align: center; }
.hidden { display: none !important; }
.row-acoes { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ----- Rodape / direitos autorais ----- */
.app-rodape {
    text-align: center;
    padding: 1rem 1.25rem;
    font-size: .72rem;
    color: var(--cor-texto-suave);
    line-height: 1.4;
}
.app-rodape p { margin: 0; }
.app-main + .app-rodape {
    /* Espaco extra para nao ficar sob a navegacao inferior no celular. */
    padding-bottom: calc(var(--nav-altura) + .5rem);
}
.auth-body .app-rodape {
    padding: 1.25rem 1rem 2rem;
}

/* ===================== Responsivo (tablet/desktop) ===================== */
@media (min-width: 768px) {
    .grid-cards { grid-template-columns: repeat(4, 1fr); }
    .atalhos { grid-template-columns: repeat(3, 1fr); }
    .modal-overlay { align-items: center; }
    .modal { border-radius: 18px; }
    .form-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
}

@media (min-width: 1024px) {
    /* Em telas largas a navegacao inferior some e vira menu no topo. */
    .bottom-nav { display: none; }
    .app-main { padding-bottom: 1.5rem; }
    .app-main + .app-rodape { padding-bottom: 1rem; }
    .top-nav { display: flex !important; }
}

/* ===================== Impressao ===================== */
@media print {
    /* Oculta elementos de navegacao e acoes; imprime apenas o conteudo. */
    .app-header, .bottom-nav, .escala-toolbar, .row-acoes, form { display: none !important; }
    .app-main { padding: 0; max-width: none; }
    .card { box-shadow: none; border: none; padding: 0; margin: 0; }
    body { background: #fff; }
}

/* Navegacao no topo (desktop) - escondida no mobile */
.top-nav { display: none; gap: .25rem; }
.top-nav a {
    color: #fff;
    padding: .4rem .7rem;
    border-radius: 8px;
    font-size: .9rem;
    font-weight: 600;
    opacity: .9;
}
.top-nav a.ativo, .top-nav a:hover { background: rgba(255,255,255,.18); opacity: 1; }
