/* style.css */
:root {
    --primary-color: #8BC34A; /* Light Green */
    --primary-dark: #689F38;
    --bg-color: #f1f8e9;
    --text-color: #333;
    --border-color: #ccc;
    --print-border: 1.5px solid #000;
}

body {
    font-family: 'Roboto', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
}

#app-tabs {
    width: 100%;
    background: #2e7d32;
    padding: 15px;
    display: flex;
    justify-content: center;
    gap: 15px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    box-sizing: border-box;
    z-index: 100;
}

.t-btn {
    padding: 12px 25px;
    font-size: 16px;
    font-weight: bold;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    background: #fff;
    color: #2e7d32;
    transition: 0.3s;
}

.t-btn:hover { background: #e0e0e0; }

.t-btn.active {
    background: #4caf50;
    color: #fff;
    box-shadow: inset 0 3px 5px rgba(0,0,0,0.2);
}

.logout-btn {
    background: #fff !important;
    color: #c62828 !important;
    border: 1.5px solid #ef9a9a !important;
    margin-left: auto; /* Empurra para a direita se houver espaço */
}

.logout-btn:hover {
    background: #ffebee !important;
    border-color: #c62828 !important;
}

.tab-content {
    width: 100%;
    display: none;
    justify-content: center;
    padding: 20px 0;
}

.tab-content.active {
    display: flex;
}

/* Dashboard Styles */
.dashboard-ui {
    background-color: #fff;
    width: 100%;
    max-width: 1200px;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    box-sizing: border-box;
}

.dashboard-ui h1 {
    color: var(--primary-color);
    text-align: center;
    margin-bottom: 5px;
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin: 30px 0;
}

.chart-card {
    background: #f9f9f9;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    border: 1px solid #eee;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 250px;
}

.wide-chart {
    grid-column: 1 / -1;
    min-height: 400px;
}

.table-container {
    margin-top: 40px;
    overflow-x: auto;
}

#table-fichas {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

#table-fichas th, #table-fichas td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

#table-fichas th {
    background: var(--primary-color);
    color: #fff;
}

#table-fichas tr:hover {
    background-color: #f1f1f1;
}

/* =========================================
   WEB UI STYLES
   ========================================= */

