/* Custom Font Declaration - RoxboroughCF Font Files */
@font-face {
    font-family: 'RoxboroughCF';
    src: url('../fonts/fonnts.com-roxboroughcf-regular.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'RoxboroughCF';
    src: url('../fonts/fonnts.com-roxboroughcf-bold.otf') format('opentype');
    font-weight: bold;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'RoxboroughCF';
    src: url('../fonts/fonnts.com-roxboroughcf-medium.otf') format('opentype');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'RoxboroughCF';
    src: url('../fonts/fonnts.com-roxboroughcf-light.otf') format('opentype');
    font-weight: 300;
    font-style: normal;
    font-display: swap;
}

/* Color Theme Variables */
:root {
    --primary-orange: #f27232;
    --secondary-purple: #d2bce7;
    --accent-green: #b2ef43;
    --dark-gray: #121212;
    --white: #ffffff;
    --light-gray: #f8f9fa;
    --text-dark: #121212;
    --text-light: #666666;
}

@media (max-width: 600px) {
    .invoice-preview .totals {
        max-width: 100%;
        width: 100%;
        padding: 18px 8px 10px 8px;
        border-radius: 10px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    }
    .invoice-preview .totals td {
        font-size: 0.98rem;
        padding: 7px 0;
    }
    .invoice-preview .totals .total-row td {
        font-size: 1.08rem;
        padding-top: 10px;
    }
}

/* Invoice Generator Styles */
.invoice-generator {
    background: linear-gradient(135deg, rgba(210, 188, 231, 0.1) 0%, rgba(178, 239, 67, 0.05) 100%);
    padding: 100px 0;
    margin-top: 80px;
    min-height: 100vh;
}

.invoice-header {
    text-align: center;
    margin-bottom: 80px;
}

.invoice-header h2 {
    font-size: 48px;
    font-weight: 300;
    margin-bottom: 32px;
    letter-spacing: 2px;
    color: var(--text-dark);
}

.invoice-header p {
    font-size: 18px;
    color: var(--text-light);
    font-weight: 300;
}

.invoice-content {
    display: flex;
    gap: 60px;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

.invoice-form-wrapper {
    flex: 1;
    background: var(--white);
    padding: 60px;
    box-shadow: 0 4px 30px rgba(242, 114, 50, 0.1);
    border-radius: 8px;
}

.invoice-form .form-section {
    margin-bottom: 60px;
    padding-bottom: 40px;
    border-bottom: 1px solid rgba(210, 188, 231, 0.3);
}

.invoice-form .form-section:last-child {
    border-bottom: none;
}

.invoice-form .form-section h3 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 24px;
    color: var(--primary-orange);
    letter-spacing: 1px;
    text-transform: uppercase;
}

.invoice-form .form-row {
    display: flex;
    gap: 30px;
    margin-bottom: 0;
}

.invoice-form .form-group {
    margin-bottom: 40px;
    position: relative;
    flex: 1;
}

.invoice-form .form-group input,
.invoice-form .form-group textarea {
    width: 100%;
    padding: 15px 0;
    border: none;
    border-bottom: 2px solid var(--secondary-purple);
    background: transparent;
    font-size: 16px;
    font-family: inherit;
    transition: all 0.3s ease;
    color: var(--text-dark);
}

.invoice-form .form-group input:focus,
.invoice-form .form-group textarea:focus {
    outline: none;
    padding-left: 20px;
    border-bottom-color: var(--primary-orange);
}

.invoice-form .form-group label {
    position: absolute;
    left: 0;
    top: 15px;
    font-size: 14px;
    letter-spacing: 1px;
    text-transform: uppercase;
    transition: all 0.3s ease;
    pointer-events: none;
    color: var(--text-light);
}

.invoice-form .form-group input:focus + label,
.invoice-form .form-group input:not(:placeholder-shown) + label,
.invoice-form .form-group input[readonly] + label,
.invoice-form .form-group textarea:focus + label,
.invoice-form .form-group textarea:not(:placeholder-shown) + label {
    top: -20px;
    font-size: 11px;
    font-weight: 500;
    color: var(--primary-orange);
}

/* Items Container */
.items-container {
    background: transparent;
    padding: 0;
    margin-top: 20px;
}

.items-header {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr 60px;
    gap: 20px;
    padding: 15px 0;
    font-weight: 600;
    font-size: 12px;
    letter-spacing: 1px;
    text-transform: uppercase;
    border-bottom: 2px solid var(--accent-green);
    margin-bottom: 20px;
    color: var(--text-dark);
}

.item-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr 60px;
    gap: 20px;
    margin-bottom: 20px;
    align-items: end;
}

