/* Desktop Optimization for Leads Management */

/* Defer sidebar width/position/z-index to admin-style.css for consistency across admin pages */

/* Optimize main container height */
.leads-main-container {
    height: calc(100vh - 60px - 130px);
    width: 100%;
    overflow: hidden;
    display: flex;
    flex-wrap: nowrap;
    box-sizing: border-box;
}

/* Optimize panels proportions */
.leads-list-panel {
    width: 30%;
    min-width: 280px;
    max-width: 380px;
    flex-shrink: 0;
}

/* Ghosted scrollbar for leads list */
.leads-list-panel {
    scrollbar-width: thin; /* Firefox */
    scrollbar-color: rgba(128, 128, 128, 0.3) transparent; /* Firefox */
}

.leads-list-panel::-webkit-scrollbar {
    width: 6px;
}

.leads-list-panel::-webkit-scrollbar-track {
    background: transparent;
}

.leads-list-panel::-webkit-scrollbar-thumb {
    background-color: rgba(128, 128, 128, 0.3);
    border-radius: 3px;
}

.leads-list-panel::-webkit-scrollbar-thumb:hover {
    background-color: rgba(128, 128, 128, 0.5);
}

/* Apply scrollbar styling to the leads list body */
#leadsListBody {
    scrollbar-width: thin; /* Firefox */
    scrollbar-color: rgba(128, 128, 128, 0.3) transparent; /* Firefox */
    max-height: calc(100vh - 220px);
    overflow-y: auto;
    padding-bottom: 10px;
}

#leadsListBody::-webkit-scrollbar {
    width: 6px;
}

#leadsListBody::-webkit-scrollbar-track {
    background: transparent;
}

#leadsListBody::-webkit-scrollbar-thumb {
    background-color: rgba(128, 128, 128, 0.3);
    border-radius: 3px;
}

#leadsListBody::-webkit-scrollbar-thumb:hover {
    background-color: rgba(128, 128, 128, 0.5);
}

/* Lead detail panel */
.lead-detail-panel {
    flex: 1;
    min-width: 0; /* Important for flex items to prevent overflow */
    overflow-y: auto;
    padding: 0.5rem;
    scrollbar-width: thin; /* Firefox */
    scrollbar-color: rgba(128, 128, 128, 0.3) transparent; /* Firefox */
}

.lead-detail-panel::-webkit-scrollbar {
    width: 6px;
}

.lead-detail-panel::-webkit-scrollbar-track {
    background: transparent;
}

.lead-detail-panel::-webkit-scrollbar-thumb {
    background-color: rgba(128, 128, 128, 0.3);
    border-radius: 3px;
}

.lead-detail-panel::-webkit-scrollbar-thumb:hover {
    background-color: rgba(128, 128, 128, 0.5);
}

/* Make stats more compact */
.leads-stats-container {
    padding: 0.5rem;
    margin-bottom: 5px;
    overflow-x: auto; /* Allow horizontal scrolling on small screens */
}

/* Hide original stat cards on all screen sizes */
.stat-card, .row.g-2 {
    display: none;
}

/* Desktop stats row */
.mobile-stats-row {
    display: flex;
    justify-content: space-around;
    align-items: center;
    width: 100%;
    padding: 0;
}

/* Desktop stat card */
.mobile-stat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 0;
    width: 25%;
    text-align: center;
}

/* Desktop stat icon */
.mobile-stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
}

.mobile-stat-icon i {
    font-size: 1.2rem;
    color: white;
}

/* Desktop stat value */
.mobile-stat-value {
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1.2;
    margin: 4px 0;
}

/* Desktop stat title */
.mobile-stat-title {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.2;
}

.pipeline-container {
    padding: 0.6rem;
    margin-bottom: 0.5rem;
}

/* Pipeline chart height is now controlled in pipeline-chart.css */
.pipeline-chart {
    margin-top: 0.5rem;
    min-height: 60px;
}

/* Reduce spacing */
.row.mb-4 {
    margin-bottom: 0.75rem !important;
}

