/* ============================================
   TECHNICAL ANALYSIS PAGE - STYLES
   ============================================ */

.technical-analysis-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* ============================================
   HEADER SECTION
   ============================================ */

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--primary-color);
}

.page-header h1 {
    font-size: 2rem;
    color: var(--text-color);
    margin: 0;
}

.header-actions {
    display: flex;
    gap: 15px;
}

/* ============================================
   ANALYSIS FORM
   ============================================ */

/* Colonne Actions - alignement spécifique */
.data-table td.actions {
    vertical-align: middle;
    white-space: nowrap;
}

/* Boutons dans la colonne Actions */
.data-table td.actions .button {
    margin: 0 2px;
}

/* Pour les colonnes avec plusieurs lignes (nom + symbole) */
.data-table td > strong {
    display: block;
    margin-bottom: 4px;
}

.data-table td > .text-small {
    display: block;
    margin-top: 4px;
}

.data-table tbody td {
    vertical-align: middle;
    height: inherit;
}

/* S'assurer que les bordures s'alignent correctement */
.data-table {
    border-collapse: collapse;
}

.data-table tbody tr {
    border-bottom: 1px solid #e5e7eb;
}

/* Supprimer les bordures individuelles des cellules si elles existent */
.data-table td {
    border-bottom: none;
}