.item-input {
    margin-bottom: 0 !important;
}

.item-total {
    margin-bottom: 0 !important;
}

.item-total input {
    border-bottom: 2px solid #000 !important;
    background: transparent !important;
    cursor: not-allowed;
    text-align: left;
    font-weight: 700 !important;
    color: #000 !important;
}

.item-total input:focus {
    padding-left: 0 !important;
    border-bottom: 2px solid #000 !important;
}

.item-total label {
    color: #000 !important;
}

.remove-item {
    background: var(--text-light);
    color: var(--white);
    border: none;
    width: 40px;
    height: 40px;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    border-radius: 4px;
}

.remove-item:hover {
    background: var(--primary-orange);
}

.add-item-btn {
    background: var(--accent-green);
    color: var(--dark-gray);
    border: 2px solid var(--accent-green);
    padding: 15px 30px;
    cursor: pointer;
    margin-top: 20px;
    font-size: 12px;
    letter-spacing: 2px;
    text-transform: uppercase;
    transition: all 0.3s ease;
    position: relative;
    font-weight: 600;
    border-radius: 4px;
}

.add-item-btn::before {
    content: '';
    position: absolute;
    bottom: -8px;
    left: -8px;
    width: 30px;
    height: 30px;
    background: var(--secondary-purple);
    z-index: -1;
    border-radius: 4px;
}

.add-item-btn:hover {
    background: transparent;
    color: var(--accent-green);
    transform: translate(-4px, -4px);
}

/* Totals Section */
.totals-wrapper {
    flex: 1;
    max-width: none;
    margin-left: 0;
    background: #f9f9f9;
    padding: 30px;
}

@media (max-width: 600px) {
    .totals-wrapper {
        padding: 0;
        background: transparent;
    }
}

/* Payment Information Section */
.payment-info-wrapper {
    flex: 1;
    margin-right: 30px;
}

.payment-info-wrapper h3 {
    margin-bottom: 30px;
    font-size: 24px;
    font-weight: 500;
    color: #333;
}

.total-input {
    margin-bottom: 30px !important;
}

.final-total input {
    font-weight: 700;
    font-size: 18px;
}

.final-total {
    border-top: none;
    padding-top: 5px;
}

.final-total label {
    font-weight: 700;
}

/* Form Actions */
.form-actions {
    display: flex;
    gap: 30px;
    justify-content: center;
    margin-top: 50px;
}

@media (max-width: 600px) {
    .form-actions {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }
    .form-actions .submit-btn {
        width: 100%;
        padding-left: 0;
        padding-right: 0;
        font-size: 14px;
    }
}

.submit-btn {
    padding: 18px 60px;
    background: #000;
    color: #fff;
    border: 2px solid #000;
    font-size: 12px;
    letter-spacing: 2px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    position: relative;
}

.submit-btn::before {
    content: '';
    position: absolute;
    bottom: -8px;
    left: -8px;
    width: 30px;
    height: 30px;
    border-bottom: 2px solid var(--secondary-purple);
    border-left: 2px solid var(--secondary-purple);
}

.submit-btn:hover {
    background: transparent;
    color: var(--primary-orange);
    transform: translate(3px, 3px);
}

.generate-btn {
    background: var(--primary-orange) !important;
    color: var(--white) !important;
    border: 2px solid var(--primary-orange) !important;
    font-weight: 600;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.generate-btn::before {
    background: var(--accent-green) !important;
    border-radius: 4px;
}

.generate-btn:hover {
    background: transparent !important;
    color: var(--primary-orange) !important;
    transform: translate(-4px, -4px);
}

/* Invoice Preview - FIXED DESIGN TO MATCH YOUR TEMPLATE */
.invoice-preview {
    flex: 1;
    background: var(--white);
    box-shadow: 0 4px 30px rgba(242, 114, 50, 0.1);
    overflow: hidden;
    border-radius: 8px;
}

.invoice-document {
  max-width: 800px;
  margin: 0 auto;
  background: var(--light-gray);
  padding: 40px;
  font-family: 'Arial', sans-serif;
  color: var(--text-dark);
  min-height: auto;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}/* Invoice Header to match your template */
.invoice-header-doc {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 60px;
    border-bottom: none;
    margin-top: 45px;
    flex-shrink: 0;
}

.logo {
    font-size: 2.5rem;
    font-weight: bold;
    color: #000;
    letter-spacing: 3px;
    text-transform: uppercase;
    font-family: 'RoxboroughCF', 'Times New Roman', 'Georgia', serif !important;
}

.invoice-title {
    font-size: 2.5rem;
    font-weight: bold;
    color: #000;
    letter-spacing: 3px;
    text-transform: uppercase;
    font-family: 'RoxboroughCF', 'Times New Roman', 'Georgia', serif !important;
}

/* Additional selectors to ensure font applies */
#preview_company_name {
    font-family: 'RoxboroughCF', 'Times New Roman', 'Georgia', serif !important;
    font-weight: bold !important;
}

