@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600;700&family=DM+Mono:wght@400;500&display=swap');

:root {
    --primary: #0A7C3E;
    --primary-light: #12A050;
    --primary-dark: #065C2E;
    --primary-glow: rgba(10,124,62,0.15);
    --accent: #F0A500;
    --danger: #E53935;
    --info: #1565C0;
    --info-light: #1976D2;

    --bg: #F2F4F3;
    --bg-card: #FFFFFF;
    --bg-subtle: #F7F9F8;
    --border: #E0E6E3;
    --border-strong: #CBD5D0;

    --text: #1A2420;
    --text-secondary: #4A6055;
    --text-muted: #8A9E97;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.12), 0 4px 8px rgba(0,0,0,0.06);
    --shadow-modal: 0 25px 60px rgba(0,0,0,0.2), 0 8px 20px rgba(0,0,0,0.1);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;
}

*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'DM Sans', sans-serif;
    margin: 0;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ─── HEADER ─────────────────────────────────────────────── */
header {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 60%, var(--primary-light) 100%);
    color: white;
    padding: 0;
    box-shadow: 0 4px 20px rgba(6,92,46,0.35);
    position: sticky;
    top: 0;
    z-index: 100;
}

header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 16px 28px;
    flex-wrap: wrap;
}

header h1 {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.3px;
    display: flex;
    align-items: center;
    gap: 10px;
}



.search-container {
    display: flex;
    gap: 0;
    flex: 1;
    max-width: 480px;
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: 50px;
    overflow: hidden;
    transition: background 0.2s, box-shadow 0.2s;
}

.search-container:focus-within {
    background: rgba(255,255,255,0.2);
    box-shadow: 0 0 0 3px rgba(255,255,255,0.2);
}

.search-container input {
    flex: 1;
    padding: 11px 18px;
    border: none;
    background: transparent;
    color: white;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.95rem;
    outline: none;
}

.search-container input::placeholder { color: rgba(255,255,255,0.6); }

#btnSearch {
    background: rgba(255,255,255,0.2);
    color: white;
    border: none;
    padding: 11px 20px;
    cursor: pointer;
    font-family: 'DM Sans', sans-serif;
    font-weight: 600;
    font-size: 0.9rem;
    transition: background 0.2s;
    white-space: nowrap;
}

#btnSearch:hover { background: rgba(255,255,255,0.35); }

/* ─── CONTAINER ─────────────────────────────────────────── */
.container { max-width: 1200px; margin: 0 auto; padding: 24px 28px; }

/* ─── LOADING / MESSAGES ─────────────────────────────────── */
#loading {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
    font-size: 0.95rem;
}

#messageArea {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 12px;
    border-left: 4px solid;
}

.msg-warning {
    background: #FFF8E1;
    border-color: var(--accent);
    color: #7B5800;
}

.msg-error {
    background: #FFEBEE;
    border-color: var(--danger);
    color: #B71C1C;
}

/* ─── NO RESULTS AREA ────────────────────────────────────── */
#noResultsArea {
    background: linear-gradient(135deg, #F0F7F2, #E8F4EC);
    border: 1.5px dashed var(--primary);
    border-radius: var(--radius-lg);
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
    animation: slideDown 0.3s ease;
}

#noResultsArea p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ─── MAIN TABLE ─────────────────────────────────────────── */
.table-responsive {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
}

table { width: 100%; border-collapse: collapse; }

thead { background: var(--bg-subtle); }

th {
    padding: 13px 16px;
    text-align: left;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
}

td {
    padding: 14px 16px;
    font-size: 0.92rem;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    vertical-align: middle;
}

tbody tr {
    transition: background 0.15s;
    cursor: pointer;
}

tbody tr:hover { background: var(--bg-subtle); }

tbody tr:last-child td { border-bottom: none; }

/* ─── BADGES ─────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 50px;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    vertical-align: middle;
    margin-left: 6px;
}

.badge-totvs {
    background: #E8F0FE;
    color: #1557C0;
    border: 1px solid #BECEF7;
}

.badge-mysql {
    background: #E6F4EA;
    color: #1E7E34;
    border: 1px solid #A8D5B5;
}

/* ─── MODAL SYSTEM ──────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(10, 24, 18, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

.modal-content {
    background: var(--bg-card);
    padding: 32px;
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 920px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: var(--shadow-modal);
    border: 1px solid var(--border);
    animation: slideUp 0.25s ease;
}

.modal-content h2 {
    margin: 0 0 4px 0;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text);
}

.modal-content h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0;
}

.modal-content hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 16px 0;
}

.modal-header-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

#modalEmployeeInfo {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 4px 0 0;
    font-family: 'DM Mono', monospace;
}

.close-btn {
    position: absolute;
    right: 20px;
    top: 16px;
    font-size: 26px;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.15s, color 0.15s;
}

.close-btn:hover {
    background: var(--bg-subtle);
    color: var(--text);
}

/* ─── FICHA PAPER ────────────────────────────────────────── */
.ficha-paper {
    max-width: 660px;
}

