/* ============================================================
   OsterTrack / CCPS — Global Stylesheet
   Compartilhado entre: altera_reg, insere_reg, audita_reg,
   upload, delete, login, index e demais páginas.
   ============================================================ */

/* ---- Reset mínimo ---- */
*, *::before, *::after { box-sizing: border-box; }

/* ---- Variáveis ---- */
:root {
    --primary:      #2F2F2F;
    --primary-600:  #444444;
    --accent:       #3498db;
    --accent-light: #eaf4fb;
    --bg-gradient:  linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    --card-bg:      #ffffff;
    --text:         #333333;
    --muted:        #64748b;
    --border:       #e2e8f0;
    --readonly-bg:  #f8fafc;
    --danger:       #e74c3c;
    --shadow:       0 10px 25px rgba(0,0,0,.10);
    --radius:       16px;
    --field-radius: 8px;
}

/* ---- Base ---- */
body {
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg-gradient);
    color: var(--text);
    margin: 0;
    padding: 20px;
    min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }

/* ---- Card / Container ---- */
.card,
.container {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 30px;
    width: 100%;
}

/* Centraliza card na tela (páginas de formulário) */
body.centered {
    display: flex;
    align-items: center;
    justify-content: center;
}

body.centered .container {
    max-width: 550px;
}

/* ---- Títulos de seção ---- */
.section-title {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--accent);
    letter-spacing: 0.08em;
    margin: 20px 0 10px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 4px;
    grid-column: span 2;
}

/* ---- Grid de formulário ---- */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.form-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 4px;
}

.full-width { grid-column: span 2; }

/* ---- Labels e campos ---- */
label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: .2px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
select,
textarea {
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: var(--field-radius);
    font-size: 0.95rem;
    color: var(--text);
    background: #fff;
    outline: none;
    transition: border-color .2s ease, box-shadow .2s ease;
    width: 100%;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(52,152,219,.18);
}

input[readonly],
input[disabled] {
    background: var(--readonly-bg);
    color: #94a3b8;
    cursor: not-allowed;
    border-style: dashed;
}

textarea { height: 80px; resize: vertical; }

/* ---- Botão principal ---- */
.btn-submit,
.btn-primary {
    width: 100%;
    background: var(--primary);
    color: #fff;
    padding: 14px;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    font-size: 1rem;
    transition: background .2s ease, transform .1s ease, box-shadow .2s ease;
    margin-top: 20px;
}

.btn-submit:hover,
.btn-primary:hover {
    background: var(--primary-600);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,.15);
}

.btn-submit:active,
.btn-primary:active { transform: translateY(0); }

