/* style.css */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    background: linear-gradient(135deg, hsl(26, 85%, 98%) 0%, hsl(26, 85%, 95%) 50%, hsl(26, 85%, 92%) 100%);
    min-height: 100vh;
    line-height: 1.6;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

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

.header {
    background: linear-gradient(135deg, hsl(26, 85%, 50%), hsl(26, 85%, 45%));
    color: white;
    padding: 25px;
    border-radius: 12px;
    margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(230, 126, 34, 0.2);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 20px;
    text-align: left;
}

.logo {
    background: white;
    border-radius: 12px;
    width: 142px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    animation: float 3s ease-in-out infinite;
}

.logo-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 6px;
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-5px); }
}

.header-text h1 {
    font-size: 28px;
    margin-bottom: 8px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
}

.header-text p {
    font-size: 16px;
    opacity: 0.9;
    margin: 0;
}

.navigation {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 20px;
}

.nav-btn {
    padding: 12px 24px;
    border: 2px solid hsl(26, 85%, 50%);
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    background: white;
    color: hsl(26, 85%, 50%);
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-btn.active {
    background: hsl(26, 85%, 50%);
    color: white;
}

.nav-btn:hover {
    background: hsl(26, 85%, 50%);
    color: white;
}

.form-section {
    background: white;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px hsla(26, 85%, 50%, 0.1);
}

.form-title {
    color: hsl(26, 85%, 50%);
    margin-bottom: 15px;
    font-size: 18px;
    font-weight: bold;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
}

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

.form-group.full-width {
    grid-column: 1 / -1;
}

label {
    margin-bottom: 5px;
    font-weight: bold;
    color: #333;
}

input, select, textarea {
    padding: 10px;
    border: 2px solid #e5e7eb;
    border-radius: 4px;
    font-size: 14px;
    background: white;
    font-family: Arial, sans-serif;
}

textarea {
    resize: vertical;
    min-height: 80px;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: hsl(26, 85%, 50%);
    box-shadow: 0 0 0 3px hsla(26, 85%, 50%, 0.1);
}

.item-row {
    display: grid;
    grid-template-columns: 2fr 80px 100px 100px 100px 50px;
    gap: 10px;
    align-items: end;
    margin-bottom: 10px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 4px;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.3s;
}

.btn-primary {
    background-color: hsl(26, 85%, 50%);
    color: white;
}

.btn-primary:hover {
    background-color: hsl(26, 85%, 45%);
}

.btn-secondary {
    background-color: hsl(140, 40%, 45%);
    color: white;
}

.btn-secondary:hover {
    background-color: hsl(140, 40%, 40%);
}

.btn-danger {
    background-color: #ef4444;
    color: white;
    padding: 8px 12px;
}

.btn-danger:hover {
    background-color: #dc2626;
}

.btn-outline {
    background-color: white;
    color: hsl(26, 85%, 50%);
    border: 2px solid hsl(26, 85%, 50%);
}

.btn-outline:hover {
    background-color: hsl(26, 85%, 50%);
    color: white;
}

.btn:disabled {
    background-color: #ccc;
    cursor: not-allowed;
    opacity: 0.6;
}

.total-section {
    text-align: right;
    padding: 20px;
    background: linear-gradient(135deg, hsl(140, 40%, 95%), hsl(140, 40%, 92%));
    border-radius: 8px;
    margin: 20px 0;
    border: 1px solid hsl(140, 40%, 80%);
}

.total-amount {
    font-size: 24px;
    font-weight: bold;
    color: hsl(26, 85%, 50%);
}

.total-words {
    font-size: 14px;
    color: #666;
    margin-top: 5px;
}

/* Browser View Styles */
.browser-view {
    display: none;
}

.search-box {
    position: relative;
    margin-bottom: 20px;
}

.search-box input {
    width: 100%;
    padding-left: 45px;
}

.search-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #666;
}

.invoice-card {
    background: white;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 15px;
    box-shadow: 0 2px 8px hsla(26, 85%, 50%, 0.1);
    transition: all 0.3s;
    border: 1px solid #e5e7eb;
}

.invoice-card:hover {
    box-shadow: 0 4px 12px hsla(26, 85%, 50%, 0.2);
    transform: translateY(-2px);
}

.invoice-card-header {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    align-items: center;
}

.invoice-info {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 5px;
}

.invoice-info-label {
    font-weight: bold;
    color: hsl(26, 85%, 50%);
}

.invoice-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    align-items: center;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #666;
    background: white;
    border-radius: 8px;
    border: 2px dashed #e5e7eb;
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 15px;
    opacity: 0.5;
}

