/* Main Styles for AMREST HELPER Website */

/* General styles */
body {
    font-family: 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f8f9fa;
}

[data-bs-theme="dark"] {
    color: #e0e0e0;
    background-color: #121212;
}

/* Card styling enhancements */
.card {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 1.5rem;
    border-radius: 0.375rem;
    overflow: hidden;
}

[data-bs-theme="dark"] .card {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    background-color: #2a2a2a !important;
    border-color: #444 !important;
    color: #e0e0e0;
}

.card-header {
    font-weight: 500;
    border-bottom: 1px solid rgba(0, 0, 0, 0.125);
}

[data-bs-theme="dark"] .card-header {
    border-bottom-color: rgba(255, 255, 255, 0.1);
    background-color: #3a3a3a !important;
    color: #e0e0e0;
}

/* Progress bar styling */
.progress {
    background-color: #e9ecef;
    border-radius: 0.25rem;
    overflow: hidden;
}

[data-bs-theme="dark"] .progress {
    background-color: #3a3a3a;
}

.progress-bar {
    transition: width 0.3s ease;
}

/* Form elements */
.form-control:focus {
    box-shadow: 0 0 0 0.2rem rgba(16, 49, 107, 0.2);
    border-color: #10316b;
}

[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select,
[data-bs-theme="dark"] textarea {
    background-color: #2a2a2a;
    color: #e0e0e0;
    border-color: #444;
}

[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
    background-color: #2a2a2a;
    color: #e0e0e0;
    border-color: #80bdff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* Buttons */
.btn-primary {
    background-color: #10316b;
    border-color: #10316b;
    color: #ffffff;
}

.btn-primary:hover {
    background-color: #0d2858;
    border-color: #0d2858;
}

.btn-primary:focus,
.btn-primary.focus {
    background-color: #0d2858;
    border-color: #0d2858;
    box-shadow: 0 0 0 0.2rem rgba(16, 49, 107, 0.25);
}

.btn-primary:active,
.btn-primary.active,
.show > .btn-primary.dropdown-toggle {
    background-color: #0b234d;
    border-color: #0b234d;
}

.btn-primary:disabled,
.btn-primary.disabled {
    background-color: #10316b;
    border-color: #10316b;
    opacity: 0.7;
}

/* Dark mode button variants */
[data-bs-theme="dark"] .btn-outline-light {
    color: #e0e0e0;
    border-color: #e0e0e0;
}

[data-bs-theme="dark"] .btn-outline-light:hover {
    background-color: #e0e0e0;
    color: #121212;
}

[data-bs-theme="dark"] .btn-light {
    background-color: #e0e0e0;
    color: #121212;
}

[data-bs-theme="dark"] .btn-light:hover {
    background-color: #c0c0c0;
}

/* Spinner animations */
.spinner-border {
    display: inline-block;
    width: 2rem;
    height: 2rem;
    vertical-align: -0.125em;
    border: 0.25em solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
}

/* PDF compressor specific styles */
#processing-spinner {
    padding: 1.5rem;
    transition: all 0.3s ease;
}

#upload-progress {
    margin-top: 1rem;
    margin-bottom: 1rem;
}

.alert-info {
    background-color: #d1ecf1;
    border-color: #bee5eb;
    color: #0c5460;
}

[data-bs-theme="dark"] .alert-info {
    background-color: #1a4d5c;
    border-color: #2a6d7c;
    color: #a0d0e0;
}

[data-bs-theme="dark"] .alert {
    background-color: #2a2a2a;
    border-color: #444;
    color: #e0e0e0;
}

[data-bs-theme="dark"] .alert-success {
    background-color: #1a3a1a;
    border-color: #2a5a2a;
}

[data-bs-theme="dark"] .alert-danger {
    background-color: #3a1a1a;
    border-color: #5a2a2a;
}

[data-bs-theme="dark"] .alert-warning {
    background-color: #3a3a1a;
    border-color: #5a5a2a;
}

/* Table styles */
[data-bs-theme="dark"] .table {
    color: #e0e0e0;
    border-color: #444;
}

[data-bs-theme="dark"] .table-hover tbody tr:hover {
    background-color: #2a2a2a;
}

[data-bs-theme="dark"] .table-dark {
    background-color: #1a1a1a;
    color: #e0e0e0;
}

[data-bs-theme="dark"] .table-dark th,
[data-bs-theme="dark"] .table-dark td {
    border-color: #444;
}

/* Modal styles */
[data-bs-theme="dark"] .modal-content {
    background-color: #2a2a2a;
    color: #e0e0e0;
    border-color: #444;
}

