/* Custom styles for PropSpectra */

/* Print styles */
@media print {
    .navbar,
    .btn,
    footer,
    .breadcrumb {
        display: none !important;
    }

    .card {
        border: 1px solid #dee2e6 !important;
        box-shadow: none !important;
    }

    .analysis-content {
        font-size: 12px;
        line-height: 1.4;
    }
}

/* Analysis content styling */
.analysis-content {
    line-height: 1.7;
    font-size: 14px;
    color: #333;
}

.analysis-content p {
    margin-bottom: 1rem;
}

/* Analysis section header styling */
.ps-section-header {
    background: linear-gradient(135deg, #f8fafc 0%, #eef4ff 100%);
    border-bottom: 1px solid #e2e8f0;
    padding: 1rem 1.25rem;
}

.ps-analysis-heading {
    color: #1e293b;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
}

.ps-analysis-heading svg {
    color: #3b82f6;
}

/* Numbered badge for analysis sections */
.analysis-number-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    background: #3b82f6;
    color: #fff;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 600;
    margin-right: 10px;
    flex-shrink: 0;
}

/* Section subheading in analysis */
.analysis-subheading {
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: flex-start;
}

/* Content items with dash prefix */
.analysis-content-item {
    margin-bottom: 0.3rem;
    padding-left: 0;
    color: #475569;
    line-height: 1.55;
}

.analysis-content-item::before {
    content: "– ";
    color: #64748b;
}

/* Analysis section wrapper */
.analysis-section-block {
    margin-bottom: 1rem;
    padding-bottom: 0.25rem;
}

.analysis-section-block:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
}

/* Recommendations — compact card-style sections */
.recommendations-analysis .analysis-section-block {
    margin-bottom: 0.5rem;
    padding: 0.55rem 0.75rem 0.55rem 0.65rem;
    border-left: 3px solid #3b82f6;
    border-radius: 0 6px 6px 0;
    background: rgba(59, 130, 246, 0.04);
}

.recommendations-analysis .analysis-section-block:last-child {
    margin-bottom: 0;
}

.recommendations-analysis .analysis-content-item {
    margin-bottom: 0.2rem;
    font-size: 0.9rem;
}

.recommendations-analysis .analysis-subheading {
    margin-bottom: 0.3rem;
}

/* Progress bars */
.progress {
    height: 8px;
}

/* Score display improvements */
.display-4 {
    font-weight: 700;
}

/* Card hover effects */
.card {
    transition: transform 0.2s ease-in-out;
}

.card:hover {
    transform: translateY(-2px);
}

/* Table improvements */
.table th {
    font-weight: 600;
    border-top: none;
    font-size: 14px;
}

.table td {
    vertical-align: middle;
    font-size: 14px;
}

/* Badge improvements */
.badge {
    font-size: 11px;
    padding: 0.4em 0.6em;
}

/* Button improvements */
.btn {
    border-radius: 6px;
    font-weight: 500;
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1.1rem;
}

/* Form improvements */
.form-control {
    border-radius: 6px;
}

.form-control:focus {
    border-color: #0d6efd;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.15);
}

/*Navbar improvements */
.navbar-brand {
    font-weight: 600;
    font-size: 1.2rem;
}

/* Hero section */
.bg-primary {
    background: linear-gradient(135deg, #0d6efd 0%, #0b5ed7 100%) !important;
}

/* Feature cards */
.card.border-0 {
    transition: all 0.3s ease;
}

.card.border-0:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.15) !important;
}

/* Census Data Styles */
.census-data-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
    margin: 1rem 0;
}

.census-card {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 1rem;
}

.census-card h4 {
    color: #495057;
    margin: 0 0 0.75rem 0;
    font-size: 1rem;
    font-weight: 600;
}

.metric {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0.5rem 0;
    padding: 0.25rem 0;
    border-bottom: 1px solid #e9ecef;
}

.metric:last-child {
    border-bottom: none;
}

.metric .label {
    font-weight: 500;
    color: #6c757d;
    font-size: 0.9rem;
}

.metric .value {
    font-weight: 600;
    color: #495057;
    font-size: 0.9rem;
}

