/* ==========================================================================
   INSTRUTORES VEICULAR CFSD 2025 - ESTILOS PRINCIPAIS (UI/UX MODERNA)
   ========================================================================== */

:root {
    --primary: #0d47a1;
    --primary-light: #1976d2;
    --primary-dark: #002171;
    --primary-subtle: #e3f2fd;
    --accent: #d32f2f;
    --accent-subtle: #ffebee;
    --success: #2e7d32;
    --success-light: #4caf50;
    --success-subtle: #e8f5e9;
    --warning: #f57c00;
    --warning-subtle: #fff3e0;
    --bg: #f0f2f5;
    --surface: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -1px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: var(--font-family);
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg);
    color: var(--text);
    min-height: 100vh;
    padding: 12px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

/* --- CONTAINER PRINCIPAL --- */
.container {
    width: 100%;
    max-width: 680px;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    margin: 8px auto 30px auto;
    border: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
}

/* --- CABEÇALHO --- */
header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #ffffff;
    padding: 24px 20px;
    text-align: center;
    position: relative;
}

header .badge-header {
    display: inline-block;
    background: rgba(255, 255, 255, 0.2);
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin-bottom: 8px;
    backdrop-filter: blur(4px);
}

header h1 {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin-bottom: 4px;
}

header p {
    font-size: 0.9rem;
    opacity: 0.9;
    font-weight: 400;
}

/* --- BARRA DE PROGRESSO GLOBAL --- */
.progress-card {
    background: #ffffff;
    padding: 16px 20px 12px 20px;
    border-bottom: 1px solid var(--border);
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.progress-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.status-badge {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary);
    background: var(--primary-subtle);
    padding: 2px 8px;
    border-radius: 12px;
}

.status-badge.completed {
    color: var(--success);
    background: var(--success-subtle);
}

.progress-container {
    background-color: #e2e8f0;
    height: 10px;
    border-radius: 5px;
    overflow: hidden;
    width: 100%;
}

.progress-bar {
    background: linear-gradient(90deg, var(--primary-light), var(--success));
    height: 100%;
    width: 0%;
    border-radius: 5px;
    transition: width 0.35s ease, background-color 0.35s ease;
}

.progress-bar.completed {
    background: linear-gradient(90deg, var(--success-light), var(--success));
}

/* --- BARRA DE BUSCA RÁPIDA --- */
.search-wrapper {
    padding: 12px 20px;
    background: #fafbfc;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 14px;
    color: var(--text-muted);
    font-size: 1rem;
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: 10px 38px 10px 40px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    outline: none;
    background: #ffffff;
    color: var(--text);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.15);
}

.search-clear-btn {
    position: absolute;
    right: 10px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    width: 26px;
    height: 26px;
    display: none;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.search-clear-btn:hover {
    background: var(--border);
    color: var(--text);
}

/* --- NAVEGAÇÃO POR ABAS --- */
.tabs-container {
    display: flex;
    background-color: #f1f5f9;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    scrollbar-width: none;
}

.tabs-container::-webkit-scrollbar {
    display: none;
}

.tab-btn {
    flex: 1;
    min-width: 120px;
    padding: 14px 10px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--text-muted);
    transition: all 0.2s ease;
    border-bottom: 3px solid transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    user-select: none;
}

.tab-btn:hover {
    color: var(--primary);
    background-color: rgba(255, 255, 255, 0.5);
}

.tab-btn.active {
    color: var(--primary);
    background-color: var(--surface);
    border-bottom: 3px solid var(--primary);
}

.tab-count-badge {
    font-size: 0.72rem;
    padding: 1px 7px;
    border-radius: 10px;
    background: #e2e8f0;
    color: #475569;
    font-weight: 700;
    transition: background-color 0.2s, color 0.2s;
}

.tab-btn.active .tab-count-badge {
    background: var(--primary-subtle);
    color: var(--primary);
}

.tab-count-badge.done {
    background: var(--success-subtle) !important;
    color: var(--success) !important;
}