[data-bs-theme="dark"] .modal-header {
    border-bottom-color: #444;
}

[data-bs-theme="dark"] .modal-footer {
    border-top-color: #444;
}

[data-bs-theme="dark"] .close,
[data-bs-theme="dark"] .btn-close {
    color: #e0e0e0;
}

/* Badge styles */
[data-bs-theme="dark"] .badge {
    background-color: #dc3545;
    color: #ffffff;
}

[data-bs-theme="dark"] .badge.bg-danger {
    background-color: #dc3545 !important;
    color: #ffffff !important;
}

[data-bs-theme="dark"] .badge.bg-red,
[data-bs-theme="dark"] .badge.bg-warning {
    background-color: #ffc107 !important;
    color: #000000 !important;
}

/* UNIVERSAL DARK MODE FIXES - Override ANY white element */
[data-bs-theme="dark"] {
    --bs-body-bg: #121212;
    --bs-body-color: #e0e0e0;
}

/* Target all container/wrapper divs that might have white backgrounds */
[data-bs-theme="dark"] .container,
[data-bs-theme="dark"] .container-fluid,
[data-bs-theme="dark"] [class*="container"] {
    background-color: transparent;
}

/* Override any element that LOOKS like a white box/card */
[data-bs-theme="dark"] div[style*="background"],
[data-bs-theme="dark"] section[style*="background"],
[data-bs-theme="dark"] article[style*="background"] {
    background-color: #2a2a2a !important;
    color: #e0e0e0 !important;
}

/* Ensure all text inside dark mode is readable - but EXCLUDE navbar and critical elements */
[data-bs-theme="dark"] .card,
[data-bs-theme="dark"] .modal,
[data-bs-theme="dark"] .modal-content,
[data-bs-theme="dark"] .alert,
[data-bs-theme="dark"] .table,
[data-bs-theme="dark"] .btn,
[data-bs-theme="dark"] .dropdown-menu {
    border-color: #444 !important;
}

[data-bs-theme="dark"] h1,
[data-bs-theme="dark"] h2,
[data-bs-theme="dark"] h3,
[data-bs-theme="dark"] h4,
[data-bs-theme="dark"] h5,
[data-bs-theme="dark"] h6,
[data-bs-theme="dark"] p,
[data-bs-theme="dark"] span,
[data-bs-theme="dark"] a,
[data-bs-theme="dark"] li,
[data-bs-theme="dark"] div {
    color: inherit;
}

/* Input group */
[data-bs-theme="dark"] .input-group-text {
    background-color: #3a3a3a;
    border-color: #444;
    color: #e0e0e0;
}

/* All text inputs - force dark background */
[data-bs-theme="dark"] input[type="text"],
[data-bs-theme="dark"] input[type="email"],
[data-bs-theme="dark"] input[type="password"],
[data-bs-theme="dark"] input[type="number"],
[data-bs-theme="dark"] input[type="date"],
[data-bs-theme="dark"] input[type="search"],
[data-bs-theme="dark"] textarea {
    background-color: #2a2a2a !important;
    color: #e0e0e0 !important;
    border-color: #444 !important;
}

[data-bs-theme="dark"] input::placeholder,
[data-bs-theme="dark"] textarea::placeholder {
    color: #888 !important;
}

/* Dropdown menu */
[data-bs-theme="dark"] .dropdown-menu {
    background-color: #2a2a2a;
    border-color: #444;
}

[data-bs-theme="dark"] .dropdown-item {
    color: #e0e0e0;
}

[data-bs-theme="dark"] .dropdown-item:hover,
[data-bs-theme="dark"] .dropdown-item:focus {
    background-color: #3a3a3a;
    color: #e0e0e0;
}

/* Divider */
[data-bs-theme="dark"] .dropdown-divider {
    border-color: #444;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    h3 {
        font-size: 1.5rem;
    }
}

/* ============================================
   COMPREHENSIVE DARK MODE BOOTSTRAP OVERRIDES
   ============================================ */

/* Background and Text utilities */
[data-bs-theme="dark"] .bg-white,
[data-bs-theme="dark"] .bg-light {
    background-color: #2a2a2a !important;
    color: #e0e0e0 !important;
}

[data-bs-theme="dark"] .bg-secondary {
    background-color: #3a3a3a !important;
}

/* Text utilities */
[data-bs-theme="dark"] .text-dark,
[data-bs-theme="dark"] .text-secondary {
    color: #e0e0e0 !important;
}