.analysis-form {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 25px;
    margin-bottom: 30px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.form-section {
    margin-bottom: 25px;
}

.form-section:last-child {
    margin-bottom: 0;
}

.form-section h3 {
    font-size: 1.2rem;
    color: var(--text-color);
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 15px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.form-group input,
.form-group select {
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: var(--bg-color);
    color: var(--text-color);
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.form-group input[readonly] {
    background-color: var(--bg-light);
    cursor: not-allowed;
    color: var(--text-muted);
}

.form-group small {
    margin-top: 5px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ============================================
   FETCH PRICES BUTTON & STATUS
   ============================================ */

.form-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.form-section-header h4 {
    margin: 0;
}

.fetch-prices-btn {
    font-size: 12px !important;
    padding: 6px 12px !important;
    white-space: nowrap;
}

.fetch-status {
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 8px;
}

.fetch-loading {
    color: #2563eb;
}

.fetch-success {
    color: #166534;
}

.fetch-warning {
    color: #854d0e;
}

.fetch-error {
    color: #991b1b;
}

/* ============================================
   PRICE INPUTS SECTION
   ============================================ */

.price-inputs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.price-input-group {
    background: var(--bg-light);
    padding: 15px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.price-input-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-color);
}

.price-input-group .date-info {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.price-input-group input {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
    background: white;
}

/* ============================================
   LIVE RESULTS SECTION
   ============================================ */

.live-results {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 25px;
    margin-bottom: 30px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.live-results h3 {
    font-size: 1.2rem;
    color: var(--text-color);
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.result-card {
    background: var(--bg-light);
    padding: 20px;
    border-radius: 8px;
    border-left: 4px solid var(--border-color);
    transition: all 0.3s ease;
}

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

.result-card h4 {
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 10px;
    font-weight: 500;
}

.result-card .value {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 5px;
}

.result-card .trend {
    font-size: 0.9rem;
    font-weight: 500;
}

/* Result Card Colors */
.result-card.positive {
    border-left-color: var(--success-color);
}

.result-card.positive .value {
    color: var(--success-color);
}

.result-card.negative {
    border-left-color: var(--danger-color);
}

.result-card.negative .value {
    color: var(--danger-color);
}

.result-card.neutral {
    border-left-color: var(--warning-color);
}

.result-card.neutral .value {
    color: var(--warning-color);
}

/* ============================================
   SIGNAL DISPLAY
   ============================================ */

.signal-card {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 25px;
    margin-bottom: 30px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.signal-card h3 {
    font-size: 1.2rem;
    color: var(--text-color);
    margin-bottom: 20px;
}

.signal-display {
    display: inline-block;
    padding: 20px 40px;
    border-radius: 8px;
    font-size: 1.5rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.signal-display.buy {
    background-color: rgba(76, 175, 80, 0.1);
    color: var(--success-color);
    border: 2px solid var(--success-color);
}

.signal-display.sell {
    background-color: rgba(244, 67, 54, 0.1);
    color: var(--danger-color);
    border: 2px solid var(--danger-color);
}

.signal-display.hold {
    background-color: rgba(255, 152, 0, 0.1);
    color: var(--warning-color);
    border: 2px solid var(--warning-color);
}

.confidence-level {
    margin-top: 15px;
    font-size: 1rem;
    color: var(--text-muted);
}

.confidence-bar {
    width: 100%;
    height: 8px;
    background-color: var(--bg-light);
    border-radius: 4px;
    margin-top: 10px;
    overflow: hidden;
}

.confidence-fill {
    height: 100%;
    transition: width 0.5s ease;
    border-radius: 4px;
}

.confidence-fill.high {
    background-color: var(--success-color);
}

.confidence-fill.medium {
    background-color: var(--warning-color);
}

.confidence-fill.low {
    background-color: var(--danger-color);
}

/* ============================================
   FILTERS SECTION
   ============================================ */

.filters-bar .form-label {
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
    display: block;
}

.filters-bar .button-group {
    display: flex;
    gap: 0.5rem;
}

/* ============================================
   ALERTS SECTION
   ============================================ */

.alerts-section {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 25px;
    margin-bottom: 30px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.alerts-section h3 {
    font-size: 1.2rem;
    color: var(--text-color);
    margin-bottom: 15px;
}

.alert-item {
    display: flex;
    align-items: flex-start;
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 6px;
    border-left: 4px solid;
}

.alert-item:last-child {
    margin-bottom: 0;
}

.alert-item.warning {
    background-color: rgba(255, 152, 0, 0.1);
    border-left-color: var(--warning-color);
}

.alert-item.danger {
    background-color: rgba(244, 67, 54, 0.1);
    border-left-color: var(--danger-color);
}

.alert-item.info {
    background-color: rgba(33, 150, 243, 0.1);
    border-left-color: var(--info-color);
}

.alert-icon {
    font-size: 1.5rem;
    margin-right: 15px;
    flex-shrink: 0;
}

.alert-content {
    flex-grow: 1;
}

.alert-content strong {
    display: block;
    margin-bottom: 5px;
    font-size: 1rem;
}

.alert-content p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-color);
}

/* ============================================
   HISTORY TABLE
   ============================================ */

/* Modal Historique */
.history-modal-content {
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding: 20px;
    max-height: 75vh;
    overflow-y: auto;
}

/* Graphique principal */
.chart-main {
    background: #f9fafb;
    border-radius: 8px;
    padding: 16px;
    height: 320px;
}

.chart-main h3 {
    margin: 0 0 12px 0;
    font-size: 16px;
    color: #374151;
}

.chart-main canvas {
    max-height: 260px;
}

/* Heatmap */
.chart-heatmap {
    background: #f9fafb;
    border-radius: 8px;
    padding: 16px;
}

.chart-heatmap h3 {
    margin: 0 0 12px 0;
    font-size: 16px;
    color: #374151;
}

.heatmap-grid {
    display: grid;
    gap: 4px;
    font-size: 13px;
}

.heatmap-label {
    padding: 12px 8px;
    text-align: right;
    font-weight: 600;
    font-size: 12px;
    color: #374151;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    background: #f9fafb;
    border-radius: 4px;
}

.heatmap-header {
    padding: 10px 4px;
    text-align: center;
    font-weight: 600;
    font-size: 11px;
    color: #374151;
    background: #e5e7eb;
    border-radius: 4px;
}

.heatmap-cell {
    padding: 12px 8px;
    min-height: 50px;
    text-align: center;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.heatmap-cell:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    z-index: 10;
}

.heatmap-cell.highlighted {
    box-shadow: inset 0 0 0 3px #3b82f6;
    transform: scale(1.05);
}

.heatmap-cell.green {
    background: #dcfce7;
    color: #166534;
}

.heatmap-cell.yellow {
    background: #fef3c7;
    color: #854d0e;
}

.heatmap-cell.red {
    background: #fee2e2;
    color: #991b1b;
}

.heatmap-cell.dark-green {
    background: #059669;
    color: white;
}

.heatmap-cell.dark-red {
    background: #dc2626;
    color: white;
}

.heatmap-separator {
    border-bottom: 2px solid #d1d5db;
    grid-column: 1 / -1;
    margin: 4px 0;
}

.heatmap-legend {
    display: flex;
    gap: 16px;
    margin-top: 12px;
    padding: 8px;
    background: white;
    border-radius: 4px;
    font-size: 12px;
}

.legend-indicator {
    font-size: 16px;
    margin-right: 4px;
}

/* Tableau */
.table-section {
    background: white;
    border-radius: 8px;
    padding: 16px;
}

.table-section h3 {
    margin: 0 0 12px 0;
    font-size: 16px;
    color: #374151;
}

.table-container {
    overflow-x: auto;
}

#history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

#history-table th {
    background: #f3f4f6;
    padding: 12px 8px;
    text-align: left;
    font-weight: 600;
    color: #374151;
    border-bottom: 2px solid #d1d5db;
}

#history-table td {
    padding: 12px 8px;
    border-bottom: 1px solid #e5e7eb;
}

#history-table tbody tr {
    cursor: pointer;
    transition: background-color 0.2s;
}

#history-table tbody tr:hover {
    background-color: #f9fafb;
}

#history-table tbody tr.highlighted {
    background-color: #dbeafe;
    box-shadow: inset 0 0 0 2px #3b82f6;
}

/* Badges RSI avec 5 niveaux */
/* Badges SMA 3 */
.sma3-badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.sma3-buy, .sma3-buy_open, .sma3-buy_cross {
    background: #dcfce7;
    color: #166534;
}

.sma3-hold {
    background: #fef3c7;
    color: #854d0e;
}

.sma3-sell, .sma3-sell_open, .sma3-sell_cross {
    background: #fee2e2;
    color: #991b1b;
}

/* Calculateur d'écart SMA 3 */
.sma3-calculator {
    margin-top: 12px;
    padding: 12px;
    background: var(--gray-50, #f9fafb);
    border-radius: 8px;
    border: 1px dashed var(--border-color, #d1d5db);
}

.sma3-gap-display {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    padding: 8px 12px;
    background: white;
    border-radius: 6px;
    font-size: 14px;
}

.sma3-gap-label {
    font-weight: 600;
    color: #374151;
}

.sma3-gap-value {
    font-weight: 700;
    font-size: 16px;
}

.sma3-gap-value.positive {
    color: #dc2626;
}

.sma3-gap-value.negative {
    color: #16a34a;
}

.sma3-gap-value.neutral {
    color: #854d0e;
}

.sma3-gap-interpretation {
    font-size: 12px;
    color: #6b7280;
    font-style: italic;
}

.actions {
    display: flex;
    gap: 8px;
}

.btn-icon {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.btn-icon:hover {
    background: #f3f4f6;
}

.btn-icon.btn-danger:hover {
    background: #fee2e2;
}

.no-data {
    text-align: center;
    padding: 40px;
    color: #6b7280;
}

/* Responsive */
@media (max-width: 768px) {
    .history-modal-content {
        padding: 12px;
        gap: 16px;
    }
    
    .chart-main {
        height: 250px;
    }
    
    .heatmap-grid {
        font-size: 11px;
        grid-template-columns: 60px repeat(auto-fit, minmax(50px, 1fr));
    }
    
    .heatmap-cell {
        padding: 6px 2px;
        font-size: 14px;
    }
}

/* Modal Historique */
.history-modal-content {
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding: 20px;
    max-height: 75vh;
    overflow-y: auto;
}

.modal-content.large {
    max-width: 1200px;
    width: 95%;
}

/* Graphique principal */
.chart-main {
    background: #f9fafb;
    border-radius: 8px;
    padding: 16px;
    height: 320px;
}

.chart-main h3 {
    margin: 0 0 12px 0;
    font-size: 16px;
    color: #374151;
}

.chart-main canvas {
    max-height: 260px;
}

/* Heatmap */
.chart-heatmap {
    background: #f9fafb;
    border-radius: 8px;
    padding: 16px;
}

.chart-heatmap h3 {
    margin: 0 0 12px 0;
    font-size: 16px;
    color: #374151;
}

.heatmap-grid {
    display: grid;
    grid-template-columns: 80px repeat(auto-fit, minmax(60px, 1fr));
    gap: 4px;
    font-size: 13px;
}

.heatmap-label {
    padding: 8px 4px;
    text-align: right;
    font-weight: 500;
    color: #6b7280;
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.heatmap-header {
    padding: 8px;
    text-align: center;
    font-weight: 600;
    color: #374151;
    background: #e5e7eb;
    border-radius: 4px;
}

.heatmap-cell {
    padding: 10px 4px;
    text-align: center;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.heatmap-cell:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    z-index: 10;
}

.heatmap-cell.highlighted {
    box-shadow: inset 0 0 0 3px #3b82f6;
    transform: scale(1.05);
}

.heatmap-cell.green {
    background: #dcfce7;
    color: #166534;
}

.heatmap-cell.yellow {
    background: #fef3c7;
    color: #854d0e;
}

.heatmap-cell.red {
    background: #fee2e2;
    color: #991b1b;
}

.heatmap-cell.gray {
    background: #f3f4f6;
    color: #9ca3af;
}

.heatmap-separator {
    border-bottom: 2px solid #d1d5db;
    grid-column: 1 / -1;
    margin: 4px 0;
}

.heatmap-legend {
    display: flex;
    gap: 16px;
    margin-top: 12px;
    padding: 8px;
    background: white;
    border-radius: 4px;
    font-size: 12px;
}

.legend-indicator {
    font-size: 16px;
    margin-right: 4px;
}

/* Tableau */
.table-section {
    background: white;
    border-radius: 8px;
    padding: 16px;
}

.table-section h3 {
    margin: 0 0 12px 0;
    font-size: 16px;
    color: #374151;
}

.table-container {
    overflow-x: auto;
}

#history-table tbody tr.highlighted {
    background-color: #dbeafe;
    box-shadow: inset 0 0 0 2px #3b82f6;
}


.no-data {
    text-align: center;
    padding: 40px;
    color: #6b7280;
}

/* ============================================
   BUTTONS
   ============================================ */

.btn-calculate {
    background-color: var(--primary-color);
    color: white;
    padding: 12px 30px;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-calculate:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.3);
}

.btn-calculate:disabled {
    background-color: var(--text-muted);
    cursor: not-allowed;
    transform: none;
}

.btn-reset {
    background-color: transparent;
    color: var(--text-color);
    padding: 12px 30px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-reset:hover {
    background-color: var(--bg-light);
    border-color: var(--text-color);
}

.btn-history {
    background-color: var(--info-color);
    color: white;
    padding: 12px 30px;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-history:hover {
    background-color: #1976D2;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3);
}

/* ============================================
   LOADING STATE
   ============================================ */

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================
   EMPTY STATE
   ============================================ */

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: 0.3;
}

.empty-state h3 {
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: var(--text-color);
}

.empty-state p {
    font-size: 1rem;
    margin-bottom: 0;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 1024px) {
    .results-grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .technical-analysis-container {
        padding: 15px;
    }
    
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .header-actions {
        width: 100%;
        flex-direction: column;
    }
    
    .header-actions button {
        width: 100%;
    }
    
    .price-inputs {
        grid-template-columns: 1fr;
    }
    
    .results-grid {
        grid-template-columns: 1fr;
    }
    
    .history-table {
        font-size: 0.85rem;
    }
    
    .history-table th,
    .history-table td {
        padding: 8px 10px;
    }
    
    .signal-display {
        padding: 15px 25px;
        font-size: 1.2rem;
    }
}

@media (max-width: 480px) {
    .page-header h1 {
        font-size: 1.5rem;
    }
    
    .result-card .value {
        font-size: 1.5rem;
    }
    
    .history-table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
}

/* ============================================
   DARK MODE SUPPORT (Optional)
   ============================================ */

@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #1a1a1a;
        --card-bg: #2d2d2d;
        --text-color: #e0e0e0;
        --border-color: #404040;
    }
    
    .form-group input,
    .form-group select,
    .price-input-group input {
        background: #1a1a1a;
        color: #e0e0e0;
        border-color: #404040;
    }
    
    .history-table {
        background: #2d2d2d;
    }
    
    .history-table tbody tr:hover {
        background-color: #3a3a3a;
    }
}