/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    font-size: 12px;
    line-height: 1.4;
    color: #333;
}

/* Container */
.invoice-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    background: white;
}

/* Header Styles */
.header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    border-bottom: 2px solid #333;
    padding-bottom: 15px;
}

.invoice-number {
    font-size: 14px;
    font-weight: bold;
    text-align: right;
}

.export-btn {
    background-color: #4CAF50;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background-color 0.3s;
}

.export-btn:hover {
    background-color: #45a049;
}

.date-input {
    padding: 4px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 12px;
    width: 140px;
}

.company-info {
    flex: 1;
}

.company-name {
    font-size: 18px;
    font-weight: bold;
    color: #000;
    margin-bottom: 5px;
}

.company-details {
    font-size: 10px;
    line-height: 1.3;
}

.coordinator-note {
    font-style: italic;
    margin-top: 5px;
}


/* Information Sections */
.info-section {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
}

.supplier-info, .client-info {
    flex: 1;
}

.supplier-info {
    margin-right: 20px;
}

.section-title {
    font-weight: bold;
    margin-bottom: 5px;
    text-decoration: underline;
}

/* Booking Section */
.booking-section {
    background-color: #ffcccc;
    padding: 10px;
    margin-bottom: 15px;
    border: 1px solid #999;
}

.booking-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px 20px;
}

.booking-item {
    display: flex;
}

.booking-label {
    font-weight: bold;
    min-width: 120px;
}

/* Costs Section */
.costs-section {
    background-color: #ffffcc;
    padding: 10px;
    margin-bottom: 15px;
    border: 1px solid #999;
}

.costs-title {
    font-weight: bold;
    margin-bottom: 10px;
    background-color: #ffff99;
    padding: 5px;
    text-align: center;
}

.costs-table {
    width: 100%;
    border-collapse: collapse;
}

.costs-table th {
    background-color: #e6e6e6;
    padding: 5px;
    border: 1px solid #999;
    text-align: center;
    font-weight: bold;
}

.costs-table td {
    padding: 5px;
    border: 1px solid #999;
    text-align: center;
}

.costs-table .description-col {
    text-align: left;
    width: 40%;
}

.total-row {
    font-weight: bold;
    background-color: #f0f0f0;
}

.vat-row {
    font-weight: bold;
    background-color: #e8e8e8;
}

.grand-total-row {
    font-weight: bold;
    background-color: #d0d0d0;
    font-size: 14px;
}

/* Items Included Section */
.included-section {
    background-color: #ccffcc;
    padding: 10px;
    margin-bottom: 15px;
    border: 1px solid #999;
}

.included-title {
    font-weight: bold;
    margin-bottom: 5px;
}

.included-text {
    line-height: 1.5;
    min-height: 60px;
}

/* Payment Section */
.payment-section {
    background-color: #ccccff;
    padding: 10px;
    margin-bottom: 15px;
    border: 1px solid #999;
    page-break-inside: avoid;
    break-inside: avoid;
    -webkit-column-break-inside: avoid;
}

.payment-title {
    font-weight: bold;
    margin-bottom: 10px;
}

.payment-grid {
    display: grid;
    grid-template-columns: 150px 1fr;
    gap: 5px;
}

.payment-label {
    font-weight: bold;
}

/* Additional Section */
.additional-section {
    background-color: #ffcc99;
    padding: 10px;
    margin-bottom: 15px;
    border: 1px solid #999;
}

.additional-title {
    font-weight: bold;
    margin-bottom: 10px;
}

/* Thank You Message */
.thank-you {
    text-align: center;
    font-weight: bold;
    margin-top: 30px;
    font-style: italic;
}

/* Editable Fields */
.editable {
    background-color: #f9f9f9;
    border: 1px dashed #ccc;
    padding: 2px;
    min-height: 20px;
    position: relative;
}

.editable:focus {
    outline: 2px solid #4CAF50;
    background-color: white;
}

.editable[contenteditable="true"] {
    cursor: text;
}

.placeholder {
    color: #999;
    font-style: italic;
}

/* Hide placeholders when printing or exporting to PDF */
@media print {
    .placeholder {
        display: none;
    }
}

/* Instructions */
.instruction {
    color: #666;
    font-size: 10px;
    font-style: italic;
    display: none; /* Hide instructions by default */
}

/* Expandable Fields */
.expandable-field {
    line-height: 1.5;
    word-wrap: break-word;
    resize: vertical;
    overflow: auto;
    min-height: 60px;
    border: 1px solid #ddd;
    padding: 5px;
    background-color: #f9f9f9;
    position: relative;
}

.expandable-field:focus {
    outline: 2px solid #4CAF50;
    background-color: white !important;
}

.expandable-field:empty::before {
    content: attr(data-placeholder);
    color: #999;
    font-style: italic;
    position: absolute;
    pointer-events: none;
}

/* Hide placeholder when printing */
@media print {
    .expandable-field:empty::before {
        display: none;
    }
}

/* Responsive Styles */
@media screen and (max-width: 768px) {
    .invoice-container {
        padding: 10px;
    }

    .header {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .company-info {
        margin-bottom: 15px;
    }


    .invoice-number {
        text-align: center;
    }

    .info-section {
        flex-direction: column;
    }

    .supplier-info, .client-info {
        margin-right: 0;
        margin-bottom: 20px;
    }

    .booking-grid {
        grid-template-columns: 1fr;
    }

    .costs-table {
        font-size: 11px;
    }

    .costs-table th, 
    .costs-table td {
        padding: 3px;
    }

    .payment-grid {
        grid-template-columns: 1fr;
    }

    .payment-label {
        font-weight: bold;
        margin-top: 10px;
    }

    .signature-line {
        width: 100%;
    }
}

@media screen and (max-width: 480px) {
    body {
        font-size: 11px;
    }

    .company-name {
        font-size: 16px;
    }

    .costs-table {
        font-size: 10px;
    }

    .booking-label {
        min-width: 100px;
    }

    .costs-table .description-col {
        width: 30%;
    }

    .grand-total-row {
        font-size: 12px;
    }
}

/* Print Styles */
@media print {
    body {
        background: white;
    }
    
    .invoice-container {
        width: 100%;
        max-width: none;
        padding: 0;
        margin: 0;
    }
    
    .instruction {
        display: none;
    }
    
    .editable {
        border: none;
        background: none;
    }

    /* Hide the Add Row button when printing */
    .costs-section button {
        display: none !important;
    }
    
    .costs-section,
    .included-section,
    .payment-section,
    .additional-section {
        break-inside: avoid;
    }

    /* Ensure expandable fields don't show borders or backgrounds when printing */
    .expandable-field {
        border: none !important;
        background: none !important;
        padding: 0 !important;
    }
}