.web-ui {
    background: #fff;
    max-width: 800px;
    width: 100%;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.ui-header {
    text-align: center;
    margin-bottom: 30px;
}

.ui-header h1 {
    color: var(--primary-dark);
    margin: 0 0 10px 0;
}

.ui-header p {
    color: #666;
    margin: 0;
}

.form-section {
    background: #fafafa;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.form-section h2 {
    font-size: 1.2rem;
    color: var(--primary-dark);
    margin-top: 0;
    margin-bottom: 15px;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 5px;
    display: inline-block;
}

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

.form-row {
    display: flex;
    gap: 15px;
}

.form-row .form-group {
    flex: 1;
}

label {
    font-weight: bold;
    margin-bottom: 5px;
    font-size: 0.9rem;
    color: #444;
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="time"],
textarea {
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-family: inherit;
    font-size: 1rem;
    transition: border-color 0.3s;
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
input[type="time"]:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 5px rgba(139, 195, 74, 0.3);
}

textarea {
    resize: vertical;
}

.checkbox-group {
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.checkbox-group label {
    margin-bottom: 0;
    font-weight: normal;
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
}

.form-actions {
    text-align: center;
    margin-top: 30px;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 15px 30px;
    font-size: 1.1rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.3s, transform 0.1s;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.btn-primary:hover {
    background-color: var(--primary-dark);
}

.btn-primary:active {
    transform: translateY(2px);
}

.btn-secondary {
    background-color: #78909c;
    color: white;
    border: none;
    padding: 12px 20px;
    font-size: 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: 0.3s;
}

.btn-secondary:hover { background-color: #546e7a; }

.btn-info {
    background-color: #0288d1;
    color: white;
    border: none;
    padding: 12px 20px;
    font-size: 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: 0.3s;
}

.btn-info:hover { background-color: #01579b; }

.btn-danger-sm {
    background-color: #ef5350;
    color: white;
    border: none;
    padding: 5px 10px;
    font-size: 0.8rem;
    border-radius: 4px;
    cursor: pointer;
    transition: 0.3s;
}

.btn-danger-sm:hover { background-color: #c62828; }

/* Modal Styles */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: #fff;
    padding: 25px;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 10px;
}

.modal-header h2 { margin: 0; color: var(--primary-dark); }

.close-modal {
    font-size: 24px;
    cursor: pointer;
    color: #888;
}

.draft-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid #eee;
    transition: 0.2s;
}

.draft-item:hover { background: #f5f5f5; }

.draft-info { flex: 1; }
.draft-info strong { display: block; color: #333; }
.draft-info span { font-size: 0.85rem; color: #777; }

.draft-actions { display: flex; gap: 8px; }

/* =========================================
   PRINT TEMPLATE STYLES (MATCHES MOCKUP)
   ========================================= */

.print-wrapper {
    display: none;
}

.a4-page {
    width: 210mm;
    height: 296mm; /* Strictly constrain height */
    max-height: 296mm;
    background: white;
    padding: 2mm 12mm; /* Reduced top/bottom padding heavily to crush ghost pages */
    position: relative;
    overflow: hidden;
    box-sizing: border-box;
    font-family: Arial, Helvetica, sans-serif;
    color: #000;
    font-size: 13px;
    line-height: 1.4;
}

.header {
    text-align: center;
    margin-bottom: 2mm;
    position: relative;
    padding-top: 0;
}

.logo-container {
    width: 80px;
    height: 80px;
    margin: 0 auto 4px auto;
    border-radius: 50%;
    overflow: hidden;
    /* Place for user logo */
    display: flex;
    justify-content: center;
    align-items: center;
}

.logo-container img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.header h2 {
    font-size: 14px;
    font-weight: bold;
    margin: 0 0 2px 0;
}

.header h3 {
    font-size: 12px;
    font-weight: normal;
    margin: 0 0 3px 0;
}

.header h4 {
    font-size: 12px;
    font-weight: bold;
    font-style: italic;
    margin: 0;
    white-space: nowrap;
}

.box {
    margin-bottom: 5px;
    border: 1px solid #000;
    border-radius: 2px;
    overflow: hidden;
}

.box-title {
    text-align: center;
    font-weight: bold;
    padding: 3px 8px 1px 8px; /* Reduced vertical padding */
    border-bottom: none;
}

.box-content {
    padding: 0 12px 6px 12px;
}

.line {
    margin-bottom: 4px; /* Reduced from 6px */
}

.flex-line {
    display: flex;
    align-items: flex-end;
}

.fill {
    flex-grow: 1;
    border-bottom: var(--print-border);
    height: 20px; /* Reduced from 24px */
    box-sizing: border-box;
    padding-top: 4px; /* Adjusted baseline push */
    margin-left: 5px;
    padding-left: 5px;
    font-family: 'Courier New', monospace;
    font-size: 13px; /* Reduced from 14px */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fix-width-small { flex-grow: 0; width: 40px; text-align: center; padding: 0 !important; }
.fix-width-med { flex-grow: 0; width: 60px; }
.fix-width-date { flex-grow: 0; width: 90px; text-align: center;}
.fix-width-sig { flex-grow: 0; width: 250px; text-align: center; margin-left: 10px;}

.min-line {
    display: inline-block;
    min-width: 60px;
    border-bottom: 1px solid #000;
    text-align: center;
    font-family: 'Courier New', monospace;
}

.dt-line {
    flex-grow: 0 !important;
    min-width: 20px;
    text-align: center;
    padding-left: 0 !important;
    margin-left: 2px !important;
    margin-right: 2px !important;
}

.dt-line-y {
    min-width: 35px;
}

.m-left {
    margin-left: 25px;
}

.m-far {
    margin-left: 40px;
}

.checkbox {
    width: 12px;
    height: 12px;
    border: var(--print-border);
    display: inline-flex;
    justify-content: center;
    align-items: center;
    margin-left: 5px;
    font-weight: bold;
    font-size: 12px;
    position: relative;
    top: -2px;
}

.bold-label {
    font-weight: bold;
}

/* Área de Intervenção centered block */
.area-int-block {
    text-align: center;
    margin-top: 4px;
    margin-bottom: 2px;
}

.area-int-label {
    font-weight: bold;
    font-size: 12px;
    margin-bottom: 8px; /* Same as signature-line span */
}

.area-int-fill {
    border-bottom: 1px solid #000;
    width: 65%;
    margin: 0 auto;
    text-align: center;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    min-height: 18px;
    box-sizing: border-box;
    padding-top: 2px;
}

.text-lines {
    margin-top: -4px;
}

.signature-line {
    display: block !important;
    text-align: center;
    margin-top: 8px;
    margin-bottom: 4px;
}

.signature-line span {
    display: block;
    font-weight: bold;
    margin-bottom: 8px;
}

.signature-line .fill.fix-width-sig {
    width: 65% !important;
    margin: 0 auto;
    border-bottom: 1px solid #000;
}

.mb-extra {
    margin-bottom: 6px;
}

/* For multi-line text mapping */
.printed-text-line {
    border-bottom: var(--print-border);
    height: 25px; /* Reduced from 28px */
    margin-bottom: 2px;
    font-family: 'Courier New', monospace;
    font-size: 13px; /* Reduced to match .fill */
    box-sizing: border-box;
    padding-top: 8px; /* Adjusted baseline push */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.empty-line {
    border-bottom: var(--print-border);
    height: 25px; /* Reduced from 28px */
    margin-bottom: 2px;
    box-sizing: border-box;
}

/* ===== EFEITO PARTICULAS E ACESSO RESTRITO (Referência) ===== */
#particles-js {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: var(--secondary-color);
    background-image: url('bg_login.jpg'); /* Fotografia de Fundo */
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    z-index: 0;
}

#main-app {
    position: relative;
    z-index: 10; /* Fica por cima do fundo fixo */
    width: 100%;
}

#auth-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4); 
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 5000;
    pointer-events: none; /* Deixa o ponteiro passar para as partículas brincarem */
}

.auth-box {
    position: relative;
    background: rgba(245, 245, 245, 0.95);
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
    text-align: center;
    max-width: 400px;
    width: 90%;
    overflow: hidden;
    pointer-events: auto; /* Mas permite clicar na caixa de form */
}

.auth-box h2, .auth-box p, .auth-box input, .auth-box button {
    position: relative;
    z-index: 1; 
}

.auth-input {
    width: 100%;
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 10px;
    font-size: 1rem;
    margin-bottom: 20px;
    outline: none;
    transition: border-color 0.3s;
    font-family: inherit;
    text-align: center; 
    background: #fff;
    box-sizing: border-box;
}

.auth-input:focus {
    border-color: #dc1414;
    box-shadow: 0 0 0 4px rgba(220, 20, 20, 0.15);
}

.login-btn {
    width: 100%;
    padding: 15px;
    background: linear-gradient(135deg, rgba(185, 20, 20, 1), rgba(135, 0, 0, 1));
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 8px 15px rgba(185, 20, 20, 0.2);
}

.login-btn:hover {
    background: var(--primary-light-color);
    transform: translateY(-2px);
    box-shadow: 0 12px 20px rgba(128, 0, 0, 0.35);
}

/* ===== SPLASH SCREEN ===== */
.splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #ffffff;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.8s ease-in-out;
}

.splash-logo {
    width: 280px;
    height: auto;
    opacity: 0;
    animation: dramaticReveal 1.2s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes dramaticReveal {
    0% {
        transform: translateY(40px) scale(0.6) rotate(-5deg);
        opacity: 0;
        filter: drop-shadow(0 5px 10px rgba(0, 0, 0, 0.05));
    }
    100% {
        transform: translateY(0) scale(1) rotate(0deg);
        opacity: 1;
        filter: drop-shadow(0 15px 30px rgba(128, 0, 0, 0.2));
    }
}

.fade-out {
    opacity: 0;
    pointer-events: none;
}