.ficha-header {
    text-align: center;
    border-bottom: 2px solid var(--border-strong);
    margin-bottom: 24px;
    padding-bottom: 14px;
}

.ficha-header h2 {
    font-size: 1.15rem;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--primary-dark);
}

.ficha-header p {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    margin: 4px 0 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ─── FICHA FORM ─────────────────────────────────────────── */
.ficha-form .row {
    display: flex;
    gap: 14px;
    margin-bottom: 14px;
}

.ficha-form .group {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.flex-2 { flex: 2 !important; }

.ficha-form label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
    margin-bottom: 5px;
}

.ficha-form input,
.ficha-form select {
    padding: 10px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.92rem;
    color: var(--text);
    background: var(--bg-subtle);
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}

.ficha-form input:focus,
.ficha-form select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
    background: white;
}

.ficha-form select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238A9E97' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    cursor: pointer;
}

/* ─── SIGNATURE ──────────────────────────────────────────── */
.sig-section {
    text-align: center;
    margin: 20px 0;
    padding: 16px;
    background: var(--bg-subtle);
    border-radius: var(--radius-md);
    border: 1.5px solid var(--border);
}

.sig-section label {
    display: block;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
    margin-bottom: 10px;
}

#sig-canvas {
    border: 1.5px dashed var(--border-strong);
    background: white;
    width: 100%;
    max-width: 450px;
    cursor: crosshair;
    border-radius: var(--radius-sm);
    display: block;
    margin: 0 auto;
}

#sig-clearBtn {
    background: none;
    border: 1px solid var(--border-strong);
    cursor: pointer;
    padding: 5px 14px;
    font-size: 0.78rem;
    margin-top: 8px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-family: 'DM Sans', sans-serif;
    transition: all 0.2s;
}

#sig-clearBtn:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: white;
}

/* ─── BUTTONS ────────────────────────────────────────────── */
.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 10px 20px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.9rem;
    transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: 0 4px 12px rgba(10,124,62,0.3);
    transform: translateY(-1px);
}

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

.btn-success {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    border: none;
    padding: 14px;
    cursor: pointer;
    width: 100%;
    font-size: 1rem;
    font-weight: 600;
    font-family: 'DM Sans', sans-serif;
    border-radius: var(--radius-md);
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(10,124,62,0.25);
    margin-top: 8px;
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(10,124,62,0.35);
}

.btn-success:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-report {
    background: var(--info);
    color: white;
    border: none;
    padding: 7px 13px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.15s;
}

.btn-report:hover {
    transform: scale(1.08);
    background: var(--info-light);
    box-shadow: 0 3px 10px rgba(21,101,192,0.3);
}

/* ─── FORM ERROR ─────────────────────────────────────────── */
.form-error {
    background: #FFEBEE;
    border: 1px solid #FFCDD2;
    border-left: 4px solid var(--danger);
    color: #C62828;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    margin-top: 4px;
}

/* ─── TERMO PAPER (modal de assinatura inicial) ──────────── */
.termo-paper {
    max-width: 780px;
    font-family: Arial, sans-serif;
}


.report-paper {
    background: white;
    color: #111;
    max-width: 900px;
    font-family: Arial, sans-serif;
}

/* Cada "página" dentro do modal */
.report-page {
    padding: 28px 32px;
    background: white;
}

.report-page-portrait  { /* retrato — sem estilo extra na tela */ }

/* Página 2: simula folha paisagem dentro do modal (visual apenas) */
.report-page-landscape {
    margin-top: 24px;
    border-top: 3px dashed var(--border-strong);
    padding-top: 24px;
}

/* Cabeçalho das páginas */
.report-header {
    text-align: center;
    border-bottom: 2px solid var(--primary-dark);
    margin-bottom: 16px;
    padding-bottom: 10px;
}

.report-header h2 {
    color: var(--primary-dark);
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin: 0 0 4px;
}

.report-subtitle {
    font-size: 0.78rem;
    color: #444;
    margin: 0;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* ── Seção de identificação ─── */
.rep-section-title {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--primary-dark);
    background: #EBF5EE;
    border-left: 3px solid var(--primary);
    padding: 4px 10px;
    margin: 12px 0 6px;
}

.rep-id-grid {
    display: flex;
    gap: 0;
    border: 1px solid #C8D4CF;
    border-top: none;
    margin-bottom: 0;
}

