/* =============================================================================
   ADVANCED CHART MODAL - COMPACT ICON-BASED INTERFACE
   Touch-friendly UI for indicator selection with visual feedback
   ============================================================================= */

/* Modal body full-height layout - responsive flex container */
#advancedChartModal .lightweight-modal-body {
    padding: 0;
    height: calc(98vh - 80px);
    max-height: calc(98vh - 80px);
    overflow: hidden !important;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* Ensure modal dialog doesn't overflow */
#advancedChartModal .lightweight-modal-content {
    overflow: hidden !important;
    max-height: 98vh;
    transition: all 0.3s ease;
}

#advancedChartModal .lightweight-modal-dialog {
    overflow: hidden !important;
    max-height: 98vh;
    margin: 0.5rem auto;
    display: flex;
    align-items: center;
}

/* Fullscreen mode */
#advancedChartModal .lightweight-modal-content.fullscreen-mode {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    margin: 0 !important;
    border-radius: 0 !important;
    z-index: 999999 !important;
}

#advancedChartModal .lightweight-modal-content.fullscreen-mode .lightweight-modal-body {
    height: calc(100vh - 80px) !important;
    max-height: calc(100vh - 80px) !important;
}

/* Fullscreen icon button styling */
.fullscreen-icon {
    transition: transform 0.3s ease;
}

/* Category Selector Container - flexible height */
.category-selector-container {
    position: relative;
    background: rgba(255, 255, 255, 0.98);
    border-top: 2px solid #dee2e6;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 10;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    padding: 12px;
    max-height: 35vh;
    overflow-y: auto;
    overflow-x: hidden;
    opacity: 1;
    flex-shrink: 0;
}

.category-selector-container.minimized {
    max-height: 0;
    opacity: 0;
    padding: 0;
    overflow: hidden;
}

/* Minimize Toggle Button in Header */
.minimize-toggle-header {
    background: rgba(255, 255, 255, 0.95);
    color: #c5000b;
    border: 2px solid rgba(255, 255, 255, 1);
    border-radius: 8px;
    padding: 6px 14px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 700;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.minimize-toggle-header:hover {
    background: #ffffff;
    border-color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.minimize-toggle-header i {
    transition: transform 0.3s ease;
}

.category-selector-container.minimized ~ .lightweight-modal-header .minimize-toggle-header i {
    transform: rotate(180deg);
}

/* Category Icon Grid */
.category-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    padding: 0;
    margin-bottom: 10px;
    transition: all 0.3s ease;
}

/* Compact mode - single row with icons only */
.category-grid.compact {
    grid-template-columns: repeat(8, 1fr);
    gap: 6px;
    margin-bottom: 8px;
}

.category-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px 8px;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border: 2px solid #dee2e6;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 80px;
}

/* Compact mode button styling */
.category-grid.compact .category-btn {
    padding: 8px;
    min-height: 40px;
    border-radius: 8px;
}

.category-grid.compact .category-btn span {
    display: none;
}

.category-grid.compact .category-btn i {
    font-size: 1.2rem;
    margin: 0;
}

.category-btn:hover {
    background: linear-gradient(135deg, #e3f2fd 0%, #ffffff 100%);
    border-color: #007bff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.15);
}

.category-btn.active {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    border-color: #0056b3;
    color: white;
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
}

.category-btn i {
    font-size: 1.5rem;
    color: #495057;
    transition: color 0.2s;
}

.category-btn:hover i,
.category-btn.active i {
    color: #007bff;
}

.category-btn.active i {
    color: white;
}

.category-btn span {
    font-size: 0.75rem;
    font-weight: 600;
    color: #495057;
    text-align: center;
    line-height: 1.2;
    transition: color 0.2s;
}

.category-btn:hover span {
    color: #007bff;
}

.category-btn.active span {
    color: white;
}

/* Expandable Indicator Panel - responsive sizing */
.indicator-panel {
    margin-top: 10px;
    padding: 10px;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border: 2px solid #007bff;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.15);
    max-height: 20vh;
    overflow-y: auto;
    overflow-x: hidden;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #dee2e6;
}

.panel-header h6 {
    color: #007bff;
    font-weight: 600;
    font-size: 0.95rem;
}

.btn-collapse {
    background: none;
    border: none;
    color: #6c757d;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.btn-collapse:hover {
    background: rgba(0, 123, 255, 0.1);
    color: #007bff;
}

/* Indicator Options Grid */
.indicator-options-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}