.invoice-document .logo {
    font-family: 'RoxboroughCF', 'Times New Roman', 'Georgia', serif !important;
    font-weight: bold !important;
}

.invoice-document .invoice-title {
    font-family: 'RoxboroughCF', 'Times New Roman', 'Georgia', serif !important;
    font-weight: bold !important;
}

.invoice-info-section {
    display: flex;
    justify-content: space-between;
    margin-bottom: 50px;
    align-items: flex-start;
    flex-shrink: 0;
}

.bill-to {
    flex: 1;
}

.bill-to h4 {
    font-size: 1rem;
    font-weight: bold;
    margin-bottom: 15px;
    color: #000;
    text-transform: uppercase;
}

.bill-to p {
    margin: 5px 0;
    color: #000;
    line-height: 1.4;
    font-size: 1rem;
}

.invoice-details {
    text-align: right;
    flex: 1;
}

.invoice-details p {
    margin: 5px 0;
    color: #000;
    font-size: 1rem;
}

/* Items Table */
.items-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 30px;
    background: #F5F5F5;
    flex-shrink: 0;
}

.items-table th {
    padding: 15px 10px;
    text-align: left;
    font-weight: bold;
    font-size: 1rem;
    color: #000;
    border-bottom: 2px solid #000;
    background: #F5F5F5;
}

.items-table th:nth-child(2),
.items-table th:nth-child(3),
.items-table th:nth-child(4) {
    text-align: right;
}

.items-table td {
    padding: 15px 10px;
    border-bottom: 1px solid #ddd;
    font-size: 1rem;
    color: #000;
    background: #F5F5F5;
}

.items-table td:nth-child(2),
.items-table td:nth-child(3),
.items-table td:nth-child(4) {
    text-align: right;
}

/* Totals Section to match your template */
.invoice-preview .totals {
    margin: 30px 0;
    width: 100%;
    max-width: 350px;
    margin-left: 395px;
    background: #F5F5F5;
    border-radius: 0;
    box-shadow: none;
    padding: 25px;
    border: 1px solid #F5F5F5;
    flex-shrink: 0;
    font-family: 'Arial', sans-serif;
}

.invoice-preview .totals table {
    width: 100%;
    border-collapse: collapse;
    background: #F5F5F5;
}

/* Responsive design for totals margin - maintain mobile compatibility */
@media (max-width: 1200px) {
    .invoice-preview .totals {
        margin-left: auto;
    }
}

@media (max-width: 768px) {
    .invoice-preview .totals {
        margin-left: 0;
        max-width: 100%;
    }
}

/* Desktop and large screens: use the fixed margin */
@media (min-width: 1201px) {
    .invoice-preview .totals {
        margin-left: 395px;
    }
}

.invoice-preview .totals tr {
    background: #F5F5F5;
}

.invoice-preview .totals td {
    font-size: 1rem;
    padding: 8px 0;
    color: #000;
    border: none;
    background: #F5F5F5;
    font-family: 'Arial', sans-serif;
    line-height: 1.4;
}

.invoice-preview .totals td:first-child {
    text-align: left;
    font-weight: normal;
}

.invoice-preview .totals td:last-child {
    text-align: right;
    font-weight: bold;
}

.invoice-preview .totals .total-row {
    background: #F5F5F5;
}

.invoice-preview .totals .total-row td {
    font-weight: bold;
    font-size: 1.2rem;
    color: #000;
    border-top: 2px solid #000;
    padding-top: 15px;
    margin-top: 10px;
    background: #F5F5F5;
    font-family: 'Arial', sans-serif;
}

.invoice-preview .totals .total-row td:first-child {
    font-weight: bold;
}

.invoice-preview .totals .total-row td:last-child {
    font-weight: bold;
    text-align: right;
}

.thank-you {
    font-size: 1.5rem;
    margin: 40px 0;
    color: #000;
    text-align: center;
    flex-shrink: 0;
}

/* FIXED - Payment Info Section */
.payment-info {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-top: 40px;
    flex-shrink: 0;
}

.payment-details {
    flex: 1;
}

.payment-details h4 {
    font-size: 1rem;
    font-weight: bold;
    margin-bottom: 15px;
    color: #000;
    text-transform: uppercase;
}

