:root {
    --primary: #2c5282;
    --primary-hover: #1a365d;
    --secondary: #319795;
    --secondary-hover: #285e61;
    --bg-color: #f7fafc;
    --border-color: #cbd5e0;
    --text-main: #2d3748;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    padding: 20px;
    transition: background-color 0.3s, color 0.3s;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: hidden;
}

.header { 
    max-width: 1200px; 
    margin: 0 auto 10px auto; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    position: relative; 
    min-height: 60px;
    width: 100%;
}

.header h1 { 
    color: var(--primary); 
    font-size: 24px; 
    text-align: center;
}

.logo-img { 
    position: absolute; 
    left: 0; 
    height: 50px;
    top: 50%; 
    transform: translateY(-50%);
}

.top-controls {
    max-width: 1200px; width: 100%; margin: 0 auto 15px auto;
    display: flex; flex-direction: column; align-items: flex-start; gap: 12px;
}

.tabs {
    width: 100%; 
    display: flex; 
    border-bottom: 2px solid var(--border-color);
    flex-wrap: wrap; 
    gap: 5px;
    padding-bottom: 5px;
}

.tab-btn {
    background: none; border: none; padding: 10px 15px; font-size: 15px;
    font-weight: 600; color: #718096; cursor: pointer; border-bottom: 3px solid transparent;
    margin-bottom: -2px; transition: all 0.3s;
}