/* Invoice Print Styles */
.invoice-preview {
    background: white;
    margin-top: 30px;
    padding: 30px;
    border: 2px solid #333;
    border-radius: 8px;
    page-break-inside: avoid;
}

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

.invoice-info-section {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 4px;
}

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

.invoice-table th,
.invoice-table td {
    border: 1px solid #333;
    padding: 8px;
    text-align: left;
    word-wrap: break-word;
}

.invoice-table th {
    background-color: #f0f0f0;
    font-weight: bold;
}

.invoice-table .text-center {
    text-align: center;
}

.invoice-total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid #333;
    padding: 15px;
    margin-bottom: 20px;
    background: #f8f9fa;
}

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

.signature-line {
    width: 150px;
    height: 60px;
    border-bottom: 1px solid #333;
    margin: 0 0 10px auto;
}

.save-indicator {
    background: #10b981;
    color: white;
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 12px;
    display: none;
}

.save-indicator.show {
    display: inline-block;
}

.gst-field {
    transition: all 0.3s ease;
}

.custom-unit-container {
    display: flex;
    gap: 5px;
    position: relative;
}

.custom-unit-input {
    display: none;
    width: 100%;
}

.invoice-preview.pdf-export {
    border: none !important;
    padding: 40px !important;
    margin: 20px !important;
    box-shadow: none !important;
}

/* Additional fix for template display */
.modern-template {
    display: none;
}

.modern-template.active-print {
    display: block !important;
}

.classic-template.active-print {
    display: block !important;
}

.footer {
    background-color: #2c3e50;
    color: #ecf0f1;
    padding: 40px 0 20px;
    /*margin-top: 40px;*/
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
}

.footer-section h3 {
    color: #e67e22;
    margin-bottom: 15px;
    font-size: 18px;
}

.footer-section p, .footer-section li {
    line-height: 1.6;
    margin-bottom: 10px;
}

.footer-section ul {
    list-style: none;
    padding: 0;
}

.footer-section a {
    color: #ecf0f1;
    text-decoration: none;
    transition: color 0.3s;
}

.footer-section a:hover {
    color: #e67e22;
}

.footer-bottom {
    text-align: center;
    padding-top: 20px;
    margin-top: 20px;
    border-top: 1px solid #34495e;
}

/* SEO Content Styles */
.seo-content {
    max-width: 1200px;
    margin: 40px auto;
    padding: 0 20px;
}

.seo-content h2 {
    color: #e67e22;
    margin-bottom: 15px;
    font-size: 28px;
}

.seo-content h3 {
    color: #2c3e50;
    margin-top: 25px;
    margin-bottom: 10px;
    font-size: 22px;
}

.seo-content p {
    line-height: 1.6;
    margin-bottom: 15px;
    font-size: 16px;
}

.seo-content ul, .seo-content ol {
    margin-bottom: 15px;
    padding-left: 20px;
}

.seo-content li {
    margin-bottom: 8px;
    line-height: 1.5;
}

