/* === Visual Invoice Editor — A4 document layout === */

.ve-page {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

/* Toolbar sidebar */
.ve-toolbar {
    position: sticky;
    top: 16px;
    width: 200px;
    flex-shrink: 0;
}

.ve-toolbar .btn {
    width: 100%;
    text-align: left;
    margin-bottom: 4px;
    font-size: 0.82rem;
    padding: 5px 10px;
}

.ve-toolbar .ve-section-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 12px;
    margin-bottom: 4px;
    padding-left: 2px;
}

.ve-toolbar .form-check {
    font-size: 0.82rem;
    margin-bottom: 2px;
    padding-left: 26px;
}

.ve-toolbar .form-check-input {
    margin-top: 0.3em;
}

/* A4 paper container */
.ve-paper {
    width: 210mm;
    min-height: 297mm;
    margin: 0 auto;
    padding: 15mm 18mm;
    background: white;
    box-shadow: 0 2px 12px rgba(0,0,0,0.12);
    font-family: 'Segoe UI', Arial, sans-serif;
    font-size: 10pt;
    color: #222;
    flex: 1;
    min-width: 0;
}

/* === Editable field === */
.ve-field {
    display: inline-block;
    min-width: 60px;
    min-height: 1.3em;
    padding: 1px 4px;
    border-bottom: 1px dashed #ccc;
    cursor: text;
    transition: border-color 0.15s, background-color 0.15s;
    line-height: 1.4;
}

.ve-field:hover {
    border-bottom-color: #0d6efd;
    background: #f0f6ff;
}

.ve-field--empty::after {
    content: attr(data-placeholder);
    color: #aaa;
    font-style: italic;
    font-size: 0.9em;
}

.ve-field-input {
    border: none;
    border-bottom: 2px solid #0d6efd;
    outline: none;
    background: #f0f6ff;
    padding: 1px 4px;
    font: inherit;
    color: inherit;
    width: 100%;
    min-width: 60px;
}

.ve-field--error {
    border-bottom-color: #dc3545 !important;
    background: #fff5f5;
}

.ve-field--wide {
    min-width: 180px;
}

.ve-field--number {
    text-align: right;
    min-width: 80px;
}

.ve-field--date {
    min-width: 100px;
}

.ve-select {
    border: none;
    border-bottom: 1px dashed #ccc;
    background: transparent;
    padding: 1px 4px;
    font: inherit;
    cursor: pointer;
    min-width: 80px;
}

.ve-select:hover {
    border-bottom-color: #0d6efd;
    background: #f0f6ff;
}

.ve-select:focus {
    border-bottom: 2px solid #0d6efd;
    background: #f0f6ff;
    outline: none;
}

/* === Document header === */
.ve-header {
    text-align: center;
    margin-bottom: 8mm;
}

.ve-title {
    font-size: 16pt;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin: 0;
    color: #1a1a1a;
}

.ve-subtitle {
    font-size: 9pt;
    color: #666;
    margin-top: 2px;
}

.ve-type-badge {
    display: inline-block;
    font-size: 8pt;
    padding: 2px 8px;
    border-radius: 3px;
    background: #e9ecef;
    color: #495057;
    font-weight: 600;
    margin-left: 8px;
    vertical-align: middle;
}

.ve-type-badge--kor {
    background: #ffeeba;
    color: #856404;
}

/* === Meta row (dates, number) === */
.ve-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6mm;
    margin-bottom: 6mm;
    padding: 4px 0;
    border-bottom: 1px solid #ddd;
}

.ve-meta-item {
    display: flex;
    flex-direction: column;
}

.ve-label {
    font-size: 7.5pt;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 1px;
}

/* === Party blocks (Sprzedawca / Nabywca) === */
.ve-parties {
    display: flex;
    gap: 10mm;
    margin-bottom: 6mm;
}

.ve-party {
    flex: 1;
    border: 1px solid #ccc;
    padding: 8px 12px;
    border-radius: 3px;
}

.ve-party-title {
    font-size: 8pt;
    font-weight: 700;
    text-transform: uppercase;
    color: #555;
    border-bottom: 2px solid #333;
    padding-bottom: 3px;
    margin-bottom: 6px;
    letter-spacing: 0.5px;
}

.ve-party-row {
    display: flex;
    gap: 4px;
    margin-bottom: 2px;
    align-items: baseline;
}

.ve-party-row .ve-label {
    min-width: 40px;
    flex-shrink: 0;
}

/* === Line items table === */
.ve-items-table {
    width: 100%;
    border-collapse: collapse;
    margin: 4mm 0;
    font-size: 9pt;
}

