/* Main Invoice Styles */

body {
    font-family: Arial, sans-serif;
    margin: 20px;
    background-color: #f5f5f5;
}

/* Hide old button container - now using side menu */
.button-container {
    display: none;
}
.container {
    max-width: 800px;
    margin: 0 auto;
    background-color: white;
    padding: 20px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
}

.button-container {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 2px solid #f0f0f0;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    justify-content: flex-start;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
    /* padding-top: 10px; */
}

.logo-section {
    display: flex;
    align-items: flex-start;
    width: 240px; /* Fixed width to contain the logo + margin */
    height: 220px; /* Fixed height */
    flex-shrink: 0; /* Prevent shrinking */
}

.company-details {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-end;
    text-align: right;
    margin-top: 30px; /* Push company name down */
}

.logo {
    width: 220px !important;
    height: 220px !important;
    margin-right: 20px;
    object-fit: contain !important; /* Maintains aspect ratio within the specified dimensions */
    display: block;
    /* border: 1px solid #ddd; Optional: adds a subtle border */
}

.company-name {
    font-size: 24px;
    font-weight: bold;
    color: #1e3a8a;
    margin: 0 0 5px 0; /* Reduced bottom margin to bring closer to details */
    /* letter-spacing: 1px; */
}

.company-info {
    text-align: right;
    font-size: 14px;
    line-height: 1.4;
    color: #333;
}

.invoice-title {
    text-align: center;
    font-size: 28px;
    font-weight: bold;
    color: #1e3a8a;
    margin: 20px 0;
    text-decoration: underline;
}

.top-section {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
}

.date-section, .invoice-no-section {
    border: 1px solid #000;
    padding: 8px;
    min-width: 150px;
}

.date-section {
    margin-right: 20px;
}

.section-label {
    font-weight: bold;
    margin-bottom: 5px;
}

.input-field {
    border: none;
    background: transparent;
    width: 100%;
    padding: 5px 0;
    font-size: 14px;
}

/* Center-align input fields in QTY, Unit, and Price columns */
.invoice-table td:nth-child(1) .input-field,
.invoice-table td:nth-child(2) .input-field,
.invoice-table td:nth-child(4) .input-field {
    text-align: center;
}

/* Left-align input fields in Description column */
.invoice-table td:nth-child(3) .input-field {
    text-align: left;
}

.middle-section {
    display: flex;
    gap: 40px;
    margin-bottom: 20px;
}

.sold-to, .consigned-to {
    flex: 1;
    border: 1px solid #000;
    padding: 10px;
    min-height: 120px;
}

.invoice-table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid #000;
}

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

/* Specific column widths */
.invoice-table th:nth-child(1),
.invoice-table td:nth-child(1) {
    width: 8%; /* Qty column - smaller */
    text-align: center;
}

.invoice-table th:nth-child(2),
.invoice-table td:nth-child(2) {
    width: 10%; /* Unit column - smaller */
    text-align: center;
}

.invoice-table th:nth-child(3),
.invoice-table td:nth-child(3) {
    width: 50%; /* Description column - larger */
    text-align: left;
    padding-left: 12px;
}

.invoice-table th:nth-child(4),
.invoice-table td:nth-child(4) {
    width: 15%; /* Price column */
    text-align: center;
}

.invoice-table th:nth-child(5),
.invoice-table td:nth-child(5) {
    width: 17%; /* Total column */
    text-align: right;
    padding-right: 12px;
}

/* Grand Total Row Styling - Remove Cell Dividers */
.grand-total-row td {
    border-left: none !important;
    border-right: none !important;
}

.grand-total-row td:first-child {
    border-left: 1px solid #000 !important;
}

.grand-total-row td:last-child {
    border-right: 1px solid #000 !important;
}

/* Ensure GRAND TOTAL text is properly positioned */
.grand-total-row td:nth-child(3) {
    text-align: right;
    font-weight: bold;
    padding-right: 12px;
    border-right: 1px solid #000 !important; /* Add divider after GRAND TOTAL */
}