/* --- CONTEÚDO DAS ABAS --- */
.tab-content {
    display: none;
    padding: 0;
    animation: fadeIn 0.25s ease-in-out;
}

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

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(3px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- DIVISORES DE SEÇÃO --- */
.section-divider {
    background-color: #334155;
    color: #ffffff;
    padding: 12px 20px;
    font-size: 0.95rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: space-between;
    letter-spacing: 0.01em;
}

.section-divider.aph-header {
    background: linear-gradient(90deg, #1e3a8a, #2563eb);
}

.section-divider.corte-header {
    background: linear-gradient(90deg, #9a3412, #c2410c);
}

/* --- LISTA DE ITENS (CHECKLIST) --- */
ul.checklist {
    list-style: none;
    padding: 0;
    margin: 0;
}

ul.checklist li {
    border-bottom: 1px solid var(--border-light);
    transition: background-color 0.15s;
}

.item-row {
    display: flex;
    align-items: center;
    padding: 14px 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    position: relative;
}

.item-row:hover {
    background-color: #f8fafc;
}

.item-row:active {
    background-color: #f1f5f9;
}

/* Custom Checkbox */
.checkbox-container {
    position: relative;
    width: 24px;
    height: 24px;
    margin-right: 14px;
    flex-shrink: 0;
}

.checkbox-container input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 100%;
    width: 100%;
    margin: 0;
    z-index: 2;
}

.custom-checkmark {
    position: absolute;
    top: 0;
    left: 0;
    height: 24px;
    width: 24px;
    background-color: #ffffff;
    border: 2px solid #cbd5e1;
    border-radius: 6px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.checkbox-container:hover .custom-checkmark {
    border-color: var(--primary-light);
}

.checkbox-container input:checked ~ .custom-checkmark {
    background-color: var(--success);
    border-color: var(--success);
    transform: scale(1.05);
}

.custom-checkmark::after {
    content: "";
    display: none;
    width: 6px;
    height: 11px;
    border: solid white;
    border-width: 0 2.5px 2.5px 0;
    transform: rotate(45deg) translate(-1px, -1px);
}

.checkbox-container input:checked ~ .custom-checkmark::after {
    display: block;
}

/* Informações do Item */
.item-content {
    flex: 1;
    min-width: 0;
}

.item-header-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 3px;
}

.item-qty {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--primary-dark);
    background: #e0f2fe;
    padding: 2px 8px;
    border-radius: 12px;
    display: inline-block;
    letter-spacing: 0.02em;
}

.item-name {
    font-size: 0.98rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.4;
    transition: color 0.2s, text-decoration 0.2s;
    word-break: break-word;
}

.item-note {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.78rem;
    color: #c2410c;
    background: var(--warning-subtle);
    padding: 3px 8px;
    border-radius: 6px;
    margin-top: 5px;
    font-weight: 500;
    width: fit-content;
}

/* Estado Marcado */
.item-row.checked {
    background-color: #f0fdf4;
}

.item-row.checked .item-name {
    text-decoration: line-through;
    color: #94a3b8;
}

.item-row.checked .item-qty {
    background: #dcfce7;
    color: var(--success);
}

/* Estado Vazio de Busca */
.empty-search {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted);
}

.empty-search-icon {
    font-size: 2.5rem;
    margin-bottom: 10px;
    opacity: 0.7;
}

.empty-search p {
    font-size: 0.95rem;
}

/* --- ROTEIRO DETALHADO APH (ACORDEÃO) --- */
.accordion-wrapper {
    background: #ffffff;
}

.accordion-item {
    border-bottom: 1px solid var(--border);
}

.accordion-header {
    width: 100%;
    background: #ffffff;
    padding: 16px 20px;
    text-align: left;
    border: none;
    outline: none;
    font-size: 0.96rem;
    font-weight: 700;
    color: #1e293b;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.accordion-header:hover {
    background-color: #f8fafc;
    color: var(--primary);
}

.accordion-header.active {
    background-color: #f0f7ff;
    color: var(--primary);
}

.accordion-header .arrow-icon {
    font-size: 0.75rem;
    transition: transform 0.25s ease;
    color: var(--text-muted);
}

.accordion-header.active .arrow-icon {
    transform: rotate(180deg);
    color: var(--primary);
}

.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s cubic-bezier(0, 1, 0, 1);
    background-color: #fafbfc;
}

.accordion-content-inner {
    padding: 16px 22px;
    font-size: 0.92rem;
    line-height: 1.6;
    color: #334155;
    border-top: 1px solid var(--border-light);
}

.accordion-content-inner ul {
    padding-left: 20px;
    margin: 6px 0;
}

.accordion-content-inner li {
    margin-bottom: 8px;
}

.accordion-content-inner li:last-child {
    margin-bottom: 0;
}

.accordion-content-inner strong {
    color: #0f172a;
}

/* --- BOTÕES DE AÇÃO E CONTROLES INFERIORES --- */
.action-panel {
    padding: 20px;
    background: #fafbfc;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.btn-row {
    display: flex;
    gap: 10px;
}

.btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 13px 18px;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    text-align: center;
}