.rep-id-grid:first-of-type { border-top: 1px solid #C8D4CF; }

.rep-field {
    flex: 1;
    padding: 6px 10px;
    border-right: 1px solid #C8D4CF;
}

.rep-field:last-child { border-right: none; }
.rep-field-xl { flex: 3; }

.rep-label {
    display: block;
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #666;
    margin-bottom: 2px;
}

.rep-value {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    color: #111;
    min-height: 18px;
}

/* ── Texto do Termo ─── */
.rep-termo-body {
    margin: 16px 0 0;
    font-size: 0.83rem;
    line-height: 1.6;
    color: #222;
    text-align: justify;
}

.rep-termo-body p { margin: 0 0 8px; }

.rep-termo-list {
    margin: 6px 0 0 0;
    padding-left: 20px;
}

.rep-termo-list li {
    margin-bottom: 5px;
    font-size: 0.8rem;
    line-height: 1.55;
}

/* ── Assinatura de Ciência dos Termos ─── */
.rep-termo-assinatura {
    margin-top: 20px;
    border-top: 1px solid #C8D4CF;
    padding-top: 14px;
}

.rep-ciente-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #333;
    margin: 0 0 8px;
}

.rep-sig-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

#rep-sig-canvas {
    border: 1.5px dashed #999;
    border-radius: 4px;
    background: #FAFAFA;
    cursor: crosshair;
    max-width: 100%;
    width: 500px;
    height: 100px;
    display: block;
}

.rep-sig-controls {
    align-self: flex-end;
    width: 500px;
    max-width: 100%;
    text-align: right;
    margin-bottom: 2px;
}

.btn-outline-sm {
    background: none;
    border: 1px solid var(--border-strong);
    color: var(--text-muted);
    font-size: 0.75rem;
    padding: 4px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: 'DM Sans', sans-serif;
    transition: all 0.2s;
}

.btn-outline-sm:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: white;
}

.rep-sig-underline {
    width: 500px;
    max-width: 100%;
    height: 1px;
    background: #333;
    margin-top: 2px;
}

.rep-sig-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: #222;
    margin-top: 3px;
}

.rep-sig-date {
    font-size: 0.75rem;
    color: #555;
}

/* ── Tabela de Entregas ─── */
.report-table-section { margin-top: 10px; }

.report-table-section table {
    width: 100%;
    border-collapse: collapse;
}

.report-table-section th,
.report-table-section td {
    border: 1px solid #C8D4CF;
    padding: 7px 10px;
    font-size: 0.82rem;
    text-align: left;
    word-wrap: break-word;
}

.report-table-section th {
    background: #EBF5EE;
    font-weight: 700;
    color: var(--primary-dark);
    text-transform: uppercase;
    font-size: 0.66rem;
    letter-spacing: 0.5px;
}

.report-table-section img {
    height: 44px;
    width: auto;
    max-width: 160px;
    mix-blend-mode: multiply;
    display: inline-block;
}

.report-footer {
    margin-top: 14px;
    text-align: right;
    font-size: 0.72rem;
    color: #888;
    padding-top: 8px;
    border-top: 1px solid #ddd;
}

.modal-actions {
    margin-top: 20px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

/* ─── ANIMATIONS ─────────────────────────────────────────── */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ─── UTILITY ────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ─── SCROLLBAR ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ─── PRINT ──────────────────────────────────────────────────
   Página 1 → retrato  |  Página 2 → paisagem
   ──────────────────────────────────────────────────────────── */
@media print {
    body > *       { display: none !important; }
    #reportModal   { display: block !important; position: static !important;
                     background: none !important; padding: 0 !important; }
    .modal-content { box-shadow: none !important; border: none !important;
                     padding: 0 !important; max-width: 100% !important; }
    .no-print, .close-btn { display: none !important; }

    /* Cada página ocupa uma folha separada */
    .report-page {
        margin: 0;
        padding: 1.2cm 1.5cm;
        page-break-after: always;
        break-after: page;
    }
    .report-page:last-child {
        page-break-after: avoid;
        break-after: avoid;
    }

    /* Página 1: retrato */
    .report-page-portrait  { page: portrait-page; }

    /* Página 2: paisagem */
    .report-page-landscape { page: landscape-page; }

    @page portrait-page  { size: A4 portrait;  margin: 0; }
    @page landscape-page { size: A4 landscape; margin: 0; }
}

/* ─── RESPONSIVE ─────────────────────────────────────────── */
@media (max-width: 700px) {
    header .container { flex-direction: column; align-items: stretch; }
    .search-container { max-width: 100%; }
    .container { padding: 16px; }
    .ficha-form .row { flex-direction: column; gap: 10px; }
    .modal-content { padding: 22px 18px; }
    #noResultsArea { flex-direction: column; text-align: center; }
    .rep-id-grid { flex-direction: column; }
    .rep-field { border-right: none; border-bottom: 1px solid #C8D4CF; }
    #rep-sig-canvas { width: 100%; }
    .rep-sig-controls, .rep-sig-underline { width: 100%; }
}

