/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: #f5f7fa;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px 0;
    background: linear-gradient(135deg, #3498db, #2c3e50);
    color: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
}

header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Form Styles */
.form-container, .invoice-container {
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    padding: 30px;
    margin-bottom: 30px;
    transition: all 0.3s ease;
}

.form-container:hover {
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.invoice-container {
    display: none;
}

.form-section {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid #eee;
}

.form-section:last-child {
    border-bottom: none;
}

.form-section h3 {
    font-size: 1.3rem;
    color: #2c3e50;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #3498db;
}

.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 20px;
}

.form-group {
    flex: 1;
    min-width: 200px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #2c3e50;
}

input, textarea, select {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    transition: border-color 0.3s, box-shadow 0.3s;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

textarea {
    min-height: 100px;
    resize: vertical;
}

.item-container {
    background-color: #f9f9f9;
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 15px;
    transition: all 0.3s ease;
}

.item-container:hover {
    background-color: #f0f4f8;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

/* Button Styles */
.buttons {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 30px;
    gap: 15px;
}

.left-buttons, .right-buttons {
    flex: 0 0 auto; /* Don't stretch */
}

.middle-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex: 1;  /* Take available space */
}

.btn {
    min-width: 150px;
    padding: 12px 24px;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn:not(.back-btn, .add-item-btn, .json-btn) {
    background-color: #3498db;
    color: white;
}

.btn:not(.back-btn, .add-item-btn, .json-btn):hover {
    background-color: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.back-btn {
    background-color: #95a5a6;
    color: white;
}

.back-btn:hover {
    background-color: #7f8c8d;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.add-item-btn {
    background-color: #2ecc71;
    color: white;
}

.add-item-btn:hover {
    background-color: #27ae60;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.print-btn {
    background-color: #e74c3c;
    color: white;
}

.print-btn:hover {
    background-color: #c0392b;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.json-btn {
    color: white;
}

.upload-btn {
    background-color: #9b59b6;
}

.upload-btn:hover {
    background-color: #8e44ad;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.upload-btn.drag-over {
    background-color: #8e44ad;
    box-shadow: 0 0 10px rgba(142, 68, 173, 0.5);
}

.download-btn {
    background-color: #f39c12;
}

.download-btn:hover {
    background-color: #d35400;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

/* Signature Preview */
.signature-preview {
    margin-top: 10px;
    display: none;
}

#signatureImagePreview {
    max-width: 200px;
    max-height: 100px;
    border: 1px solid #ddd;
    margin-top: 10px;
    border-radius: 4px;
}

/* Logo Upload */
.logo-upload {
    margin-bottom: 20px;
}

.logo-preview {
    margin-top: 10px;
    display: none;
}

#logoPreview {
    max-width: 200px;
    max-height: 100px;
    border: 1px solid #ddd;
    margin-top: 10px;
    border-radius: 4px;
}

/* Invoice Styles */
#invoice {
    background-color: white;
    padding: 40px;
    max-width: 800px;
    margin: 0 auto;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
}

.invoice-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #3498db;
}

.logo {
    width: 150px;
    height: 80px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.invoice-header h3 {
    font-size: 1.8rem;
    color: #2c3e50;
    text-align: right;
}

#invoice-number {
    font-size: 1rem;
    color: #7f8c8d;
    text-align: right;
}

.invoice-details {
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
    margin-bottom: 30px;
}

.column {
    flex: 1;
    min-width: 200px;
}

.column h4 {
    font-size: 1.2rem;
    color: #2c3e50;
    margin-bottom: 15px;
    padding-bottom: 5px;
    border-bottom: 1px solid #eee;
}

.invoice-items {
    margin-bottom: 30px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: #2c3e50;
}

tbody tr:hover {
    background-color: #f8f9fa;
}

.invoice-totals {
    text-align: right;
    margin-bottom: 30px;
}

.invoice-totals table {
    width: 300px;
    margin-left: auto;
}

.invoice-totals td {
    padding: 10px 15px;
}

.invoice-totals tr:last-child td {
    font-weight: 600;
    font-size: 1.1rem;
    color: #2c3e50;
    border-top: 2px solid #3498db;
}

.invoice-notes {
    margin-bottom: 30px;
    padding: 15px;
    background-color: #f0f7ff;
    border-radius: 4px;
    border-left: 3px solid #3498db;
}

.invoice-notes h4 {
    font-size: 1.1rem;
    color: #2c3e50;
    margin-bottom: 10px;
}

.signature-section {
    margin-top: 50px;
}

.signature-container {
    display: flex;
    justify-content: flex-end;
}

.signature-box {
    text-align: center;
    width: 300px;
}

#signatureImageDisplay {
    height: 60px;
    margin-bottom: 10px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.signature-line {
    border-top: 1px solid #333;
    margin-bottom: 5px;
}

.invoice-footer {
    text-align: center;
    margin-top: 50px;
    padding-top: 20px;
    border-top: 1px solid #eee;
    color: #7f8c8d;
    font-style: italic;
}

/* Print-only styles */
@media print {
    body {
        background-color: white;
    }
    
    .container {
        padding: 0;
        width: 100%;
    }
    
    .buttons, header {
        display: none;
    }
    
    .invoice-container {
        display: block;
        box-shadow: none;
        padding: 0;
    }
    
    #invoice {
        box-shadow: none;
        max-width: 100%;
    }
}

/* Print Preview Styles */
body.print-preview {
    background-color: white;
}

body.print-preview .container {
    max-width: 100%;
    padding: 0;
}

body.print-preview header,
body.print-preview .form-container,
body.print-preview .buttons {
    display: none;
}

body.print-preview .invoice-container {
    display: block;
    box-shadow: none;
    padding: 0;
}

body.print-preview #invoice {
    box-shadow: none;
    padding: 20px;
    margin: 0;
}

/* Responsive Styles */
@media (max-width: 768px) {
    .form-row, .invoice-details {
        flex-direction: column;
        gap: 15px;
    }

    .form-group {
        min-width: 100%;
    }

    .invoice-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .invoice-header h3, #invoice-number {
        text-align: left;
        margin-top: 20px;
    }

    .buttons {
        flex-direction: column;
    }
    
    .middle-buttons {
        flex-direction: row;
        width: 100%;
    }
    
    .btn {
        width: 100%;
    }
}