/* Enhanced Financial Tab Styles */
.financial-tab-container {
    padding: 1rem;
    background: #f8f9fa;
    min-height: 400px;
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    flex: 1 !important;
    box-sizing: border-box;
}

/* Financial tab content container */
#financial-tab-content {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    flex: 1 !important;
    min-height: 400px !important;
    overflow-y: auto;
    box-sizing: border-box;
}

/* Hide loading message when content is present */
#financial-tab-content:has(.financial-content-horizontal) > .text-muted {
    display: none !important;
}

/* Removed global #tab-content rule that was causing conflicts */

/* Fix nested containers */
.financial-tab-container > .financial-tab-container {
    padding: 0 !important;
    background: transparent !important;
}

/* Force content to be on top */
.financial-content-horizontal {
    position: relative !important;
    z-index: 10 !important;
}

.financial-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid #dee2e6;
}

.financial-header h5 {
    margin: 0;
    color: #2c3e50;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.financial-header .badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
}

/* Main Horizontal Layout */
.financial-content-horizontal {
    display: grid !important;
    grid-template-columns: 250px 1fr 280px !important;
    gap: 1rem !important;
    margin-bottom: 1rem;
    flex: 1 !important;
    height: fit-content !important;
    width: 100% !important;
    box-sizing: border-box;
}

/* Panel Styles */
.financial-input-panel,
.financial-services-panel,
.financial-summary-panel {
    background: white;
    border-radius: 8px;
    padding: 0.75rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    height: fit-content;
}

/* Section Titles */
.section-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #495057;
    margin: 0 0 0.5rem 0;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.section-title i {
    font-size: 0.875rem;
    color: #6c757d;
}