.payment-details p {
    margin: 5px 0;
    color: #000;
    font-size: 1rem;
    line-height: 1.4;
}

.company-info {
    text-align: right;
    flex: 1;
}

.company-name {
    margin-top: 75px;
    font-size: 1.8rem;
    font-weight: bold;
    color: #000;
    font-family: 'RoxboroughCF', 'Times New Roman', 'Georgia', serif !important;
    /* margin-bottom: 5px; */
}

.company-address {
    color: #000;
    font-size: 1rem;
}

.preview-actions {
    padding: 30px;
    display: flex;
    gap: 20px;
    justify-content: center;
    background: white;
}

.preview-actions .submit-btn {
    flex: 1;
    max-width: 200px;
}

/* Flexible spacer for consistent layout */
.invoice-document::after {
    content: '';
    flex: 1;
    min-height: 20px;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .invoice-content {
        flex-direction: column;
        gap: 40px;
    }
    
    .invoice-preview {
        order: -1;
    }
    
    .items-header {
        display: none;
    }
}

@media (max-width: 768px) {
    .invoice-header h2 {
        font-size: 36px;
    }
    
    .invoice-form-wrapper {
        padding: 40px 30px;
    }
    
    .invoice-document {
        padding: 30px 20px;
        margin: 0;
        max-width: 100%;
    }
    
    .invoice-header-doc {
        flex-direction: column;
        gap: 20px;
        text-align: center;
        align-items: center;
        margin-bottom: 40px;
        margin-top: 20px;
    }
    
    .invoice-info-section {
        flex-direction: column;
        gap: 25px;
        text-align: left;
        margin-bottom: 30px;
    }
    
    .logo,
    .invoice-title {
        font-size: 1.8rem;
        letter-spacing: 2px;
    }
    
    .invoice-details {
        text-align: left;
    }
    
    .bill-to h4 {
        font-size: 0.9rem;
        margin-bottom: 10px;
    }
    
    .bill-to p,
    .invoice-details p {
        font-size: 0.9rem;
        line-height: 1.3;
        margin: 3px 0;
    }
    
    .items-table {
        font-size: 0.85rem;
        margin-bottom: 20px;
    }
    
    .items-table th,
    .items-table td {
        padding: 10px 8px;
        font-size: 0.85rem;
    }
    
    .items-table th:first-child,
    .items-table td:first-child {
        max-width: 120px;
        word-wrap: break-word;
    }
    
    .payment-info {
        flex-direction: column;
        gap: 25px;
        margin-top: 20px;
    }
    
    .payment-details h4 {
        font-size: 0.9rem;
        margin-bottom: 8px;
    }
    
    .payment-details p {
        font-size: 0.85rem;
        line-height: 1.3;
        margin: 2px 0;
    }
    
    .company-info {
        text-align: left;
    }
    
    .company-name {
        font-size: 1.1rem;
        margin-bottom: 5px;
    }
    
    .company-address {
        font-size: 0.85rem;
        line-height: 1.3;
    }
    
    .invoice-preview .totals {
        margin: 20px 0 15px auto;
        max-width: 100%;
        width: 100%;
    }
    
    .invoice-preview .totals td {
        font-size: 0.9rem;
        padding: 8px 5px;
    }
    
    .invoice-preview .totals .total-row td {
        font-size: 1rem;
        padding-top: 12px;
    }
    
    .invoice-preview {
        box-shadow: 0 2px 15px rgba(0,0,0,0.1);
        margin: 0;
        border-radius: 8px;
        overflow: hidden;
    }
    
    .invoice-form .form-row {
        flex-direction: column;
        gap: 0;
    }
    
    .items-header {
        display: none;
    }
    
    .item-row {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .payment-info {
        flex-direction: column;
        gap: 30px;
    }
    
    .company-info {
        text-align: left;
    }
    
    .preview-actions {
        flex-direction: column;
        padding: 20px;
        gap: 15px;
    }
    
    .preview-actions .submit-btn {
        max-width: none;
        width: 100%;
    }
}

@media (max-width: 480px) {
    .invoice-generator {
        padding: 50px 0;
    }
    
    .invoice-content {
        padding: 0 15px;
    }
    
    .invoice-form-wrapper {
        padding: 30px 20px;
    }
    
    .invoice-document {
        padding: 20px 15px;
        margin: 0;
    }
    
    .invoice-header-doc {
        margin-bottom: 30px;
        margin-top: 15px;
        gap: 15px;
    }
    
    .logo,
    .invoice-title {
        font-size: 1.5rem;
        letter-spacing: 1px;
    }
    
    .invoice-info-section {
        gap: 20px;
        margin-bottom: 25px;
    }
    
    .bill-to h4 {
        font-size: 0.85rem;
    }
    
    .bill-to p,
    .invoice-details p {
        font-size: 0.8rem;
    }
    
    .items-table {
        font-size: 0.75rem;
        margin-bottom: 15px;
    }
    
    .items-table th,
    .items-table td {
        padding: 8px 5px;
        font-size: 0.75rem;
    }
    
    .items-table th:first-child,
    .items-table td:first-child {
        max-width: 100px;
    }
    
    .payment-info {
        gap: 20px;
        margin-top: 15px;
    }
    
    .payment-details h4 {
        font-size: 0.85rem;
    }
    
    .payment-details p {
        font-size: 0.75rem;
    }
    
    .company-name {
        font-size: 1rem;
    }
    
    .company-address {
        font-size: 0.75rem;
    }
    
    .invoice-preview .totals {
        margin: 15px 0 10px auto;
        width: 100%;
    }
    
    .invoice-preview .totals td {
        font-size: 0.8rem;
        padding: 6px 3px;
    }
    
    .invoice-preview .totals .total-row td {
        font-size: 0.9rem;
        padding-top: 10px;
    }
    
    .preview-actions {
        padding: 15px;
        gap: 12px;
    }
    
    .preview-actions .submit-btn {
        padding: 12px 20px;
        font-size: 14px;
    }
}

/* CRITICAL FIX - Print Styles for Single Page */
@media print {
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    
    @page {
        size: A4;
        margin: 0.5in;
    }
    
    body {
        margin: 0 !important;
        padding: 0 !important;
        background: #F5F5F5 !important;
        font-family: 'Arial', sans-serif !important;
    }
    
    /* Hide everything except invoice document */
    body * {
        visibility: hidden;
    }
    
    .invoice-document,
    .invoice-document * {
        visibility: visible;
    }
    
    /* Position invoice document properly */
    .invoice-document {
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        width: 100% !important;
        max-width: none !important;
        padding: 20px !important;
        background: #f5f5f5 !important;
        margin: 0 !important;
        font-family: 'Arial', sans-serif !important;
        font-size: 12px !important;
        line-height: 1.3 !important;
        page-break-inside: avoid !important;
        height: auto !important;
        min-height: auto !important;
    }
    
    /* Hide form and other elements */
    .invoice-form-wrapper,
    .preview-actions,
    .form-actions {
        display: none !important;
    }
    
    .invoice-preview {
        display: block !important;
        box-shadow: none !important;
        background: transparent !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .invoice-content {
        display: block !important;
        max-width: none !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    
    /* Compact spacing for single page */
    .invoice-header-doc {
        margin-bottom: 20px !important;
    }
    
    .logo,
    .invoice-title {
        font-size: 2rem !important;
        line-height: 1 !important;
    }
    
    .invoice-info-section {
        margin-bottom: 20px !important;
    }
    
    .bill-to h4,
    .payment-details h4 {
        font-size: 0.9rem !important;
        margin-bottom: 8px !important;
    }
    
    .bill-to p,
    .invoice-details p,
    .payment-details p {
        font-size: 0.85rem !important;
        margin: 2px 0 !important;
        line-height: 1.2 !important;
    }
    
    .items-table {
        margin-bottom: 15px !important;
        font-size: 0.85rem !important;
    }
    
    .items-table th,
    .items-table td {
        padding: 8px 5px !important;
        font-size: 0.85rem !important;
    }
    
    .invoice-preview .totals {
        width: 250px !important;
        margin: 15px auto 15px auto !important;
        padding: 15px !important;
    }
    
    .invoice-preview .totals td {
        padding: 4px 0 !important;
        font-size: 0.85rem !important;
    }
    
    .invoice-preview .totals .total-row td {
        font-size: 1rem !important;
        padding-top: 8px !important;
    }
    
    .thank-you {
        font-size: 1.2rem !important;
        margin: 1px 0 10px 0 !important;
    }
    
    .payment-info {
        margin-top: 20px !important;
    }
    
    .company-name {
        font-size: 1.4rem !important;
        /* margin-bottom: 3px !important; */
    }
    
    .company-address {
        font-size: 0.85rem !important;
    }
    
    /* Force everything to fit on one page */
    .invoice-document,
    .invoice-header-doc,
    .invoice-info-section,
    .items-table,
    .totals,
    .thank-you,
    .payment-info {
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }
}

/* Add padding-top to labels in items section for mobile and tablet */
@media (max-width: 1024px) {
    #itemsList .item-row .form-group label {
        padding-top: 10px;
    }
}