/* Custom Styles for Invoice Generator */

body {
    background-color: #f5f5f5;
}

.navbar {
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.card {
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    border: none;
}

.form-label {
    font-weight: 500;
    margin-bottom: 0.5rem;
}

#logoPreview img,
#signaturePreview img {
    max-width: 200px;
    max-height: 100px;
    border: 1px solid #ddd;
    padding: 5px;
    background: white;
}

/* Invoice Preview Styles */
.invoice-preview {
    background: white;
    padding: 30px;
    margin: 0 auto;
    max-width: 210mm;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
}

.invoice-header {
    border-bottom: 2px solid #333;
    padding-bottom: 20px;
    margin-bottom: 20px;
}

.invoice-logo {
    max-width: 150px;
    max-height: 80px;
    margin-bottom: 10px;
}

.business-info {
    font-size: 0.9rem;
    line-height: 1.6;
}

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

.invoice-meta p {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.invoice-meta .badge {
    font-size: 0.9rem;
    padding: 0.5rem;
}

.invoice-section {
    margin-bottom: 25px;
}

.invoice-section h5 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 10px;
    color: #333;
    border-bottom: 1px solid #ddd;
    padding-bottom: 5px;
}

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

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

.products-table th {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    padding: 10px;
    text-align: left;
    font-weight: 600;
}

.products-table th.text-right {
    text-align: right;
}

.products-table td {
    border: 1px solid #dee2e6;
    padding: 8px;
}

.products-table tbody tr:nth-child(even) {
    background-color: #f8f9fa;
}

.products-table .text-right {
    text-align: right;
}

.totals-box {
    border: 2px solid #333;
    padding: 15px;
    margin-bottom: 20px;
}

.totals-table {
    width: 100%;
    margin-bottom: 0;
}

.totals-table td {
    padding: 5px 10px;
    border: none;
}

.totals-table tr:last-child td {
    border-top: 2px solid #333;
    font-weight: bold;
    font-size: 1.1rem;
}

.gst-breakup-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

.gst-breakup-table th,
.gst-breakup-table td {
    border: 1px solid #dee2e6;
    padding: 8px;
    text-align: right;
}

.gst-breakup-table th {
    background-color: #f8f9fa;
    text-align: left;
}

.notes-section {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #ddd;
}

.notes-section ul {
    margin-bottom: 0;
    padding-left: 20px;
}

.signature-section {
    margin-top: 40px;
    text-align: right;
}

.signature-image {
    max-width: 150px;
    max-height: 80px;
}

.footer-branding {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid #ddd;
    text-align: center;
    color: #666;
    font-size: 0.9rem;
}

.qr-code-space {
    margin-top: 20px;
    padding: 10px;
    border: 1px dashed #ddd;
    text-align: center;
    min-height: 100px;
}

/* Print Styles */
@media print {
    body {
        background: white;
    }
    
    .navbar,
    .nav-tabs,
    .btn,
    .card-header,
    #generatePdfBtnPreview,
    #printBtnPreview {
        display: none !important;
    }
    
    .invoice-preview {
        box-shadow: none;
        padding: 0;
        margin: 0;
        max-width: 100%;
    }
    
    .invoice-header {
        page-break-after: avoid;
    }
    
    .products-table {
        page-break-inside: auto;
    }
    
    .products-table tbody tr {
        page-break-inside: avoid;
    }
    
    .totals-box {
        page-break-inside: avoid;
    }
    
    @page {
        size: A4;
        margin: 12mm;
    }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .invoice-preview {
        padding: 15px;
    }
    
    .customer-details {
        grid-template-columns: 1fr;
    }
    
    .invoice-meta {
        text-align: left;
        margin-top: 20px;
    }
    
    .products-table {
        font-size: 0.85rem;
    }
    
    .btn-group {
        display: flex;
        flex-direction: column;
    }
    
    .btn-group .btn {
        margin-bottom: 5px;
        width: 100%;
    }
}

/* Loading states */
.btn.loading {
    position: relative;
    color: transparent;
}

.btn.loading::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spinner 0.6s linear infinite;
}

@keyframes spinner {
    to { transform: rotate(360deg); }
}

/* Validation styles */
.is-invalid {
    border-color: #dc3545;
}

.invalid-feedback {
    display: block;
    width: 100%;
    margin-top: 0.25rem;
    font-size: 0.875rem;
    color: #dc3545;
}

.is-valid {
    border-color: #198754;
}
