/* ==========================================================================
   CIPA Onix (PHP) — estilos portados do app Next.js (Tailwind -> CSS estático).
   Variáveis de marca de src/app/globals.css; layouts dos componentes React.
   ========================================================================== */

:root {
    --cipa-purple: #43097d;
    --cipa-purple-light: #f0ebf8;
    --brand-purple: #43097d;
    --brand-purple-dark: #260449;
    --brand-purple-light: #f0ebf8;
    --brand-magenta: #c026d3;
    --brand-cyan: #17c3c3;
    --safety-yellow: #ffc42c;
    --cipa-green: #2fa84f;
    --ink: #241338;
    --paper: #ffffff;
    --paper-soft: #f8f6fb;
    --line: #e4deef;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    background: #ffffff;
    color: #333333;
    font-family: "Roboto", Arial, Helvetica, sans-serif;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p, ul, ol, figure { margin: 0; }

a { color: inherit; }

.font-display { font-family: "Barlow Condensed", Arial, Helvetica, sans-serif; }
.font-mono { font-family: "Roboto Mono", "Courier New", monospace; }

.hazard-stripe {
    background-image: repeating-linear-gradient(
        135deg,
        var(--brand-purple) 0,
        var(--brand-purple) 10px,
        var(--safety-yellow) 10px,
        var(--safety-yellow) 20px
    );
}

/* ==========================================================================
   Apresentação (SlideDeck)
   ========================================================================== */

.deck {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100vh;
    width: 100%;
    overflow: hidden;
}

.deck-header {
    display: flex;
    height: 80px;
    flex-shrink: 0;
    align-items: center;
    justify-content: space-around;
    gap: 16px;
    background: var(--brand-purple);
    padding: 0 16px;
    color: #fff;
}
.deck-header img { height: 70%; width: auto; object-fit: contain; }
.deck-header h1 { text-align: center; font-size: 1.125rem; font-weight: 500; }

.deck-footer {
    flex-shrink: 0;
    background: var(--brand-purple);
    padding: 4px 8px;
    text-align: center;
    font-size: 0.75rem;
    color: #fff;
}

.deck-main {
    display: flex;
    min-height: 0;
    flex: 1;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 8px 20px;
}

.deck-row {
    display: flex;
    width: 100%;
    min-height: 0;
    flex: 1;
    align-items: center;
    gap: 16px;
}

.deck-stage { height: 100%; min-height: 0; flex: 1; overflow: hidden; }

/* Setas de navegação */
.deck-arrow {
    display: flex;
    height: 50px;
    width: 50px;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    align-self: center;
    border: none;
    border-radius: 9999px;
    background: #f0ebf8;
    color: #43097d;
    font-size: 1.5rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
}
.deck-arrow:hover:not(:disabled) { background: #43097d; color: #fff; }
.deck-arrow:disabled { cursor: not-allowed; opacity: 0.6; }
.deck-arrow.is-hidden { visibility: hidden; }
.deck-arrow .count { font-size: 0.75rem; font-weight: 600; }

/* Indicadores (dots) */
.deck-dots {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding-bottom: 8px;
}
.deck-dot { height: 10px; width: 10px; border-radius: 9999px; background: #f0ebf8; }
.deck-dot.is-active { background: #43097d; box-shadow: 0 0 0 3px #43097d; }

/* Slide (2 colunas) */
.slide {
    display: grid;
    grid-template-columns: 1fr;
    height: 100%;
    width: 100%;
    align-items: center;
    gap: 24px;
    overflow-y: auto;
    padding: 16px 8px;
}
.slide-media { display: flex; width: 100%; flex-direction: column; align-items: center; justify-content: center; }
.slide-media img { width: 80%; border-radius: 20px; object-fit: cover; }
.slide-body { display: flex; width: 100%; flex-direction: column; justify-content: center; text-align: center; }
.slide-body h2 { margin: 20px 0; font-size: 1.25rem; font-weight: 900; line-height: 1.2; color: #333; }
.slide-body p { margin-bottom: 20px; font-size: 1rem; line-height: 1.2; font-weight: 500; }
.slide-list { margin-bottom: 8px; }
.slide-list-label { margin-bottom: 8px; font-size: 1.125rem; font-weight: 700; line-height: 1.2; }
.slide-list ul, .slide-list ol { padding-left: 1.25rem; display: flex; flex-direction: column; gap: 8px; }
.slide-list ul { list-style: disc; }
.slide-list ol { list-style: decimal; }
.slide-list li { font-size: 1rem; font-weight: 500; line-height: 1.2; text-align: left; }

/* Tela final / PortariaCard */
.deck-end {
    display: flex;
    height: 100%;
    width: 100%;
    align-items: center;
    justify-content: center;
    padding: 0 24px;
    text-align: center;
    font-size: 1.25rem;
    font-weight: 600;
    color: #333;
}
.portaria { align-items: center; }
.portaria .slide-media img { width: 60%; border-radius: 0; }
.portaria-body { display: flex; width: 100%; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 20px; }
.portaria-body h2 { font-size: 1.25rem; font-weight: 900; line-height: 1.2; color: #333; }
.portaria-body p { font-size: 1rem; font-weight: 500; line-height: 1.2; }
.btn-portaria {
    border-radius: 9999px;
    background: #43097d;
    padding: 12px 32px;
    font-size: 1.125rem;
    font-weight: 600;
    color: #fff;
    text-decoration: none;
    transition: opacity 0.2s;
}
.btn-portaria:hover { opacity: 0.9; }

@media (min-width: 768px) {
    .deck-main { padding: 8px 20px; }
    .slide { grid-template-columns: 1fr 1fr; gap: 40px; padding: 16px 24px; }
    .slide-body { text-align: left; }
    .portaria .slide-media img { width: 80%; }
}

/* ==========================================================================
   Login
   ========================================================================== */

.login { display: flex; min-height: 100vh; width: 100%; flex-direction: column; }
.login-hero {
    position: relative;
    display: flex;
    width: 100%;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
    background: linear-gradient(135deg, var(--brand-purple-dark), var(--brand-purple) 55%, #5a12a0);
    padding: 40px 32px;
    color: #fff;
}
.login-hero .blob { position: absolute; border-radius: 9999px; filter: blur(60px); pointer-events: none; }
.login-hero .blob-1 { right: -96px; top: -96px; height: 288px; width: 288px; background: var(--brand-magenta); opacity: 0.2; }
.login-hero .blob-2 { bottom: -128px; left: 40px; height: 320px; width: 320px; background: var(--brand-cyan); opacity: 0.1; }
.login-hero .row { position: relative; z-index: 10; display: flex; align-items: center; gap: 12px; }
.login-hero .row img { height: 44px; width: auto; object-fit: contain; }
.login-hero .divider { height: 32px; width: 1px; background: rgba(255,255,255,0.25); }
.login-hero .kicker { font-family: "Roboto Mono", monospace; font-size: 11px; text-transform: uppercase; letter-spacing: 0.25em; color: rgba(255,255,255,0.7); }
.login-hero .headline { position: relative; z-index: 10; display: flex; flex-direction: column; gap: 24px; padding: 48px 0; }
.login-hero .headline h1 { font-family: "Barlow Condensed", sans-serif; font-size: 3rem; font-weight: 700; text-transform: uppercase; line-height: 0.95; }
.login-hero .headline p { max-width: 24rem; font-size: 0.875rem; line-height: 1.6; color: rgba(255,255,255,0.75); }
.login-hero .stripe { position: relative; z-index: 10; height: 6px; width: 100%; border-radius: 9999px; opacity: 0.9; }

.login-panel { display: flex; width: 100%; flex: 1; align-items: center; justify-content: center; background: var(--paper-soft); padding: 64px 24px; }
.login-form { width: 100%; max-width: 24rem; }
.login-form img.logo { margin-bottom: 24px; height: 48px; width: 48px; object-fit: contain; }
.login-form h2 { font-family: "Barlow Condensed", sans-serif; font-size: 1.875rem; font-weight: 700; text-transform: uppercase; color: var(--ink); }
.login-form .lead { margin-top: 8px; font-size: 0.875rem; line-height: 1.6; color: #666; }
.btn-ms {
    margin-top: 32px;
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: center;
    gap: 12px;
    border: none;
    border-radius: 9999px;
    background: var(--brand-purple);
    padding: 14px 24px;
    font-size: 0.875rem;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    transition: opacity 0.2s;
    text-decoration: none;
}
.btn-ms:hover { opacity: 0.9; }
.btn-ms svg { height: 16px; width: 16px; flex-shrink: 0; }
.login-error { margin-top: 16px; border-radius: 8px; border: 1px solid #fecaca; background: #fef2f2; padding: 12px 16px; font-size: 0.75rem; line-height: 1.6; color: #b91c1c; }
.login-note { margin-top: 40px; font-size: 0.75rem; line-height: 1.6; color: #999; }

@media (min-width: 768px) {
    .login { flex-direction: row; }
    .login-hero { width: 55%; padding: 56px 64px; }
    .login-hero .headline h1 { font-size: 3.75rem; }
    .login-panel { width: 45%; }
}

/* ==========================================================================
   Cadastro (painel admin)
   ========================================================================== */

.admin { min-height: 100vh; width: 100%; background: var(--paper-soft); }
.admin-stripe { height: 6px; width: 100%; }
.admin-header { border-bottom: 1px solid var(--line); background: var(--brand-purple); }
.admin-header .inner { margin: 0 auto; display: flex; width: 100%; max-width: 64rem; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 24px; }
.admin-header .brand { display: flex; align-items: center; gap: 12px; }
.admin-header .brand img { height: 36px; width: auto; object-fit: contain; }
.admin-header h1 { font-family: "Barlow Condensed", sans-serif; font-size: 1.125rem; font-weight: 700; text-transform: uppercase; line-height: 1; color: #fff; }
.admin-header .who { margin-top: 4px; font-family: "Roboto Mono", monospace; font-size: 11px; color: rgba(255,255,255,0.6); }
.btn-signout { border: 1px solid rgba(255,255,255,0.3); border-radius: 9999px; background: transparent; padding: 6px 16px; font-size: 0.875rem; color: rgba(255,255,255,0.85); cursor: pointer; transition: background 0.2s; }
.btn-signout:hover { background: rgba(255,255,255,0.1); }

.admin-main { margin: 0 auto; display: flex; width: 100%; max-width: 64rem; flex-direction: column; gap: 32px; padding: 40px 24px; }

.card { overflow: hidden; border-radius: 16px; border: 1px solid var(--line); background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,0.05); }
.card .stripe { height: 6px; width: 100%; }
.card .body { padding: 24px; }
.card h2 { font-family: "Barlow Condensed", sans-serif; font-size: 1.25rem; font-weight: 700; text-transform: uppercase; color: var(--ink); }
.card .sub { margin-top: 4px; font-size: 0.875rem; color: #777; }

.form-grid { margin-top: 24px; display: grid; gap: 20px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 0.875rem; font-weight: 500; color: var(--ink); }
.field input {
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--paper-soft);
    padding: 10px 14px;
    color: var(--ink);
    font: inherit;
    outline: none;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}
.field input:focus { border-color: var(--brand-purple); background: #fff; box-shadow: 0 0 0 2px rgba(67,9,125,0.15); }
.field-hint { font-size: 0.75rem; font-weight: 400; color: #999; }
.form-actions { display: flex; align-items: center; gap: 16px; }
.btn-primary {
    border: none;
    border-radius: 9999px;
    background: var(--brand-purple);
    padding: 10px 28px;
    font-size: 0.875rem;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    transition: opacity 0.2s;
}
.btn-primary:hover { opacity: 0.9; }
.btn-primary:disabled { opacity: 0.5; cursor: default; }
.form-error { font-size: 0.875rem; color: #dc2626; }
.form-success { margin-top: 20px; border-radius: 8px; border: 1px solid rgba(47,168,79,0.3); background: rgba(47,168,79,0.1); padding: 12px 16px; font-size: 0.875rem; color: #1f7a3a; }
.form-success a { font-weight: 500; text-decoration: underline; }

.section-head { margin-bottom: 16px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.section-head h2 { font-family: "Barlow Condensed", sans-serif; font-size: 1.25rem; font-weight: 700; text-transform: uppercase; color: var(--ink); }

.table-wrap { overflow: hidden; border-radius: 16px; border: 1px solid var(--line); background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,0.05); }
.table-scroll { overflow-x: auto; }
table.tecnicos { width: 100%; min-width: 720px; text-align: left; font-size: 0.875rem; border-collapse: collapse; }
table.tecnicos thead { background: var(--paper-soft); font-family: "Roboto Mono", monospace; font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; color: #888; }
table.tecnicos th { padding: 12px 20px; font-weight: 500; }
table.tecnicos td { padding: 14px 20px; border-top: 1px solid var(--line); }
table.tecnicos tbody tr:hover { background: rgba(248,246,251,0.6); }
.cell-strong { font-weight: 500; color: var(--ink); }
.cell-sub { font-size: 0.75rem; color: #999; }
.cell-muted { color: #444; }
.badge { display: inline-block; border-radius: 9999px; padding: 4px 10px; font-size: 0.75rem; font-weight: 500; }
.badge-green { background: rgba(47,168,79,0.1); color: var(--cipa-green); }
.badge-yellow { background: rgba(255,196,44,0.2); color: #8a6200; }
.badge-gray { background: var(--paper-soft); color: #888; }
.badge-red { background: #fee2e2; color: #b91c1c; }
.btn-copy { border: 1px solid var(--line); border-radius: 9999px; background: transparent; padding: 6px 14px; font-size: 0.75rem; font-weight: 500; color: var(--brand-purple); cursor: pointer; transition: all 0.2s; }
.btn-copy:hover { border-color: var(--brand-purple); background: var(--brand-purple-light); }
.convite-actions { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.btn-revoke { border: 1px solid #e5b4b4; border-radius: 9999px; background: transparent; padding: 6px 14px; font-size: 0.75rem; font-weight: 500; color: #c0392b; cursor: pointer; transition: all 0.2s; }
.btn-revoke:hover { border-color: #c0392b; background: #fbeaea; }
.btn-revoke:disabled { opacity: 0.6; cursor: default; }

.empty-state { border-radius: 16px; border: 1px dashed var(--line); background: #fff; padding: 40px 24px; text-align: center; }
.empty-state p { font-size: 0.875rem; color: #888; }

.btn-outline { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--brand-purple); border-radius: 9999px; background: transparent; padding: 8px 20px; font-size: 0.875rem; font-weight: 600; color: var(--brand-purple); cursor: pointer; transition: all 0.2s; }
.btn-outline:hover { background: var(--brand-purple); color: #fff; }
.btn-outline svg { height: 16px; width: 16px; }

@media (min-width: 640px) {
    .card .body { padding: 32px; }
    .form-grid { grid-template-columns: 1fr 1fr; }
    .field.full, .form-actions { grid-column: 1 / -1; }
}

/* ==========================================================================
   Modal de auditoria
   ========================================================================== */

.modal-overlay { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; background: rgba(36,19,56,0.5); padding: 32px 16px; }
/* O atributo HTML `hidden` tem especificidade baixíssima e seria ignorado pela
   regra acima (display: flex), deixando o modal sempre visível. Reforçamos aqui. */
.modal-overlay[hidden] { display: none; }
.modal { display: flex; max-height: 80vh; width: 100%; max-width: 32rem; flex-direction: column; overflow: hidden; border-radius: 16px; background: #fff; box-shadow: 0 25px 50px -12px rgba(0,0,0,0.4); }
.modal .stripe { height: 6px; width: 100%; flex-shrink: 0; }
.modal-head { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); padding: 16px 24px; }
.modal-head h2 { font-family: "Barlow Condensed", sans-serif; font-size: 1.25rem; font-weight: 700; text-transform: uppercase; color: var(--ink); }
.modal-head .sub { font-family: "Roboto Mono", monospace; font-size: 11px; color: #999; }
.modal-close { display: flex; height: 32px; width: 32px; align-items: center; justify-content: center; border: none; border-radius: 9999px; background: transparent; color: #999; cursor: pointer; transition: all 0.2s; }
.modal-close:hover { background: var(--paper-soft); color: var(--ink); }
.modal-body { flex: 1; overflow-y: auto; padding: 16px 24px; }
.audit-list { display: flex; flex-direction: column; gap: 12px; list-style: none; padding: 0; margin: 0; }
.audit-item { display: flex; align-items: flex-start; gap: 12px; border-bottom: 1px solid var(--line); padding-bottom: 12px; }
.audit-item:last-child { border-bottom: none; }
.audit-badge { margin-top: 2px; flex-shrink: 0; border-radius: 9999px; padding: 4px 10px; font-family: "Roboto Mono", monospace; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.audit-main { min-width: 0; flex: 1; }
.audit-main .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.875rem; font-weight: 500; color: var(--ink); }
.audit-main .actor { margin-top: 2px; font-size: 0.75rem; color: #777; }
.audit-time { flex-shrink: 0; font-family: "Roboto Mono", monospace; font-size: 11px; color: #999; }
.muted { font-family: "Roboto Mono", monospace; font-size: 0.75rem; color: #999; }

/* ==========================================================================
   404
   ========================================================================== */

.notfound { display: flex; min-height: 100vh; width: 100%; flex-direction: column; align-items: center; justify-content: center; background: var(--paper-soft); padding: 64px 24px; text-align: center; }
.notfound .top-stripe, .notfound .bottom-stripe { position: fixed; left: 0; height: 6px; width: 100%; }
.notfound .top-stripe { top: 0; }
.notfound .bottom-stripe { bottom: 0; }
.notfound img { margin-bottom: 32px; height: 64px; width: auto; object-fit: contain; opacity: 0.9; }
.notfound .kicker { font-family: "Roboto Mono", monospace; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.3em; color: var(--brand-purple); }
.notfound .code { margin-top: 16px; font-family: "Barlow Condensed", sans-serif; font-size: 7rem; font-weight: 700; text-transform: uppercase; line-height: 1; color: var(--ink); }
.notfound .msg { margin-top: 8px; max-width: 32rem; font-family: "Barlow Condensed", sans-serif; font-size: 1.5rem; font-weight: 700; text-transform: uppercase; line-height: 1.2; color: var(--brand-purple); }
.notfound .desc { margin-top: 16px; max-width: 24rem; font-size: 0.875rem; line-height: 1.6; color: #777; }
.notfound .actions { margin-top: 36px; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px; }
.notfound .btn-fill { border-radius: 9999px; background: var(--brand-purple); padding: 12px 28px; font-size: 0.875rem; font-weight: 600; color: #fff; text-decoration: none; transition: opacity 0.2s; }
.notfound .btn-fill:hover { opacity: 0.9; }
.notfound .btn-line { border-radius: 9999px; border: 1px solid var(--brand-purple); padding: 12px 28px; font-size: 0.875rem; font-weight: 600; color: var(--brand-purple); text-decoration: none; transition: background 0.2s; }
.notfound .btn-line:hover { background: var(--brand-purple-light); }

@media (min-width: 640px) {
    .notfound .code { font-size: 9rem; }
    .notfound .msg { font-size: 1.875rem; }
}
