/* Estilos Gerais (Formulário e Página) */
:root {
    /* Cores da Aplicação baseadas em digyo.net */
    --primary: #7A29FF; /* Roxo principal */
    --secondary: #6c757d;
    --success: #198754;
    --danger: #dc3545;
    --pink: #F21B7F;
    --dark-blue: #170F49;
    
    /* Cores Neutras */
    --background: #f8f9fa;
    --card-bg: #ffffff;
    --border-radius: 8px;
    --shadow: 0 4px 12px rgba(0,0,0,0.08);
    --header-height: 70px;
    
    /* Cores do Preview */
    --preview-primary: #c00000;
}
* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Poppins', sans-serif; }
body { background-color: var(--background); }

/* === ESTILOS PARA OS FORMULÁRIOS DE AUTENTICAÇÃO === */
.auth-form-container h2 { color: var(--dark-blue); font-size: 24px; font-weight: 600; margin-bottom: 8px; }
.auth-form-container p { color: var(--secondary); margin-bottom: 24px; text-align: center; }
.form-control-auth { text-align: left; margin-bottom: 16px; }
.form-control-auth label { display: block; margin-bottom: 6px; font-size: 14px; font-weight: 500; color: var(--dark-blue); }
.form-control-auth input { width: 100%; padding: 12px; border: 1px solid #ddd; border-radius: 6px; font-size: 16px; }
.form-control-auth input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(122, 41, 255, 0.2); }
.btn-auth { width: 100%; padding: 14px; border: none; border-radius: 6px; background-color: var(--primary); color: white; font-size: 16px; font-weight: 600; cursor: pointer; transition: background-color 0.3s ease; }
.btn-auth:hover { background-color: #6212E6; }
.auth-switch { margin-top: 20px; font-size: 14px; text-align: center; }
.auth-switch a { color: var(--pink); font-weight: 600; text-decoration: none; }

/* === ESTILOS DA APLICAÇÃO PRINCIPAL === */
.app-container { display: flex; flex-direction: column; }
.container { max-width: 1800px; margin: 0 auto; padding: 20px; }
.main-content { padding-top: var(--header-height); }
header {
    background-color: var(--card-bg); box-shadow: var(--shadow);
    position: sticky; top: 0; z-index: 1000; width: 100%; height: var(--header-height);
}
.header-content {
    display: flex; justify-content: space-between; align-items: center;
    max-width: 1800px; margin: 0 auto; padding: 0 20px; height: 100%;
}
.header-welcome { display: flex; align-items: center; gap: 15px; }
#loggedInUserName { font-size: 1rem; color: var(--secondary); font-weight: 500; }
nav.controls { display: flex; align-items: center; gap: 10px; }
.controls-divider {
    height: 24px;
    border-left: 1px solid #ddd;
    margin: 0 5px;
}

.btn { 
    padding: 8px 16px; 
    border-radius: var(--border-radius); 
    border: none; 
    cursor: pointer; 
    font-weight: bold; 
    transition: all 0.2s;
    text-decoration: none;
}

.btn-primary { background-color: var(--primary); color: white; }
.btn-primary:hover { background-color: #6212E6; }
.btn-success { background-color: var(--success); color: white; }
.btn-secondary { background-color: var(--secondary); color: white; }
.btn-outline { background: transparent; border: 2px solid var(--primary); color: var(--primary); }
.btn-outline:hover { background-color: var(--primary); color: white; }
.btn-danger { background-color: var(--danger); color: white; }
.btn-icon {
    width: 40px; height: 40px; padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 50%; color: var(--secondary); background: transparent;
    border: 2px solid transparent;
}
.btn-icon i { font-size: 16px; }
.btn-icon:hover { color: var(--primary); background-color: #f0f0f0; }
.btn-icon.btn-success { background-color: var(--success); color: white; }
.btn-icon.btn-success:hover { background-color: #157347; }
.btn-icon.btn-primary { background-color: var(--primary); color: white; }
.btn-icon.btn-primary:hover { background-color: #6212E6; }
.btn-icon.btn-danger { background-color: var(--danger); color: white; }
.btn-icon.btn-danger:hover { background-color: #b02a37; }
.btn-icon.btn-outline { color: var(--primary); border-color: #ddd; }
.btn-icon.btn-outline:hover { background-color: var(--primary); color: white; border-color: var(--primary); }

.btn-icon-action {
    background-color: transparent;
    border: none;
    color: var(--secondary);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 5px;
    margin: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
    text-decoration: none;
}
.btn-icon-action:hover {
    color: var(--primary);
}
.btn-icon-action.delete:hover {
    color: var(--danger);
}


.two-columns { display: flex; gap: 20px; align-items: flex-start; }
.form-column { flex: 1; min-width: 450px; }
.preview-column { flex: 1.5; position: sticky; top: calc(var(--header-height) + 20px); }
.card { background-color: var(--card-bg); border-radius: var(--border-radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px; }
.card-header-action { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; }
.card-title { font-size: 1.2rem; color: var(--dark-blue); font-weight: 600; margin-bottom: 0; }
.form-row { display: flex; gap: 15px; align-items: flex-end; }
.form-control { flex: 1; display: flex; flex-direction: column; margin-bottom: 15px; min-width: 0; }
.form-control select { padding: 7px; /* ALTERADO */ }
label { margin-bottom: 5px; font-size: 0.7rem; /* ALTERADO */ font-weight: 500; color: #555; }
input, textarea, select { 
    padding: 7px; /* ALTERADO */
    border: 1px solid #ccc; 
    border-radius: 4px; 
    width: 100%; 
    font-family: 'Poppins', sans-serif; 
    font-size: 0.7rem; /* ALTERADO */
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(122, 41, 255, 0.2); }
.form-buttons { display: flex; gap: 10px; margin-top: 10px; }
.items-table { width: 100%; margin-top: 15px; border-collapse: collapse;}
.items-table td { padding: 8px 4px; vertical-align: middle; border-bottom: 1px solid #eee; }
.items-table tr:last-child td { border-bottom: none; }
.item-table-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; }
.action-btn-icon { background: transparent; border: none; padding: 0; margin: 0; -webkit-appearance: none; appearance: none; width: 32px; height: 32px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; transition: background-color 0.2s ease; }
.action-btn-icon i { font-size: 14px; color: var(--secondary); transition: color 0.2s ease; }
.action-btn-icon:hover { background-color: #f0f0f0; }
.action-btn-icon.edit:hover i { color: var(--primary); }
.action-btn-icon.delete:hover i { color: var(--danger); }

#logoPreviewContainer, #settingsLogoPreviewContainer { position: relative; width: 150px; height: 150px; margin-top: 10px; display: none; }
#logoPreview, #settingsLogoPreview { width: 100%; height: 100%; object-fit: contain; border: 1px solid #ddd; border-radius: var(--border-radius); }
.remove-btn { position: absolute; top: -10px; right: -10px; width: 28px; height: 28px; background-color: var(--danger); color: white; border: 2px solid white; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: bold; line-height: 1; padding: 0; box-shadow: 0 2px 5px rgba(0,0,0,0.2); transition: transform 0.2s ease; }
.remove-btn:hover { transform: scale(1.1); }

/* === ESTILOS DA PRÉ-VISUALIZAÇÃO (PDF) === */
#quotePreview.a4, #quoteViewContent.a4 { background: white; width: 210mm; min-height: 297mm; padding: 10mm; margin: 0 auto; box-shadow: 0 0 15px rgba(0,0,0,0.2); font-size: 9pt; color: #000; display: flex; flex-direction: column; }
.preview-content { flex-grow: 1; }
.red-line { border: 0; height: 3px; background-color: var(--preview-primary); margin: 5px 0 15px 0; }
.preview-header { display: flex; justify-content: space-between; align-items: center; min-height: 80px; gap: 15px; }
.header-logo { flex-shrink: 0; text-align: left; }
.header-logo img { max-width: 250px; max-height: 80px; object-fit: contain; }
.header-logo h2 { font-size: 24pt; color: #000; }
.header-details { border: 1px solid var(--preview-primary); border-radius: var(--border-radius); padding: 8px; text-align: left; line-height: 1.5; overflow-wrap: break-word; min-width: 0; }
.company-name-header { font-size: 11pt; font-weight: bold; }
.meta-section { display: flex; gap: 15px; margin-bottom: 20px; }
.client-card, .quote-card { border: 1px solid var(--preview-primary); border-radius: var(--border-radius); padding: 10px; line-height: 1.6; overflow-wrap: break-word; min-width: 0; }
.client-card { flex-basis: 60%; }
.quote-card { flex-basis: 40%; }
.client-card .card-header { font-weight: bold; margin-bottom: 5px; text-decoration: underline; }
.quote-card h3 { font-size: 16pt; margin-bottom: 10px; text-align: center; }
.preview-items-table { width: 100%; margin-top: 10px; }
.preview-items-table h3 { font-size: 12pt; margin-bottom: 5px; color: var(--dark-blue); }
.preview-items-table table { width: 100%; border-collapse: collapse; font-size: 9.5pt; }
.preview-items-table th, .preview-items-table td { border-bottom: 1px solid #ccc; padding: 8px; text-align: center; }
.preview-items-table th { background-color: #444; color: white; font-weight: bold; border-top: 2px solid #000; border-bottom: 2px solid #000; }
.preview-items-table td:first-child { text-align: left; }
.totals-section { margin-top: 20px; float: right; width: 45%; clear: both; }
.totals-item { display: flex; justify-content: space-between; padding: 5px; font-size: 10pt; }
.totals-item.grand-total { font-weight: bold; font-size: 12pt; border-top: 1px solid #000; }
.preview-footer { width: 100%; margin-top: auto; padding-top: 10px; }
.additional-info-preview { margin-top: 30px; padding-top: 15px; border-top: 1px solid #ddd; font-size: 9pt; line-height: 1.6; clear: both; }
.additional-info-preview h4 { font-size: 10pt; font-weight: bold; margin-top: 10px; margin-bottom: 5px; }
.retroactive-legend { text-align: right; font-size: 8pt; font-style: italic; color: #555; border-top: 1px dashed #ccc; padding-top: 20px; margin-top: 20px; }

/* === ESTILOS PARA OS MODAIS GENÉRICOS === */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex; justify-content: center; align-items: center;
    z-index: 4000;
    backdrop-filter: blur(5px);
}
.modal-content { background-color: var(--card-bg); border-radius: var(--border-radius); box-shadow: 0 10px 30px rgba(0,0,0,0.2); width: 100%; max-width: 900px; max-height: 90vh; display: flex; flex-direction: column; }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 15px 20px; border-bottom: 1px solid #eee; }
.modal-header h2 { color: var(--dark-blue); margin: 0; }
.modal-close { background: none; border: none; font-size: 28px; cursor: pointer; color: var(--secondary); }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-subtitle { font-size: 0.9rem; color: var(--secondary); margin-top: -10px; margin-bottom: 20px; text-align: center; }
.modal-footer { padding: 15px 20px; border-top: 1px solid #eee; text-align: right; }
.quotes-list-table { width: 100%; border-collapse: collapse; }
.quotes-list-table th, .quotes-list-table td { padding: 12px; border-bottom: 1px solid #ddd; text-align: left; }
.quotes-list-table th { background-color: var(--gray-light); font-weight: 600; }
.quotes-list-table .actions-cell { display: flex; gap: 15px; align-items: center; justify-content: flex-start; }
.modal-search { padding: 10px 20px; border-bottom: 1px solid #eee; }
.modal-search input { width: 100%; padding: 12px; border: 1px solid #ddd; border-radius: 6px; font-size: 1rem; }
.modal-search input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(122, 41, 255, 0.2); }

/* === ESTILOS PARA O MODAL DE VISUALIZAÇÃO === */
.modal-content.modal-lg {
    max-width: 950px;
}
.modal-header-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    border-bottom: 1px solid #eee;
    background-color: #f8f9fa;
}
.modal-title-action {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--dark-blue);
}
.modal-buttons-action {
    display: flex;
    gap: 10px;
}
.modal-body-preview {
    padding: 20px;
    background-color: #e9e9e9;
    overflow-y: auto;
}
#quoteViewContent {
    transform-origin: top center;
}
@media (max-width: 950px) {
    #quoteViewContent.a4 {
        width: 100%;
        min-height: auto;
        height: auto;
        padding: 15px;
        box-shadow: none;
    }
    .modal-body-preview {
        padding: 0;
    }
}


/* === NOTIFICAÇÕES (TOAST) === */
.toast {
    position: fixed;
    bottom: -100px;
    left: 50%;
    transform: translateX(-50%);
    padding: 15px 25px;
    border-radius: var(--border-radius);
    background-color: var(--dark-blue);
    color: white;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 9999;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s, bottom 0.3s ease-out;
}
.toast.show {
    bottom: 30px;
    opacity: 1;
    visibility: visible;
}
.toast.success { background-color: var(--success); }
.toast.error { background-color: var(--danger); }
.toast i { font-size: 20px; }

/* CLASSE PARA CONTROLAR VISIBILIDADE */
.hidden { display: none !important; }

/* ======================================================= */
/* === BLOCO DE RESPONSIVIDADE E MENU HAMBURGER (FINAL) === */
/* ======================================================= */

#hamburger-btn {
    display: none;
}
#menu-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none; 
}
#menu-overlay:not(.hidden) {
    opacity: 1;
    pointer-events: auto;
}

@media (min-width: 901px) {
    nav.controls .btn span {
        display: none;
    }
    nav.controls .btn {
        min-width: 40px;
        padding-left: 12px;
        padding-right: 12px;
    }
    .controls-divider {
        display: block;
    }
}

@media (max-width: 900px) {
    
    header {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
    }

    .app-container {
        padding-top: var(--header-height);
    }
    .main-content {
         padding-top: 20px;
    }

    .main-content.two-columns {
        flex-direction: column;
    }
    .form-column, 
    .preview-column {
        width: 100%;
        max-width: 100%;
        position: static;
    }
    .preview-column {
        margin-top: 20px;
    }
    
    #hamburger-btn {
        display: flex;
    }

    .header-content > nav.controls {
        display: none;
    }
    
    .header-content > nav.controls.menu-open {
        display: flex;
        position: fixed;
        top: 0;
        right: 0;
        width: 280px;
        height: 100%;
        background-color: #fff;
        flex-direction: column;
        align-items: flex-start;
        padding: 20px;
        gap: 10px;
        transform: translateX(0);
        transition: transform 0.3s ease-in-out;
        border-left: 1px solid #eee;
    }
    
    .header-content > nav.controls {
        display: flex;
        position: fixed;
        top: 0;
        right: 0;
        width: 280px;
        height: 100%;
        background-color: #fff;
        flex-direction: column;
        align-items: flex-start;
        padding: 20px;
        gap: 10px;
        transform: translateX(100%);
        transition: transform 0.3s ease-in-out;
    }
    
    nav.controls .btn {
        display: flex;
        align-items: center;
        width: 100%;
        justify-content: flex-start;
        padding: 12px 15px;
        font-size: 1rem;
    }
    nav.controls .btn i {
        margin-right: 15px;
        width: 20px;
    }
    .controls-divider {
        display: none;
    }
}

@media print {
    body * {
        visibility: hidden;
    }

    #quoteViewContent, #quoteViewContent * {
        visibility: visible;
    }

    .modal-overlay, .modal-content, .modal-body-preview {
        visibility: visible;
        position: static;
        width: auto;
        height: auto;
        background: none;
        border: none;
        padding: 0;
        margin: 0;
        box-shadow: none;
        overflow: visible;
        backdrop-filter: none;
    }

    #quoteViewContent {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        height: auto;
        margin: 0;
        padding: 0;
        box-shadow: none;
        border: none;
    }
}