/* Responsive adjustments */
@media (max-width: 1200px) {
    .leads-main-container {
        height: calc(100vh - 60px - 120px);
    }
}

@media (max-width: 992px) {
    .leads-main-container {
        height: calc(100vh - 60px - 110px);
    }
    
    .leads-list-panel {
        width: 35%;
        min-width: 260px;
        max-width: 320px;
    }
    
    .lead-detail-panel {
        width: 65%;
    }
}

@media (max-width: 768px) {
    .leads-main-container {
        flex-direction: column;
        height: auto;
        min-height: calc(100vh - 60px - 100px);
    }
    
    .leads-list-panel {
        width: 100%;
        max-width: 100%;
        height: calc(100vh - 60px - 100px);
        overflow-y: auto;
    }
    
    .lead-detail-panel {
        width: 100%;
        max-height: calc(100vh - 60px - 100px);
    }
    
    #leadsListBody {
        max-height: none;
        height: calc(100vh - 60px - 200px);
        overflow-y: auto;
    }
    
    /* Mobile fullscreen mode */
    .leads-fullscreen .leads-main-container {
        width: 100%;
        padding: 0;
        margin-top: 10px;
    }
    
    /* Show lead detail panel on mobile in fullscreen */
    .leads-fullscreen .lead-detail-panel {
        display: block !important;
        position: fixed !important;
        top: 60px !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        height: calc(100vh - 60px) !important;
        max-height: none !important;
        overflow-y: auto !important;
        z-index: 1300 !important;
        background-color: var(--bg-color) !important;
    }
    
    /* Make lead action buttons horizontal on mobile */
    .lead-detail-header {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        padding: 10px;
    }
    
    .lead-actions {
        display: flex;
        flex-direction: row;
        width: 100%;
        margin-top: 10px;
        justify-content: space-around;
    }
    
    .lead-actions .btn {
        margin: 0 5px;
        padding: 8px 12px;
        display: flex;
        align-items: center;
        justify-content: center;
        min-width: 70px;
    }
    
    .lead-actions .btn i {
        margin-right: 5px;
    }
    
    /* Show button labels on mobile */
    .lead-actions .btn::after {
        content: attr(title);
        display: inline;
        margin-left: 5px;
    }
    
    /* Show back button on mobile in fullscreen */
    @media (max-width: 768px) {
        .leads-fullscreen .back-to-list {
            display: inline-block !important;
            margin-bottom: 10px;
        }
    }
    
    /* Hide leads list panel on mobile in fullscreen */
    @media (max-width: 768px) {
        .leads-fullscreen .leads-list-panel {
            display: none;
        }
    }
    
    /* Desktop fullscreen panel heights */
    @media (min-width: 769px) {
        .leads-fullscreen .leads-list-panel {
            height: 40vh;
            max-height: 40vh;
        }
    }
    
    /* Desktop fullscreen lead detail panel height */
    @media (min-width: 769px) {
        .leads-fullscreen .lead-detail-panel {
            height: 60vh;
            max-height: 60vh;
        }
    }
    
    
    /* Fix z-index for fullscreen toggle on mobile */
    .fullscreen-toggle {
        z-index: 1060;
    }
    
    /* Body class for mobile detection no longer required; unified on 60px header height */
}

/* Responsive adjustments for stat cards */
@media (max-width: 992px) {
    .mobile-stat-icon {
        width: 32px;
        height: 32px;
    }
    
    .mobile-stat-icon i {
        font-size: 1rem;
    }
    
    .mobile-stat-value {
        font-size: 1.2rem;
    }
    
    .mobile-stat-title {
        font-size: 0.75rem;
    }
}

@media (max-width: 768px) {
    .mobile-stat-icon {
        width: 28px;
        height: 28px;
    }
    
    .mobile-stat-icon i {
        font-size: 0.9rem;
    }
    
    .mobile-stat-value {
        font-size: 1rem;
    }
    
    .mobile-stat-title {
        font-size: 0.7rem;
    }
}