.insight-box {
    background: #e8f4fd;
    border: 1px solid #b3d9f7;
    border-radius: 6px;
    padding: 1rem;
    margin: 1rem 0;
}

.insight-box h4 {
    color: #0c63e4;
    margin: 0 0 0.5rem 0;
    font-size: 0.95rem;
}

.insight-box p {
    color: #495057;
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.4;
}

.data-source {
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid #e9ecef;
    text-align: center;
}

.data-source small {
    color: #6c757d;
    font-size: 0.8rem;
}

/* Responsive improvements */
@media (max-width: 768px) {
    .display-4 {
        font-size: 2rem;
    }

    .display-5 {
        font-size: 1.8rem;
    }

    .display-6 {
        font-size: 1.5rem;
    }

    .table-responsive {
        font-size: 13px;
    }
}

/* Loading states */
.spinner-border-sm {
    width: 1rem;
    height: 1rem;
}

/* Status badges */
.badge.bg-success {
    background-color: #28a745 !important;
}

.badge.bg-warning {
    background-color: #ffc107 !important;
    color: #000 !important;
}

.badge.bg-danger {
    background-color: #dc3545 !important;
}

/* Image carousel improvements */
.carousel-control-prev,
.carousel-control-next {
    width: 15%;
}

.carousel-control-prev-icon,
.carousel-control-next-icon {
    background-size: 16px 16px;
}

/* Profile image in navbar */
.navbar .rounded-circle {
    border: 2px solid rgba(255,255,255,0.2);
}

/* Footer */
footer {
    margin-top: auto;
}

/* Body layout improvements */
body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
}

/* Global text readability improvements */
.text-muted {
    color: #6c757d !important; /* Darker muted text for better readability on white backgrounds */
}

/* Ensure good contrast on white/light backgrounds */
.lead.text-muted {
    color: #5a6268 !important; /* Even darker for lead text */
}

small.text-muted {
    color: #6c757d !important; /* Consistent darker muted for small text */
}

/* Breadcrumb */
.breadcrumb {
    background: none;
    padding: 0;
    margin-bottom: 1rem;
}

.breadcrumb-item + .breadcrumb-item::before {
    content: "›";
    color: #6c757d;
}

/* Deal Analysis Section Custom Styling */
.card.border-warning {
    border: 1px solid #e8b347 !important;
    box-shadow: 0 4px 12px rgba(232, 179, 71, 0.15);
}

.card-header.bg-warning {
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%) !important;
    border-bottom: 1px solid #d68910;
    color: white !important;
}

.card-header.bg-warning h5 {
    color: white !important;
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* Wholesale Deal Analysis - Enhanced Green */
.bg-success.text-white {
    background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%) !important;
    border: none;
    box-shadow: 0 2px 8px rgba(39, 174, 96, 0.3);
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.text-success.fw-bold {
    color: #27ae60 !important;
}

/* 70% Rule Analysis - Enhanced Blue */
.bg-primary.text-white {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%) !important;
    border: none;
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.3);
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* Analysis Cards Styling */
.card.bg-light {
    background: #f8f9fa !important;
    border: 1px solid #e9ecef;
    transition: all 0.3s ease;
    color: #212529 !important; /* Darker text for better contrast */
}

.card.bg-light:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    transform: translateY(-2px);
}

.card.bg-light .card-header {
    background: white !important;
    border-bottom: 1px solid #e9ecef;
    padding: 0.75rem 1rem;
}

.card.bg-light .card-header h6 {
    font-weight: 600;
    margin: 0;
    color: #495057 !important; /* Darker header text */
}

.card.bg-light .card-body {
    color: #212529 !important; /* Ensure body text is dark */
}

.card.bg-light strong {
    color: #343a40 !important; /* Very dark for emphasis */
}

.card.bg-light .text-muted {
    color: #6c757d !important; /* Darker muted text for better readability */
}

/* Text color improvements - moved to Deal Verdict section below */

/* Button and interactive elements in deal analysis */
.p-2.rounded.text-center {
    font-weight: 600;
    font-size: 1.1rem;
    margin-top: 1rem;
    transition: all 0.3s ease;
}

