/* Custom Styles for BuildConnect PHP */

/* Rupee symbol consistency fix */
.rupee,
[data-currency] {
    font-family: 'Segoe UI', 'Segoe UI Symbol', Arial, sans-serif;
    font-weight: inherit; /* Match the surrounding element's weight */
    font-size: inherit;
}

.budget-icon {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    width: 15px;
    height: 15px;
    color: #10B981;
    pointer-events: none;
}

.budget-icon svg {
    stroke-width: 1.7px;
}

* {
    scroll-behavior: smooth;
}

body {
    font-family: 'Poppins', sans-serif;
    color: #1f2937;
}

html {
    scroll-behavior: smooth;
}

/* Animation Classes */
[data-animate] {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

[data-animate].animate-in {
    opacity: 1;
    transform: translateY(0);
}

/* Staggered animation delays */
[data-animate][data-delay="1"] {
    transition-delay: 0.1s;
}

[data-animate][data-delay="2"] {
    transition-delay: 0.2s;
}

[data-animate][data-delay="3"] {
    transition-delay: 0.3s;
}

[data-animate][data-delay="4"] {
    transition-delay: 0.4s;
}

[data-animate][data-delay="5"] {
    transition-delay: 0.5s;
}

/* Fade in animation for tab content */
.fade-in {
    animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Hide scrollbar for carousel */
.scrollbar-hide {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.scrollbar-hide::-webkit-scrollbar {
    display: none;
}

/* Smooth transitions for interactive elements */
button, a {
    transition: all 0.2s ease-out;
}

/* Hover scale effect */
.hover-scale:hover {
    transform: scale(1.04);
}

/* Hover lift effect */
.hover-lift:hover {
    transform: translateY(-6px);
}

/* Active nav link styling */
.nav-link.active {
    color: #F97316;
    font-weight: 600;
}

/* Mobile menu transition */
.mobile-menu {
    transition: max-height 0.3s ease-out, opacity 0.3s ease-out;
}

/* Line clamp utilities (for older browsers) */
.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Backdrop blur fallback */
@supports not (backdrop-filter: blur(10px)) {
    .backdrop-blur-sm {
        background-color: rgba(255, 255, 255, 0.95);
    }
}

/* Focus styles for accessibility */
button:focus-visible,
a:focus-visible {
    outline: 2px solid #F97316;
    outline-offset: 2px;
}

/* Screen reader only class */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

.sr-only:focus {
    position: static;
    width: auto;
    height: auto;
    padding: 0.5rem 1rem;
    margin: 0;
    overflow: visible;
    clip: auto;
    white-space: normal;
}

select,
select option,
select optgroup {
    font-family: 'Segoe UI', 'Segoe UI Symbol', Arial, sans-serif;
    font-weight: 500;
}

/* Fix for existing bottom sheets (kyc, leads, mappings, etc.) */
@media (max-width: 768px) {
    /* Hide desktop tables */
    .hidden.md\:block,
    .desktop-table-wrapper {
        display: none !important;
    }
    
    /* Show mobile cards */
    .block.md\:hidden,
    .mobile-table-wrapper {
        display: block !important;
    }
    
    /* Ensure all bottom sheets work */
    #req-panel, #kyc-panel, #lead-panel, #mapping-panel, #quote-panel, #payment-sheet, #provider-panel {
        z-index: 210 !important;
    }
    
    #req-panel-overlay, #kyc-panel-overlay, #lead-panel-overlay, #mapping-panel-overlay, #quote-panel-overlay, #payment-overlay, #provider-overlay {
        z-index: 209 !important;
    }
}

/* Mobile card styles */
.mobile-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.mobile-card:hover {
    background: #f9fafb;
}

.mobile-card:active {
    background: #f3f4f6;
}

.mobile-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.mobile-card-content {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mobile-card-item {
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.mobile-card-label {
    font-size: 11px;
    font-weight: 700;
    color: #9ca3af;
    text-transform: uppercase;
}

.mobile-card-value {
    font-size: 12px;
    color: #1f2937;
    font-weight: 600;
    text-align: right;
}

/* ================ RESPONSIVE STYLES ================ */

/* Prevent horizontal scroll on mobile */
html, body {
    overflow-x: hidden;
}

/* Header/user name truncation utility to prevent overflow in small viewports */
.header-username {
    display: inline-block;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
}

@media (max-width: 640px) {
    .header-username { max-width: 120px; }
}

/* Cover larger mobile/tablet widths (e.g. some Samsung devices, tablets) so header names are hidden
   when the layout switches to mobile-style topbar (matches JS/CSS breakpoints used elsewhere). */
@media (max-width: 1023px) {
    .header-username { display: none !important; }
    /* Slightly tighten header action spacing to avoid overflow */
    .dashboard-header-actions { gap: 8px !important; }
    .dashboard-header-brand { gap: 8px !important; }
}

/* Offset the fixed top navbar so public page content is not hidden behind it */
#navbar + main,
#navbar + section,
#navbar + div {
    padding-top: 5rem;
}

body.pt-20 #navbar + main,
body.pt-20 #navbar + section,
body.pt-20 #navbar + div {
    padding-top: 0;
}

/* Mobile Card View for Tables */
.mobile-table-wrapper {
    display: none;
}

@media (max-width: 768px) {
    /* Hide desktop tables on mobile */
    .desktop-table-wrapper {
        display: none !important;
    }
    
    /* Show mobile card view */
    .mobile-table-wrapper {
        display: block !important;
    }
    
    /* Mobile bottom sheet/modal styles */
    .mobile-bottom-sheet {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 1000;
        background: #fff;
        border-radius: 20px 20px 0 0;
        max-height: 88vh;
        overflow-y: auto;
        box-shadow: 0 -8px 32px rgba(0,0,0,0.18);
        transform: translateY(100%);
        transition: transform 0.3s ease;
    }
    
    .mobile-bottom-sheet.open {
        transform: translateY(0);
    }
    
    .mobile-overlay {
        display: none;
        position: fixed;
        inset: 0;
        z-index: 999;
        background: rgba(0,0,0,0.5);
    }
    
    .mobile-overlay.open {
        display: block;
    }

    /* Profile upload preview on mobile */
    #profile-photo-preview {
        width: 5rem !important;
        height: 5rem !important;
        min-width: 5rem !important;
        min-height: 5rem !important;
        background: #f8fafc !important;
    }

    #profile-photo-preview i[data-lucide="camera"],
    #profile-photo-preview .lucide,
    #profile-photo-preview svg,
    #profile-photo-preview img {
        width: 2rem !important;
        height: 2rem !important;
        min-width: 2rem !important;
        min-height: 2rem !important;
        color: #4b5563 !important;
        stroke: #4b5563 !important;
        fill: none !important;
        opacity: 1 !important;
        display: block !important;
    }

    #profile-photo-preview .lucide {
        stroke-width: 1.8 !important;
    }

    #btn-add-photo,
    #btn-delete-photo {
        width: 2.25rem !important;
        height: 2.25rem !important;
        right: -0.5rem !important;
        bottom: -0.5rem !important;
    }

    #btn-add-photo i,
    #btn-delete-photo i,
    #btn-add-photo .lucide,
    #btn-delete-photo .lucide {
        width: 1.1rem !important;
        height: 1.1rem !important;
    }
}