.indicator-option {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 6px;
    background: white;
    border: 2px solid #dee2e6;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 70px;
}

.indicator-option:hover {
    background: rgba(0, 123, 255, 0.05);
    border-color: #007bff;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 123, 255, 0.1);
}

.indicator-option.selected {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    border-color: #28a745;
    color: white;
}

.indicator-option i:first-child {
    font-size: 1.3rem;
    color: #495057;
    transition: color 0.2s;
}

.indicator-option:hover i:first-child {
    color: #007bff;
}

.indicator-option.selected i:first-child {
    color: white;
}

.indicator-option span {
    font-size: 0.7rem;
    font-weight: 600;
    color: #495057;
    text-align: center;
    line-height: 1.2;
    transition: color 0.2s;
}

.indicator-option:hover span {
    color: #007bff;
}

.indicator-option.selected span {
    color: white;
}

.check-mark {
    position: absolute;
    top: 4px;
    right: 4px;
    font-size: 0.9rem !important;
    color: white !important;
}

/* Chart Display Area - Full height */
.advanced-chart-display {
    height: 100%;
    width: 100%;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border: 2px dashed #dee2e6;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

/* Chart container wrapper - flexible height */
.chart-container-wrapper {
    position: relative;
    flex: 1;
    min-height: 250px;
    background: white;
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

#advancedChartCanvas {
    width: 100% !important;
    height: 100% !important;
    display: none;
}

.advanced-chart-display {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.advanced-chart-display:hover {
    border-color: #007bff;
    background: linear-gradient(135deg, #e3f2fd 0%, #ffffff 100%);
}

.advanced-chart-display .text-muted {
    font-size: 1rem;
    color: #6c757d;
}

/* Timeframe Selector */
.timeframe-selector {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 8px;
    justify-content: center;
}

.timeframe-btn {
    padding: 8px 16px;
    border: 2px solid #e5e7eb;
    background: white;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #6b7280;
}

.timeframe-btn:hover {
    border-color: #c5000b;
    color: #c5000b;
    transform: translateY(-1px);
}

.timeframe-btn.active {
    background: #c5000b;
    color: white;
    border-color: #c5000b;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    #advancedChartModal .lightweight-modal-body {
        height: calc(96vh - 70px);
        max-height: calc(96vh - 70px);
    }

    #advancedChartModal .lightweight-modal-dialog {
        margin: 0.25rem auto;
        max-height: 96vh;
    }

    .chart-container-wrapper {
        padding: 10px;
        min-height: 200px;
    }

    .category-selector-container {
        padding: 8px;
        max-height: 30vh;
    }

    .category-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }

    .category-btn {
        padding: 10px 4px;
        min-height: 60px;
    }

    .category-btn i {
        font-size: 1.2rem;
    }

    .category-btn span {
        font-size: 0.65rem;
    }

    .indicator-options-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 5px;
    }

    .indicator-option {
        padding: 8px 3px;
        min-height: 55px;
    }

    .indicator-option i:first-child {
        font-size: 1rem;
    }

    .indicator-option span {
        font-size: 0.6rem;
    }

    .indicator-panel {
        max-height: 15vh;
        padding: 8px;
    }

    .timeframe-selector-header {
        gap: 4px;
    }

    .timeframe-btn {
        padding: 6px 10px;
        font-size: 0.75rem;
    }
}

/* Extra Small Screens */
@media (max-width: 480px) {
    .indicator-options-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .pills-container {
        flex-direction: column;
        align-items: flex-start;
    }
}

.lightweight-modal-header {
    padding: 12px 20px;
    border-bottom: 2px solid #333;
    border-radius: 15px 15px 0 0;
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
}

.lightweight-modal-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
}

.lightweight-modal-close {
    background: #3a3a3a;
    border: 1.5px solid #444;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.lightweight-modal-close:hover {
    background: #c5000b;
    border-color: #c5000b;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(197, 0, 11, 0.4);
}