[data-bs-theme="dark"] .text-body {
    color: #e0e0e0 !important;
}

[data-bs-theme="dark"] .text-reset {
    color: #e0e0e0 !important;
}

/* Border utilities */
[data-bs-theme="dark"] .border-secondary {
    border-color: #444 !important;
}

[data-bs-theme="dark"] .border-light {
    border-color: #444 !important;
}

/* Panels and Well-like containers */
[data-bs-theme="dark"] .well,
[data-bs-theme="dark"] .panel,
[data-bs-theme="dark"] .list-group {
    background-color: #2a2a2a;
    border-color: #444;
    color: #e0e0e0;
}

[data-bs-theme="dark"] .list-group-item {
    background-color: #2a2a2a;
    border-color: #444;
    color: #e0e0e0;
}

[data-bs-theme="dark"] .list-group-item:hover {
    background-color: #3a3a3a;
}

[data-bs-theme="dark"] .list-group-item.active {
    background-color: #1a4b97;
    border-color: #1a4b97;
}

/* Jumbotron */
[data-bs-theme="dark"] .jumbotron {
    background-color: #2a2a2a;
    color: #e0e0e0;
}

/* Pagination */
[data-bs-theme="dark"] .pagination .page-link {
    background-color: #2a2a2a;
    border-color: #444;
    color: #e0e0e0;
}

[data-bs-theme="dark"] .pagination .page-link:hover {
    background-color: #3a3a3a;
    color: #e0e0e0;
}

[data-bs-theme="dark"] .pagination .page-item.active .page-link {
    background-color: #1a4b97;
    border-color: #1a4b97;
}

/* Breadcrumb */
[data-bs-theme="dark"] .breadcrumb {
    background-color: #2a2a2a;
}

[data-bs-theme="dark"] .breadcrumb .breadcrumb-item {
    color: #b0b0b0;
}

[data-bs-theme="dark"] .breadcrumb .breadcrumb-item.active {
    color: #e0e0e0;
}

[data-bs-theme="dark"] .breadcrumb a {
    color: #4a90e2;
}

/* Code blocks */
[data-bs-theme="dark"] code,
[data-bs-theme="dark"] pre {
    background-color: #1a1a1a;
    color: #e0e0e0;
    border-color: #444;
}

/* Spinner */
[data-bs-theme="dark"] .spinner-border,
[data-bs-theme="dark"] .spinner-grow {
    color: #4a90e2;
}

/* Tooltips and Popovers */
[data-bs-theme="dark"] .tooltip-inner {
    background-color: #3a3a3a;
    color: #e0e0e0;
}

[data-bs-theme="dark"] .popover {
    background-color: #2a2a2a;
    border-color: #444;
    color: #e0e0e0;
}

[data-bs-theme="dark"] .popover-header {
    background-color: #3a3a3a;
    border-bottom-color: #444;
}

/* Carousel */
[data-bs-theme="dark"] .carousel-item {
    background-color: #2a2a2a;
}

/* Offcanvas */
[data-bs-theme="dark"] .offcanvas {
    background-color: #2a2a2a;
    color: #e0e0e0;
}

[data-bs-theme="dark"] .offcanvas-header {
    background-color: #3a3a3a;
    border-bottom-color: #444;
}

/* ============================================
   FORCE ALL WHITE BACKGROUNDS TO DARK
   ============================================ */

/* All elements with inline white backgrounds */
[data-bs-theme="dark"] [style*="background: white"],
[data-bs-theme="dark"] [style*="background:white"],
[data-bs-theme="dark"] [style*="background-color: white"],
[data-bs-theme="dark"] [style*="background-color:white"] {
    background-color: #2a2a2a !important;
    color: #e0e0e0 !important;
}

/* Force ALL divs and sections to be dark */
[data-bs-theme="dark"] .bg-body,
[data-bs-theme="dark"] .bg-body-secondary {
    background-color: #2a2a2a !important;
    color: #e0e0e0 !important;
}

/* Section/Panel headers */
[data-bs-theme="dark"] .section-header,
[data-bs-theme="dark"] [class*="header"] {
    background-color: #2a2a2a !important;
    color: #e0e0e0 !important;
    border-color: #444 !important;
}

/* Table cells that might have white background */
[data-bs-theme="dark"] td,
[data-bs-theme="dark"] th {
    background-color: inherit;
    color: #e0e0e0;
    border-color: #444 !important;
}

/* All rows */
[data-bs-theme="dark"] tr {
    background-color: #2a2a2a;
    color: #e0e0e0;
}