#profile-photo-preview i[data-lucide="camera"],
#profile-photo-preview .lucide,
#profile-photo-preview svg,
#profile-photo-preview img {
    width: 2rem !important;
    height: 2rem !important;
    min-width: 2rem !important;
    min-height: 2rem !important;
    color: #4b5563 !important;
    stroke: #4b5563 !important;
    fill: none !important;
    opacity: 1 !important;
    display: block !important;
}

#profile-photo-preview {
    background: #f8fafc !important;
}

/* Responsive Modals */
@media (max-width: 768px) {
    /* Make all modals full width on mobile with max height */
    [id*="modal"]:not(.hidden) .bg-white,
    [id*="Modal"]:not(.hidden) .bg-white {
        width: 95% !important;
        max-width: 95% !important;
        max-height: 90vh !important;
        overflow-y: auto !important;
        border-radius: 16px !important;
    }
    
    /* Ensure modal content is scrollable */
    [id*="modal"] .overflow-y-auto,
    [id*="Modal"] .overflow-y-auto {
        max-height: calc(80vh - 100px) !important;
    }
    
    /* Stack buttons vertically in modals */
    [id*="modal"] .flex.justify-end.gap-3,
    [id*="Modal"] .flex.justify-end.gap-3 {
        flex-direction: column !important;
        width: 100% !important;
    }
    
    [id*="modal"] .flex.justify-end.gap-3 button,
    [id*="Modal"] .flex.justify-end.gap-3 button {
        width: 100% !important;
    }
}

/* Filter bars - stack vertically on mobile */
@media (max-width: 768px) {
    .filter-bar {
        flex-direction: column !important;
        align-items: stretch !important;
    }
    
    .filter-bar > * {
        width: 100% !important;
    }
}

/* Mobile Card Styles */
.mobile-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.mobile-card:hover {
    background-color: #f9fafb;
}

.mobile-card .mobile-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.mobile-card .mobile-card-content {
    display: grid;
    gap: 8px;
    margin-top: 12px;
}

.mobile-card .mobile-card-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mobile-card .mobile-card-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: #9ca3af;
}

.mobile-card .mobile-card-value {
    font-size: 13px;
    color: #374151;
    font-weight: 500;
}

.mobile-card .mobile-card-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.mobile-card .mobile-card-actions button,
.mobile-card .mobile-card-actions a {
    flex: 1;
    min-width: 0;
}

/* Styles for existing bottom sheets (kyc, leads, mappings, etc.) */
@media (max-width: 768px) {
    /* Ensure all existing bottom sheets animate and are styled correctly */
    #req-panel,
    #kyc-panel,
    #lead-panel,
    #mapping-panel,
    #quote-panel,
    #payment-sheet,
    #provider-panel {
        transform: translateY(100%) !important;
    }
    
    /* Show sheet when it has display: block */
    #req-panel[style*="display: block"],
    #kyc-panel[style*="display: block"],
    #lead-panel[style*="display: block"],
    #mapping-panel[style*="display: block"],
    #quote-panel[style*="display: block"],
    #payment-sheet[style*="display: block"],
    #provider-panel[style*="display: block"] {
        transform: translateY(0) !important;
    }
}

