/* ========================================== */
/* 1. ESTILOS GERAIS E TIPOGRAFIA             */
/* ========================================== */
body { 
    font-family: Arial, sans-serif; 
    margin: 0; 
    padding: 0;
    background-color: #f0f0f0; 
    font-size: 12px; 
    color: #000; 
}

h1 { text-align: center; margin: 10px 0; font-size: 24px; font-weight: bold; }
.label { font-size: 10px; color: #333; display: block; margin-bottom: 2px; }
.bold { font-weight: bold; }
.texto-vermelho { color: red !important; font-weight: bold !important; }

/* ========================================== */
/* 2. CLASSES UTILITÁRIAS (LAYOUT)            */
/* ========================================== */
.d-none { display: none !important; }
.mt-10 { margin-top: 10px; }
.mt-20 { margin-top: 20px; }
.mb-20 { margin-bottom: 20px; }
.p-0 { padding: 0 !important; }
.p-10 { padding: 10px; }
.text-center { text-align: center !important; }
.text-right { text-align: right !important; }
.align-middle { vertical-align: middle; }
.align-top { vertical-align: top; }
.border-right-none { border-right: none; }
.border-left-none { border-left: none; }

/* Larguras */
.w-10 { width: 10%; }
.w-15 { width: 15%; }
.col-5 { width: 5%; }
.col-7 { width: 7%; }
.col-8 { width: 8%; }
.col-18 { width: 18%; }
.col-25 { width: 25%; }
.col-30 { width: 30%; }
.col-40 { width: 40%; }
.col-44 { width: 44%; }
.col-50 { width: 50%; }

/* Flexbox Helpers */
.flex-between { display: flex; justify-content: space-between; }
.flex-between-center { display: flex; justify-content: space-between; align-items: center; }
.flex-center-gap { display: flex; align-items: center; gap: 15px; }

/* Cores de Fundo Padrão Ecool Star */
.bg-azul-escuro { background-color: #8ea9db; font-weight: bold; }
.bg-azul-claro { background-color: #d9e1f2; font-weight: bold; text-align: center; }
.bg-cinza { background-color: #f2f2f2; font-weight: bold; text-align: right; }

/* ========================================== */
/* 3. TELA DE LOGIN                           */
/* ========================================== */
.login-container { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100vh; background-color: #f0f0f0; }
.login-box { background: white; padding: 30px; border-radius: 8px; box-shadow: 0 4px 10px rgba(0,0,0,0.1); text-align: center; width: 300px; }
.login-logo { max-width: 150px; margin-bottom: 20px; }
.login-input { margin-bottom: 10px; width: 100%; padding: 8px; box-sizing: border-box; }
#login-senha { margin-bottom: 15px; }
.btn-full { width: 100%; justify-content: center; }
.login-erro { color: red; font-size: 12px; margin-top: 10px; display: none; }

/* ========================================== */
/* 4. NAVBAR SUPERIOR E SIDEBAR CONFIGURAÇÕES */
/* ========================================== */
.app-container { position: relative; }

.navbar-superior {
    display: flex; justify-content: space-between; align-items: center;
    background: #ffffff; padding: 12px 25px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    position: sticky; top: 0; z-index: 1000;
}
.navbar-grupo { display: flex; gap: 12px; align-items: center; }

/* Botões da Navbar */
.btn-padrao {
    border: none; border-radius: 6px; padding: 10px 16px; font-size: 13px; font-weight: bold;
    cursor: pointer; transition: background 0.2s; color: white; display: flex; align-items: center; gap: 6px;
}
.btn-info { background-color: #6c757d; } .btn-info:hover { background-color: #5a6268; }
.btn-primario { background-color: #0056b3; } .btn-primario:hover { background-color: #004494; }
.btn-sucesso { background-color: #28a745; } .btn-sucesso:hover { background-color: #218838; }
.btn-perigo { background-color: #dc3545; } .btn-perigo:hover { background-color: #c82333; }
.btn-config { background-color: #495057; } .btn-config:hover { background-color: #343a40; }

#overlay-config {
    position: fixed; top: 0; left: 0; width: 100%; height: 100vh;
    background: rgba(0,0,0,0.5); z-index: 1999; display: none; opacity: 0;
    transition: opacity 0.3s ease;
}

#sidebar-config {
    position: fixed; top: 0; right: -320px; width: 300px; height: 100vh;
    background: #ffffff; box-shadow: -4px 0 15px rgba(0,0,0,0.1);
    z-index: 2000; transition: right 0.3s ease; display: flex; flex-direction: column;
}
.sidebar-header { background-color: #495057; padding: 20px; color: white; display: flex; justify-content: space-between; align-items: center; }
.sidebar-header h3 { margin: 0; font-size: 16px; }
.btn-fechar-sidebar { background: none; border: none; color: white; font-size: 22px; cursor: pointer; }
.sidebar-content { padding: 10px 25px; overflow-y: auto; }
.config-linha { display: flex; justify-content: space-between; align-items: center; padding: 15px 0; border-bottom: 1px solid #f0f0f0; width: 100%; cursor: pointer; }
.config-linha span { font-size: 14px; font-weight: 500; color: #333; }

/* Toggles (Interruptores de Ligar/Desligar) */
.toggle-container { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: bold; color: #444; cursor: pointer; }
.toggle-sm { margin: 0; font-size: 11px; color: #000; }
.switch { position: relative; display: inline-block; width: 36px; height: 20px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #ccc; transition: .3s; border-radius: 20px; }
.slider:before { position: absolute; content: ""; height: 14px; width: 14px; left: 3px; bottom: 3px; background-color: white; transition: .3s; border-radius: 50%; }

/* Cores dos Toggles */
input:checked + .slider { background-color: #0056b3; }
input:checked + .slider:before { transform: translateX(16px); }
#check-desc-prod:checked + .slider, #check-desc-mat:checked + .slider, #check-desc-serv:checked + .slider { background-color: #28a745; }

/* ========================================== */
/* 5. TELA DE ORÇAMENTO (FOLHA A4)            */
/* ========================================== */
.folha-preview {
    background: #fff; max-width: 900px; margin: 20px auto;
    box-shadow: 0 0 15px rgba(0,0,0,0.15);
}

/* Tabelas Estruturais */
table { width: 100%; border-collapse: collapse; margin-bottom: 10px; table-layout: fixed; }
th, td { border: 1px solid #000; padding: 3px 5px; text-align: left; vertical-align: top; height: 24px; }
.no-break { page-break-inside: avoid; break-inside: avoid; }
.tabela-alinhada td { vertical-align: top !important; padding: 4px 6px !important; }
.tabela-alinhada td.bg-azul-escuro { vertical-align: middle !important; }
.tabela-meio td { vertical-align: middle !important; }

/* Tabela Mestra (Controla as margens do PDF) */
table.master-table, .master-table > thead > tr > td, .master-table > tbody > tr > td, .master-table > tfoot > tr > td { border: none !important; }
.espaco-margem { height: 8mm !important; } 
.conteudo-principal { padding: 0 8mm !important; } 

/* Cabeçalho do Documento */
.header-table { width: 100%; border-collapse: collapse; margin-bottom: 10px; table-layout: fixed; border: 1px solid #000; }
.header-table td { border: none; padding: 8px; }
.logo-header { max-width: 130px; }
.titulo-documento { margin: 0; font-size: 32px; }
.cabecalho-endereco { font-size: 11px; padding-top: 0; border-top: 1px solid transparent; font-weight: bold; vertical-align: bottom; }
.cabecalho-numero { font-size: 14px; padding-top: 0; border-top: 1px solid transparent; font-weight: bold; text-align: right; vertical-align: bottom; color: #333; }

/* Botões DENTRO da folha (ex: + Produto) */
.btn-add-tabela {
    background-color: #28a745; color: white; border: none; border-radius: 4px; 
    padding: 5px 12px; cursor: pointer; font-size: 11px; font-weight: bold; text-transform: none; transition: background 0.2s;
}
.btn-add-tabela:hover { background-color: #218838; }

.btn-ordem {
    background: #f0f0f0; border: 1px solid #ccc; border-radius: 3px; cursor: pointer;
    font-size: 9px; padding: 1px 4px; color: #555; transition: 0.2s;
}
.btn-ordem:hover { background: #e0e0e0; color: #000; }

/* ========================================== */
/* 6. INPUTS E FORMULÁRIOS DA FOLHA           */
/* ========================================== */
input, select, textarea.observacoes { 
    width: 100%; border: 1px solid #ccc; background-color: #fafafa;
    font-family: Arial; font-size: 12px; box-sizing: border-box; padding: 4px; display: block; margin: 0; 
}

#input-data { width: 110px; display: inline-block; text-align: center; font-size: 15px; font-weight: bold; }

textarea.auto-expand {
    width: 100%; border: 1px solid #ccc; background-color: #fafafa;
    font-family: Arial; font-size: 12px; box-sizing: border-box; display: block;
    padding: 4px; resize: none; overflow: hidden; 
    min-height: 26px; line-height: 14px; margin: 0; 
    word-wrap: break-word; overflow-wrap: break-word; word-break: break-word;
}

/* Modificadores de Input Numérico / Moeda */
input[type="number"] { text-align: center; -moz-appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.input-money { text-align: right; }
.input-wrapper-moeda { position: relative; width: 100%; display: block; }
.moeda-prefixo { position: absolute; left: 6px; top: 50%; transform: translateY(-50%); pointer-events: none; font-size: 11px; font-weight: bold; }
.input-desc { padding-left: 30px; width: 100%; box-sizing: border-box; margin: 0; background: transparent; border: none; text-align: right; }

#tabela-total div { margin-bottom: 0 !important; }
#tabela-total td { padding: 4px 6px !important; vertical-align: middle !important; }

/* Caixa de Responsabilidades Editável */
.caixa-responsabilidades { width: 100%; border: 1px solid #ccc; background-color: #fafafa; box-sizing: border-box; padding: 8px; }
.colunas-responsabilidades {
    column-count: 2; column-gap: 40px; text-align: left; width: 100%; border: none;
    background-color: transparent; font-family: Arial; font-size: 12px; outline: none;
    word-wrap: break-word; word-break: break-word; white-space: pre-wrap; 
}
[contenteditable=true]:empty:before { content: attr(placeholder); color: #888; pointer-events: none; display: block; }

/* ========================================== */
/* 7. IMAGENS E ASSINATURAS                   */
/* ========================================== */
.dropzone {
    border: 2px dashed #aaa; border-radius: 8px; padding: 25px; text-align: center;
    background-color: #fcfcfc; color: #666; font-size: 14px; font-weight: bold;
    cursor: pointer; margin-bottom: 15px; transition: all 0.3s ease;
}
.dropzone:hover, .dropzone.dragover { background-color: #e9f5ff; border-color: #2196F3; color: #2196F3; }

.image-grid-container { display: flex; flex-wrap: wrap; gap: 15px; justify-content: center; align-items: flex-start; }
.img-wrapper { position: relative; display: inline-block; margin: 5px; }
.img-resizable {
    resize: both; overflow: hidden; width: 220px; height: 220px; min-width: 100px; min-height: 100px;
    background: #fff; border: 1px solid #ccc; border-radius: 4px; padding: 5px; box-sizing: border-box; display: flex; justify-content: center; align-items: center;
}
.img-preview { width: 100%; height: 100%; object-fit: contain; }
.btn-remove-img {
    position: absolute; top: -10px; right: -10px; z-index: 10; background: red; color: white; border: none; border-radius: 50%;
    width: 24px; height: 24px; font-weight: bold; cursor: pointer; display: flex; justify-content: center; align-items: center; box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.tabela-assinaturas { border: none; margin-top: 10px; width: 100%; text-align: center; }
.col-assinatura { border: none; width: 50%; vertical-align: bottom; padding: 0; }
.assinatura-box { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 80px; position: relative; }
.assinatura-img { max-height: 60px; position: absolute; bottom: 15px; right: calc(50% + 20px); }
.assinatura-linha { width: 250px; text-align: center; }
.assinatura-linha hr { border-color: #000; margin: 0; }
.assinatura-linha span { font-size: 11px; }

/* ========================================== */
/* 8. TELA DE HISTÓRICO DE CLIENTES           */
/* ========================================== */
.tela-historico { background-color: #f4f6f8; padding: 40px 20px; min-height: 100vh; position: absolute; top: 0; left: 0; width: 100%; box-sizing: border-box; z-index: 500; }
.historico-card { max-width: 1000px; margin: 0 auto; background: white; padding: 30px; border-radius: 8px; box-shadow: 0 4px 15px rgba(0,0,0,0.05); }
.historico-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid #0056b3; padding-bottom: 15px; margin-bottom: 20px; }
.historico-label { font-size: 12px; color: #777; font-weight: bold; }
.historico-titulo { margin: 0; color: #0056b3; font-size: 22px; text-transform: uppercase; }
.input-busca { width: 100%; padding: 12px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; font-size: 14px; }
.linha-cliente { cursor: pointer; transition: background 0.2s; border-bottom: 1px solid #eee; padding: 12px 10px; font-size: 14px; color: #333; }
.linha-cliente:hover { background-color: #f0f8ff; }
.linha-orcamento { border-bottom: 1px solid #ddd; padding: 15px 10px; transition: background 0.2s; }
.linha-orcamento:hover { background-color: #f9f9f9; }

/* ========================================== */
/* 9. BOTÕES DE AÇÕES E CORES DE STATUS       */
/* ========================================== */
.container-acoes-grid {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 4px 0;
    align-items: center;
    justify-content: center;
}
.linha-acoes-botoes {
    display: flex;
    gap: 4px;
    justify-content: center;
    width: 100%;
}

.btn-acao-txt {
    border: 1px solid #ccc;
    background-color: #f8f9fa;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    color: #333;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}
.btn-acao-txt:hover { 
    background-color: #e2e6ea; 
    border-color: #adb5bd;
}
.btn-acao-txt:active { 
    transform: translateY(1px); 
}

/* Hover Azul específico para Solicitar Aprovação */
.btn-txt-solicitar:hover {
    background-color: #0056b3 !important;
    color: white !important;
    border-color: #004494 !important;
}

/* Hover Vermelho específico para Excluir */
.btn-txt-exc:hover {
    background-color: #dc3545 !important;
    color: white !important;
    border-color: #bd2130 !important;
}

/* Cores de Background para as linhas do Status */
.linha-status-andamento { background-color: #fff3cd !important; }
.linha-status-aprovado { background-color: #d4edda !important; }
.linha-status-cancelado { background-color: #f8d7da !important; }

.linha-status-andamento:hover { background-color: #ffeeba !important; }
.linha-status-aprovado:hover { background-color: #c3e6cb !important; }
.linha-status-cancelado:hover { background-color: #f5c6cb !important; }

/* ========================================== */
/* 10. POPUP / MODAL DE VISUALIZAÇÃO          */
/* ========================================== */
.modal-visualizar {
    position: fixed; top: 0; left: 0; width: 100%; height: 100vh;
    background: rgba(0,0,0,0.6); z-index: 3000;
    display: flex; align-items: center; justify-content: center;
}
.modal-visualizar-conteudo {
    background: white; width: 90%; max-width: 850px; max-height: 85vh;
    border-radius: 8px; display: flex; flex-direction: column;
    box-shadow: 0 5px 25px rgba(0,0,0,0.3);
    animation: popupFadeIn 0.2s ease-out;
}
.modal-visualizar-header {
    background-color: #0056b3; padding: 15px 20px; color: white;
    display: flex; justify-content: space-between; align-items: center;
    border-top-left-radius: 8px; border-top-right-radius: 8px;
}
.modal-visualizar-header h2 { margin: 0; font-size: 18px; font-weight: bold; }
.btn-fechar-modal { background: none; border: none; color: white; font-size: 26px; cursor: pointer; line-height: 1; }
.modal-visualizar-corpo { padding: 30px; overflow-y: auto; background-color: #f0f0f0; }

@keyframes popupFadeIn {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}

/* ========================================== */
/* 11. MENU SUSPENSO DE AÇÕES (DROPDOWN)      */
/* ========================================== */
.dropdown-acoes {
    position: relative;
    display: inline-block;
    text-align: right;
    width: 100%;
}

.btn-dropdown {
    background-color: #f8f9fa;
    border: 1px solid #ccc;
    padding: 6px 14px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    font-size: 12px;
    color: #333;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: 0.2s;
}

.btn-dropdown:hover {
    background-color: #e2e6ea;
}

.dropdown-conteudo {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    background-color: #ffffff;
    min-width: 240px; /* Largura suficiente para ler tudo */
    box-shadow: 0px 8px 20px rgba(0,0,0,0.15);
    z-index: 1000;
    border-radius: 6px;
    border: 1px solid #ddd;
    padding: 6px;
    flex-direction: column;
    gap: 2px;
}

/* O menu aparece magicamente ao passar o mouse */
.dropdown-acoes:hover .dropdown-conteudo {
    display: flex; 
}

/* Adaptando seus botões para a lista vertical */
.dropdown-conteudo .btn-acao-txt {
    width: 100%;
    text-align: left;
    border: none;
    background: transparent;
    padding: 10px 12px;
    justify-content: flex-start;
    border-radius: 4px;
}

.dropdown-conteudo .btn-acao-txt:hover {
    background-color: #f0f8ff;
}

/* ========================================== */
/* 12. REGRAS DE IMPRESSÃO (PDF) - FINAL      */
/* ========================================== */
@page { margin: 0; }

@media print {
    .no-print { display: none !important; }
    .tabela-vazia-print { display: none !important; }
    
    body { background-color: #fff; }
    td.bg-azul-escuro { border-left: 1px solid #000 !important; }
    .folha-preview { margin: 0; box-shadow: none; max-width: 100%; } 
    * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    
    input, select, textarea.auto-expand, textarea.observacoes, .caixa-responsabilidades, .colunas-responsabilidades { 
        border: none !important; background: transparent !important; padding: 0 !important; font-size: 12px; box-shadow: none; outline: none;
        -webkit-appearance: none; -moz-appearance: none; appearance: none;
        margin: 0 !important; 
        line-height: 1.2 !important; 
    }

    .tabela-alinhada td, #tabela-total td {
        padding-top: 2px !important;
        padding-bottom: 3px !important; 
    }
    .caixa-responsabilidades { padding: 8px !important; } 

    .tabela-alinhada textarea.auto-expand, .tabela-alinhada input {
        min-height: 0 !important; height: max-content !important; padding-bottom: 0 !important;
    }

    textarea.desc { overflow: visible !important; white-space: pre-wrap !important; }
    
    input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
    input[type="number"]::-webkit-outer-spin-button, input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none !important; margin: 0 !important; }
    
    ::-webkit-input-placeholder { color: transparent !important; }
    ::-moz-placeholder { color: transparent !important; }
    :-ms-input-placeholder { color: transparent !important; }
    ::placeholder { color: transparent !important; }
    
    [contenteditable=true]:empty:before { content: none !important; }
    
    .img-resizable { border: none; padding: 0; resize: none; background: transparent; } 
    input.texto-vermelho { color: red !important; } 
}