/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f4f4f4;
    padding: 20px;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
}

/* Header Styles */
.invoice-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #ff6b47;
}

.company-info .logo {
    display: flex;
    align-items: center;
    font-size: 24px;
    font-weight: bold;
    color: #ff6b47;
    margin-bottom: 5px;
}

.company-info .logo i {
    margin-right: 10px;
    font-size: 28px;
}

.tagline {
    font-size: 12px;
    color: #666;
    font-style: italic;
}

.invoice-details h1 {
    font-size: 28px;
    color: #333;
    margin-bottom: 5px;
}

.date {
    color: #666;
    font-size: 14px;
}

/* Bill To Section */
.bill-to-section {
    margin-bottom: 25px;
}

.bill-to-section h2 {
    font-size: 18px;
    color: #333;
}

.client-name {
    color: #ff6b47;
    font-weight: bold;
}

/* Amount Due */
.amount-due {
    background: linear-gradient(135deg, #ff6b47, #ff8566);
    color: white;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 30px;
    text-align: center;
}

.amount-due h2 {
    font-size: 24px;
    margin-bottom: 5px;
}

.amount {
    font-size: 32px;
    font-weight: bold;
}

.due-description {
    font-size: 14px;
    opacity: 0.9;
}

/* Table Styles */
.services-table, .payment-section {
    margin-bottom: 30px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    position: relative;
}

/* Scroll indicator for tables */
.services-table::after, .payment-section::after {
    content: "← Scroll to see more →";
    position: absolute;
    bottom: -25px;
    right: 0;
    font-size: 11px;
    color: #666;
    background: rgba(255,255,255,0.9);
    padding: 2px 8px;
    border-radius: 4px;
    display: none;
}

@media (max-width: 768px) {
    .services-table::after, .payment-section::after {
        display: block;
    }
}

table {
    width: 100%;
    min-width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
    background: white;
    table-layout: fixed;
}

th, td {
    padding: 15px 8px;
    text-align: left;
    border-bottom: 1px solid #ddd;
    word-wrap: break-word;
    vertical-align: top;
    overflow: hidden;
}

th {
    background-color: #f8f9fa;
    font-weight: bold;
    color: #333;
    border-bottom: 2px solid #ff6b47;
    position: sticky;
    top: 0;
    z-index: 10;
}

tbody tr:hover {
    background-color: #f8f9fa;
}

/* Services table specific columns - optimized for visibility */
.services-table th:nth-child(1),
.services-table td:nth-child(1) {
    width: 18%;
    min-width: 80px;
    text-align: center;
}

.services-table th:nth-child(2),
.services-table td:nth-child(2) {
    width: 52%;
    min-width: 200px;
}

.services-table th:nth-child(3),
.services-table td:nth-child(3) {
    width: 30%;
    min-width: 100px;
    text-align: right;
    font-weight: 600;
    white-space: nowrap;
}

/* Payment table specific columns */
.payment-table th:nth-child(1),
.payment-table td:nth-child(1) {
    width: 50%;
    min-width: 200px;
}

.payment-table th:nth-child(2),
.payment-table td:nth-child(2) {
    width: 25%;
    min-width: 100px;
    text-align: right;
}

.payment-table th:nth-child(3),
.payment-table td:nth-child(3) {
    width: 25%;
    min-width: 100px;
    text-align: center;
}

.payment-terms h3 {
    color: #333;
    margin-bottom: 15px;
    font-size: 18px;
}

/* Bank Details */
.bank-details {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 30px;
    border-left: 4px solid #ff6b47;
}

.bank-details h3 {
    color: #333;
    margin-bottom: 10px;
}

/* Footer Message */
.footer-message {
    text-align: center;
    margin-bottom: 30px;
}

.signature {
    margin-top: 20px;
}

.signature-line {
    width: 200px;
    height: 1px;
    background: #333;
    margin: 20px auto;
}

/* Contact Info */
.contact-info {
    display: flex;
    justify-content: space-between;
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 30px;
    font-size: 14px;
}

.contact-info a {
    color: #ff6b47;
    text-decoration: none;
}

.contact-info a:hover {
    text-decoration: underline;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 30px;
}

.print-btn, .download-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.print-btn {
    background: #ff6b47;
    color: white;
}

.print-btn:hover {
    background: #e55a42;
    transform: translateY(-2px);
}

.download-btn {
    background: #28a745;
    color: white;
}

.download-btn:hover {
    background: #218838;
    transform: translateY(-2px);
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .container {
        padding: 20px;
    }
    
    .invoice-header {
        flex-direction: column;
        gap: 20px;
        text-align: center;
    }
    
    .company-info .logo {
        justify-content: center;
        font-size: 20px;
    }
    
    .amount-due h2 {
        font-size: 20px;
    }
    
    .amount {
        font-size: 28px;
    }
    
    .contact-info {
        flex-direction: column;
        gap: 15px;
    }
    
    .action-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .print-btn, .download-btn {
        width: 100%;
        max-width: 250px;
    }
    
    /* Enhanced table responsive */
    .services-table, .payment-section {
        margin-bottom: 20px;
        border-radius: 6px;
        box-shadow: 0 2px 12px rgba(0,0,0,0.15);
    }
    
    table {
        min-width: 100%;
        font-size: 12px;
        table-layout: fixed;
    }
    
    th, td {
        padding: 12px 6px;
        font-size: 12px;
    }
    
    th {
        background-color: #f8f9fa !important;
        z-index: 15;
        font-size: 11px;
        font-weight: 600;
    }
    
    /* Services table mobile adjustments - ensure price column visible */
    .services-table th:nth-child(1),
    .services-table td:nth-child(1) {
        width: 18%;
        min-width: 60px;
        padding: 8px 4px;
        text-align: center;
        font-size: 11px;
    }
    
    .services-table th:nth-child(2),
    .services-table td:nth-child(2) {
        width: 42%;
        min-width: 120px;
        white-space: normal;
        word-wrap: break-word;
        line-height: 1.3;
        padding: 8px 4px;
    }
    
    .services-table th:nth-child(3),
    .services-table td:nth-child(3) {
        width: 40%;
        min-width: 80px;
        text-align: right;
        font-weight: 600;
        white-space: nowrap;
        padding: 8px 4px;
    }
    
    /* Payment table mobile adjustments */
    .payment-table th:nth-child(1),
    .payment-table td:nth-child(1) {
        min-width: 180px;
        width: 55%;
        white-space: normal;
        word-wrap: break-word;
        line-height: 1.3;
    }
    
    .payment-table th:nth-child(2),
    .payment-table td:nth-child(2) {
        min-width: 80px;
        width: 22%;
        text-align: right;
        font-weight: 600;
    }
    
    .payment-table th:nth-child(3),
    .payment-table td:nth-child(3) {
        min-width: 85px;
        width: 23%;
        text-align: center;
        font-size: 11px;
    }
}

/* Medium screens (tablets) */
@media (max-width: 640px) and (min-width: 481px) {
    .services-table, .payment-section {
        border-radius: 6px;
        box-shadow: 0 2px 10px rgba(0,0,0,0.12);
    }
    
    table {
        min-width: 520px;
        font-size: 11px;
    }
    
    th, td {
        padding: 12px 8px;
        font-size: 11px;
    }
    
    th {
        font-size: 10px;
        font-weight: 600;
    }
    
    /* Services table tablet */
    .services-table th:nth-child(2),
    .services-table td:nth-child(2) {
        min-width: 240px;
        line-height: 1.3;
    }
    
    /* Payment table tablet */
    .payment-table th:nth-child(1),
    .payment-table td:nth-child(1) {
        min-width: 170px;
        line-height: 1.3;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 15px;
    }
    
    .company-info .logo {
        font-size: 18px;
    }
    
    .company-info .logo i {
        font-size: 20px;
    }
    
    .invoice-details h1 {
        font-size: 24px;
    }
    
    .amount-due {
        padding: 15px;
    }
    
    .amount-due h2 {
        font-size: 18px;
    }
    
    .amount {
        font-size: 24px;
    }
    
    th, td {
        padding: 10px 6px;
        font-size: 10px;
    }
    
    /* Optimized tables for small screens - no horizontal scroll */
    table {
        min-width: 100%;
        font-size: 10px;
        table-layout: fixed;
    }
    
    /* Services table small screen - ensure all columns fit */
    .services-table th:nth-child(1),
    .services-table td:nth-child(1) {
        width: 16%;
        min-width: 50px;
        padding: 6px 2px;
        font-size: 9px;
        text-align: center;
    }
    
    .services-table th:nth-child(2),
    .services-table td:nth-child(2) {
        width: 40%;
        min-width: 90px;
        line-height: 1.2;
        padding: 6px 3px;
        font-size: 9px;
    }
    
    .services-table th:nth-child(3),
    .services-table td:nth-child(3) {
        width: 44%;
        min-width: 70px;
        font-size: 9px;
        font-weight: 700;
        text-align: right;
        white-space: nowrap;
        padding: 6px 2px;
    }
    
    /* Payment table small screen */
    .payment-table th:nth-child(1),
    .payment-table td:nth-child(1) {
        min-width: 160px;
        width: 60%;
        line-height: 1.2;
        padding: 8px 4px;
    }
    
    .payment-table th:nth-child(2),
    .payment-table td:nth-child(2) {
        min-width: 65px;
        width: 20%;
        font-size: 9px;
        font-weight: 700;
    }
    
    .payment-table th:nth-child(3),
    .payment-table td:nth-child(3) {
        min-width: 70px;
        width: 20%;
        font-size: 8px;
    }
    
    .bank-details, .contact-info {
        padding: 15px;
    }
}

/* Extra small mobile (320px and below) */
@media (max-width: 320px) {
    .container {
        padding: 10px;
    }
    
    /* Stack table approach for tiny screens */
    .services-table table,
    .payment-table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
    
    .services-table thead,
    .payment-table thead {
        display: block;
    }
    
    .services-table tbody,
    .payment-table tbody {
        display: block;
    }
    
    .services-table tr,
    .payment-table tr {
        display: block;
        border: 1px solid #ddd;
        margin-bottom: 10px;
        padding: 10px;
        border-radius: 5px;
    }
    
    .services-table th,
    .services-table td,
    .payment-table th,
    .payment-table td {
        display: block;
        text-align: left;
        padding: 3px 0;
        border: none;
        white-space: normal;
    }
    
    .services-table th::before,
    .payment-table th::before {
        content: attr(data-label) ": ";
        font-weight: bold;
    }
    
    /* Hide table headers on tiny screens */
    .services-table thead,
    .payment-table thead {
        display: none;
    }
}

/* Print Styles */
@media print {
    * {
        -webkit-print-color-adjust: exact !important;
        color-adjust: exact !important;
    }
    
    @page {
        margin: 0.5in;
        size: A4 portrait;
    }
    
    body {
        background: white;
        padding: 0;
        font-size: 11px !important;
        line-height: 1.3 !important;
    }
    
    .container {
        box-shadow: none;
        border-radius: 0;
        padding: 10px !important;
        max-width: none;
        margin: 0;
    }
    
    .no-print {
        display: none !important;
    }
    
    .action-buttons {
        display: none !important;
    }
    
    /* Header compact */
    .invoice-header {
        border-bottom: 2px solid #000;
        margin-bottom: 15px !important;
        padding-bottom: 10px !important;
    }
    
    .company-info .logo {
        color: #000 !important;
        font-size: 18px !important;
    }
    
    .company-info .logo i {
        font-size: 20px !important;
    }
    
    .tagline {
        font-size: 10px !important;
    }
    
    .invoice-details h1 {
        font-size: 20px !important;
        margin-bottom: 3px !important;
    }
    
    .date {
        font-size: 11px !important;
    }
    
    /* Bill to section */
    .bill-to-section {
        margin-bottom: 15px !important;
    }
    
    .bill-to-section h2 {
        font-size: 14px !important;
    }
    
    .client-name {
        color: #000 !important;
    }
    
    /* Amount due compact */
    .amount-due {
        background: #f0f0f0 !important;
        color: #000 !important;
        border: 1px solid #000;
        padding: 10px !important;
        margin-bottom: 15px !important;
    }
    
    .amount-due h2 {
        font-size: 16px !important;
        margin-bottom: 3px !important;
    }
    
    .amount {
        font-size: 20px !important;
    }
    
    .due-description {
        font-size: 10px !important;
    }
    
    /* Tables compact */
    .services-table, .payment-section {
        margin-bottom: 15px !important;
    }
    
    table {
        margin-bottom: 10px !important;
        page-break-inside: avoid;
    }
    
    th, td {
        padding: 5px !important;
        font-size: 10px !important;
        border-bottom: 1px solid #000 !important;
    }
    
    th {
        background-color: #f0f0f0 !important;
        border-bottom: 2px solid #000 !important;
        font-size: 10px !important;
    }
    
    .payment-terms h3 {
        font-size: 12px !important;
        margin-bottom: 8px !important;
    }
    
    /* Bank details compact */
    .bank-details {
        background: #f8f8f8 !important;
        border-left: 4px solid #000;
        padding: 10px !important;
        margin-bottom: 15px !important;
        page-break-inside: avoid;
    }
    
    .bank-details h3 {
        font-size: 12px !important;
        margin-bottom: 5px !important;
    }
    
    .bank-details p {
        font-size: 10px !important;
        line-height: 1.2 !important;
    }
    
    /* Footer compact */
    .footer-message {
        text-align: center;
        margin-bottom: 15px !important;
        font-size: 10px !important;
    }
    
    .signature {
        margin-top: 10px !important;
    }
    
    .signature-line {
        width: 150px !important;
        margin: 10px auto !important;
    }
    
    .signature p {
        font-size: 10px !important;
        line-height: 1.2 !important;
    }
    
    /* Contact info compact */
    .contact-info {
        background: #f8f8f8 !important;
        padding: 10px !important;
        margin-bottom: 0 !important;
        font-size: 9px !important;
        page-break-inside: avoid;
    }
    
    .contact-info p {
        line-height: 1.2 !important;
        margin-bottom: 5px !important;
    }
    
    /* Prevent page breaks */
    .payment-section {
        page-break-inside: avoid;
    }
    
    .bank-details {
        page-break-inside: avoid;
    }
    
    /* Links */
    a {
        color: #000 !important;
        text-decoration: underline !important;
    }
    
    /* Force single page */
    html, body {
        height: auto !important;
        overflow: visible !important;
    }
}

/* Desktop PDF Generation Styles */
.pdf-desktop-generation {
    font-size: 12px !important;
    line-height: 1.4 !important;
}

.pdf-desktop-generation .container {
    padding: 20px !important;
    margin: 0 !important;
    max-width: 900px !important;
    background: white !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    box-sizing: border-box;
    overflow: visible !important;
}

.pdf-desktop-generation .invoice-header {
    margin-bottom: 20px !important;
    padding-bottom: 15px !important;
    border-bottom: 2px solid #ff6b47 !important;
}

.pdf-desktop-generation .company-info .logo {
    font-size: 24px !important;
}

.pdf-desktop-generation .company-info .logo i {
    font-size: 28px !important;
}

.pdf-desktop-generation .tagline {
    font-size: 12px !important;
}

.pdf-desktop-generation .invoice-details h1 {
    font-size: 28px !important;
    margin-bottom: 5px !important;
}

.pdf-desktop-generation .date {
    font-size: 14px !important;
}

.pdf-desktop-generation .bill-to-section {
    margin-bottom: 20px !important;
}

.pdf-desktop-generation .bill-to-section h2 {
    font-size: 18px !important;
}

.pdf-desktop-generation .amount-due {
    padding: 20px !important;
    margin-bottom: 25px !important;
}

.pdf-desktop-generation .amount-due h2 {
    font-size: 24px !important;
    margin-bottom: 5px !important;
}

.pdf-desktop-generation .amount {
    font-size: 32px !important;
}

.pdf-desktop-generation .due-description {
    font-size: 14px !important;
}

.pdf-desktop-generation .services-table,
.pdf-desktop-generation .payment-section {
    margin-bottom: 25px !important;
}

.pdf-desktop-generation table {
    margin-bottom: 15px !important;
}

.pdf-desktop-generation th,
.pdf-desktop-generation td {
    padding: 10px !important;
    font-size: 12px !important;
}

.pdf-desktop-generation .payment-terms h3 {
    font-size: 18px !important;
    margin-bottom: 15px !important;
}

.pdf-desktop-generation .bank-details {
    padding: 20px !important;
    margin-bottom: 25px !important;
    background: #f8f9fa !important;
    border-left: 4px solid #ff6b47 !important;
    border-radius: 8px !important;
}

.pdf-desktop-generation .bank-details h3 {
    font-size: 16px !important;
    margin-bottom: 10px !important;
}

.pdf-desktop-generation .bank-details p {
    font-size: 12px !important;
    line-height: 1.4 !important;
}

.pdf-desktop-generation .footer-message {
    margin-bottom: 25px !important;
    font-size: 12px !important;
}

.pdf-desktop-generation .signature {
    margin-top: 15px !important;
}

.pdf-desktop-generation .signature-line {
    width: 200px !important;
    margin: 15px auto !important;
}

.pdf-desktop-generation .signature p {
    font-size: 12px !important;
    line-height: 1.4 !important;
}

.pdf-desktop-generation .contact-info {
    padding: 20px !important;
    margin-bottom: 0 !important;
    font-size: 12px !important;
    background: #f8f9fa !important;
    border-radius: 8px !important;
}

.pdf-desktop-generation .contact-info p {
    line-height: 1.4 !important;
    margin-bottom: 8px !important;
} 