/* ---- Botão secundário ---- */
.btn-sec {
    background: #66707A;
    color: #fff;
    padding: 8px 14px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background .2s;
}
.btn-sec:hover { background: #4f5861; }

/* ---- Botão de perigo (delete/excluir) ---- */
.btn-danger,
button.btn-danger,
input.btn-danger {
    width: 100%;
    background: var(--danger);
    color: #fff;
    padding: 14px;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    font-size: 1rem;
    transition: background .2s, transform .1s, box-shadow .2s;
    margin-top: 10px;
}
.btn-danger:hover { background: #c0392b; transform: translateY(-2px); box-shadow: 0 4px 12px rgba(231,76,60,.25); }
.btn-danger:active { transform: translateY(0); }

/* ---- Botão voltar / link discreto ---- */
.btn-back,
.btn-cancel {
    display: inline-block;
    margin-top: 16px;
    color: #666;
    font-size: .9rem;
    text-decoration: none;
    transition: color .2s;
}
.btn-back:hover,
.btn-cancel:hover { color: var(--primary); text-decoration: underline; }

/* ---- Link home / nav ---- */
.nav-home { display: block; text-align: left; margin-bottom: 20px; }

/* ---- Título de página (h2 e h4 com sublinhado accent) ---- */
.page-title,
h2.page-title,
h4.page-title {
    color: var(--primary);
    text-align: center;
    margin: 0 0 25px;
    font-size: 1.3rem;
    border-bottom: 2px solid var(--accent);
    padding-bottom: 10px;
    font-weight: 600;
}

/* ---- Rodapé de logos — aliases unificados ---- */
.footer-logos,
.logo-footer,
.logo {
    text-align: center;
    margin-top: 30px;
    opacity: 0.6;
}

/* ---- Validação ---- */
.campo-erro { border-color: var(--danger) !important; background: #fff5f5 !important; }
.msg-erro   { font-size: .75rem; color: var(--danger); margin-top: 4px; display: none; }
.msg-erro.visivel { display: block; }

/* ---- Alertas ---- */
.alert {
    padding: 10px 14px;
    border-radius: 10px;
    font-size: .92rem;
    margin-bottom: 14px;
    border: 1px solid transparent;
}
.alert-error { background: #fff5f5; color: #c62828; border-color: #ffd6d6; }
.alert-info  { background: #f3f8ff; color: #233a4d; border-color: #cfe3ff; }
.alert-ok    { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }

/* ---- Modal de erros ---- */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}
.modal-overlay.ativo { display: flex; }

.modal-box {
    background: #fff;
    border-radius: 14px;
    padding: 28px 30px;
    max-width: 420px;
    width: 90%;
    box-shadow: 0 12px 30px rgba(0,0,0,.15);
}
.modal-box h5 {
    margin: 0 0 15px 0;
    color: var(--danger);
    font-size: 1.1rem;
    border-bottom: 2px solid var(--danger);
    padding-bottom: 8px;
}
.modal-box ul {
    margin: 0 0 20px 0;
    padding-left: 20px;
    color: #555;
    line-height: 1.9;
    font-size: .9rem;
}
.modal-btn-fechar {
    width: 100%;
    padding: 11px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: .95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s;
}
.modal-btn-fechar:hover { background: var(--primary-600); }

/* ---- Painel lateral de equipamentos (insere_reg) ---- */
.equip-panel {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    width: 220px;
    min-width: 220px;
    padding: 20px;
    position: sticky;
    top: 20px;
}
.equip-panel h5 {
    margin: 0 0 15px 0;
    color: var(--primary);
    font-size: .9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 2px solid var(--accent);
    padding-bottom: 8px;
}
.equip-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 70vh;
    overflow-y: auto;
}
.equip-list li { border-bottom: 1px solid var(--border); }
.equip-list li:last-child { border-bottom: none; }
.equip-item {
    display: flex;
    flex-direction: column;
    padding: 10px 8px;
    cursor: pointer;
    border-radius: 8px;
    transition: background .2s;
}
.equip-item:hover { background: var(--accent-light); }
.equip-item.selecionado {
    background: #d1ecf1;
    border-left: 3px solid var(--accent);
}
.equip-cd { font-weight: 700; font-size: .95rem; color: var(--accent); }
.equip-nm { font-size: .78rem; color: var(--muted); margin-top: 2px; }
.equip-vazio { font-size: .85rem; color: #94a3b8; text-align: center; padding: 10px 0; }

/* ---- Instrução / info box ---- */
.instruction {
    background: #f8f9fa;
    padding: 12px;
    border-left: 4px solid var(--accent);
    font-size: .85rem;
    color: #666;
    text-align: left;
    margin-bottom: 20px;
    border-radius: 4px;
}

/* ---- Responsivo ---- */
@media (max-width: 700px) {
    body { padding: 12px; }
    body.has-sidebar { flex-direction: column; align-items: center; }
    .equip-panel { width: 100%; min-width: unset; position: static; }
    .form-grid { grid-template-columns: 1fr; }
    .full-width,
    .section-title { grid-column: span 1; }
}

@media (max-width: 500px) {
    .container { padding: 20px 16px; }
}