.p-2.rounded.text-center:hover {
    transform: translateY(-1px);
}

/* Deal Verdict & Next Steps Section Custom Styling */
.card.border-success {
    border: 1px solid #28a745 !important;
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.15);
}

.card-header.bg-success {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%) !important;
    border-bottom: 1px solid #1e7e34;
    color: white !important;
}

.card-header.bg-success h5 {
    color: white !important;
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* Enhanced success text styling */
h6.text-success {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 700;
    font-size: 1.1rem;
}

/* Next Actions card styling */
.col-md-4 .card.bg-light {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%) !important;
    border: 1px solid #dee2e6;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    color: #212529 !important; /* Ensure dark text in Next Actions cards */
}

.col-md-4 .card.bg-light .card-body {
    color: #212529 !important; /* Dark text for card body content */
}

.col-md-4 .card.bg-light ol li {
    color: #343a40 !important; /* Dark text for list items */
}

.col-md-4 .card.bg-light .card-header {
    background: linear-gradient(135deg, #6c757d 0%, #495057 100%) !important;
    color: white !important;
    border-bottom: 1px solid #5a6268;
}

.col-md-4 .card.bg-light .card-header h6 {
    color: white !important;
    font-weight: 600;
    margin: 0;
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* Example URLs and Addresses Section Custom Styling - Properly scoped */
.card.example-urls-card {
    background: linear-gradient(135deg, #6f42c1 0%, #6610f2 100%) !important;
    border: 1px solid #6f42c1;
    box-shadow: 0 4px 12px rgba(111, 66, 193, 0.15);
    color: white !important;
}

.card.example-urls-card .card-body {
    background: transparent;
}

.card.example-urls-card .card-title {
    color: white !important;
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 1rem;
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.card.example-urls-card strong {
    color: #e0cffc !important;
    font-weight: 600;
}

.card.example-urls-card .text-muted {
    color: rgba(255, 255, 255, 0.85) !important;
}

.card.example-urls-card ul li {
    margin-bottom: 0.25rem;
}

/* Flip Percentage Buttons */
.flip-percentage-btn {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    font-weight: 600;
    transition: all 0.2s ease;
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.flip-percentage-btn:hover {
    background-color: rgba(255, 255, 255, 0.3) !important;
    border-color: rgba(255, 255, 255, 0.8);
    transform: translateY(-1px);
}

.flip-percentage-btn.active {
    background-color: rgba(255, 255, 255, 0.95) !important;
    border-color: white;
    color: #198754 !important;
    font-weight: 700;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Novation & Flip Section Custom Styling */
#novation-view .card.border-info {
    border: 1px solid #0dcaf0 !important;
    box-shadow: 0 4px 12px rgba(13, 202, 240, 0.15);
}

#novation-view .card-header.bg-info {
    background: linear-gradient(135deg, #0dcaf0 0%, #0aa2c0 100%) !important;
    border-bottom: 1px solid #0aa2c0;
    color: white !important;
}

#novation-view .card-header.bg-info h6 {
    color: white !important;
    font-weight: 600;
    margin-bottom: 0;
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

#novation-view .card-header.bg-info small {
    color: rgba(255, 255, 255, 0.85) !important;
}

/* Novation MAO Display */
#novation-view .p-2.bg-info.text-white {
    background: linear-gradient(135deg, #0dcaf0 0%, #0aa2c0 100%) !important;
    border: none;
    box-shadow: 0 2px 8px rgba(13, 202, 240, 0.3);
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* Novation Fee Text */
#novation-view .text-info {
    color: #0aa2c0 !important;
    font-weight: 600;
}

/* Novation Discount Slider Styling */
#novation-discount-slider {
    accent-color: #0dcaf0;
}

#novation-discount-display {
    min-width: 50px;
    text-align: center;
}

/* Novation Toggle Button Styling */
.btn-outline-info:not(:disabled):not(.disabled).active,
.btn-outline-info:not(:disabled):not(.disabled):active {
    background-color: #0dcaf0;
    border-color: #0dcaf0;
    color: white;
}

.btn-check:checked + .btn-outline-info {
    background-color: #0dcaf0;
    border-color: #0dcaf0;
    color: white;
}

/* Novation Strategy Alert */
#novation-view .alert-info {
    background: linear-gradient(135deg, #d1ecf1 0%, #bee5eb 100%);
    border: 1px solid #0dcaf0;
    color: #0c5460;
}

#novation-view .alert-info strong {
    color: #0a6c7d;
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */
#ps-toast {
    min-width: 300px;
    max-width: 450px;
    background: linear-gradient(135deg, #28a745 0%, #218838 100%);
    color: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
}

#ps-toast.toast-success {
    background: linear-gradient(135deg, #28a745 0%, #218838 100%);
}

#ps-toast.toast-error {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
}

#ps-toast.toast-warning {
    background: linear-gradient(135deg, #ffc107 0%, #e0a800 100%);
    color: #000;
}

#ps-toast.toast-warning .btn-close {
    filter: invert(0);
}

