@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', Arial, sans-serif;
    background: #f0f2f5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 20px;
}

h1.page-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: #1a1a2e;
    margin-bottom: 24px;
    letter-spacing: 0.5px;
}

/* ===== TABLE CONTAINER ===== */
.table-container {
    background: #fff;
    width: 1500px;
    /* Increased from 1150px */
    max-width: 100%;
    border: 2px solid #1a1a2e;
    margin-bottom: 24px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
}

/* ===== HEADER ROW ===== */
.header-row {
    display: grid;
    grid-template-columns: 280px 1fr 280px;
    /* Fixed side widths, flexible center */
    border-bottom: 2px solid #1a1a2e;
    min-height: 85px;
}

.header-cell {
    padding: 10px 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.header-cell:not(:last-child) {
    border-right: 2px solid #1a1a2e;
}

.logo-cell {
    justify-content: center;
}

.logo-img {
    max-width: 220px;
    max-height: 65px;
    object-fit: contain;
}

/* Title cell */
.title-cell {
    flex-direction: column;
    gap: 4px;
}

/* Info cell */
.info-cell {
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
    font-size: 0.95rem;
    /* Increased size */
}

.info-cell .info-line {
    display: flex;
    align-items: center;
    gap: 4px;
    width: 100%;
}

.info-cell .info-label {
    font-weight: 700;
    color: #1a1a2e;
    white-space: nowrap;
    font-size: 0.9rem;
    /* Increased size */
}

/* ===== FOOTER ROW (ELABORADO / APROVADO / VALIDADO) ===== */
.footer-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    min-height: 45px;
}

.footer-cell {
    padding: 8px 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.footer-cell:not(:last-child) {
    border-right: 2px solid #1a1a2e;
}

.footer-cell .footer-label {
    font-weight: 700;
    font-size: 1.4rem;
    /* Increased size */
    color: #1a1a2e;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ===== SIGNATURE ROWS ===== */
.signature-section {
    border-top: 2px solid #1a1a2e;
}

.signature-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    /* Updated to 3 columns */
    min-height: 50px;
    border-bottom: 1px solid #ccc;
}

.signature-row:last-child {
    border-bottom: none;
}

.signature-cell {
    padding: 8px 14px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 2px;
}

.signature-cell:not(:last-child) {
    border-right: 2px solid #1a1a2e;
}

.signature-cell .sig-label {
    font-weight: 600;
    font-size: 0.65rem;
    /* Increased size */
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    text-align: left;
}

/* ===== EDITABLE FIELDS ===== */
.editable-field {
    border: none;
    background: transparent;
    outline: none;
    font-family: 'Inter', Arial, sans-serif;
    color: #333;
    transition: background 0.2s;
    padding: 6px 10px;
    border-radius: 4px;
    width: 100%;
    min-height: 1.4em;
    font-size: 1rem;
    /* Added custom font size */
    text-transform: uppercase;
    /* Ensure all fields are uppercase */
    word-break: break-word;
    /* Allow wrapping */
    white-space: pre-wrap;
    /* Preserve line breaks if any */
    display: block;
}

/* Specific styling for contenteditable placeholder behavior */
.editable-field:empty::before {
    content: attr(data-placeholder);
    color: #bbb;
    font-style: italic;
}

.editable-field:hover {
    background: #f5f7ff;
}

.editable-field:focus {
    background: #eef1ff;
    box-shadow: 0 0 0 2px rgba(26, 26, 78, 0.15);
}

/* ===== BUTTONS ===== */
.actions {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 20px;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 28px;
    border: none;
    border-radius: 8px;
    font-family: 'Inter', Arial, sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    letter-spacing: 0.3px;
}

.btn svg {
    width: 18px;
    height: 18px;
}

.btn-image {
    background: linear-gradient(135deg, #1a1a4e, #2d2d7a);
    color: #fff;
    box-shadow: 0 4px 14px rgba(26, 26, 78, 0.3);
}

.btn-image:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(26, 26, 78, 0.4);
}

.btn-save {
    background: #28a745;
    color: #fff;
    box-shadow: 0 4px 14px rgba(40, 167, 69, 0.3);
}

.btn-save:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(40, 167, 69, 0.4);
}

.btn-add {
    background: #fff;
    color: #1a1a4e;
    border: 2px solid #1a1a4e;
}

/* ===== INPUT CARD & SIDEBAR ===== */
.main-wrapper {
    display: flex;
    gap: 40px;
    align-items: flex-start;
    width: 1650px;
    /* Increased from 1550px */
    max-width: 98vw;
}

.input-sidebar {
    width: 350px;
    flex-shrink: 0;
}

.input-card {
    background: #fff;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    border: 1px solid #e1e4e8;
    position: sticky;
    top: 40px;
}

.input-card h2 {
    font-size: 1.1rem;
    color: #1a1a4e;
    margin-bottom: 20px;
    font-weight: 700;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.7rem;
    font-weight: 800;
    color: #888;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid #f0f0f0;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
    transition: all 0.2s;
}

.form-group input:focus {
    border-color: #1a1a4e;
    background: #fcfcff;
}

/* ===== REGISTROS SALVOS (BOTTOM SECTION) ===== */
.presets-section {
    margin-top: 40px;
    background: #fff;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
    border: 1px solid #e1e4e8;
    width: 100%;
    margin-bottom: 40px;
}

.presets-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.presets-header h2 {
    font-size: 1.1rem;
    color: #1a1a4e;
    font-weight: 700;
}

.filters {
    display: flex;
    gap: 12px;
}

.filters input {
    padding: 8px 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    outline: none;
    transition: all 0.2s;
    min-width: 220px;
}

.filters input[type="date"] {
    min-width: 140px;
}

.filters input:focus {
    border-color: #1a1a4e;
    background: #fcfcff;
}

.presets-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.preset-item {
    padding: 12px;
    background: #f8f9fa;
    border: 1px solid #eee;
    border-radius: 8px;
    margin-bottom: 10px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.preset-item:hover {
    background: #eef1ff;
    border-color: #1a1a4e;
    transform: translateX(5px);
}

.preset-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.btn-delete {
    background: transparent;
    border: none;
    color: #cc0000;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.5;
}

.btn-delete:hover {
    background: rgba(204, 0, 0, 0.1);
    opacity: 1;
}

.btn-delete svg {
    width: 16px;
    height: 16px;
}

.preset-item b {
    color: #1a1a4e;
}

.preset-item span {
    font-size: 0.7rem;
    color: #999;
}

/* ===== TOAST NOTIFICATION ===== */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #1a1a4e;
    color: #fff;
    padding: 12px 28px;
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-size: 0.88rem;
    font-weight: 500;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.22, 1, 0.36, 1);
    z-index: 1000;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ===== MODAL DE CONFIRMAÇÃO ===== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

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

.modal-box {
    background: #fff;
    border-radius: 12px;
    padding: 32px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    max-width: 380px;
    width: 90%;
    text-align: center;
    font-family: 'Inter', sans-serif;
}

.modal-box p {
    font-size: 1rem;
    color: #1a1a4e;
    margin-bottom: 24px;
    font-weight: 600;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.btn-image.danger {
    background: linear-gradient(135deg, #c0392b, #e74c3c);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1400px) {
    .main-wrapper {
        flex-direction: column;
        align-items: center;
    }

    .input-sidebar {
        width: 100%;
        max-width: 1150px;
    }
}

@media (max-width: 600px) {
    .header-row {
        grid-template-columns: 1fr;
    }

    .signature-row {
        grid-template-columns: 1fr;
    }
}