/* Input Panel Styles */
.input-controls {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.control-group label {
    font-size: 0.8rem;
    font-weight: 500;
    color: #6c757d;
}

/* Subscription Toggle Switch */
.subscription-toggle {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem;
    background: linear-gradient(135deg, #f0f8ff 0%, #e7f3ff 100%);
    border-radius: 8px;
    border: 1px solid #cce5ff;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 24px;
    margin: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e0;
    transition: all 0.3s ease;
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: all 0.3s ease;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + .toggle-slider {
    background: linear-gradient(135deg, #0066cc 0%, #0052a3 100%);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

.toggle-switch:hover .toggle-slider {
    box-shadow: 0 0 8px rgba(0, 102, 204, 0.3);
}

.toggle-label {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.toggle-text {
    font-size: 0.875rem;
    font-weight: 600;
    color: #2c3e50;
}

.toggle-amount {
    font-size: 0.8rem;
    font-weight: 500;
    color: #0066cc;
}

/* Custom Price Label Styling */
.control-group label .badge {
    font-size: 0.7rem;
    padding: 0.2rem 0.4rem;
    margin-left: 0.5rem;
    vertical-align: middle;
}

.control-group label i {
    margin-right: 0.3rem;
    color: #6c757d;
}

.control-group .form-control,
.control-group .form-select {
    font-size: 0.875rem;
}

.currency-display {
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: #e7f3ff;
    border-radius: 6px;
    font-size: 0.875rem;
    color: #0066cc;
    text-align: center;
}

/* Services Panel */
.financial-services-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    height: 100%;
}

.services-section,
.discounts-section {
    display: flex;
    flex-direction: column;
}

.services-compact-list,
.discounts-compact {
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 0.5rem;
    min-height: 60px;
    height: auto;
}

/* Compact Service Items */
.service-item-compact {
    display: flex;
    align-items: center;
    padding: 0.375rem 0.5rem;
    margin-bottom: 0.25rem;
    background: #f8f9fa;
    border-radius: 4px;
    font-size: 0.8rem;
}

.service-item-compact:hover {
    background: #e9ecef;
}

.service-item-compact input[type="checkbox"] {
    margin-right: 0.5rem;
}

.service-item-compact .service-name {
    flex: 1;
    font-weight: 500;
}

.service-item-compact .service-price {
    color: #6c757d;
    margin: 0 0.5rem;
}

.service-item-compact .quantity-input {
    width: 50px;
    padding: 0.2rem 0.4rem;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    text-align: center;
    font-size: 0.8rem;
}

/* Summary Panel */
.summary-compact {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.summary-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
    padding: 0.25rem 0;
}

.summary-line.subtotal {
    padding-top: 0.5rem;
    border-top: 1px solid #e9ecef;
}

.summary-line.total {
    padding-top: 0.5rem;
    margin-top: 0.25rem;
    border-top: 2px solid #dee2e6;
    font-size: 1rem;
    color: #0066cc;
}

/* Empty States */
.empty-state-compact {
    text-align: center;
    padding: 0.75rem;
    color: #6c757d;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 60px;
}

/* Section Cards */
.financial-section {
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    padding: 1rem;
    transition: all 0.3s ease;
    border: 1px solid #e9ecef;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.financial-section:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    transform: translateY(-2px);
}

.section-header {
    display: flex;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #e9ecef;
}

.section-header h6 {
    margin: 0;
    color: #495057;
    font-weight: 600;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.section-header .icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e7f3ff;
    border-radius: 50%;
    color: #0066cc;
}

/* Basic Info Section */
.basic-info-group {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.basic-info-horizontal {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    align-items: end;
}

.basic-info-horizontal .currency-badge {
    grid-column: 1 / -1;
    justify-self: start;
    margin-top: 0.5rem;
}

.form-group-enhanced {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group-enhanced label {
    font-weight: 500;
    color: #6c757d;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-group-enhanced .form-control,
.form-group-enhanced .form-select {
    border: 2px solid #e9ecef;
    border-radius: 8px;
    padding: 0.625rem 0.875rem;
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

.form-group-enhanced .form-control:focus,
.form-group-enhanced .form-select:focus {
    border-color: #0066cc;
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

.input-with-unit {
    position: relative;
}

.input-with-unit .unit {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
    font-weight: 500;
    pointer-events: none;
}

.currency-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.375rem 0.75rem;
    background: #e7f3ff;
    color: #0066cc;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 500;
    margin-top: 0.5rem;
}

/* Services & Discounts Section */
.services-list {
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 0.5rem;
}

.services-list-horizontal {
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 0.5rem;
}

.service-item,
.discount-item {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    background: #f8f9fa;
    transition: all 0.2s ease;
    cursor: pointer;
}

.service-item:hover,
.discount-item:hover {
    background: #e9ecef;
}

.service-item:last-child,
.discount-item:last-child {
    margin-bottom: 0;
}

.service-checkbox {
    width: 20px;
    height: 20px;
    margin-right: 0.75rem;
    cursor: pointer;
}

.service-details {
    flex: 1;
}

.service-name {
    font-weight: 500;
    color: #2c3e50;
    margin-bottom: 0.25rem;
}

.service-price {
    font-size: 0.875rem;
    color: #6c757d;
}

.service-quantity {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.quantity-input {
    width: 60px;
    padding: 0.25rem 0.5rem;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    text-align: center;
}

/* Summary Section */
.pricing-summary-enhanced {
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
}

.summary-rows {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.summary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.summary-column {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
}

.summary-row.subtotal {
    padding-top: 0.75rem;
    border-top: 1px solid #e9ecef;
}

.summary-row.total {
    padding-top: 1rem;
    margin-top: 0.5rem;
    border-top: 2px solid #dee2e6;
    font-size: 1.1rem;
    font-weight: 600;
    color: #2c3e50;
}

.summary-label {
    color: #6c757d;
    font-weight: 500;
}

.summary-value {
    font-weight: 600;
    color: #2c3e50;
    font-size: 1rem;
}

.summary-value.discount {
    color: #28a745;
}

.summary-value.total {
    color: #0066cc;
    font-size: 1.25rem;
}

/* Discount Section Enhancement */
.discount-section {
    margin-top: 1rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
}

#discounts-section {
    display: flex;
    flex-direction: column;
}

.manual-discount-compact {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    padding: 0.5rem;
}

.manual-discount-compact .control-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.manual-discount-compact label {
    font-size: 0.75rem;
    font-weight: 500;
    color: #6c757d;
}

.manual-discount-controls {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 0.75rem;
    align-items: end;
}

.discount-type-select {
    width: 120px;
}

/* Action Buttons */
.financial-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0.75rem 1rem;
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-top: 0.5rem;
}

.action-buttons {
    display: flex;
    gap: 1rem;
}

.btn-save-pricing {
    padding: 0.625rem 1.5rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.btn-save-pricing:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.calculation-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #6c757d;
    font-size: 0.875rem;
}

.calculation-status .status-icon {
    width: 8px;
    height: 8px;
    background: #28a745;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* Scrollbar Styling */
.services-list::-webkit-scrollbar {
    width: 6px;
}

.services-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.services-list::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.services-list::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Empty States */
.empty-state {
    text-align: center;
    padding: 2rem;
    color: #6c757d;
}

.empty-state i {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    opacity: 0.5;
}

/* Loading States */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    z-index: 10;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .financial-content-horizontal {
        grid-template-columns: 200px 1fr 250px;
    }
}

@media (max-width: 992px) {
    .financial-content-horizontal {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
    }
    
    .financial-input-panel {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 1rem;
    }
    
    .input-section {
        grid-column: 1 / -1;
    }
    
    .financial-services-panel {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto;
    }
}

@media (max-width: 576px) {
    .financial-content-horizontal {
        gap: 0.75rem;
    }
    
    .financial-input-panel,
    .financial-services-panel,
    .financial-summary-panel {
        padding: 0.75rem;
    }
    
    .financial-services-panel {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto;
    }
}

/* Dark Mode Support */
.dark-mode .financial-tab-container {
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
}

.dark-mode .financial-section {
    background: #2d2d2d;
    border-color: #3d3d3d;
}

.dark-mode .section-header h6,
.dark-mode .summary-value,
.dark-mode .service-name {
    color: #e9ecef;
}

.dark-mode .form-control,
.dark-mode .form-select {
    background: #1a1a1a;
    border-color: #3d3d3d;
    color: #e9ecef;
}

.dark-mode .service-item,
.dark-mode .discount-item {
    background: #1a1a1a;
}

.dark-mode .service-item:hover,
.dark-mode .discount-item:hover {
    background: #3d3d3d;
}

.dark-mode .subscription-toggle {
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
    border-color: #3d3d3d;
}

.dark-mode .toggle-text {
    color: #e9ecef;
}

.dark-mode .toggle-amount {
    color: #66b3ff;
}

.dark-mode .toggle-switch input:checked + .toggle-slider {
    background: linear-gradient(135deg, #0066cc 0%, #004c99 100%);
}

.dark-mode .custom-price-group .input-group-text {
    background: #2d2d2d;
    border-color: #3d3d3d;
    color: #e9ecef;
}

/* Email Summary Section */
.email-summary-section {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    margin-top: 1.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.email-summary-section .section-header {
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 0.75rem;
}

.email-summary-content {
    margin-top: 1rem;
    background: #f8f9fa;
    border-radius: 6px;
    padding: 1rem;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    white-space: pre-wrap;
    overflow: hidden;
}

.email-summary-placeholder {
    background: #f8f9fa;
    border-radius: 6px;
}

.email-summary-content.has-content {
    border: 1px solid #dee2e6;
}

#copy-summary-btn {
    transition: all 0.2s;
}

#copy-summary-btn:hover {
    transform: translateY(-1px);
}

#copy-summary-btn.copied {
    background-color: #28a745;
    border-color: #28a745;
    color: white;
}

/* Dark mode support */
body.dark-mode .email-summary-section {
    background: var(--bg-secondary);
}

body.dark-mode .email-summary-content {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

body.dark-mode .email-summary-placeholder {
    background: var(--bg-tertiary);
}