#ps-toast.toast-info {
    background: linear-gradient(135deg, #17a2b8 0%, #138496 100%);
}

#ps-toast .toast-body {
    font-size: 0.95rem;
    font-weight: 500;
    padding: 1rem 1.25rem;
}

#ps-toast svg {
    width: 20px;
    height: 20px;
}

/* ============================================
   MOBILE-FIRST RESPONSIVE DESIGN
   ============================================ */

/* Touch-friendly tap targets */
@media (max-width: 992px) {
    .btn, .nav-link, .dropdown-item {
        min-height: 44px;
        padding-top: 10px;
        padding-bottom: 10px;
    }
    
    .navbar-nav .nav-link {
        padding: 12px 16px;
    }
}

/* Mobile-specific improvements */
@media (max-width: 768px) {
    /* Navigation */
    .navbar-brand {
        font-size: 1.1rem;
    }
    
    .navbar-brand .badge {
        display: none;
    }
    
    /* Dashboard metric cards */
    .ps-metric-card {
        margin-bottom: 1rem;
        padding: 1rem;
    }
    
    .ps-metric-card h2 {
        font-size: 1.75rem;
    }
    
    .ps-metric-card h6 {
        font-size: 0.85rem;
    }
    
    /* Cards and sections */
    .card-body {
        padding: 1rem;
    }
    
    .card-header {
        padding: 0.75rem 1rem;
    }
    
    /* Tables - horizontal scroll with better UX */
    .table-responsive {
        -webkit-overflow-scrolling: touch;
        margin: 0 -1rem;
        padding: 0 1rem;
    }
    
    .ps-table th, .ps-table td {
        padding: 0.5rem;
        white-space: nowrap;
    }
    
    /* Hide less important columns on mobile */
    .ps-table .hide-mobile {
        display: none;
    }
    
    /* Form inputs - larger touch targets */
    .form-control, .form-select {
        min-height: 44px;
        font-size: 16px; /* Prevents iOS zoom on focus */
    }
    
    /* Buttons - full width on mobile */
    .btn-mobile-full {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    /* Page headers */
    .display-6 {
        font-size: 1.4rem;
    }
    
    h1 {
        font-size: 1.5rem;
    }
    
    h2 {
        font-size: 1.3rem;
    }
    
    h3 {
        font-size: 1.1rem;
    }
    
    /* Container padding */
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    /* Welcome section */
    .my-5 {
        margin-top: 1.5rem !important;
        margin-bottom: 1.5rem !important;
    }
    
    .mb-4 {
        margin-bottom: 1rem !important;
    }
    
    /* Property details grid */
    .row.align-items-center .col-md-6 {
        margin-bottom: 1rem;
    }
    
    /* Footer adjustments */
    footer .col-md-4 {
        text-align: center !important;
        margin-bottom: 1rem;
    }
    
    /* Action buttons in tables */
    .btn-sm {
        padding: 0.4rem 0.6rem;
    }
    
    /* Modal full screen on mobile */
    .modal-dialog {
        margin: 0;
        max-width: 100%;
        height: 100%;
    }
    
    .modal-content {
        height: 100%;
        border-radius: 0;
    }
    
    /* Pagination */
    .pagination {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .page-link {
        padding: 0.5rem 0.75rem;
    }
}

/* Small mobile devices */
@media (max-width: 480px) {
    .display-6 {
        font-size: 1.25rem;
    }
    
    .ps-metric-card h2 {
        font-size: 1.5rem;
    }
    
    .metric-icon {
        width: 40px;
        height: 40px;
    }
    
    .metric-icon i, .metric-icon svg {
        width: 20px !important;
        height: 20px !important;
    }
    
    /* Stack buttons */
    .d-flex.gap-2 {
        flex-direction: column;
    }
    
    .d-flex.gap-2 .btn {
        width: 100%;
    }
}

/* PWA / Standalone app mode */
@media (display-mode: standalone) {
    .navbar {
        padding-top: env(safe-area-inset-top);
    }
    
    body {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* iOS safe areas */
@supports (padding: max(0px)) {
    .navbar {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }
    
    footer {
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Prevent text selection on buttons */
.btn, .nav-link {
    -webkit-user-select: none;
    user-select: none;
}

/* Active states for touch */
.btn:active, .nav-link:active, .ps-metric-card:active {
    transform: scale(0.98);
    transition: transform 0.1s ease;
}

/* Disable hover effects on touch devices */
@media (hover: none) {
    .btn:hover, .nav-link:hover {
        transform: none;
    }
}

.ps-term-tip {
    cursor: help;
    position: relative;
}
.ps-term-tip i {
    transition: opacity 0.2s;
}
.ps-term-tip:hover i {
    opacity: 1 !important;
}
.ps-term-popup {
    position: absolute;
    z-index: 1060;
    max-width: 260px;
    padding: 10px 14px;
    font-size: 0.82rem;
    font-weight: 400;
    line-height: 1.45;
    color: #fff;
    background: rgba(30, 30, 40, 0.95);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.18);
    pointer-events: none;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.18s, transform 0.18s;
    white-space: normal;
    text-align: left;
    left: 50%;
    translate: -50% 0;
    top: calc(100% + 8px);
}
.ps-term-popup.ps-term-visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}
.ps-term-popup::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 50%;
    translate: -50% 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 6px solid rgba(30, 30, 40, 0.95);
}

.report-tab-bar {
    position: sticky;
    top: 0;
    z-index: 1020;
    background: var(--ps-surface, #fff);
    padding: 12px 0 0;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--ps-border, #dee2e6);
}
.report-tabs {
    display: flex;
    gap: 0;
    overflow-x: auto;
    scrollbar-width: none;
}
.report-tabs::-webkit-scrollbar {
    display: none;
}
.report-tab {
    flex: 1;
    min-width: 0;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    padding: 10px 16px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s;
    color: var(--ps-text-muted, #6c757d);
}
.report-tab:hover {
    background: var(--ps-surface-2, #f8f9fa);
}
.report-tab.active {
    color: var(--ps-brand-blue-1, #0d6efd);
    border-bottom-color: var(--ps-brand-blue-1, #0d6efd);
}
.report-tab-num {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    background: var(--ps-surface-2, #e9ecef);
    color: var(--ps-text-muted, #6c757d);
    transition: all 0.25s;
}
.report-tab.active .report-tab-num {
    background: var(--ps-brand-blue-1, #0d6efd);
    color: #fff;
}
.report-tab-text {
    text-align: left;
}
.report-tab-label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    line-height: 1.3;
}
.report-tab-sub {
    display: block;
    font-size: 0.72rem;
    font-weight: 400;
    opacity: 0.7;
    margin-top: 2px;
}
.report-tab-pane {
    display: none;
}
.report-tab-pane.active {
    display: block;
}

@media print {
    .report-tab-bar {
        display: none !important;
    }
    .report-tab-pane {
        display: block !important;
    }
}

@media (max-width: 576px) {
    .report-tab-label {
        font-size: 0.78rem;
    }
    .report-tab-sub {
        font-size: 0.65rem;
    }
    .report-tab {
        padding: 8px 8px 10px;
    }
    .report-tab-num {
        width: 24px;
        height: 24px;
        font-size: 0.72rem;
    }
}