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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    width: 100%;
}

header {
    text-align: center;
    margin-bottom: 30px;
    padding: 0 10px;
}

header h1 {
    font-size: 2rem;
    color: #2c3e50;
    margin-bottom: 5px;
}

header p {
    color: #7f8c8d;
}

/* Main Grid Layout */
.main-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

@media (min-width: 768px) {
    .main-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (min-width: 992px) {
    .main-grid {
        grid-template-columns: 1fr 2fr;
    }
}

/* Form Styles */
.settings-section, .invoice-section {
    background-color: white;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow-x: auto;
}

h2, h3 {
    color: #2c3e50;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

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

label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #34495e;
}

input, select, textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #3498db;
}

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

@media (min-width: 768px) {
    .form-row {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 992px) {
    .form-row {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Logo Settings Preview */
.logo-preview-container {
    margin-top: 10px;
    width: 100%;
    max-width: 150px;
    height: 80px;
    border: 1px solid #ddd;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#logo-preview {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: none;
}

.logo {
    max-width: 180px;
    margin: 0 auto 1rem;
}

@media (prefers-color-scheme: dark) {
    .logo img {
        filter: brightness(0) invert(1);
    }
}

@media print {
    .logo {
        max-width: 120px !important;
        filter: none !important;
    }
}

.invoice-logo {
    width: 100px;
    height: 50px;
    object-fit: contain;
    margin-bottom: 10px;
}

/* Table Styles */
.products-section {
    margin-top: 20px;
}

.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 15px;
    min-width: 600px;
}

th, td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: #34495e;
}

/* Button Styles */
button {
    padding: 10px 15px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.3s;
    font-size: 14px;
}

button[type="submit"], #generate-invoice {
    background-color: #3498db;
    color: white;
}

button[type="submit"]:hover, #generate-invoice:hover {
    background-color: #2980b9;
}

#reset-settings, #clear-invoice {
    background-color: #e74c3c;
    color: white;
}

#reset-settings:hover, #clear-invoice:hover {
    background-color: #c0392b;
}

#add-product {
    background: none;
    color: #3498db;
    padding: 5px 10px;
    font-size: 14px;
}

#add-product:hover {
    text-decoration: underline;
}

.delete-product {
    background: none;
    color: #e74c3c;
    padding: 5px 10px;
    font-size: 14px;
}

.delete-product:hover {
    text-decoration: underline;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

/* Totals Section */
.totals-section {
    margin-top: 20px;
    padding-top: 10px;
    border-top: 1px solid #eee;
}

.total-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
}

.grand-total {
    font-weight: bold;
    font-size: 1.1rem;
    border-top: 1px solid #ddd;
    margin-top: 5px;
    padding-top: 10px;
}

/* Invoice Preview Section */
#invoice-preview-section {
    background-color: white;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-top: 30px;
    display: none;
    overflow-x: auto;
}

.preview-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
    gap: 10px;
}

.preview-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

#print-invoice {
    background-color: #7f8c8d;
    color: white;
}

#print-invoice:hover {
    background-color: #95a5a6;
}

#export-pdf {
    background-color: #27ae60;
    color: white;
}

#export-pdf:hover {
    background-color: #219653;
}

/* Invoice Print Styles */
#invoice-print {
    font-family: Arial, sans-serif;
    line-height: 1.5;
}

.invoice-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    margin-bottom: 30px;
}

.invoice-title {
    font-size: 1.5rem;
    font-weight: bold;
    color: #2c3e50;
}

.invoice-meta {
    text-align: right;
}

.invoice-meta p {
    margin-bottom: 5px;
}

.invoice-body {
    margin-bottom: 30px;
    overflow-x: auto;
}

.invoice-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
    min-width: 600px;
}

.invoice-table th, .invoice-table td {
    border: 1px solid #ddd;
    padding: 8px 12px;
    text-align: left;
}

.invoice-table th {
    background-color: #f2f2f2;
}

.invoice-totals {
    margin-top: 20px;
    text-align: right;
}

.invoice-totals div {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.invoice-footer {
    margin-top: 40px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    flex-wrap: wrap;
}

.invoice-message {
    font-style: italic;
    text-align: center;
    margin-top: 30px;
}

.signature {
    margin-top: 50px;
    border-top: 1px solid #333;
    width: 200px;
    text-align: center;
    padding-top: 5px;
}

/* Success Message */
#success-message {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    display: none;
}

.success-content {
    background-color: white;
    padding: 30px;
    border-radius: 8px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    animation: fadeIn 0.3s ease-in-out;
}

.success-icon {
    width: 50px;
    height: 50px;
    margin-bottom: 15px;
    fill: none;
    stroke: #27ae60;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

#success-message h3 {
    margin-bottom: 10px;
    color: #2c3e50;
    border-bottom: none;
    padding-bottom: 0;
}

#success-message p {
    margin-bottom: 20px;
    color: #7f8c8d;
}

#close-success {
    background-color: #3498db;
    color: white;
    padding: 8px 20px;
}

#close-success:hover {
    background-color: #2980b9;
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

/* Print Styles */
@media print {
    body * {
        visibility: hidden;
    }
    #invoice-print, #invoice-print * {
        visibility: visible;
    }
    #invoice-print {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        padding: 20px;
        font-size: 14px;
    }
    .no-print {
        display: none !important;
    }
    .invoice-table {
        page-break-inside: avoid;
    }
    .invoice-totals {
        page-break-before: avoid;
    }
}