/* Template Selection Styles */
.template-selection {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

.template-option {
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
    width: 150px;
    background: white;
}

.template-option.active {
    border-color: hsl(26, 85%, 50%);
    background-color: hsl(26, 85%, 97%);
    box-shadow: 0 4px 8px hsla(26, 85%, 50%, 0.2);
}

.template-option:hover {
    border-color: hsl(26, 85%, 50%);
    transform: translateY(-2px);
}

.template-preview {
    height: 72px;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 10px;
    position: relative;
    overflow: hidden;
    background: white;
}

.classic-preview {
    background: linear-gradient(45deg, #f8f9fa 25%, transparent 25%), 
                linear-gradient(-45deg, #f8f9fa 25%, transparent 25%), 
                linear-gradient(45deg, transparent 75%, #f8f9fa 75%), 
                linear-gradient(-45deg, transparent 75%, #f8f9fa 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

.classic-preview::before {
    content: "";
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    height: 15px;
    background: #333;
    border-radius: 2px;
}

.classic-preview::after {
    content: "";
    position: absolute;
    top: 35px;
    left: 10px;
    right: 60px;
    height: 8px;
    background: #666;
    border-radius: 1px;
}

.modern-preview {
    background: white;
    background-image: 
        linear-gradient(90deg, transparent 79px, #abced4 79px, #abced4 81px, transparent 81px),
        linear-gradient(#eee .1em, transparent .1em);
    background-size: 100% 1.2em;
}

.modern-preview::before {
    content: "";
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    height: 25px;
    background: linear-gradient(135deg, hsl(26, 85%, 50%), hsl(26, 85%, 45%));
    border-radius: 4px;
}

.modern-preview::after {
    content: "";
    position: absolute;
    top: 45px;
    left: 10px;
    width: 40%;
    height: 4px;
    background: hsl(26, 85%, 50%);
    border-radius: 2px;
}

.template-name {
    font-weight: bold;
    margin-bottom: 5px;
    color: #333;
}

.template-description {
    font-size: 12px;
    color: #666;
}

/* Modern Template Styles */
.modern-template {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 30px;
    margin-top: 30px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.modern-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid hsl(26, 85%, 50%);
}

.modern-brand h1 {
    font-size: 28px;
    color: #2c3e50;
    margin-bottom: 5px;
    font-weight: 700;
}

.modern-subtitle {
    font-size: 14px;
    color: hsl(26, 85%, 50%);
    font-weight: 600;
    letter-spacing: 2px;
    text-transform: uppercase;
}

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

.invoice-number {
    font-size: 18px;
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 5px;
}

.invoice-date {
    color: #666;
    font-size: 14px;
}

.modern-address-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    margin-bottom: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
}

.modern-from strong,
.modern-to strong {
    display: block;
    margin-bottom: 10px;
    color: #2c3e50;
    font-size: 16px;
}

.modern-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 25px;
    table-layout: fixed;
}

.modern-table th {
    background: hsl(26, 85%, 50%);
    color: white;
    padding: 12px 15px;
    text-align: left;
    font-weight: 600;
    border: none;
}

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

.modern-table td {
    padding: 12px 15px;
    border-bottom: 1px solid #e0e0e0;
    word-wrap: break-word;
}

.modern-table tbody tr:hover {
    background: #f8f9fa;
}

.modern-table .total-row {
    background: #f8f9fa;
    font-weight: bold;
}

.modern-table .total-row td {
    border-bottom: none;
    border-top: 2px solid #2c3e50;
}

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

.modern-words-section {
    padding: 15px;
    background: #f8f9fa;
    border-radius: 6px;
    margin-bottom: 25px;
    font-style: italic;
}

.modern-footer {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
}

.modern-notes-terms {
    flex: 1;
    margin-right: 20px;
}

.modern-signature {
    text-align: center;
}

/* FAQ Section Styles */
.faq-section {
    background: #f8f9fa;
    padding: 60px 0;
    margin-top: 40px;
}

.faq-section h2 {
    text-align: center;
    color: #2c3e50;
    margin-bottom: 40px;
    font-size: 32px;
}

.faq-item {
    background: white;
    border-radius: 8px;
    margin-bottom: 15px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.faq-question {
    padding: 20px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    color: #2c3e50;
    transition: background-color 0.3s;
    font-size: 18px;
}

.faq-question:hover {
    background: #f8f9fa;
}

.faq-toggle {
    font-size: 20px;
    font-weight: bold;
    color: hsl(26, 85%, 50%);
    transition: transform 0.3s;
    min-width: 20px;
    text-align: center;
}

.faq-answer {
    padding: 0 20px;
    max-height: 0;
    overflow: hidden;
    transition: all 0.3s ease;
    background: white;
}

.faq-answer.active {
    padding: 0 20px 20px 20px;
    max-height: 500px;
}

.faq-item.active .faq-question {
    background: #f8f9fa;
}

/* Notes and Terms styling for print */
.notes-terms-section {
    page-break-inside: avoid;
}

/* PRINT STYLES - FIXED */
@media print {
    body {
        background: white !important;
        margin: 0 !important;
        padding: 0 !important;
        font-size: 12pt;
    }
    
    .container {
        max-width: none !important;
        padding: 0 !important;
        margin: 0 !important;
        width: 100% !important;
    }
    
    .header,
    .navigation,
    .form-section,
    .total-section,
    .btn,
    .no-print,
    .browser-view,
    .template-selection,
    .faq-section,
    .footer,
    .seo-content {
        display: none !important;
    }
    
    .invoice-preview {
        margin: 0 !important;
        padding: 10mm !important;
        border: none !important;
        border-radius: 0 !important;
        page-break-inside: avoid;
        box-shadow: none !important;
        width: 100% !important;
    }
    
    .invoice-preview * {
        print-color-adjust: exact !important;
        -webkit-print-color-adjust: exact !important;
    }

    .invoice-table th,
    .invoice-table td {
        padding: 4px 3px !important;
        font-size: 10pt !important;
    }

    .invoice-header {
        padding-bottom: 8px !important;
        margin-bottom: 10px !important;
    }

    .invoice-info-section {
        padding: 8px !important;
        margin-bottom: 10px !important;
        background: transparent !important;
    }

    .signature-section {
        margin-top: 20px !important;
    }
    
    /* Modern template specific print styles */
    .modern-template.active-print .modern-header {
        border-bottom: 2px solid hsl(26, 85%, 50%) !important;
        margin-bottom: 20px !important;
        padding-bottom: 15px !important;
    }
    
    .modern-template.active-print .modern-table {
        width: 100% !important;
    }
    
    .modern-template.active-print .modern-table th {
        background: hsl(26, 85%, 50%) !important;
        color: white !important;
    }
    
    .modern-template.active-print .modern-table th,
    .modern-template.active-print .modern-table td {
        padding: 8px 10px !important;
        font-size: 10pt !important;
        border-bottom: 1px solid #ddd !important;
    }
    
    .modern-template.active-print .modern-address-section {
        background: #f8f9fa !important;
    }
    
    /* Ensure proper page breaks */
    .invoice-preview.active-print {
        page-break-inside: avoid;
    }
    
    /* Hide elements that shouldn't print */
    .no-print,
    .header,
    .navigation,
    .form-section,
    .total-section,
    .btn,
    .browser-view,
    .template-selection,
    .faq-section,
    .footer,
    .seo-content,
    .invoice-preview:not(.active-print) {
        display: none !important;
        visibility: hidden !important;
        height: 0 !important;
        width: 0 !important;
        overflow: hidden !important;
    }
    
    /* Fix for empty rows in tables */
    .invoice-table tr td:empty::before {
        content: " ";
        white-space: pre;
    }
    
    /* Ensure text colors are preserved */
    .total-amount,
    .modern-brand h1,
    .invoice-number {
        color: #2c3e50 !important;
    }
    
    /* Improve print quality */
    .invoice-preview {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* Notes and Terms print styles */
    .notes-terms-section {
        border-top: 1px dashed #ccc !important;
    }
    
    #printNotes, #printTerms,
    #modernNotes, #modernTerms {
        color: #000 !important;
        font-size: 10pt !important;
    }
}

/* Responsive design improvements */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .header {
        padding: 15px;
    }
    
    .header-content {
        flex-direction: column;
        text-align: center;
    }
    
    .logo-container {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .logo {
        width: 70px;
        height: 70px;
        margin: 0 auto;
    }
    
    .header-text h1 {
        font-size: 22px;
    }
    
    .header-text p {
        font-size: 14px;
    }
    
    .navigation {
        flex-direction: column;
        gap: 10px;
    }
    
    .nav-btn {
        width: 100%;
        justify-content: center;
    }
    
    .item-row {
        grid-template-columns: 1fr;
        gap: 10px;
        padding: 15px;
    }
    
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .form-group.full-width {
        grid-column: 1;
    }
    
    .invoice-info-section {
        flex-direction: column;
        gap: 10px;
    }

    .invoice-card-header {
        grid-template-columns: 1fr;
        gap: 15px;
        text-align: center;
    }

    .invoice-actions {
        justify-content: center;
        flex-wrap: wrap;
    }

    .footer-content {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .footer-section {
        margin-bottom: 20px;
        text-align: center;
    }

    .template-selection {
        flex-direction: column;
        align-items: center;
    }
    
    .template-option {
        width: 100%;
        max-width: 200px;
    }
    
    .modern-header {
        flex-direction: column;
        text-align: center;
    }
    
    .modern-meta {
        text-align: center;
        margin-top: 15px;
    }
    
    .modern-address-section {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .modern-footer {
        flex-direction: column;
        gap: 20px;
        text-align: center;
    }
    
    .modern-notes-terms {
        margin-right: 0;
        margin-bottom: 20px;
    }
    
    .faq-section {
        padding: 40px 20px;
    }
    
    .faq-section h2 {
        font-size: 24px;
    }
    
    .faq-question {
        font-size: 16px;
        padding: 15px;
    }
    
    /* Action buttons on mobile */
    .no-print > .btn {
        width: 100%;
        margin-bottom: 10px;
    }
    
    /* Mobile print adjustments */
    @media print {
        .classic-template.active-print,
        .modern-template.active-print {
            padding: 5mm !important;
        }
        
        .classic-template.active-print .invoice-table th,
        .classic-template.active-print .invoice-table td,
        .modern-template.active-print .modern-table th,
        .modern-template.active-print .modern-table td {
            padding: 3px 2px !important;
            font-size: 9pt !important;
        }
        
        .invoice-preview {
            font-size: 10pt !important;
        }
    }
}

@media (max-width: 480px) {
    .header-text h1 {
        font-size: 20px;
    }
    
    .form-section {
        padding: 15px;
    }
    
    .invoice-preview {
        padding: 10px;
    }
    
    .modern-template {
        padding: 15px;
    }
    
    textarea {
        min-height: 60px;
    }
}