/**
 * Invoice Frontend Styles
 * 
 * Styling for invoice management interface and user-facing invoice displays
 * Healthcare-focused design with agency branding support
 */

/* Invoice Dashboard */
.invoice-dashboard {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin: 20px 0;
}

.invoice-dashboard h2 {
    color: var(--agency-primary-color, #007cba);
    margin-bottom: 20px;
    font-size: 24px;
}

/* Invoice Grid */
.invoice-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin: 20px 0;
}

.invoice-card {
    background: white;
    border: 1px solid #e0e6ed;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: box-shadow 0.3s ease;
}

.invoice-card:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.invoice-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.invoice-number {
    font-weight: bold;
    font-size: 16px;
    color: #333;
}

.invoice-status {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: bold;
    text-transform: uppercase;
}

.invoice-status.draft {
    background: #f0f0f0;
    color: #666;
}

.invoice-status.sent {
    background: #cce5ff;
    color: #0066cc;
}

.invoice-status.paid {
    background: #d4edda;
    color: #155724;
}

.invoice-status.overdue {
    background: #f8d7da;
    color: #721c24;
}

.invoice-status.cancelled {
    background: #e2e3e5;
    color: #383d41;
}

.invoice-card-body {
    margin-bottom: 15px;
}

.invoice-amount {
    font-size: 18px;
    font-weight: bold;
    color: var(--agency-primary-color, #007cba);
    margin-bottom: 5px;
}

.invoice-date {
    color: #666;
    font-size: 14px;
    margin-bottom: 5px;
}

.invoice-description {
    color: #666;
    font-size: 13px;
    line-height: 1.4;
    margin-bottom: 10px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.invoice-card-footer {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.invoice-action-btn {
    padding: 6px 12px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.invoice-action-btn:hover {
    background: #f8f9fa;
    border-color: #adb5bd;
    text-decoration: none;
}

.invoice-action-btn.primary {
    background: var(--agency-primary-color, #007cba);
    color: white;
    border-color: var(--agency-primary-color, #007cba);
}

.invoice-action-btn.primary:hover {
    background: color-mix(in srgb, var(--agency-primary-color, #007cba) 85%, black);
    color: white;
}

.invoice-action-btn.danger {
    background: #dc3545;
    color: white;
    border-color: #dc3545;
}

.invoice-action-btn.danger:hover {
    background: #c82333;
    color: white;
}

/* Invoice Details View */
.invoice-details {
    background: white;
    border-radius: 8px;
    padding: 30px;
    margin: 20px 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.invoice-header-section {
    display: flex;
    justify-content: between;
    align-items: flex-start;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--agency-primary-color, #007cba);
}

.invoice-company-info {
    flex: 1;
}

.invoice-meta-info {
    text-align: right;
    flex-shrink: 0;
    margin-left: 40px;
}

.company-logo {
    max-width: 200px;
    max-height: 80px;
    margin-bottom: 15px;
}

.company-name {
    font-size: 22px;
    font-weight: bold;
    color: var(--agency-primary-color, #007cba);
    margin-bottom: 8px;
}

.company-address {
    color: #666;
    line-height: 1.4;
}

.invoice-title {
    font-size: 28px;
    font-weight: bold;
    color: var(--agency-primary-color, #007cba);
    margin-bottom: 10px;
}

.invoice-meta-table {
    border-collapse: collapse;
}

.invoice-meta-table td {
    padding: 4px 8px;
    font-size: 14px;
}

.invoice-meta-table .label {
    font-weight: bold;
    text-align: right;
    color: #666;
}

/* Billing Information */
.billing-info-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin: 30px 0;
}

.billing-info-box {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 6px;
    border-left: 4px solid var(--agency-primary-color, #007cba);
}

.billing-info-title {
    font-weight: bold;
    color: var(--agency-primary-color, #007cba);
    margin-bottom: 10px;
    font-size: 14px;
    text-transform: uppercase;
}

/* Line Items Table */
.line-items-table {
    width: 100%;
    border-collapse: collapse;
    margin: 30px 0;
    font-size: 14px;
}

.line-items-table th {
    background: var(--agency-primary-color, #007cba);
    color: white;
    padding: 12px 8px;
    text-align: left;
    font-weight: bold;
    font-size: 13px;
}

.line-items-table td {
    padding: 10px 8px;
    border-bottom: 1px solid #eee;
}

.line-items-table tbody tr:hover {
    background: #f8f9fa;
}

.line-items-table .text-right {
    text-align: right;
}

.line-items-table .text-center {
    text-align: center;
}

.cpt-code {
    font-family: 'Courier New', monospace;
    background: #f0f0f0;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 12px;
}

.service-date {
    color: #666;
    font-size: 12px;
}

/* Totals Section */
.totals-section {
    display: flex;
    justify-content: flex-end;
    margin-top: 30px;
}

.totals-table {
    border-collapse: collapse;
    min-width: 300px;
}

.totals-table td {
    padding: 8px 15px;
    border-top: 1px solid #ddd;
    font-size: 14px;
}

.totals-table .total-label {
    font-weight: bold;
    text-align: right;
    color: #666;
}

.totals-table .total-amount {
    text-align: right;
    font-weight: bold;
}

.totals-table .grand-total {
    background: var(--agency-primary-color, #007cba);
    color: white;
    font-size: 16px;
}

.totals-table .balance-due {
    background: #dc3545;
    color: white;
    font-size: 16px;
}

/* Payment Information */
.payment-info-section {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 6px;
    padding: 20px;
    margin: 30px 0;
}

.payment-info-title {
    font-weight: bold;
    color: #856404;
    margin-bottom: 15px;
}

/* Healthcare Notices */
.healthcare-notice {
    background: #e7f3ff;
    border-left: 4px solid #007cba;
    padding: 15px;
    margin: 30px 0;
    font-size: 12px;
    color: #666;
    line-height: 1.4;
}

.insurance-info {
    background: #e8f5e8;
    border-left: 4px solid #28a745;
    padding: 15px;
    margin: 20px 0;
    font-size: 13px;
}

/* Invoice Actions */
.invoice-actions {
    background: #f8f9fa;
    border-top: 1px solid #eee;
    padding: 20px;
    margin-top: 30px;
    display: flex;
    gap: 10px;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.invoice-actions-left {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.invoice-actions-right {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Forms */
.invoice-form {
    background: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.invoice-form-section {
    margin-bottom: 30px;
}

.invoice-form-section h3 {
    color: var(--agency-primary-color, #007cba);
    margin-bottom: 15px;
    font-size: 18px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: bold;
    margin-bottom: 5px;
    color: #333;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--agency-primary-color, #007cba);
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.2);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.form-row.three-col {
    grid-template-columns: 1fr 1fr 1fr;
}

/* Line Items Editor */
.line-items-editor {
    border: 1px solid #ddd;
    border-radius: 6px;
    overflow: hidden;
}

.line-items-header {
    background: #f8f9fa;
    padding: 15px;
    border-bottom: 1px solid #ddd;
    display: flex;
    justify-content: between;
    align-items: center;
}

.line-items-body {
    padding: 15px;
}

.line-item-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr auto;
    gap: 10px;
    align-items: end;
    margin-bottom: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 4px;
}

.line-item-row:last-child {
    margin-bottom: 0;
}

.remove-line-item {
    background: #dc3545;
    color: white;
    border: none;
    padding: 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.add-line-item {
    background: var(--agency-primary-color, #007cba);
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 4px;
    cursor: pointer;
    margin-top: 15px;
}

/* Loading States */
.invoice-loading {
    text-align: center;
    padding: 40px;
    color: #666;
}

.invoice-loading .spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--agency-primary-color, #007cba);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Success/Error Messages */
.invoice-message {
    padding: 15px;
    border-radius: 4px;
    margin: 15px 0;
}

.invoice-message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.invoice-message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.invoice-message.warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

/* Print Styles */
@media print {
    .invoice-actions,
    .invoice-action-btn,
    .no-print {
        display: none !important;
    }
    
    .invoice-details {
        box-shadow: none;
        border: none;
        padding: 0;
    }
    
    body {
        font-size: 10pt;
        color: #000;
    }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .invoice-grid {
        grid-template-columns: 1fr;
    }
    
    .invoice-header-section {
        flex-direction: column;
        text-align: left;
    }
    
    .invoice-meta-info {
        margin-left: 0;
        margin-top: 20px;
        text-align: left;
    }
    
    .billing-info-section {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .form-row,
    .form-row.three-col {
        grid-template-columns: 1fr;
    }
    
    .line-item-row {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .invoice-actions {
        flex-direction: column;
        align-items: stretch;
    }
    
    .invoice-actions-left,
    .invoice-actions-right {
        justify-content: center;
    }
    
    .totals-section {
        justify-content: stretch;
    }
    
    .totals-table {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .invoice-details {
        padding: 15px;
    }
    
    .line-items-table {
        font-size: 12px;
    }
    
    .line-items-table th,
    .line-items-table td {
        padding: 6px 4px;
    }
    
    .invoice-card {
        padding: 15px;
    }
    
    .invoice-card-footer {
        flex-direction: column;
    }
    
    .invoice-action-btn {
        justify-content: center;
    }
}

/* Agency Branding Variables */
:root {
    --agency-primary-color: #007cba;
    --agency-secondary-color: #6c757d;
    --agency-accent-color: #28a745;
}

/* Dark mode support (if implemented) */
@media (prefers-color-scheme: dark) {
    .invoice-dashboard {
        background: #2d3748;
        color: #e2e8f0;
    }
    
    .invoice-card {
        background: #4a5568;
        border-color: #2d3748;
        color: #e2e8f0;
    }
    
    .invoice-details {
        background: #4a5568;
        color: #e2e8f0;
    }
}