.btn-primary {
    background-color: var(--primary);
    color: #ffffff;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    background-color: var(--primary-light);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

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

.btn-outline-danger {
    background-color: #ffffff;
    color: #dc2626;
    border: 1.5px solid #fecaca;
}

.btn-outline-danger:hover {
    background-color: #fef2f2;
    border-color: #dc2626;
}

.btn-secondary {
    background-color: #e2e8f0;
    color: #334155;
}

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

.btn-whatsapp {
    background-color: #25d366;
    color: #ffffff;
}

.btn-whatsapp:hover {
    background-color: #20ba59;
}

/* --- MODAL DE EXPORTAÇÃO --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

.modal-overlay.open {
    display: flex;
}

.modal-card {
    background: #ffffff;
    width: 100%;
    max-width: 540px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: 90vh;
    animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.modal-header {
    padding: 18px 20px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    padding: 4px;
    border-radius: 4px;
}

.modal-close-btn:hover {
    color: var(--text);
    background: var(--border);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Filtros de Exportação */
.export-filter-label {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 6px;
    display: block;
}

.filter-pills {
    display: flex;
    gap: 8px;
    background: #f1f5f9;
    padding: 4px;
    border-radius: var(--radius-md);
}

.filter-pill {
    flex: 1;
    border: none;
    background: transparent;
    padding: 8px 6px;
    border-radius: var(--radius-sm);
    font-size: 0.84rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.filter-pill.active {
    background: #ffffff;
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

/* Área de Pré-visualização */
.export-preview-box {
    width: 100%;
    min-height: 180px;
    max-height: 240px;
    background: #f8fafc;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    font-family: monospace;
    font-size: 0.85rem;
    color: #334155;
    white-space: pre-wrap;
    overflow-y: auto;
    line-height: 1.5;
    user-select: text;
}

.export-summary-text {
    font-size: 0.85rem;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
    padding: 0 4px;
}

.modal-footer {
    padding: 16px 20px;
    background: #f8fafc;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.modal-footer-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

/* --- TOAST NOTIFICATIONS --- */
.toast-container {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    pointer-events: none;
}

.toast {
    background: #1e293b;
    color: #ffffff;
    padding: 12px 20px;
    border-radius: 30px;
    font-size: 0.9rem;
    font-weight: 600;
    box-shadow: 0 10px 25px rgba(0,0,0,0.25);
    display: flex;
    align-items: center;
    gap: 8px;
    animation: toastPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

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

/* --- RESPONSIVIDADE --- */
@media (max-width: 600px) {
    body {
        padding: 6px;
    }
    
    .container {
        margin: 0;
        border-radius: var(--radius-md);
    }
    
    header {
        padding: 18px 16px;
    }

    header h1 {
        font-size: 1.35rem;
    }

    .item-row {
        padding: 12px 16px;
    }

    .tab-btn {
        padding: 12px 6px;
        font-size: 0.82rem;
    }

    .modal-footer-grid {
        grid-template-columns: 1fr;
    }
}

/* --- ESTILOS DE IMPRESSÃO EXCLUSIVA DE MATERIAIS (PDF / A4) --- */
.print-only {
    display: none;
}

@media print {
    body {
        background: #ffffff !important;
        color: #000000 !important;
        padding: 0 !important;
        margin: 0 !important;
        font-family: Arial, Helvetica, sans-serif !important;
    }

    /* Ocultar toda a interface de tela e roteiros */
    .container,
    .modal-overlay,
    .toast-container {
        display: none !important;
    }

    /* Exibir apenas o relatório oficial de materiais */
    .print-only {
        display: block !important;
        width: 100% !important;
        padding: 10mm 12mm !important;
        box-sizing: border-box !important;
    }

    .print-header {
        border-bottom: 2px solid #000000;
        padding-bottom: 8px;
        margin-bottom: 12px;
        text-align: center;
    }

    .print-header h1 {
        font-size: 1.15rem;
        font-weight: 800;
        text-transform: uppercase;
        margin-bottom: 3px;
        letter-spacing: 0.03em;
    }

    .print-header h2 {
        font-size: 0.95rem;
        font-weight: 700;
        margin-bottom: 4px;
        color: #222222;
    }

    .print-header p {
        font-size: 0.8rem;
        color: #444444;
    }

    .print-meta-grid {
        display: flex;
        justify-content: space-between;
        font-size: 0.8rem;
        border-bottom: 1px solid #999999;
        padding-bottom: 6px;
        margin-bottom: 12px;
    }

    .print-meta-grid strong {
        color: #000000;
    }

    .print-category-title {
        font-size: 0.9rem;
        font-weight: 800;
        text-transform: uppercase;
        background-color: #f1f5f9 !important;
        padding: 6px 10px;
        border: 1px solid #000000;
        border-bottom: none;
        margin-top: 14px;
    }

    .print-table {
        width: 100%;
        border-collapse: collapse;
        font-size: 0.82rem;
        margin-bottom: 12px;
    }

    .print-table th,
    .print-table td {
        border: 1px solid #333333;
        padding: 5px 8px;
        text-align: left;
        vertical-align: middle;
    }

    .print-table th {
        background-color: #e2e8f0 !important;
        font-weight: 700;
        text-transform: uppercase;
        font-size: 0.76rem;
    }

    .print-table tr {
        page-break-inside: avoid;
    }

    .col-check {
        width: 38px;
        text-align: center !important;
    }

    .col-qty {
        width: 60px;
        text-align: center !important;
        font-weight: bold;
    }

    .col-origin {
        width: 110px;
    }

    .print-box-check {
        width: 14px;
        height: 14px;
        border: 1.5px solid #000000;
        display: inline-block;
        margin: 0 auto;
        line-height: 14px;
        text-align: center;
        font-size: 11px;
        font-weight: bold;
    }

    .print-footer-signature {
        margin-top: 25px;
        padding-top: 10px;
        border-top: 1px solid #000000;
        display: flex;
        justify-content: space-between;
        font-size: 0.8rem;
    }

    .print-signature-line {
        width: 250px;
        border-bottom: 1px solid #000000;
        display: inline-block;
        margin-bottom: 2px;
    }
}