/* Invoice Container & Layout */
.invoice-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    align-items: start;
}

.invoice-form-section {
    overflow-y: auto;
    max-height: calc(100vh - 180px);
    padding-right: 0.5rem;
}

.invoice-preview-section {
    position: sticky;
    top: 100px;
    height: fit-content;
    max-height: calc(100vh - 180px);
    overflow-y: auto;
}

/* Invoice Preview Styling */
.invoice-preview {
    background: white;
    color: black;
    padding: 1.25rem;
    border-radius: 8px;
    box-shadow: 0 0 15px rgba(0,0,0,0.2);
    font-size: 0.9rem;
}

/* Dark mode override for preview - keep white background and black text */
html.dark-mode .invoice-preview {
    background: white !important;
    color: black !important;
}

html.dark-mode .invoice-preview * {
    color: black !important;
}

html.dark-mode .invoice-preview table {
    color: black !important;
}

html.dark-mode .invoice-preview td,
html.dark-mode .invoice-preview th {
    color: black !important;
}

html.dark-mode .invoice-preview p,
html.dark-mode .invoice-preview span,
html.dark-mode .invoice-preview div {
    color: black !important;
}

.placeholder-preview {
    background: linear-gradient(135deg, rgba(33, 150, 243, 0.08) 0%, rgba(25, 118, 210, 0.04) 100%);
    color: #6c757d;
    padding: 2rem;
    border-radius: 8px;
    text-align: center;
    border: 2px dashed #2196f3;
}

html.dark-mode .placeholder-preview {
    background: linear-gradient(135deg, rgba(100, 181, 246, 0.15) 0%, rgba(100, 181, 246, 0.08) 100%);
    color: #ffffff;
    border-color: rgba(100, 181, 246, 0.5);
}

.invoice-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 1rem;
    border-bottom: 2px solid #333;
    padding-bottom: 0.75rem;
}

.invoice-title {
    font-size: 1.5rem;
    font-weight: bold;
}

.invoice-header-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.invoice-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.invoice-section-title {
    font-weight: bold;
    margin-top: 0.75rem;
    margin-bottom: 0.25rem;
}

.invoice-items-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.75rem 0;
    font-size: 0.85rem;
}

.invoice-items-table thead {
    background-color: #f8f9fa;
    border-bottom: 2px solid #333;
}