/* Ensure Grand Total value is properly positioned */
.grand-total-row td:nth-child(5) {
    text-align: right;
    padding-right: 12px;
    font-weight: bold;
    background-color: #f0f0f0;
}

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

.total-cell {
    font-weight: bold;
    background-color: #f9f9f9;
}

.print-btn {
    background-color: #1e40af;
    color: white;
    border: none;
    padding: 10px 20px;
    cursor: pointer;
    font-size: 14px;
    border-radius: 6px;
    margin: 5px;
    font-weight: 500;
    transition: background-color 0.2s ease;
    min-width: 100px;
}

.print-btn:hover {
    background-color: #1d4ed8;
}

/* Consistent button styling for all invoice buttons */
.save-draft-btn,
.drafts-btn {
    background-color: #1e40af !important;
    color: white !important;
    border: none !important;
    padding: 10px 20px !important;
    cursor: pointer !important;
    font-size: 14px !important;
    border-radius: 6px !important;
    margin: 5px !important;
    font-weight: 500 !important;
    transition: background-color 0.2s ease !important;
    min-width: 100px !important;
}

.save-draft-btn:hover,
.drafts-btn:hover {
    background-color: #1d4ed8 !important;
}

/* Form Controls */
.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    box-sizing: border-box;
}

.form-control:focus {
    outline: none;
    border-color: #1e3a8a;
    box-shadow: 0 0 0 2px rgba(30, 58, 138, 0.1);
}

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

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #333;
}

.form-row {
    display: flex;
    gap: 15px;
}

.form-row .form-group {
    flex: 1;
}

.form-section {
    margin-bottom: 30px;
}

.form-section h3 {
    color: #1e3a8a;
    border-bottom: 2px solid #1e3a8a;
    padding-bottom: 5px;
    margin-bottom: 15px;
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #ddd;
}

.btn {
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    border: none;
    transition: background-color 0.2s;
}

.btn-primary {
    background-color: #1e3a8a;
    color: white;
}

.btn-primary:hover {
    background-color: #1e5a8a;
}

.btn-secondary {
    background-color: #6b7280;
    color: white;
}

.btn-secondary:hover {
    background-color: #4b5563;
}

.btn-outline {
    background-color: transparent;
    color: #1e3a8a;
    border: 1px solid #1e3a8a;
}

.btn-outline:hover {
    background-color: #1e3a8a;
    color: white;
}

@media print {
    /* Hide all UI elements - only show invoice content */
    .print-btn { display: none !important; }
    .save-draft-btn, .drafts-btn { display: none !important; }
    .draft-modal { display: none !important; }
    .menu-toggle { display: none !important; }
    .new-invoice-toggle { display: none !important; }
    .save-draft-toggle { display: none !important; }
    .view-drafts-toggle { display: none !important; }
    .side-menu { display: none !important; }
    .menu-overlay { display: none !important; }
    .auto-save-status { display: none !important; }
    #autoSaveStatus { display: none !important; }
    .row-controls { display: none !important; }
    .profile-card { display: none !important; }
    .form-actions { display: none !important; }
    .button-container { display: none !important; }
    
    /* Hide all fixed positioned elements */
    *[style*="position: fixed"] { display: none !important; }
    
    /* Clean up page layout for printing */
    body { 
        background-color: white !important; 
        margin: 0 !important; 
        padding: 0 !important;
    }
    
    .container { 
        box-shadow: none !important; 
        margin: 0 !important;
        max-width: none !important;
        padding: 20px !important;
        background-color: white !important;
    }
    
    /* Ensure invoice content is clearly visible */
    .invoice-container {
        width: 100% !important;
    }
    
    /* Hide any floating elements */
    .floating-action-btn { display: none !important; }
    
    /* Ensure table prints properly */
    table {
        page-break-inside: avoid;
    }
    
    /* Hide any form elements that might appear */
    input, textarea, select, button {
        border: none !important;
        background: transparent !important;
        box-shadow: none !important;
        outline: none !important;
        appearance: none !important;
        -webkit-appearance: none !important;
        -moz-appearance: none !important;
    }
    
    /* Style inputs to look like plain text when printing */
    input[type="text"],
    input[type="date"],
    input[type="number"],
    textarea {
        color: #000 !important;
        font-family: inherit !important;
        font-size: inherit !important;
        font-weight: inherit !important;
        padding: 2px !important;
        margin: 0 !important;
    }
    
    /* Clean up table formatting for print */
    .invoice-table th,
    .invoice-table td {
        border: 1px solid #000 !important;
        padding: 8px !important;
    }

    .invoice-table {
        border-collapse: collapse !important;
        width: 100% !important;
    }

    /* Remove extra spacing and borders from sections */
    .top-section,
    .middle-section {
        border: none !important;
        margin: 20px 0 !important;
    }

    .date-section,
    .invoice-no-section,
    .sold-to,
    .consigned-to {
        border: 1px solid #000 !important;
        padding: 10px !important;
        margin: 10px 0 !important;
    }    /* Ensure clean print layout */
    * {
        print-color-adjust: exact !important;
        -webkit-print-color-adjust: exact !important;
    }
}

