/* Building Highlights in Property Summary */
.building-highlights {
    margin-top: 8px;
}

.building-highlight-badges {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.highlight-badge {
    background: linear-gradient(135deg, #e8f5e8, #f0f8ff);
    border: 1px solid #4caf50;
    border-radius: 12px;
    padding: 4px 8px;
    font-size: 11px;
    font-weight: 500;
    color: #2e7d32;
    white-space: nowrap;
}

/* Enhanced Property Details Styling */
.detail-separator {
    font-weight: bold;
    color: #1976d2;
    margin: 20px 0 10px 0;
    padding: 10px 0;
    border-top: 2px solid #e3f2fd;
    font-size: 14px;
}

.enhanced-detail {
    background: linear-gradient(135deg, #f8f9fa, #e3f2fd);
    border-left: 4px solid #2196f3;
    padding-left: 12px !important;
    margin: 5px 0;
    border-radius: 0 4px 4px 0;
}

.enhanced-detail .detail-label {
    font-weight: 600;
    color: #1976d2;
}

.enhanced-detail .detail-value {
    font-weight: 500;
    color: #333;
}

/* Enhanced Comparable Properties Styling */
.enhanced-analysis-header {
    background: linear-gradient(135deg, #e3f2fd, #f8f9fa);
    border: 1px solid #2196f3;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.enhanced-analysis-header h3 {
    margin: 0 0 15px 0;
    color: #1976d2;
    font-size: 18px;
}

.subject-details {
    margin-bottom: 15px;
    font-size: 14px;
    color: #333;
}

.analysis-stats {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.stat-badge {
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 12px;
    white-space: nowrap;
}

.stat-badge.confidence-high { background: #d4edda; border-color: #c3e6cb; color: #155724; }
.stat-badge.confidence-medium { background: #fff3cd; border-color: #ffeaa7; color: #856404; }
.stat-badge.confidence-low { background: #f8d7da; border-color: #f5c6cb; color: #721c24; }

.enhanced-comp-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    margin-bottom: 15px;
    padding: 15px;
    transition: box-shadow 0.2s;
}

.enhanced-comp-card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.comp-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.comp-header h4 {
    margin: 0;
    color: #333;
    font-size: 16px;
}

.similarity-score {
    text-align: right;
}

.score-label {
    display: block;
    font-size: 11px;
    color: #666;
    margin-bottom: 2px;
}

.score-value {
    display: block;
    font-size: 18px;
    font-weight: bold;
    color: #4caf50;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 14px;
}

.detail-row .label {
    font-weight: 500;
    color: #555;
    min-width: 100px;
}

.detail-row .value {
    text-align: right;
    color: #333;
}

.variance {
    font-size: 12px;
    margin-left: 5px;
}

.variance.positive { color: #f44336; }
.variance.negative { color: #4caf50; }

.comp-btn {
    background: #2196f3;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 8px 16px;
    font-size: 12px;
    cursor: pointer;
    margin-top: 10px;
    transition: background 0.2s;
}

.comp-btn:hover {
    background: #1976d2;
}

/* Enhanced Loading Messages */
.loading-subtext {
    font-size: 12px;
    color: #666;
    margin-top: 5px;
    font-style: italic;
}

/* Modal Display Fix - Override CSS conflicts */

/* Force modal to display when active class is present - HIGHEST PRIORITY */
.modal.active,
#property-modal.active,
div.modal.active {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 99999 !important;
    background: rgba(0, 0, 0, 0.7) !important;
    align-items: center !important;
    justify-content: center !important;
}

/* Override any hidden class when modal is active */
.modal.active.hidden,
#property-modal.active.hidden,
div.modal.active.hidden {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Ensure modal content is visible - WORKING VERSION */
.modal.active .modal-content {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: relative !important;
    background: white !important;
    border-radius: 12px !important;
    width: 800px !important;
    max-width: 90vw !important;
    height: auto !important;
    min-height: 400px !important;
    max-height: 90vh !important;
    margin: 50px auto !important;
    padding: 30px !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5) !important;
    transform: none !important;
    z-index: 10 !important;
    border: none !important;
    font-family: inherit !important;
    color: black !important;
}

/* Ensure ONLY active tab content is visible */
.modal.active .tab-pane {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
}

.modal.active .tab-pane.active {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Force basic-info tab to be visible when active (specific override) */
.modal.active .tab-pane#basic-info.active {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Override any CSS that makes all tab-panes visible */
.modal.active .tab-content .tab-pane:not(.active) {
    display: none !important;
}

/* Force all modal content elements to be visible */
.modal.active #property-summary,
.modal.active #current-value,
.modal.active #prior-value,
.modal.active #value-increase,
.modal.active #property-details-grid,
.modal.active .property-header,
.modal.active .value-comparison,
.modal.active .value-card,
.modal.active .value-amount,
.modal.active .value-label,
.modal.active .detail-item,
.modal.active .detail-label,
.modal.active .detail-value,
.modal.active .tabs,
.modal.active .tab-btn,
.modal.active .tab-content {
    display: block !important;
    visibility: visible !important;
    color: black !important;
    opacity: 1 !important;
}

/* Remove .tab-pane from the above rule since it conflicts with tab switching */

/* Fix value comparison layout */
.modal.active .value-comparison {
    display: flex !important;
    gap: 1rem !important;
    margin: 20px 0 !important;
}

/* Fix value card styling */
.modal.active .value-card {
    display: block !important;
    padding: 15px !important;
    border: 1px solid #ddd !important;
    border-radius: 8px !important;
    background: #f9f9f9 !important;
    min-width: 150px !important;
}

/* Fix tabs layout */
.modal.active .tabs {
    display: flex !important;
    border-bottom: 1px solid #ddd !important;
    margin-bottom: 20px !important;
    flex-wrap: wrap !important;
}

/* Fix tab button styling */
.modal.active .tab-btn {
    display: inline-block !important;
    padding: 10px 20px !important;
    border: none !important;
    background: #f0f0f0 !important;
    cursor: pointer !important;
    margin-right: 5px !important;
    border-radius: 5px 5px 0 0 !important;
}

/* Fix active tab styling */
.modal.active .tab-btn.active {
    background: #007cba !important;
    color: white !important;
}

/* Force property details grid */
.modal.active .property-details-grid {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 1rem !important;
    margin-top: 1rem !important;
}

.modal.active .detail-item {
    display: flex !important;
    justify-content: space-between !important;
    padding: 0.5rem !important;
    border-bottom: 1px solid #eee !important;
}

/* Fix tab content overflow to prevent double scroll bars */
.modal.active .tab-content {
    overflow: visible !important;
    max-height: none !important;
}

.modal.active .tab-pane {
    overflow: visible !important;
    max-height: none !important;
}

/* Ensure chart containers don't cause overflow */
.modal.active .chart-container,
.modal.active .comps-map-container {
    overflow: visible !important;
    max-height: 300px !important;
}

/*
 * ── Z-INDEX STACKING ORDER ──────────────────────────────────────────
 * Property modal (.modal.active)     : 99999
 * Condition modal overlay            : 100000  (modern-ui.css)
 * Payment / paywall modal            : 100002  (payment-modal.html)
 * Service / protest type overlay     : 100004
 * Account creation modal             : 100006
 * Auth (login / register) modals     : 100008
 * HTML report modal                  : 100010  (report-modal.css)
 * Loading overlay                    : 100020
 * Downloading overlay                : 100022
 * ────────────────────────────────────────────────────────────────────
 */

/* Service selection, protest type, and generic overlays */
.modal-overlay {
    z-index: 100004 !important;
}

/* Account creation modal — above service selection */
.account-creation-modal,
.modal-overlay.account-creation-modal {
    z-index: 100006 !important;
}

.account-creation-modal .modal-container {
    z-index: 100007 !important;
}

/* Login / register modals — above account creation */
.auth-modal,
#login-modal,
#register-modal {
    z-index: 100008 !important;
}

.auth-modal .modal-content {
    z-index: 100009 !important;
}

/* Real-time validation styles */
.password-requirements {
    margin-top: 8px;
    font-size: 0.85rem;
}

.requirement {
    display: flex;
    align-items: center;
    margin: 4px 0;
    transition: color 0.3s ease;
}

.requirement i {
    margin-right: 8px;
    width: 12px;
}

.requirement.valid {
    color: #22c55e;
}

.requirement.invalid {
    color: #ef4444;
}

.validation-message {
    margin-top: 6px;
    font-size: 0.85rem;
    font-weight: 500;
}

.validation-message.success {
    color: #22c55e;
}

.validation-message.error {
    color: #ef4444;
}

/* Paywall modal styles */
.paywall-modal {
    z-index: 100002 !important;
}

/* Protest details modal */
.protest-modal,
#protest-details-modal {
    z-index: 100003 !important;
}

/* Loading modals - highest priority (above report modal at 100010) */
.loading-modal {
    z-index: 100020 !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
}

.downloading-modal {
    z-index: 100022 !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
}

.paywall-container {
    max-width: 600px !important;
    width: 90vw !important;
}

.pricing-preview {
    margin: 2rem 0;
}

.price-card {
    border: 2px solid var(--primary-500, #3b82f6);
    border-radius: 12px;
    padding: 2rem;
    background: #f8fafc;
}

.price-card.featured {
    background: linear-gradient(135deg, #f8fafc 0%, #e0f2fe 100%);
    border-color: var(--primary-600, #2563eb);
}

.price-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.price-header h3 {
    color: var(--gray-800, #1f2937);
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.price {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 0.25rem;
    margin: 0.5rem 0;
}

.price .currency {
    font-size: 1.5rem;
    color: var(--primary-600, #2563eb);
    font-weight: 600;
}

.price .amount {
    font-size: 3rem;
    font-weight: 700;
    color: var(--primary-600, #2563eb);
}

.price .period {
    font-size: 1rem;
    color: var(--gray-600, #4b5563);
    margin-left: 0.5rem;
}

.price-features {
    margin-top: 1.5rem;
}

.feature {
    display: flex;
    align-items: center;
    margin: 0.75rem 0;
    gap: 0.75rem;
}

.feature i {
    color: var(--success-500, #22c55e);
    font-size: 1rem;
    width: 16px;
}

.feature span {
    color: var(--gray-700, #374151);
    font-size: 0.95rem;
}

.paywall-actions {
    margin-top: 2rem;
}

.terms-note {
    text-align: center;
    margin-top: 1rem;
    color: var(--gray-500, #6b7280);
}

/* Generated document styles */
.generated-document {
    max-width: 100%;
    margin: 0 auto;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.document-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 20px;
    border-bottom: 2px solid #e5e7eb;
    background: linear-gradient(135deg, #f8fafc 0%, #e0f2fe 100%);
    border-radius: 8px 8px 0 0;
}

.document-title h3 {
    margin: 0 0 10px 0;
    color: #1f2937;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.document-meta {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 0.85rem;
    color: #6b7280;
}

.document-type {
    background: #3b82f6;
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
    font-size: 0.75rem;
    text-transform: uppercase;
    width: fit-content;
}

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

.document-actions .btn {
    padding: 8px 16px;
    font-size: 0.875rem;
    border-radius: 6px;
    border: 1px solid;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.document-actions .btn-primary {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

.document-actions .btn-primary:hover {
    background: #2563eb;
    border-color: #2563eb;
}

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

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

.document-actions .btn-outline {
    background: transparent;
    color: #3b82f6;
    border-color: #3b82f6;
}

.document-actions .btn-outline:hover {
    background: #3b82f6;
    color: white;
}

.document-content {
    padding: 30px 20px;
}

.document-text {
    font-size: 14px;
    line-height: 1.8;
    color: #374151;
    white-space: pre-wrap;
    font-family: 'Georgia', serif;
}

.document-footer {
    padding: 20px;
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
    border-radius: 0 0 8px 8px;
}

.document-disclaimer {
    background: #fef3c7;
    border: 1px solid #f59e0b;
    border-radius: 6px;
    padding: 15px;
    margin-bottom: 20px;
}

.document-disclaimer p {
    margin: 0;
    font-size: 0.875rem;
    color: #92400e;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.document-disclaimer i {
    margin-top: 2px;
    flex-shrink: 0;
}

.next-steps h4 {
    margin: 0 0 10px 0;
    color: #1f2937;
    font-size: 1.1rem;
}

.next-steps ol {
    margin: 0;
    padding-left: 20px;
    color: #4b5563;
}

.next-steps li {
    margin-bottom: 8px;
    line-height: 1.5;
}

/* Responsive design */
@media (max-width: 768px) {
    .document-header {
        flex-direction: column;
        gap: 15px;
    }
    
    .document-actions {
        width: 100%;
        justify-content: flex-start;
    }
    
    .document-content {
        padding: 20px 15px;
    }
    
    .document-footer {
        padding: 15px;
    }
}

/* Generate Evidence Button Styling */
.generate-btn {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 20px;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.generate-btn:hover {
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
}

.generate-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.generate-btn i {
    font-size: 1.1rem;
}

.evidence-placeholder {
    text-align: center;
    padding: 40px 20px;
}

.evidence-placeholder h4 {
    color: #1f2937;
    margin-bottom: 12px;
}

.evidence-placeholder p {
    color: #6b7280;
    margin-bottom: 20px;
    line-height: 1.6;
}

.evidence-placeholder i.fas.fa-file-alt {
    font-size: 3rem;
    color: #9ca3af;
    margin-bottom: 20px;
}

/* Document Preview Modal Styles */
.document-preview-modal {
    max-width: 700px !important;
    width: 90vw !important;
}

.success-message {
    text-align: center;
    padding: 20px;
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    border-radius: 12px;
    margin-bottom: 25px;
    border: 1px solid #22c55e;
}

.success-message i {
    font-size: 3rem;
    color: #16a34a;
    margin-bottom: 15px;
}

.success-message h3 {
    color: #16a34a;
    margin: 0 0 10px 0;
    font-size: 1.5rem;
}

.success-message p {
    color: #15803d;
    margin: 0;
    font-size: 1rem;
}

.document-summary {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 25px;
}

.summary-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #e2e8f0;
}

.summary-item:last-child {
    border-bottom: none;
}

.summary-item strong {
    color: #374151;
    min-width: 120px;
}

.document-actions {
    display: flex;
    gap: 12px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.document-actions .btn {
    flex: 1;
    min-width: 150px;
    padding: 12px 16px;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 8px;
    transition: all 0.2s;
}

.next-steps {
    background: #fef9e7;
    border: 1px solid #f59e0b;
    border-radius: 8px;
    padding: 20px;
}

.next-steps h4 {
    color: #92400e;
    margin: 0 0 15px 0;
    font-size: 1.1rem;
}

.next-steps ol {
    margin: 0;
    padding-left: 20px;
    color: #78350f;
}

.next-steps li {
    margin-bottom: 8px;
    line-height: 1.5;
}

.modal-footer .btn.full-width {
    width: 100%;
    padding: 15px;
    font-size: 1.1rem;
    font-weight: 600;
}

/* Responsive design for document modal */
@media (max-width: 768px) {
    .document-actions {
        flex-direction: column;
    }
    
    .document-actions .btn {
        width: 100%;
        min-width: auto;
    }
    
    .summary-item {
        flex-direction: column;
        gap: 4px;
    }
    
    .summary-item strong {
        min-width: auto;
    }
}

/* Debug styles removed - modal should now work properly */

/* ============================================================
   Mobile overrides — must use !important to beat the rules above
   ============================================================ */
@media (max-width: 768px) {
    /* Modal content: full-width, minimal padding, no top margin */
    .modal.active .modal-content {
        width: 100% !important;
        max-width: calc(100vw - 2rem) !important;
        margin: 0.5rem auto !important;
        padding: 0 !important;
        min-height: 0 !important;
        border-radius: 12px !important;
    }

    /* Value comparison: stack cards vertically */
    .modal.active .value-comparison {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
    }

    /* Value cards: no fixed min-width, compact padding */
    .modal.active .value-card {
        min-width: 0 !important;
        padding: 0.875rem !important;
    }

    /* Property details grid: single column */
    .modal.active .property-details-grid {
        grid-template-columns: 1fr !important;
        gap: 0.5rem !important;
    }

    /* Detail items: stack label over value */
    .modal.active .detail-item {
        display: block !important;
        padding: 0.625rem 0.75rem !important;
    }

    /* Tab buttons: compact so they fit on narrow screens */
    .modal.active .tab-btn {
        padding: 8px 12px !important;
        font-size: 0.8rem !important;
        margin-right: 2px !important;
    }

    /* Modal scroll body: proper padding inside */
    .modal.active .modal-body-scroll {
        padding: 1rem !important;
    }

    /* Property summary: tight */
    .modal.active .property-summary {
        padding: 1rem !important;
        margin-bottom: 0.75rem !important;
    }

    /* Property actions: stack buttons */
    .modal.active .property-actions {
        flex-direction: column !important;
        gap: 0.5rem !important;
    }

    .modal.active .property-actions .btn,
    .modal.active .property-actions button {
        width: 100% !important;
        justify-content: center !important;
    }

    /* Savings hero: compact */
    .modal.active .savings-hero {
        padding: 1rem 1.25rem !important;
    }

    .modal.active .savings-hero-amount {
        font-size: 2rem !important;
    }

    /* Savings stats: 1 column */
    .modal.active .savings-stats {
        grid-template-columns: 1fr !important;
        gap: 0.5rem !important;
    }

    /* Savings CTA: full width */
    .modal.active .savings-cta-btn {
        width: 100% !important;
        justify-content: center !important;
    }

    /* Value amount text: slightly smaller so it fits */
    .modal.active .value-amount {
        font-size: 1.25rem !important;
    }

    /* Modal header: tight */
    .modal.active .modal-header {
        padding: 0.875rem 1rem !important;
    }

    /* Modal title: smaller */
    .modal.active .modal-title,
    .modal.active .modal-header h2 {
        font-size: 1rem !important;
        line-height: 1.3 !important;
    }
}