.invoice-items-table th,
.invoice-items-table td {
    padding: 0.5rem;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

.invoice-items-table th {
    font-weight: bold;
    color: #333;
}

.invoice-summary {
    display: flex;
    justify-content: flex-end;
    margin-top: 0.75rem;
}

.summary-box {
    width: 250px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    padding: 0.4rem 0;
    border-bottom: 1px solid #ddd;
    font-size: 0.9rem;
}

.summary-row.total {
    font-weight: bold;
    font-size: 1rem;
    background-color: #f8f9fa;
    padding: 0.75rem;
    border: 2px solid #333;
    border-top: 2px solid #333;
}

/* Button Styling */
.btn-download-pdf {
    background-color: #007bff;
    color: white;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.btn-download-pdf:hover {
    background-color: #0056b3;
}

/* Form Styling Adjustments */
.invoice-form-section .widget {
    padding: 1.25rem;
    background-color: #ffffff;
    border-radius: 8px;
    border: 1px solid #f0f4f8;
}

html.dark-mode .invoice-form-section .widget {
    background-color: #232d3f;
    border-color: #2d3b52;
}

.invoice-form-section .widget-header {
    padding: 0 0 1rem 0;
    margin-bottom: 0.5rem;
    border-bottom: 2px solid #f0f4f8;
}

html.dark-mode .invoice-form-section .widget-header {
    border-bottom-color: #2d3b52;
}

.invoice-form-section .widget-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
    color: #2c3e50;
}

html.dark-mode .invoice-form-section .widget-title {
    color: #e0e6ed;
}

.invoice-form-section .mb-4 {
    margin-bottom: 0.75rem !important;
}

.invoice-form-section .mb-3 {
    margin-bottom: 0.5rem !important;
}

.invoice-form-section .mt-4 {
    margin-top: 0.75rem !important;
}

.invoice-form-section .d-grid {
    gap: 0.5rem !important;
}

.invoice-form-section .row {
    margin-bottom: 0.5rem;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.75rem;
}

.invoice-form-section .row .col-md-6 {
    padding: 0;
}

.invoice-form-section .row .col-md-8 {
    padding: 0;
    grid-column: span 2;
}

.invoice-form-section .row .col-md-4 {
    padding: 0;
}

.invoice-form-section .row .col-md-12 {
    padding: 0;
    grid-column: 1 / -1;
}

.invoice-form-section .row.address-row {
    grid-template-columns: 2fr 1fr 2fr;
}

.invoice-form-section .row.single-date-row {
    grid-template-columns: 1fr 1fr 1fr;
}

.invoice-form-section .form-label {
    margin-bottom: 0.3rem;
    font-size: 0.85rem;
    color: #495057;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.invoice-form-section .form-control,
.invoice-form-section .form-select {
    font-size: 0.9rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid #dee2e6;
    background-color: #ffffff;
    color: #212529;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.invoice-form-section .form-control:focus,
.invoice-form-section .form-select:focus {
    border-color: #80bdff;
    background-color: #ffffff;
    color: #212529;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* Dark mode overrides for form elements */
html.dark-mode .invoice-form-section .form-label {
    color: #b0b3b8;
}

html.dark-mode .invoice-form-section .form-control,
html.dark-mode .invoice-form-section .form-select {
    border-color: #3a3d47;
    background-color: #2a2d36;
    color: #fff;
}

html.dark-mode .invoice-form-section .form-control:focus,
html.dark-mode .invoice-form-section .form-select:focus {
    border-color: #4a5f7f;
    background-color: #2a2d36;
    color: #fff;
    box-shadow: 0 0 0 0.1rem rgba(74, 95, 127, 0.25);
}

.invoice-form-section textarea.form-control {
    resize: vertical;
    min-height: 60px;
}

/* Widget subtitle styling for invoice form */
.invoice-form-section .widget-subtitle {
    color: #6c757d;
    font-size: 0.95rem;
    margin-top: 0.25rem;
}

html.dark-mode .invoice-form-section .widget-subtitle {
    color: #adb5bd;
}

/* Widget title styling for invoice form */
.invoice-form-section .widget-title {
    color: #212529;
    font-weight: 600;
}

html.dark-mode .invoice-form-section .widget-title {
    color: #e9ecef;
}

.invoice-form-section .card {
    margin-bottom: 1rem;
}

.invoice-form-section .card-body {
    padding: 1rem;
}

.invoice-form-section .btn {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    border-radius: 4px;
    transition: all 0.2s ease;
    font-weight: 500;
}

.invoice-form-section .btn-primary {
    background-color: #007bff;
    border: none;
    color: #fff;
}

.invoice-form-section .btn-primary:hover {
    background-color: #0056b3;
}

.invoice-form-section .btn-danger {
    background-color: #dc3545;
    border: none;
    color: #fff;
}

.invoice-form-section .btn-danger:hover {
    background-color: #c82333;
}

.invoice-form-section .btn-outline-primary {
    color: #007bff;
    border-color: #007bff;
}

.invoice-form-section .btn-outline-primary:hover {
    background-color: #007bff;
    color: #fff;
}

.invoice-form-section .table {
    margin-bottom: 0.75rem;
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

.invoice-form-section .table thead {
    background-color: #f8f9fa;
}

.invoice-form-section .table th,
.invoice-form-section .table td {
    padding: 0.5rem;
    vertical-align: middle;
    border-color: #dee2e6;
    color: #212529;
}

.invoice-form-section .table th {
    font-weight: 600;
    color: #1976d2;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

html.dark-mode .invoice-form-section .table thead {
    background-color: #3a3d47;
}

html.dark-mode .invoice-form-section .table th,
html.dark-mode .invoice-form-section .table td {
    border-color: #3a3d47;
    color: #e9ecef;
}

html.dark-mode .invoice-form-section .table th {
    color: #64b5f6;
}

.invoice-form-section h5 {
    font-size: 0.95rem;
    margin-bottom: 0.75rem;
    margin-top: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #212529;
}

html.dark-mode .invoice-form-section h5 {
    color: #e9ecef;
}

.invoice-form-section hr {
    margin: 0.75rem 0;
    border-color: #dee2e6;
}

html.dark-mode .invoice-form-section hr {
    border-color: #3a3d47;
}

/* Scrollbar Styling */
.invoice-form-section::-webkit-scrollbar,
.invoice-preview-section::-webkit-scrollbar {
    width: 6px;
}

.invoice-form-section::-webkit-scrollbar-track,
.invoice-preview-section::-webkit-scrollbar-track {
    background: #f5f5f5;
}

.invoice-form-section::-webkit-scrollbar-thumb,
.invoice-preview-section::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

.invoice-form-section::-webkit-scrollbar-thumb:hover,
.invoice-preview-section::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

html.dark-mode .invoice-form-section::-webkit-scrollbar-track,
html.dark-mode .invoice-preview-section::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

html.dark-mode .invoice-form-section::-webkit-scrollbar-thumb,
html.dark-mode .invoice-preview-section::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
}

html.dark-mode .invoice-form-section::-webkit-scrollbar-thumb:hover,
html.dark-mode .invoice-preview-section::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Modern Form Styling */
.invoice-form-section .form-group {
    margin-bottom: 1rem;
}

/* Form section headings */
.invoice-form-section > div > h5,
.invoice-form-section h5 {
    color: #212529;
    font-weight: 600;
}

html.dark-mode .invoice-form-section > div > h5,
html.dark-mode .invoice-form-section h5 {
    color: #e9ecef;
}

.info-card {
    background: linear-gradient(135deg, rgba(33, 150, 243, 0.05) 0%, rgba(25, 118, 210, 0.03) 100%);
    border: 1px solid rgba(33, 150, 243, 0.3);
    border-radius: 8px;
    padding: 1.5rem;
    transition: all 0.3s ease;
}

.info-card:hover {
    border-color: rgba(33, 150, 243, 0.6);
    background: linear-gradient(135deg, rgba(33, 150, 243, 0.1) 0%, rgba(25, 118, 210, 0.05) 100%);
}

html.dark-mode .info-card {
    background: linear-gradient(135deg, rgba(33, 150, 243, 0.08) 0%, rgba(25, 118, 210, 0.04) 100%);
    border-color: rgba(100, 181, 246, 0.25);
}

html.dark-mode .info-card:hover {
    border-color: rgba(100, 181, 246, 0.5);
    background: linear-gradient(135deg, rgba(100, 181, 246, 0.12) 0%, rgba(100, 181, 246, 0.06) 100%);
}

.card-title {
    font-size: 0.95rem;
    margin-bottom: 1rem;
    font-weight: 600;
    color: #1976d2;
}

html.dark-mode .card-title {
    color: #64b5f6;
}

.invoice-items-table {
    width: 100%;
    border-collapse: collapse;
    background: #ffffff;
    border-radius: 6px;
    overflow: hidden;
}

.invoice-items-table thead {
    background: linear-gradient(135deg, rgba(33, 150, 243, 0.1) 0%, rgba(25, 118, 210, 0.08) 100%);
}

html.dark-mode .invoice-items-table {
    background: rgba(100, 181, 246, 0.05);
}

html.dark-mode .invoice-items-table thead {
    background: linear-gradient(135deg, rgba(100, 181, 246, 0.2) 0%, rgba(100, 181, 246, 0.12) 100%);
}

.invoice-items-table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: #1976d2;
    border-bottom: 2px solid #2196f3;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.invoice-items-table td {
    padding: 0.75rem;
    border-bottom: 1px solid #e0e0e0;
    color: #212529;
}

.invoice-items-table tbody tr:hover {
    background: rgba(33, 150, 243, 0.08);
}

html.dark-mode .invoice-items-table th {
    color: #64b5f6;
    border-bottom-color: rgba(100, 181, 246, 0.4);
}

html.dark-mode .invoice-items-table td {
    border-bottom-color: rgba(100, 181, 246, 0.2);
    color: #e9ecef;
}

.totals-card {
    background: linear-gradient(135deg, rgba(33, 150, 243, 0.05) 0%, rgba(33, 150, 243, 0.03) 100%);
    border: 2px solid rgba(33, 150, 243, 0.3);
    border-radius: 8px;
    padding: 1.5rem;
    margin-top: 2rem;
}

html.dark-mode .totals-card {
    background: linear-gradient(135deg, rgba(100, 181, 246, 0.15) 0%, rgba(100, 181, 246, 0.08) 100%);
    border-color: rgba(100, 181, 246, 0.4);
}

.totals-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid #e0e0e0;
    color: #212529;
}

.totals-row:last-child {
    border-bottom: none;
}

.totals-row.totals-total {
    background: rgba(33, 150, 243, 0.08);
    padding: 1rem;
    margin: 0.5rem -1.5rem -1.5rem -1.5rem;
    border-radius: 0 0 6px 6px;
    border-top: 2px solid #2196f3;
    font-size: 1.1rem;
    color: #1976d2;
}

html.dark-mode .totals-row {
    border-bottom-color: rgba(100, 181, 246, 0.2);
    color: #e9ecef;
}

html.dark-mode .totals-row.totals-total {
    background: rgba(100, 181, 246, 0.15);
    border-top-color: rgba(100, 181, 246, 0.6);
    color: #64b5f6;
}

.table-responsive {
    overflow-x: auto;
    border-radius: 6px;
}

.invoice-form-section .form-control.form-control-sm {
    padding: 0.5rem;
    font-size: 0.85rem;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .invoice-container {
        grid-template-columns: 1fr;
    }
    
    .invoice-form-section {
        max-height: none;
        padding-right: 0;
    }
    
    .invoice-preview-section {
        position: static;
        max-height: none;
        margin-top: 2rem;
    }

    .info-card {
        padding: 1.25rem;
    }

    .invoice-items-table th,
    .invoice-items-table td {
        padding: 0.5rem;
    }
}

@media (max-width: 768px) {
    .invoice-container {
        grid-template-columns: 1fr;
    }

    /* Stack company and client cards vertically */
    .company-client-grid {
        grid-template-columns: 1fr !important;
        gap: 1.5rem !important;
    }

    /* Stack info cards vertically */
    .info-card {
        margin-bottom: 1rem;
    }

    /* Make table more compact */
    .invoice-items-table th,
    .invoice-items-table td {
        padding: 0.4rem 0.5rem;
        font-size: 0.8rem;
    }

    .totals-card {
        padding: 1rem;
    }

    .totals-row {
        padding: 0.5rem 0;
    }

    /* Adjust button sticky position for mobile */
    .btn-success, .btn-primary {
        padding: 0.5rem 1rem;
    }
}

/* Dark Mode Support for Invoice Form */
html.dark-mode .info-card {
    background: linear-gradient(135deg, rgba(33, 150, 243, 0.08) 0%, rgba(25, 118, 210, 0.04) 100%);
    border-color: rgba(100, 181, 246, 0.25);
}

html.dark-mode .info-card:hover {
    border-color: rgba(100, 181, 246, 0.5);
    background: linear-gradient(135deg, rgba(100, 181, 246, 0.12) 0%, rgba(100, 181, 246, 0.06) 100%);
}

html.dark-mode .invoice-items-table {
    background: rgba(100, 181, 246, 0.08);
}

html.dark-mode .invoice-items-table thead {
    background: linear-gradient(135deg, rgba(100, 181, 246, 0.2) 0%, rgba(100, 181, 246, 0.12) 100%);
}

html.dark-mode .invoice-items-table th {
    color: #64b5f6;
    border-bottom-color: rgba(100, 181, 246, 0.4);
}

html.dark-mode .invoice-items-table tbody tr:hover {
    background: rgba(100, 181, 246, 0.12);
}

html.dark-mode .totals-card {
    background: linear-gradient(135deg, rgba(100, 181, 246, 0.15) 0%, rgba(100, 181, 246, 0.08) 100%);
    border-color: rgba(100, 181, 246, 0.4);
}

html.dark-mode .totals-row.totals-total {
    background: rgba(100, 181, 246, 0.2);
    border-top-color: rgba(100, 181, 246, 0.6);
}