/* Logo Upload Styling */
.logo-upload-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.current-logo-preview {
    min-height: 60px;
    display: flex;
    align-items: center;
}

.current-logo-preview img {
    max-width: 150px;
    max-height: 100px;
    object-fit: contain;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 8px;
    background-color: #f9f9f9;
}

.logo-upload-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.form-text {
    color: #666;
    font-size: 12px;
    margin-top: 5px;
}

/* New Invoice Modal Actions */
.new-invoice-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 20px;
}

.new-invoice-actions .btn {
    width: 100%;
    text-align: left;
    justify-content: flex-start;
    padding: 12px 16px;
}

.modal-body {
    padding: 20px;
}

.modal-body p {
    margin-bottom: 16px;
    color: #374151;
    line-height: 1.5;
}

/* New Invoice Modal - Compact Width */
#newInvoiceModal .draft-modal-content {
    max-width: 350px;
    width: 85%;
}

/* Side Menu Styling */
.menu-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1001;
    background-color: #1e3a8a;
    color: white;
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 18px;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.menu-toggle:hover {
    background-color: #1e5a8a;
    transform: scale(1.05);
}

.menu-toggle.active {
    background-color: #dc2626;
}

.new-invoice-toggle {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 1001;
    background-color: #059669;
    color: white;
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.new-invoice-toggle:hover {
    background-color: #047857;
    transform: scale(1.05);
}

.save-draft-toggle {
    position: fixed;
    top: 140px;
    right: 20px;
    z-index: 1001;
    background-color: #2563eb;
    color: white;
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 18px;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.save-draft-toggle:hover {
    background-color: #1d4ed8;
    transform: scale(1.05);
}

.view-drafts-toggle {
    position: fixed;
    top: 200px;
    right: 20px;
    z-index: 1001;
    background-color: #7c3aed;
    color: white;
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 18px;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.view-drafts-toggle:hover {
    background-color: #6d28d9;
    transform: scale(1.05);
}

.side-menu {
    position: fixed;
    top: 0;
    right: -300px;
    width: 300px;
    height: 100vh;
    background-color: #f8fafc;
    border-left: 1px solid #e2e8f0;
    box-shadow: -5px 0 15px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    transition: right 0.3s ease;
    overflow-y: auto;
}

.side-menu.open {
    right: 0;
}

.side-menu-header {
    background-color: #1e3a8a;
    color: white;
    padding: 20px;
    text-align: center;
    font-size: 18px;
    font-weight: bold;
}

.side-menu-content {
    padding: 20px;
}

.menu-section {
    margin-bottom: 30px;
}

.menu-section h3 {
    color: #1e3a8a;
    font-size: 16px;
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e2e8f0;
}

.menu-button {
    display: block;
    width: 100%;
    padding: 12px 16px;
    margin-bottom: 8px;
    background-color: white;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    color: #374151;
    text-decoration: none;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.menu-button:hover {
    background-color: #f1f5f9;
    border-color: #1e3a8a;
    color: #1e3a8a;
}

.menu-button:active {
    background-color: #e2e8f0;
}

.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.menu-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Responsive design for side menu */
@media (max-width: 768px) {
    .side-menu {
        width: 280px;
        right: -280px;
    }
    
    .menu-toggle {
        top: 15px;
        right: 15px;
        width: 45px;
        height: 45px;
        font-size: 16px;
    }
    
    .new-invoice-toggle {
        top: 70px;
        right: 15px;
        width: 45px;
        height: 45px;
        font-size: 20px;
    }
}

/* Inline Row Controls */
.row-controls {
    position: absolute;
    left: -30px;
    top: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.2s ease;
    height: 100%;
    justify-content: space-between;
    padding: 2px 0;
}

.row-control-btn {
    width: 20px;
    height: 20px;
    border: 1px solid #1e3a8a;
    background-color: white;
    color: #1e3a8a;
    border-radius: 50%;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    line-height: 1;
    padding: 0;
    flex-shrink: 0;
}

.row-control-btn:hover {
    background-color: #1e3a8a;
    color: white;
    transform: scale(1.1);
}

.row-control-btn.add-btn {
    border-color: #059669;
    color: #059669;
    margin-top: auto; /* Push to bottom (new row position) */
}

.row-control-btn.add-btn:hover {
    background-color: #059669;
    color: white;
}

.row-control-btn.remove-btn {
    border-color: #dc2626;
    color: #dc2626;
    margin-bottom: auto; /* Keep at top (current row position) */
}

.row-control-btn.remove-btn:hover {
    background-color: #dc2626;
    color: white;
}

/* Only show controls on last row hover */
.invoice-row:last-of-type:hover .row-controls {
    opacity: 1;
}

/* Make first cell (QTY) position relative for absolute positioning of controls */
.invoice-row td:first-child {
    position: relative;
}

/* Company Profiles Styles */
.profile-actions-section {
    margin-top: 20px;
}

.profile-actions-section hr {
    border: none;
    border-top: 1px solid #ddd;
    margin: 20px 0;
}

.profile-actions-section h3 {
    color: #1e3a8a;
    margin-bottom: 15px;
    font-size: 16px;
}

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

.profiles-content {
    padding: 20px;
}

.profiles-actions {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #ddd;
}

.profiles-list {
    max-height: 400px;
    overflow-y: auto;
}

.no-profiles {
    text-align: center;
    padding: 40px 20px;
    color: #6b7280;
}

.no-profiles p {
    margin: 10px 0;
}

.profile-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    margin-bottom: 10px;
    background-color: #f9fafb;
    transition: background-color 0.2s;
}

.profile-card:hover {
    background-color: #f3f4f6;
}

.profile-info {
    flex: 1;
}

.profile-name {
    margin: 0 0 5px 0;
    color: #1e3a8a;
    font-size: 16px;
    font-weight: 600;
}

.profile-details {
    margin: 0 0 5px 0;
    color: #4b5563;
    font-size: 14px;
}

.profile-meta {
    margin: 0;
    color: #6b7280;
    font-size: 12px;
}

.profile-actions {
    display: flex;
    gap: 8px;
    margin-left: 15px;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

/* Responsive design for profiles */
@media (max-width: 600px) {
    .profile-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .profile-actions {
        margin-left: 0;
        width: 100%;
        justify-content: flex-end;
    }
    
    .profile-form-actions {
        flex-direction: column;
    }
}

/* Color Picker Styles */
.color-input-group {
    display: flex;
    gap: 10px;
    align-items: center;
}

.color-picker {
    width: 60px;
    height: 40px;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    padding: 0;
}

.color-text {
    flex: 1;
    font-family: 'Courier New', monospace;
    text-transform: uppercase;
}

.color-preview {
    margin-top: 15px;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
}

.preview-item {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.preview-label {
    font-weight: 600;
    color: #374151;
    font-size: 14px;
}

.preview-company-name {
    font-size: 24px;
    font-weight: bold;
    color: #1e3a8a;
}

.preview-invoice-title {
    font-size: 20px;
    font-weight: bold;
    text-decoration: underline;
    color: #1e3a8a;
}