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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    background: white;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 40px 20px;
    text-align: center;
}

.header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    font-weight: 700;
}

.header p {
    font-size: 1.1em;
    opacity: 0.9;
}

form {
    padding: 40px;
}

.form-section {
    margin-bottom: 30px;
    padding-bottom: 30px;
    border-bottom: 1px solid #e0e0e0;
}

.form-section:last-of-type {
    border-bottom: none;
}

.form-section h2 {
    color: #333;
    font-size: 1.5em;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #667eea;
    display: inline-block;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
    font-size: 0.95em;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 0.95em;
    font-family: inherit;
    transition: all 0.3s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 5px rgba(102, 126, 234, 0.3);
}

.form-group textarea {
    resize: vertical;
}

/* Table Styles */
.table-wrapper {
    overflow-x: auto;
    margin-bottom: 20px;
}

#itemsTable {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 15px;
}

#itemsTable thead {
    background-color: #f5f5f5;
}

#itemsTable th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: #333;
    border-bottom: 2px solid #ddd;
}

#itemsTable td {
    padding: 12px;
    border-bottom: 1px solid #e0e0e0;
}

#itemsTable input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9em;
}

#itemsTable input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 3px rgba(102, 126, 234, 0.3);
}

.btn-remove-item {
    background-color: #ff6b6b;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85em;
    transition: background-color 0.3s;
}

.btn-remove-item:hover {
    background-color: #ff5252;
}

.btn-add-item {
    background-color: #51cf66;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 600;
    transition: background-color 0.3s;
    margin-top: 10px;
}

.btn-add-item:hover {
    background-color: #40c057;
}

/* Totals Section */
.totals-wrapper {
    background-color: #f9f9f9;
    padding: 20px;
    border-radius: 5px;
    max-width: 400px;
    margin-left: auto;
}

.total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    font-size: 0.95em;
    border-bottom: 1px solid #e0e0e0;
}

.total-row label {
    font-weight: 600;
    color: #333;
}

.total-row span {
    color: #667eea;
    font-weight: 600;
}

.tax-input-group {
    display: flex;
    gap: 10px;
    align-items: center;
}

.tax-input-group input {
    width: 80px;
    padding: 6px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.total-due {
    background-color: #667eea;
    color: white;
    padding: 15px !important;
    border-radius: 5px;
    margin-top: 15px;
    border-bottom: none;
    font-size: 1.1em;
}

.total-due label,
.total-due span {
    color: white;
    font-size: 1.1em;
}

/* Button Styles */
.btn {
    padding: 12px 30px;
    border: none;
    border-radius: 5px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-right: 10px;
}

.btn-preview {
    background-color: #4ecdc4;
    color: white;
}

.btn-preview:hover {
    background-color: #45b8ae;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(78, 205, 196, 0.3);
}

.btn-generate {
    background-color: #667eea;
    color: white;
}

.btn-generate:hover {
    background-color: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

.btn-reset {
    background-color: #adb5bd;
    color: white;
}

.btn-reset:hover {
    background-color: #95a1aa;
}

.form-actions {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    overflow: auto;
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 30px;
    border-radius: 10px;
    width: 90%;
    max-width: 900px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    position: sticky;
    top: 0;
}

.close:hover,
.close:focus {
    color: #000;
}

/* Preview Content */
.preview-content {
    background-color: white;
    padding: 40px;
    border: 1px solid #ddd;
    font-family: Arial, sans-serif;
    line-height: 1.6;
}

.preview-header {
    text-align: center;
    margin-bottom: 30px;
    border-bottom: 2px solid #667eea;
    padding-bottom: 20px;
}

.preview-header h1 {
    font-size: 2em;
    color: #667eea;
    margin-bottom: 5px;
}

.preview-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 30px;
}

.preview-details-section h3 {
    color: #333;
    font-size: 0.9em;
    text-transform: uppercase;
    margin-bottom: 10px;
    color: #667eea;
}

.preview-details-section p {
    font-size: 0.9em;
    color: #555;
    margin-bottom: 5px;
}

.preview-items {
    width: 100%;
    margin-bottom: 30px;
}

.preview-items table {
    width: 100%;
    border-collapse: collapse;
}

.preview-items th {
    background-color: #f5f5f5;
    padding: 10px;
    text-align: left;
    border-bottom: 2px solid #667eea;
    font-weight: 600;
    color: #333;
}

.preview-items td {
    padding: 10px;
    border-bottom: 1px solid #e0e0e0;
}

.preview-totals {
    text-align: right;
    margin-bottom: 30px;
}

.preview-total-row {
    display: grid;
    grid-template-columns: 200px 100px;
    gap: 10px;
    justify-content: end;
    margin-bottom: 5px;
    font-weight: 600;
}

.preview-notes {
    background-color: #f9f9f9;
    padding: 15px;
    border-radius: 5px;
    margin-top: 20px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .form-row {
        grid-template-columns: 1fr;
    }

    .header h1 {
        font-size: 1.8em;
    }

    .header p {
        font-size: 0.9em;
    }

    form {
        padding: 20px;
    }

    .totals-wrapper {
        max-width: 100%;
    }

    .preview-details {
        grid-template-columns: 1fr;
    }

    .btn {
        width: 100%;
        margin-right: 0;
        margin-bottom: 10px;
    }

    .form-actions {
        flex-direction: column;
    }

    .modal-content {
        width: 95%;
        margin: 10% auto;
        padding: 15px;
    }

    #itemsTable {
        font-size: 0.85em;
    }

    #itemsTable input {
        padding: 6px;
    }
}

@media print {
    body {
        background: white;
    }

    .close,
    .btn {
        display: none;
    }

    .modal-content {
        box-shadow: none;
        margin: 0;
        width: 100%;
    }
}