.ve-items-table th {
    background: #f0f0f0;
    border: 1px solid #999;
    padding: 3px 5px;
    text-align: center;
    font-size: 7.5pt;
    font-weight: 600;
    text-transform: uppercase;
    color: #444;
    white-space: nowrap;
}

.ve-items-table td {
    border: 1px solid #ccc;
    padding: 2px 4px;
    vertical-align: middle;
}

.ve-items-table td input,
.ve-items-table td select {
    border: none;
    background: transparent;
    width: 100%;
    font: inherit;
    padding: 1px 2px;
}

.ve-items-table td input:focus,
.ve-items-table td select:focus {
    background: #f0f6ff;
    outline: 1px solid #0d6efd;
}

.ve-items-table td.ve-col-num {
    text-align: right;
}

.ve-items-table td.ve-col-center {
    text-align: center;
}

.ve-items-table td.ve-col-lp {
    text-align: center;
    color: #888;
    width: 30px;
}

.ve-items-table .ve-row-actions {
    width: 30px;
    text-align: center;
    border: none;
    padding: 0;
}

.ve-items-table .ve-row-actions button {
    border: none;
    background: none;
    color: #999;
    cursor: pointer;
    font-size: 14px;
    padding: 2px;
    line-height: 1;
}

.ve-items-table .ve-row-actions button:hover {
    color: #dc3545;
}

.ve-add-row {
    margin-top: 4px;
    font-size: 0.82rem;
}

/* === VAT summary table === */
.ve-tax-summary {
    width: auto;
    margin: 4mm 0;
    margin-left: auto;
    border-collapse: collapse;
    font-size: 9pt;
}

.ve-tax-summary th {
    background: #f0f0f0;
    border: 1px solid #999;
    padding: 3px 8px;
    text-align: center;
    font-size: 7.5pt;
    font-weight: 600;
    text-transform: uppercase;
}

.ve-tax-summary td {
    border: 1px solid #ccc;
    padding: 2px 8px;
    text-align: right;
}

.ve-tax-summary .ve-total-row td {
    font-weight: 700;
    background: #f8f9fa;
    border-top: 2px solid #333;
}

/* === Total === */
.ve-total {
    text-align: right;
    margin: 4mm 0;
    padding: 6px 12px;
    background: #f8f9fa;
    border: 1px solid #ccc;
    border-radius: 3px;
}

.ve-total-label {
    font-size: 9pt;
    color: #666;
    text-transform: uppercase;
}

.ve-total-value {
    font-size: 14pt;
    font-weight: 700;
    color: #1a1a1a;
    margin-left: 8px;
}

/* === Payment block === */
.ve-payment {
    margin: 6mm 0;
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 3px;
}

.ve-payment-title {
    font-size: 8pt;
    font-weight: 700;
    text-transform: uppercase;
    color: #555;
    border-bottom: 1px solid #ddd;
    padding-bottom: 3px;
    margin-bottom: 6px;
}

.ve-payment-row {
    display: flex;
    gap: 4px;
    margin-bottom: 2px;
    align-items: baseline;
}

/* === Advanced section === */
.ve-advanced {
    margin: 4mm 0;
    padding: 8px 12px;
    border: 1px dashed #aaa;
    border-radius: 3px;
    background: #fdfdfd;
}

.ve-advanced-title {
    font-size: 8pt;
    font-weight: 700;
    text-transform: uppercase;
    color: #0d6efd;
    margin-bottom: 6px;
}

/* === Separator === */
.ve-separator {
    border: none;
    border-top: 1px solid #ddd;
    margin: 4mm 0;
}

/* === Print styles === */
@media print {
    .ve-toolbar,
    .ve-alert-area,
    .ve-session-dialog,
    .ve-template-dialog,
    .ve-add-row,
    .ve-row-actions,
    .ve-toolbar-area {
        display: none !important;
    }

    .ve-paper {
        box-shadow: none;
        margin: 0;
        padding: 10mm 15mm;
        width: 100%;
    }

    .ve-field {
        border-bottom: none;
    }

    .ve-page {
        display: block;
    }
}

/* === Responsive: scale paper on small screens === */
@media (max-width: 900px) {
    .ve-paper {
        width: 100%;
        min-height: auto;
        padding: 10px 14px;
        font-size: 9pt;
    }

    .ve-parties {
        flex-direction: column;
        gap: 8px;
    }

    .ve-toolbar {
        position: static;
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
    }

    .ve-toolbar .btn {
        width: auto;
    }

    .ve-page {
        flex-direction: column;
    }
}