@media (max-width: 576px) {
    /* Completely redesigned mobile stat cards */
    .leads-stats-container {
        padding: 4px 0;
        margin-bottom: 4px;
        background-color: var(--card-bg);
        border-bottom: 1px solid var(--border-color);
    }
    
    /* Mobile stat card */
    .mobile-stat-card {
        padding: 2px 0;
    }
    
    /* Mobile stat icon */
    .mobile-stat-icon {
        width: 18px;
        height: 18px;
        margin-bottom: 2px;
    }
    
    .mobile-stat-icon i {
        font-size: 0.6rem;
    }
    
    /* Mobile stat value */
    .mobile-stat-value {
        font-size: 0.8rem;
        line-height: 1;
        margin: 1px 0;
    }
    
    /* Mobile stat title */
    .mobile-stat-title {
        font-size: 0.5rem;
        line-height: 1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }
}

.row.g-2 {
    --bs-gutter-y: 0.25rem;
}

/* Optimize for large screens */
@media (min-width: 1600px) {
    .leads-list-panel {
        width: 25%;
    }
    
    .lead-detail-panel {
        width: 75%;
    }
}

/* Optimize for medium screens */
@media (min-width: 992px) and (max-width: 1599px) {
    .leads-list-panel {
        width: 30%;
    }
    
    .lead-detail-panel {
        width: 70%;
    }
}

/* Fullscreen mode toggle */
.fullscreen-toggle {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1000;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    width: 30px;
    height: 30px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.fullscreen-toggle:hover {
    background: var(--primary-color);
    color: #fff;
}

/* Fullscreen mode */
.leads-fullscreen .leads-main-container {
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    bottom: 0;
    height: calc(100vh - 60px);
    z-index: 1000;
    background-color: var(--body-bg);
    width: 100%;
}

.leads-fullscreen .leads-stats-container {
    display: none;
}

/* Adjust panels in fullscreen mode */
.leads-fullscreen .leads-list-panel {
    width: 30%;
    min-width: 280px;
    max-width: 380px;
}

.leads-fullscreen .lead-detail-panel {
    width: calc(100% - 380px);
    flex: 1 1 auto;
}

/* Fix modal and form backgrounds */
.modal-content {
    background-color: var(--card-bg);
    border-color: var(--border-color);
}

.modal-header {
    border-bottom-color: var(--border-color);
}

.modal-footer {
    border-top-color: var(--border-color);
}

.card {
    background-color: var(--card-bg);
}

.form-control, .form-select {
    background-color: var(--primary-bg);
    border-color: var(--border-color);
    color: var(--text-color);
}

/* Fix for pipeline status dropdown */
#leadStatusSelect {
    background-color: var(--primary-bg) !important;
    color: var(--text-color) !important;
    border-color: var(--border-color);
    -webkit-appearance: none !important;
    appearance: none !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath fill='%23d4af37' d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 0.75rem center !important;
    background-size: 16px 12px !important;
    padding-right: 2.5rem !important;
}

#leadStatusSelect:focus,
#leadStatusSelect:active,
#leadStatusSelect option,
#leadStatusSelect option:checked {
    background-color: var(--primary-bg) !important;
    color: var(--text-color) !important;
}

/* Fix for dropdown options */
option {
    background-color: var(--card-bg) !important;
    color: var(--text-color) !important;
}

/* Fix for modal dropdown */
#leadStatus {
    background-color: var(--primary-bg) !important;
    color: var(--text-color) !important;
    border-color: var(--border-color);
}

.form-control:focus, .form-select:focus {
    background-color: var(--primary-bg);
    color: var(--text-color);
    border-color: var(--gold-color);
    box-shadow: 0 0 0 0.25rem rgba(212, 175, 55, 0.25);
}

.form-control::placeholder {
    color: var(--text-muted);
    opacity: 0.7;
}

/* Ghost button style for action buttons */
.btn-ghost {
    background-color: transparent;
    border: none;
    color: #aaa;
    padding: 0.375rem 0.5rem;
    transition: all 0.2s ease;
}

.btn-ghost:hover {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.1);
}

.btn-ghost:focus {
    box-shadow: none;
}

.lead-actions {
    display: flex;
    gap: 0.5rem;
}