.tab-btn:hover { color: var(--primary); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

.top-actions {
    width: 100%;
    justify-content: flex-end; 
}

.view-toggle {
    display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: bold; color: var(--text-main);
    background: #e2e8f0; padding: 8px 12px; border-radius: 6px; cursor: pointer;
}
.view-toggle input { width: 16px; height: 16px; cursor: pointer; }

.tab-content { display: none; width: 100%; max-width: 1200px; margin: 0 auto; gap: 20px; flex: 1; }
.tab-content.active { display: flex; align-items: flex-start; }

.hide-preview .tab-content.active { justify-content: center; }
.hide-preview .panel-preview { display: none !important; }
.hide-preview .panel-form { flex: none !important; width: 100%; max-width: 850px; margin: 0 auto; }

.panel { background: white; padding: 20px; border-radius: 8px; box-shadow: 0 4px 6px rgba(0,0,0,0.05); flex: 1; transition: all 0.3s ease; }
.panel-form { flex: 1.2; }
.panel-preview { flex: 1; position: sticky; top: 20px; }

h2 { font-size: 18px; margin-bottom: 15px; border-bottom: 1px solid var(--border-color); padding-bottom: 10px; color: var(--primary); display: flex; justify-content: space-between; align-items: center; }
h3 { font-size: 15px; margin: 15px 0 10px 0; color: var(--text-main); }

.bag-header {
    background-color: #e2e8f0; color: var(--primary); padding: 12px 15px; cursor: pointer;
    border-radius: 6px; display: flex; justify-content: space-between; align-items: center;
    margin-top: 15px; margin-bottom: 10px; border: 1px solid var(--border-color); transition: background-color 0.2s;
}
.bag-header:hover { background-color: #cbd5e0; }
.bag-content { display: block; overflow: hidden; padding: 0 5px; }
.bag-content.collapsed { display: none; }
.bolsa-extra { margin-top: 10px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 10px; }
.form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-grid-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
.form-full { grid-column: 1 / -1; }

label { display: block; font-size: 12px; font-weight: bold; margin-bottom: 4px; color: var(--text-main); }
input[type="text"], input[type="number"], input[type="date"], input[type="time"], select, textarea {
    width: 100%; padding: 8px; border: 1px solid var(--border-color); border-radius: 4px; font-size: 14px;
    background-color: #fff; color: var(--text-main);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
input:disabled { background-color: #e2e8f0; cursor: not-allowed; opacity: 0.7; } 

.checkbox-group { display: flex; align-items: center; gap: 8px; height: 100%; }
.checkbox-group input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; }
.checkbox-group label { margin-bottom: 0; font-size: 14px; cursor: pointer; }

.btn-prefixo {
    background-color: #edf2f7; border: 1px solid var(--border-color); color: var(--text-main);
    padding: 0 10px; border-radius: 4px; cursor: pointer; font-size: 12px; font-weight: bold;
    transition: all 0.2s; white-space: nowrap; height: 100%; display: flex; align-items: center;
}
.btn-prefixo:hover { background-color: #e2e8f0; color: var(--primary); border-color: var(--primary); }
.input-with-button { display: flex; gap: 5px; align-items: stretch; height: 35px; }

.vitals-wrapper { width: 100%; margin-bottom: 15px; }
.vitals-grid {
    display: grid; 
    grid-template-columns: 1.2fr repeat(4, 1fr); 
    gap: 5px; 
    background: #edf2f7; padding: 10px; border-radius: 6px;
}
.vitals-grid-2 { grid-template-columns: 1.2fr repeat(2, 1fr); }
.vitals-header { font-size: 11px; font-weight: bold; text-align: center; color: var(--text-main); }
.vitals-row-label { font-size: 12px; font-weight: bold; display: flex; align-items: center; justify-content: flex-end; padding-right: 5px; color: var(--text-main);}

.vitals-grid input { 
    text-align: center; padding: 6px; height: 30px;
    width: 100%; min-width: 0;
}

.btn-group { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.btn { padding: 10px 15px; font-size: 14px; font-weight: bold; border-radius: 4px; border: none; cursor: pointer; color: white; transition: 0.2s; }
.btn-blue { background-color: var(--primary); }
.btn-blue:hover { background-color: var(--primary-hover); }
.btn-teal { background-color: var(--secondary); }
.btn-teal:hover { background-color: var(--secondary-hover); }
.btn-red { background-color: #e53e3e; }
.btn-red:hover { background-color: #c53030; }
.btn-pause { background-color: #cbd5e0; color: #2d3748; }

.btn-giant {
    padding: 25px 20px !important;
    font-size: 22px !important;
    width: 100%;
    margin-bottom: 10px;
    text-transform: uppercase;
}

.document-render {
    font-family: 'Times New Roman', Times, serif; font-size: 14px; line-height: 1.4; color: black;
    background: white; padding: 30px; border: 1px solid #ccc; min-height: 500px;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.05); overflow-y: auto; max-height: 75vh;
}

.document-render h1.doc-title { text-align: center; font-size: 18px; margin-bottom: 20px; }
.document-render p { margin-bottom: 10px; }
.document-render strong { font-weight: bold; }

.doc-table { width: 100%; border-collapse: collapse; margin: 15px 0 25px 0; font-size: 13px; }
.doc-table th, .doc-table td { border: 1px solid black; padding: 2px 4px; text-align: center; line-height: 1.1; margin: 0; }
.doc-table th { background-color: #f2f2f2; }

.doc-footer { text-align: center; font-weight: bold; margin-top: 20px; font-size: 13px;}

#toast {
    visibility: hidden; min-width: 250px; background-color: #38a169; color: #fff; text-align: center;
    border-radius: 6px; padding: 16px; position: fixed; z-index: 1000; left: 50%; bottom: 30px;
    transform: translateX(-50%); font-size: 15px; font-weight: bold; box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    transition: opacity 0.3s, bottom 0.3s; opacity: 0;
}
#toast.show { visibility: visible; opacity: 1; bottom: 50px; }

.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.7); display: flex;
    justify-content: center; align-items: center; z-index: 2000; visibility: hidden; opacity: 0; transition: all 0.2s;
}
.modal-overlay.show { visibility: visible; opacity: 1; }
.modal-content {
    background: white; padding: 25px; border-radius: 8px; width: 90%; max-width: 450px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2); transform: translateY(-20px); transition: transform 0.2s;
}
.modal-overlay.show .modal-content { transform: translateY(0); }

.rodape-copyright {
    text-align: center;
    padding: 20px 10px;
    margin-top: 40px;
    font-size: 13px;
    color: #718096;
    border-top: 1px solid var(--border-color);
    width: 100%;
}

@media (max-width: 900px) {
    .tab-content.active { flex-direction: column; }
    .panel { width: 100%; }
    .panel-preview { position: static; }
    h2 { flex-direction: column; align-items: flex-start; gap: 10px;}
}

@media (max-width: 600px) {
    body { padding: 10px; }
    .form-grid, .form-grid-3, .form-grid-4, .form-grid-2 { grid-template-columns: 1fr !important; }
    .top-actions { justify-content: flex-start; width: 100%; }
    .view-toggle { width: 100%; justify-content: center; margin-top: 5px; }
    .tabs { gap: 2px; }
    .tab-btn { padding: 8px; font-size: 13px; flex-grow: 1; text-align: center; }
    .btn-giant { font-size: 18px !important; padding: 20px 15px !important; }
    .vitals-grid { grid-template-columns: 45px repeat(4, 1fr); gap: 2px; padding: 5px; }
    .vitals-grid-2 { grid-template-columns: 55px repeat(2, 1fr); }
    .vitals-header { font-size: 9px; letter-spacing: -0.5px; }
    .vitals-row-label { font-size: 9px; padding-right: 2px; }
    .vitals-grid input { font-size: 11px; padding: 2px; height: 26px; }
}

/* --- ESTILOS DO ORGANIZADOR DE PLANTÃO --- */
.org-header { background: #edf2f7; padding: 15px; border-radius: 8px; margin-bottom: 20px; border: 1px solid var(--border-color); }
.org-header h2 { margin-top: 0; border: none; padding-bottom: 0; justify-content: center; }
.org-section-title { background: var(--primary); color: white; padding: 8px 12px; border-radius: 4px; display: inline-block;}
.org-section-header { 
    display: flex; justify-content: space-between; align-items: center; 
    margin-top: 25px; margin-bottom: 10px; cursor: pointer; 
    border-radius: 4px; transition: background 0.2s; padding-right: 5px;
}
.org-section-header:hover { background-color: #e2e8f0; }
.org-section-header .org-section-title { margin-top: 0; margin-bottom: 0; display: flex; align-items: center; gap: 8px; }
.toggle-icon { font-size: 14px; }
.org-collapsed { display: none !important; }
.task-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.task-item { 
    display: flex; align-items: center; gap: 10px; padding: 10px; background: white; 
    border: 1px solid var(--border-color); border-radius: 6px; transition: 0.2s;
}
.task-item.dragging { opacity: 0.5; background: #e2e8f0; }
.task-item:hover { border-color: var(--primary); box-shadow: 0 2px 4px rgba(0,0,0,0.05); }
.drag-handle { cursor: grab; color: #a0aec0; font-size: 18px; user-select: none; padding: 0 5px; }
.drag-handle:active { cursor: grabbing; }
.task-checkbox { width: 20px; height: 20px; cursor: pointer; }
.task-text { flex: 1; font-size: 14px; font-weight: 500; outline: none; }
.task-text[contenteditable="true"] { border-bottom: 1px dashed var(--primary); background: #f7fafc; padding: 2px 5px; }
.task-actions { display: flex; gap: 5px; }
.btn-icon { background: none; border: none; cursor: pointer; color: #718096; font-size: 16px; transition: 0.2s; padding: 2px 5px;}
.btn-icon:hover { color: var(--primary); transform: scale(1.1); }
.buscas-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 15px; margin-top: 15px; margin-bottom: 20px; }
.busca-item { background: #edf2f7; padding: 10px; border-radius: 6px; border: 1px solid var(--border-color); display: flex; align-items: center; gap: 10px;}
.task-item.checked { background-color: #f0fff4; border-color: #9ae6b4; }
.task-item.checked .task-text { text-decoration: line-through; color: #38a169; }
.busca-item.checked { background-color: #f0fff4; border-color: #9ae6b4; }
.busca-item.checked label, .busca-item.checked input[type="text"] { text-decoration: line-through; color: #38a169; }

/* --- ESTILOS DA ABA FERRAMENTAS --- */
.tool-card {
    background: #ffffff; padding: 20px; border-radius: 8px; border: 1px solid var(--border-color);
    box-shadow: 0 4px 6px rgba(0,0,0,0.05); display: flex; flex-direction: column; transition: transform 0.3s ease;
}
.tool-card h3 { margin-top: 0; color: var(--primary); border-bottom: 1px solid var(--border-color); padding-bottom: 10px; margin-bottom: 15px; }
.result-box { margin-top: 20px; background: var(--primary); color: white; text-align: center; border-radius: 6px; }
.timer-display { font-size: 40px; font-family: monospace; text-align: center; margin: 10px 0 20px 0; color: var(--primary); background: #edf2f7; padding: 10px; border-radius: 6px; border: 1px solid var(--border-color); font-weight: bold; }
.timer-quick-btns { display: flex; justify-content: center; gap: 10px; }
.alarm-item { background: #edf2f7; border-left: 4px solid var(--secondary); padding: 10px; margin-bottom: 8px; border-radius: 4px; display: flex; justify-content: space-between; align-items: center; font-size: 13px; font-weight: bold; transition: 0.3s; }
.alarm-item.done { opacity: 0.6; border-left-color: #cbd5e0; }
.alarm-item.done .alarm-info { text-decoration: line-through; color: #718096; }

.tool-fullscreen { position: fixed !important; top: 0; left: 0; width: 100vw; height: 100vh; z-index: 9999; background: white; margin: 0 !important; max-width: none !important; border-radius: 0; justify-content: center; overflow-y: auto; }
.tool-fullscreen .timer-display { font-size: 80px; padding: 40px 10px; }
.tool-fullscreen .btn-giant { padding: 40px 20px !important; font-size: 30px !important; }
.rotate-180 { transform: rotate(180deg); }

/* --- RODAPÉ E AVISO DE PRIVACIDADE --- */
.rodape-copyright {
    text-align: center;
    padding: 25px 15px;
    margin-top: auto; /* Empurra o rodapé pro fundo da tela */
    font-size: 13px;
    color: #718096;
    border-top: 1px solid var(--border-color);
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.aviso-privacidade {
    font-size: 11.5px;
    color: #a0aec0;
    max-width: 800px;
    margin: 0 auto;
    line-height: 1.4;
}

/* Modo escuro para o aviso de privacidade */
body.dark-mode .aviso-privacidade {
    color: #718096;
}

/* ========================================================
   MODO ESCURO (DARK MODE)
   ======================================================== */
body.dark-mode {
    --bg-color: #1a202c;
    --text-main: #e2e8f0;
    --border-color: #4a5568;
    --primary: #63b3ed; 
    --primary-hover: #4299e1;
}
body.dark-mode .panel, body.dark-mode .modal-content, body.dark-mode .tool-card, 
body.dark-mode .task-item, body.dark-mode input, body.dark-mode select, body.dark-mode textarea {
    background-color: #2d3748; color: #e2e8f0; border-color: #4a5568;
}
body.dark-mode .document-render { background-color: #1a202c; color: #e2e8f0; border-color: #4a5568; }
body.dark-mode .bag-header, body.dark-mode .vitals-grid, body.dark-mode .busca-item, 
body.dark-mode .alarm-item, body.dark-mode .org-header, body.dark-mode .btn-prefixo, 
body.dark-mode .view-toggle, body.dark-mode .timer-display {
    background-color: #4a5568; color: #e2e8f0; border-color: #718096;
}
body.dark-mode .bag-header:hover, body.dark-mode .org-section-header:hover, body.dark-mode .btn-prefixo:hover { background-color: #718096; }
body.dark-mode h3, body.dark-mode label, body.dark-mode .vitals-header { color: #cbd5e0; }
body.dark-mode table.doc-table th { background-color: #4a5568; color: #fff;}
body.dark-mode table.doc-table td, body.dark-mode table.doc-table th { border-color: #718096; }
body.dark-mode .task-item.checked, body.dark-mode .busca-item.checked { background-color: #276749; border-color: #2f855a; }
body.dark-mode .task-item.checked .task-text, body.dark-mode .busca-item.checked label, body.dark-mode .busca-item.checked input { color: #9ae6b4; }
body.dark-mode .alarm-item.done { opacity: 0.5; border-left-color: #718096; }
body.dark-mode .task-text[contenteditable="true"] { background: #1a202c; }
body.dark-mode .btn-pause { background-color: #4a5568; color: #e2e8f0; }
body.dark-mode .tool-fullscreen { background: #1a202c; }

/* IMPRESSÃO */
@media print {
    body * { visibility: hidden; }
    .printable-area, .printable-area * { visibility: visible; }
    .printable-area { position: absolute; left: 0; top: 0; width: 100%; }
    .no-print, .header, .top-controls, .drag-handle, .task-actions { display: none !important; }
    .task-item { border: none; border-bottom: 1px solid #ccc; border-radius: 0; padding: 5px 0; }
    .org-section-title { color: black !important; background: transparent !important; border-bottom: 2px solid black; padding: 0; margin-top: 15px;}
    textarea { border: 1px solid #ccc; resize: none; }
    .org-collapsed { display: block !important; }
    .toggle-icon { display: none; }
    
    /* Garante impressão com cores corretas independente do dark mode */
    body.dark-mode .printable-area { background: white; color: black; }
    body.dark-mode .org-header, body.dark-mode .task-item, body.dark-mode .busca-item { background: white; border-color: #ccc; }
    body.dark-mode .org-section-title { color: black !important; border-bottom: 2px solid black; }
}