[data-bs-theme="dark"] tbody tr {
    background-color: #2a2a2a;
}

[data-bs-theme="dark"] tbody tr:hover {
    background-color: #3a3a3a;
}

/* Stat boxes and metric cards */
[data-bs-theme="dark"] .stat-box,
[data-bs-theme="dark"] .metric-card,
[data-bs-theme="dark"] .summary-card,
[data-bs-theme="dark"] .stat-card {
    background-color: #2a2a2a !important;
    color: #e0e0e0 !important;
    border-color: #444 !important;
}

/* Summary tables */
[data-bs-theme="dark"] .summary-table {
    background-color: #2a2a2a;
    color: #e0e0e0;
}

[data-bs-theme="dark"] .summary-table tbody,
[data-bs-theme="dark"] .summary-table thead {
    background-color: #2a2a2a;
}

/* All rows in summary tables */
[data-bs-theme="dark"] .summary-table tr {
    background-color: #2a2a2a;
    color: #e0e0e0;
}

[data-bs-theme="dark"] .summary-table tbody tr:nth-child(odd) {
    background-color: #2a2a2a;
}

[data-bs-theme="dark"] .summary-table tbody tr:nth-child(even) {
    background-color: #2a2a2a;
}

/* Chart containers */
[data-bs-theme="dark"] .chart-container {
    background-color: #2a2a2a;
    color: #e0e0e0;
}

/* Info boxes */
[data-bs-theme="dark"] .info-box,
[data-bs-theme="dark"] .box,
[data-bs-theme="dark"] .alert {
    background-color: #2a2a2a !important;
    border-color: #444 !important;
    color: #e0e0e0 !important;
}

/* Labels and badges */
[data-bs-theme="dark"] label {
    color: #e0e0e0;
}

[data-bs-theme="dark"] .label,
[data-bs-theme="dark"] span {
    color: #e0e0e0;
}

/* Responsive table wrappers */
[data-bs-theme="dark"] .table-responsive {
    background-color: #2a2a2a;
}

/* Row groups and sections */
[data-bs-theme="dark"] .row-group,
[data-bs-theme="dark"] .content-section {
    background-color: #2a2a2a;
    color: #e0e0e0;
}

/* Tab content */
[data-bs-theme="dark"] .tab-content {
    background-color: #2a2a2a;
    color: #e0e0e0;
}

[data-bs-theme="dark"] .tab-pane {
    background-color: #2a2a2a;
    color: #e0e0e0;
}

/* Nav links in dark mode */
[data-bs-theme="dark"] .nav-link {
    color: #b0b0b0;
}

[data-bs-theme="dark"] .nav-link:hover {
    color: #e0e0e0;
}

[data-bs-theme="dark"] .nav-link.active {
    color: #e0e0e0;
    background-color: #3a3a3a;
}

/* Small text and descriptions */
[data-bs-theme="dark"] small {
    color: #b0b0b0;
}

[data-bs-theme="dark"] .small {
    color: #b0b0b0;
}

/* ============================================
   BREAKDOWN PAGE SPECIFIC DARK MODE FIXES
   ============================================ */

/* Section headers in breakdown */
[data-bs-theme="dark"] .bd-section {
    border-color: #444 !important;
    background-color: #2a2a2a;
}

[data-bs-theme="dark"] .bd-section-header {
    background: #3a3a3a !important;
    border-bottom-color: #444 !important;
    color: #e0e0e0;
}

[data-bs-theme="dark"] .bd-section-body {
    background-color: #2a2a2a;
    color: #e0e0e0;
}

/* Estimate type headers */
[data-bs-theme="dark"] .estimate-type-header {
    background-color: #3a3a3a !important;
    color: #e0e0e0;
    border-bottom-color: #444 !important;
}

[data-bs-theme="dark"] .estimate-type-header:hover {
    background-color: #444 !important;
}

/* Estimate type cards */
[data-bs-theme="dark"] .estimate-type-card {
    background-color: #2a2a2a;
    border-color: #444 !important;
}

/* Breakdown collapse elements */
[data-bs-theme="dark"] a[data-bs-toggle="collapse"] {
    color: #e0e0e0;
}

[data-bs-theme="dark"] a[data-bs-toggle="collapse"]:hover {
    background-color: rgba(255,255,255,0.05);
}

/* ============================================
   MANAGE ESTIMATES PAGE SPECIFIC DARK MODE
   ============================================ */

/* Loading overlay for manage estimates */
[data-bs-theme="dark"] .loading-overlay {
    background-color: rgba(0,0,0,0.7) !important;
}

/* Global search container */
[data-bs-theme="dark"] .global-search-container {
    background-color: #2a2a2a;
}

[data-bs-theme="dark"] .global-search {
    background-color: #3a3a3a !important;
    color: #e0e0e0 !important;
    border-color: #444 !important;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="%23e0e0e0" class="bi bi-search" viewBox="0 0 16 16"><path d="M11.742 10.344a6.5 6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z"/></svg>') !important;
}

/* Stat tiles in manage estimates */
[data-bs-theme="dark"] .stat-tile {
    background-color: #2a2a2a !important;
    color: #e0e0e0 !important;
    border-color: #444 !important;
}

[data-bs-theme="dark"] .stat-tile.clickable {
    cursor: pointer;
}

[data-bs-theme="dark"] .stat-tile.clickable:hover {
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4) !important;
    background-color: #3a3a3a !important;
}

[data-bs-theme="dark"] .stat-tile.clickable:hover .stat-label {
    color: #4a90e2;
}

/* Chart containers */
[data-bs-theme="dark"] .chart-container {
    background-color: #2a2a2a;
    color: #e0e0e0;
}

/* Action buttons */
[data-bs-theme="dark"] .action-btn {
    background-color: #3a3a3a !important;
    color: #e0e0e0 !important;
    border-color: #444 !important;
}

[data-bs-theme="dark"] .action-btn:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.3) !important;
    background-color: #444 !important;
}

/* ============================================
   UNIVERSAL LIGHT BACKGROUND OVERRIDES FOR DARK MODE
   ============================================ */

/* Override all bg-light classes */
[data-bs-theme="dark"] .bg-light {
    background-color: #2a2a2a !important;
    color: #e0e0e0 !important;
}

[data-bs-theme="dark"] .bg-light.card {
    background-color: #2a2a2a !important;
}

/* Handle any element with inline light background styles */
[data-bs-theme="dark"] [style*="background-color: #f8f9fa"],
[data-bs-theme="dark"] [style*="background-color: #f9f9f9"],
[data-bs-theme="dark"] [style*="background-color: #f5f5f5"],
[data-bs-theme="dark"] [style*="background-color: #f0f0f0"],
[data-bs-theme="dark"] [style*="background-color: #e9ecef"],
[data-bs-theme="dark"] [style*="background-color: #e0e0e0"],
[data-bs-theme="dark"] [style*="background: #f8f9fa"],
[data-bs-theme="dark"] [style*="background: #f9f9f9"],
[data-bs-theme="dark"] [style*="background: #f5f5f5"],
[data-bs-theme="dark"] [style*="background: #f0f0f0"],
[data-bs-theme="dark"] [style*="background: #e9ecef"] {
    background-color: #2a2a2a !important;
    color: #e0e0e0 !important;
}

/* Override light inline background-color styles */
[data-bs-theme="dark"] .card.bg-light,
[data-bs-theme="dark"] div.bg-light {
    background-color: #2a2a2a !important;
    color: #e0e0e0 !important;
}

/* Override card bodies with light backgrounds */
[data-bs-theme="dark"] .card-body.bg-light {
    background-color: #2a2a2a !important;
    color: #e0e0e0 !important;
}

/* Form sections with light backgrounds */
[data-bs-theme="dark"] .form-section,
[data-bs-theme="dark"] .calculator-section,
[data-bs-theme="dark"] .results-section {
    background-color: #2a2a2a !important;
    color: #e0e0e0 !important;
}

/* Card bodies - ensure all are dark in dark mode */
[data-bs-theme="dark"] .card-body {
    background-color: #2a2a2a !important;
    color: #e0e0e0 !important;
}

/* Card headers - ensure all are dark */
[data-bs-theme="dark"] .card-header {
    background-color: #3a3a3a !important;
    color: #e0e0e0 !important;
    border-color: #444 !important;
}

/* Ensure form controls are visible in dark mode */
[data-bs-theme="dark"] .form-control {
    background-color: #3a3a3a !important;
    color: #e0e0e0 !important;
    border-color: #444 !important;
}

[data-bs-theme="dark"] .form-control::placeholder {
    color: #b0b0b0 !important;
}

[data-bs-theme="dark"] .form-control:focus {
    background-color: #3a3a3a !important;
    color: #e0e0e0 !important;
    border-color: #4a90e2 !important;
}

/* Shadow SM dark mode */
[data-bs-theme="dark"] .shadow-sm {
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.5) !important;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    h3 {
        font-size: 1.5rem;
    }
}
