File size: 25,599 Bytes
cb756bf
 
 
 
 
 
e2bee6b
cb756bf
 
 
 
e2bee6b
 
c17011b
 
e2bee6b
 
 
cb756bf
 
 
c165635
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c17011b
e2bee6b
 
c17011b
 
 
e2bee6b
 
 
c17011b
 
 
 
 
cb756bf
 
 
 
 
 
 
 
e2bee6b
cb756bf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e2bee6b
cb756bf
 
c165635
 
cb756bf
 
 
 
 
 
7d603aa
 
e2bee6b
 
7d603aa
 
cb756bf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7d603aa
cb756bf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7d603aa
cb756bf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e2bee6b
cb756bf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7d603aa
 
 
cb756bf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e2bee6b
 
c165635
 
 
 
 
 
e2bee6b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cb756bf
e2bee6b
 
 
 
 
 
cb756bf
e2bee6b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cb756bf
e2bee6b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cb756bf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c165635
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cb756bf
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>StockSense-AI β€” Live Trading Dashboard</title>
  <link rel="stylesheet" href="style.css?v=6" />
  <!-- Razorpay Checkout Script -->
  <script src="https://checkout.razorpay.com/v1/checkout.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.0"></script>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
  <link rel="stylesheet" href="dashboard.css">
  <link rel="preconnect" href="https://fonts.googleapis.com">
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
  <link
    href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;700&display=swap"
    rel="stylesheet">
</head>

<body>
  <!-- Intro Layer -->
  <div class="intro-layer" id="introLayer">
    <!-- Background FX -->
    <div class="intro-orb orb-1"></div>
    <div class="intro-orb orb-2"></div>
    <div class="intro-grid"></div>

    <div class="intro-content">
      <div class="intro-badge">AI-Powered Trading</div>
      <h1 class="intro-title">
        <span class="intro-welcome">Welcome to</span><br />
        <span class="intro-brand">StockSense-AI</span>
      </h1>
      <p class="intro-subtitle">Venture into the future of market intelligence.</p>

      <div class="scroll-prompt" id="scrollPrompt">
        <div class="mouse-icon">
          <div class="wheel"></div>
        </div>
        <span>Scroll to Dive In</span>
      </div>
    </div>
  </div>

  <!-- Static Fibonacci/Mesh Watermark -->
  <div
    style="position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; overflow: hidden; z-index: -1; pointer-events: none; opacity: 0.03;">
    <svg width="100%" height="100%" xmlns="http://www.w3.org/2000/svg">
      <defs>
        <pattern id="fibonacciGrid" width="100" height="100" patternUnits="userSpaceOnUse">
          <path d="M 100 0 L 0 0 0 100" fill="none" stroke="#ffffff" stroke-width="0.5" />
          <path d="M 0 38.2 L 100 38.2 M 0 61.8 L 100 61.8 M 38.2 0 L 38.2 100 M 61.8 0 L 61.8 100" fill="none"
            stroke="#ffffff" stroke-width="0.2" />
        </pattern>
      </defs>
      <rect width="100%" height="100%" fill="url(#fibonacciGrid)" />
    </svg>
  </div>

  <!-- Wallet Panel β€” Premium Slide-in -->
  <div id="walletPanel" class="wallet-panel hidden">
    <div class="wallet-panel-content">
      <span class="wallet-close" onclick="closeWallet()">&times;</span>

      <!-- Header -->
      <div class="wallet-header">
        <div class="wallet-header-icon"></div>
        <h2>My Wallet</h2>
        <p class="wallet-subtitle">Synced with AutoBot Balance</p>
      </div>

      <!-- Balance Card -->
      <div class="wallet-balance-card">
        <div class="wallet-balance-label">Available Balance</div>
        <div class="wallet-balance-amount" id="walletBalance">β‚Ή10,00,000.00</div>
        <div class="wallet-balance-bar"></div>
      </div>

      <!-- Quick Add Buttons -->
      <div class="wallet-quick-add">
        <span class="wallet-quick-label">Quick Add</span>
        <div class="wallet-quick-btns">
          <button onclick="quickAdd(500)">β‚Ή500</button>
          <button onclick="quickAdd(1000)">β‚Ή1,000</button>
          <button onclick="quickAdd(5000)">β‚Ή5,000</button>
          <button onclick="quickAdd(10000)">β‚Ή10,000</button>
        </div>
      </div>

      <!-- Action Buttons -->
      <div class="wallet-actions">
        <button class="wallet-action-btn add" onclick="showAddMoney()">
          <span class="action-icon">οΌ‹</span> Add Money
        </button>
        <button class="wallet-action-btn withdraw" onclick="showWithdrawMoney()">
          <span class="action-icon">β†—</span> Withdraw
        </button>
      </div>

      <!-- Dynamic Form Area -->
      <div id="walletActionArea"></div>

      <!-- Status Message -->
      <div id="walletMessage" class="wallet-message hidden"></div>

      <!-- Transaction History -->
      <div class="wallet-txn-section">
        <h4>Recent Transactions</h4>
        <div id="walletTxnList" class="wallet-txn-list">
          <div class="wallet-txn-empty">No transactions yet</div>
        </div>
      </div>
    </div>
  </div>


  <nav class="topbar">
    <div class="brand"> <span>StockSense-AI</span></div>
    <div class="search-area">
      <div class="search-wrapper">
        <i class="fa-solid fa-magnifying-glass search-icon"></i>
        <input id="tickerInput" type="text" placeholder="Enter name or ticker... (e.g. Tata, HDFC)" spellcheck="false"
          autocomplete="off" />
        <div class="search-dropdown hidden" id="searchDropdown"></div>
      </div>
      <button id="analyzeBtn" onclick="loadTicker()">Analyze</button>
    </div>
    <div class="nav-tabs">
      <button class="nav-tab active" onclick="switchTab('charts')">Charts</button>
      <button class="nav-tab" onclick="switchTab('trading')">Auto Trade</button>
      <button class="nav-tab" onclick="switchTab('dashboard')">Company Dashboard</button>
      <button class="nav-tab" onclick="switchTab('engine')">AI Engine</button>
      <button class="btn-wallet nav-btn" onclick="showWallet()">Wallet</button>
      <button class="btn-trade nav-btn" onclick="executeManualTrade()">Trade</button>
    </div>
  </nav>

  <div class="market-bar" id="marketBar">
    <div class="market-bar-inner">
      <div class="market-item" id="mktStock">
        <span class="mkt-label" id="mktStockLabel">STOCK</span>
        <span class="mkt-price" id="mktStockPrice">β€”</span>
        <span class="mkt-change" id="mktStockChange">β€”</span>
      </div>
      <div class="market-sep">β”‚</div>
      <div class="market-item">
        <span class="mkt-label">NIFTY 50</span>
        <span class="mkt-price" id="mktNiftyPrice">β€”</span>
        <span class="mkt-change" id="mktNiftyChange">β€”</span>
      </div>
      <div class="market-sep">β”‚</div>
      <div class="market-item">
        <span class="mkt-label">SENSEX</span>
        <span class="mkt-price" id="mktSensexPrice">β€”</span>
        <span class="mkt-change" id="mktSensexChange">β€”</span>
      </div>
    </div>
  </div>


  <section class="price-banner hidden" id="priceBanner">
    <div class="price-main">
      <h1 id="bannerName">β€”</h1>
      <span class="price-value" id="bannerPrice">0.00</span>
      <span class="price-change" id="bannerChange">0.00 (0.00%)</span>
    </div>
    <div class="price-stats">
      <div><label>Open</label><span id="statOpen">β€”</span></div>
      <div><label>High</label><span id="statHigh">β€”</span></div>
      <div><label>Low</label><span id="statLow">β€”</span></div>
      <div><label>Vol</label><span id="statVol">β€”</span></div>
      <div><label>52W H</label><span id="stat52H">β€”</span></div>
      <div><label>52W L</label><span id="stat52L">β€”</span></div>
    </div>
  </section>


  <div id="chartsTab" class="tab-content">
    <div class="dashboard">
      <div class="chart-area">
        <div class="timeframe-bar">
          <button class="tf-btn active" data-tf="1d">1D</button>
          <button class="tf-btn" data-tf="5d">5D</button>
          <button class="tf-btn" data-tf="1mo">1M</button>
          <button class="tf-btn" data-tf="3mo">3M</button>
          <button class="tf-btn" data-tf="1y">1Y</button>
          <button class="tf-btn" data-tf="2y">2Y</button>
        </div>
        <div class="chart-container" id="mainChartWrap">
          <canvas id="mainChart"></canvas>
          <div class="chart-empty-state" id="chartEmptyState">
            <div class="empty-icon">πŸ“ˆ</div>
            <h3>Explore Any Stock</h3>
            <p>Search for a stock above or pick one from <strong>High Potential Stocks</strong> to view charts, analysis
              & AI insights.</p>
            <div class="empty-hint">Try: <span
                onclick="document.getElementById('tickerInput').focus()">RELIANCE.NS</span> Β· <span
                onclick="document.getElementById('tickerInput').focus()">TCS.NS</span> Β· <span
                onclick="document.getElementById('tickerInput').focus()">TATAMOTORS.NS</span></div>
          </div>
        </div>
        <div class="chart-container volume-chart"><canvas id="volumeChart"></canvas></div>

        <div class="prediction-section hidden" id="predSection">
          <h3>Next 5-Day Price Forecast</h3>

          <div class="pred-loader" id="predLoader">
            <div class="pred-loader-inner">
              <div class="neural-dots">
                <span></span><span></span><span></span><span></span><span></span>
              </div>
              <div class="loader-brain">🧠</div>
              <p class="loader-title">AI Model Training</p>
              <p class="loader-sub" id="predLoaderMsg">Analyzing patterns with 10-feature LSTM...</p>
              <div class="loader-bar">
                <div class="loader-bar-fill"></div>
              </div>
            </div>
          </div>
          <div class="chart-container" id="predChartWrap"><canvas id="predChart"></canvas></div>
          <div class="pred-metrics">
            <div class="metric-card">
              <span class="m-label">Confidence</span>
              <span class="m-value" id="predConf">β€”</span>
            </div>
            <div class="metric-card">
              <span class="m-label">Risk Level</span>
              <span class="m-value" id="predRisk">β€”</span>
            </div>
            <div class="metric-card">
              <span class="m-label">Day 1 Forecast</span>
              <span class="m-value" id="predDay1">β€”</span>
            </div>
            <div class="metric-card">
              <span class="m-label">Day 5 Forecast</span>
              <span class="m-value" id="predDay5">β€”</span>
            </div>
          </div>
        </div>
      </div>

      <aside class="sidebar">
        <div class="panel">
          <h3>High Potential Stocks</h3>
          <p class="panel-sub">Ranked by momentum + indicators</p>
          <div id="hpLoader" class="mini-loader">Loading scanner...</div>
          <div id="hpList" class="hp-list"></div>
        </div>
        <div class="panel hidden" id="sentPanel">
          <h3>πŸ“° News Sentiment</h3>
          <div class="sent-gauge">
            <div class="gauge-circle" id="gaugeCircle"><span id="gaugeText">β€”</span></div>
            <span class="gauge-label" id="gaugeLabel">Neutral</span>
          </div>
          <ul id="sentList" class="sent-list"></ul>
        </div>
        <div class="panel hidden" id="indPanel">
          <h3>πŸ“Š Technical Indicators</h3>
          <table class="ind-table">
            <tbody id="indBody"></tbody>
          </table>
        </div>
      </aside>
    </div>
  </div>


  <div id="tradingTab" class="tab-content hidden">
    <!-- Existing trading content -->
    <div class="trading-dashboard">
      <div class="trade-grid">
        <div class="portfolio-header">
          <div class="port-card balance">
            <span class="pc-label">Portfolio Value</span>
            <span class="pc-value" id="portValue">β‚Ή10,00,000.00</span>
          </div>
          <div class="port-card">
            <span class="pc-label">Cash Balance</span>
            <span class="pc-value" id="portBalance">β‚Ή10,00,000.00</span>
          </div>
          <div class="port-card">
            <span class="pc-label">Unrealized P&L</span>
            <span class="pc-value" id="portUnrealized">β‚Ή0.00</span>
          </div>
          <div class="port-card">
            <span class="pc-label">Realized P&L</span>
            <span class="pc-value" id="portRealized">β‚Ή0.00</span>
          </div>
          <div class="port-card">
            <span class="pc-label">Win Rate</span>
            <span class="pc-value" id="portWinRate">0%</span>
          </div>
          <div class="port-card">
            <span class="pc-label">Total Trades</span>
            <span class="pc-value" id="portTrades">0</span>
          </div>
        </div>


        <div class="bot-controls">
          <div class="bot-status">
            <span class="bot-dot" id="botDot"></span>
            <span id="botStatus">Bot: OFF</span>
          </div>
          <div class="bot-buttons">
            <button class="btn-bot" id="toggleBotBtn" onclick="toggleBot()">Auto Bot</button>
            <button class="btn-scan" onclick="runAutoScan()">Auto Scan</button>
            <button class="btn-reset" onclick="resetPortfolio()">Reset</button>
          </div>
        </div>


        <div class="trade-panel">
          <h3>πŸ“‚ Open Positions</h3>
          <div class="positions-table-wrap">
            <table class="positions-table">
              <thead>
                <tr>
                  <th>Ticker</th>
                  <th>Shares</th>
                  <th>Buy Price</th>
                  <th>Current</th>
                  <th>P&L</th>
                  <th>P&L %</th>
                  <th>Stop Loss</th>
                  <th>Take Profit</th>
                  <th>Action</th>
                </tr>
              </thead>
              <tbody id="positionsBody">
                <tr>
                  <td colspan="9" class="empty-msg">No open positions</td>
                </tr>
              </tbody>
            </table>
          </div>
        </div>


        <div class="trade-panel">
          <h3>πŸ“‹ Trade History</h3>
          <div class="trade-log" id="tradeLog">
            <div class="empty-msg">No trades yet. Activate the bot or execute a trade.</div>
          </div>
        </div>


        <div class="trade-panel">
          <h3>⚑ Live Trade Feed</h3>
          <div class="trade-feed" id="tradeFeed"></div>
        </div>

      </div>
    </div>
  </div>

  <!-- New Unified Company Dashboard Tab -->
  <div id="dashboardTab" class="tab-content hidden">

    <div class="dashboard-search-bar" style="display:flex; gap: 0.5rem; justify-content: flex-end; margin-bottom: 1rem; padding-right: 1rem;">
      <input type="text" id="dashboardSearchInput" placeholder="Analyze specific ticker (e.g. INFY.NS)" style="background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1); color: var(--text-bright); padding: 0.5rem 1rem; border-radius: 0.5rem; font-family: 'JetBrains Mono', monospace; font-size: 0.85rem; width: 280px;" onkeydown="if(event.key === 'Enter') document.getElementById('dashboardLoadBtn').click()">
      <button id="dashboardLoadBtn" onclick="renderUnifiedDashboard(document.getElementById('dashboardSearchInput').value.trim() || document.getElementById('tickerInput').value.trim())" style="background: var(--accent); color: #000; font-weight: bold; border: none; padding: 0.5rem 1.25rem; border-radius: 0.5rem; font-family: 'Inter', sans-serif; cursor: pointer; transition: 0.2s;">Fetch Data</button>
    </div>

    <div class="dashboard-grid" id="dashboardContentGrid">

      <!-- Zone 1: Header Panel (Top Row) -->
      <header class="zone-header">
        <div class="header-left">
          <div class="company-logo">
            <i class="fa-solid fa-code-compare"></i>
          </div>
          <div class="company-info">
            <h1 class="company-name" id="hdr-name">--</h1>
            <span class="company-ticker" id="hdr-ticker">--</span>
          </div>
        </div>

        <div class="header-center">
          <div class="real-time-metric">
            <span class="metric-label">Current Price</span>
            <span class="metric-value" id="hdr-price">--</span>
          </div>
          <div class="real-time-metric" id="hdr-change-box">
            <span class="metric-label">24h Change</span>
            <span class="metric-value" id="hdr-change">--</span>
          </div>
          <div class="real-time-metric">
            <span class="metric-label">Market Cap</span>
            <span class="metric-value" id="hdr-mcap">--</span>
          </div>
        </div>

        <div class="header-right">
          <div class="reliability-label">Reliability Score</div>
          <div class="circular-progress" id="reliabilityScoreRing">
            <svg viewBox="0 0 36 36" class="circular-chart">
              <path class="circle-bg" d="M18 2.0845
                            a 15.9155 15.9155 0 0 1 0 31.831
                            a 15.9155 15.9155 0 0 1 0 -31.831" />
              <path class="circle" id="ringPath" stroke-dasharray="0, 100" d="M18 2.0845
                            a 15.9155 15.9155 0 0 1 0 31.831
                            a 15.9155 15.9155 0 0 1 0 -31.831" />
              <text x="18" y="20.35" class="percentage" id="ringText">--</text>
            </svg>
          </div>
        </div>
      </header>

      <!-- Zone 2: News & Sentiment Feed -->
      <section class="zone-news bento-card">
        <h2>News & Sentiment Feed</h2>
        <div class="news-list" id="newsList">
        </div>
      </section>

      <!-- Zone 3: Core Parameters -->
      <section class="zone-parameters bento-card">
        <h2>Core Parameters</h2>
        <div class="params-grid" id="paramsGrid">
        </div>
      </section>

      <!-- Zone 4: Company Profile -->
      <section class="zone-profile bento-card">
        <h2>Company Overview</h2>
        <p id="companyOverviewText" class="company-desc">
          Loading profile information...
        </p>
      </section>

      <!-- Zone 5: Price Action & Forecast Graph -->
      <section class="zone-chart bento-card">
        <div class="chart-header">
          <h2>Price Action & AI Forecast</h2>
          <button class="generate-btn" id="generateAnalysisBtn">
            Run AI Analysis
          </button>
        </div>
        <div class="chart-container">
          <canvas id="priceForecastChart"></canvas>
        </div>
      </section>
    </div>
  </div>

  <!-- AI Brain / Engine Tab -->
  <div id="engineTab" class="tab-content hidden">
    <div class="engine-dashboard">
      <header class="engine-header bento-card">
        <div class="engine-header-left">
          <div class="engine-icon"></div>
          <div>
            <h1>AI Self-Correction Engine</h1>
            <p></p>
          </div>
        </div>
        <div class="engine-header-right">
          <button class="engine-btn primary" onclick="runOptimization()">
            <i class="fa-solid fa-wand-magic-sparkles"></i> Optimize Now
          </button>
          <button class="engine-btn secondary" onclick="resolvePredictions()">
            <i class="fa-solid fa-arrows-rotate"></i> Resolve Accuracy
          </button>
        </div>
      </header>

      <div class="engine-grid">
        <!-- Accuracy Overview -->
        <section class="engine-card accuracy bento-card">
          <h2>Predictive Accuracy (7D)</h2>
          <div id="accuracyStats" class="accuracy-stats">
            <div class="mini-loader">Fetching brain stats...</div>
          </div>
        </section>

        <!-- Dynamic Parameters -->
        <section class="engine-card params bento-card">
          <h2>Dynamic Parameters</h2>
          <div class="params-table-wrap">
            <table class="params-table">
              <thead>
                <tr>
                  <th>Parameter</th>
                  <th>Current Value</th>
                  <th>Description</th>
                </tr>
              </thead>
              <tbody id="engineParamsBody">
                <tr>
                  <td colspan="3" class="empty-msg">Loading engine brain...</td>
                </tr>
              </tbody>
            </table>
          </div>
        </section>

        <!-- Vision Analysis Log -->
        <section class="engine-card vision bento-card">
          <h2>Multimodal Graph Interpretation</h2>
          <div class="vision-control">
            <i class="fa-solid fa-magnifying-glass"></i>
            <input type="text" id="visionTicker" placeholder="Ticker (e.g. INFY.NS)" />
            <button onclick="runVisionAnalysis()">Run Vision Check</button>
          </div>
          <div id="visionResult" class="vision-result">
            <p class="empty-msg">Perform a visual analysis of any stock chart using Gemini 2.0 Flash.</p>
          </div>
        </section>
      </div>
    </div>
  </div>

  <section class="insights-section">
    <h2 class="section-title">🌐 AI Γ— Finance β€” Did You Know?</h2>
    <div class="insights-grid">
      <div class="insight-card">
        <div class="insight-icon">πŸ€–</div>
        <h4>AI Handles 60-70% of Trades</h4>
        <p>Algorithmic and AI-driven systems now execute the majority of trades on major stock exchanges worldwide.</p>
      </div>
      <div class="insight-card">
        <div class="insight-icon">🧠</div>
        <h4>LSTM Remembers Patterns</h4>
        <p>Long Short-Term Memory networks can learn patterns across 60+ trading days, capturing trends that humans
          easily miss.</p>
      </div>
      <div class="insight-card">
        <div class="insight-icon">πŸ“°</div>
        <h4>News Moves Markets</h4>
        <p>Studies show that news sentiment can predict short-term stock movements with up to 70% accuracy when combined
          with technical analysis.</p>
      </div>
      <div class="insight-card">
        <div class="insight-icon">πŸ“Š</div>
        <h4>Bollinger Bands</h4>
        <p>When Bollinger Band width contracts, a big price move is coming. Our model uses this "squeeze" signal in its
          10-feature pipeline.</p>
      </div>
      <div class="insight-card">
        <div class="insight-icon">⚑</div>
        <h4>Sub-Second Decisions</h4>
        <p>Once trained, our LSTM model generates 5-day forecasts in under 50ms β€” faster than any human analyst could
          process a single chart.</p>
      </div>
      <div class="insight-card">
        <div class="insight-icon">πŸ›‘οΈ</div>
        <h4>Risk Management is Key</h4>
        <p>Professional trading firms never risk more than 2% per trade. Our bot uses stop-loss, take-profit, and
          trailing stops for protection.</p>
      </div>
    </div>
  </section>


  <section class="pipeline-section">
    <h2 class="section-title">βš™οΈ How StockSense AI Works</h2>
    <div class="pipeline">
      <div class="pipe-step">
        <div class="pipe-num">01</div>
        <div class="pipe-icon">πŸ“₯</div>
        <h4>Data Ingestion</h4>
        <p>2 years of OHLCV data fetched from Yahoo Finance in real-time for any stock ticker.</p>
      </div>
      <div class="pipe-arrow">β†’</div>
      <div class="pipe-step">
        <div class="pipe-num">02</div>
        <div class="pipe-icon">πŸ“Š</div>
        <h4>Feature Engineering</h4>
        <p>10 technical indicators computed: SMA, EMA, RSI, MACD, Bollinger Bands, ATR, and Volume.</p>
      </div>
      <div class="pipe-arrow">β†’</div>
      <div class="pipe-step">
        <div class="pipe-num">03</div>
        <div class="pipe-icon">🧠</div>
        <h4>AI Prediction</h4>
        <p>3-layer LSTM neural network trained on 60-day windows predicts next 5 business days' prices.</p>
      </div>
      <div class="pipe-arrow">β†’</div>
      <div class="pipe-step">
        <div class="pipe-num">04</div>
        <div class="pipe-icon">πŸ’Ή</div>
        <h4>Smart Trading</h4>
        <p>Composite score (LSTM + Technical + Sentiment) adapts to market regime for auto BUY/SELL.</p>
      </div>
    </div>
  </section>


  <footer class="app-footer">
    <div class="footer-content">
      <div class="footer-brand">
        <span class="footer-logo">πŸ“ˆ StockSense AI</span>
        <span class="footer-tagline">Where Machine Learning Meets Market Intelligence</span>
      </div>
      <div class="footer-tech">
        <span>Built with</span>
        <span class="tech-badge">Python</span>
        <span class="tech-badge">PyTorch</span>
        <span class="tech-badge">FastAPI</span>
        <span class="tech-badge">FinBERT</span>
        <span class="tech-badge">Chart.js</span>
      </div>
    </div>
  </footer>

  <script src="app.js?v=6"></script>
  <script>
    document.addEventListener('DOMContentLoaded', () => {
      const introLayer = document.getElementById('introLayer');
      if (introLayer) {
        document.body.style.overflow = 'hidden'; // Lock scroll until they scroll past
        let isHidden = false;

        const hideIntro = () => {
          if (isHidden) return;
          isHidden = true;
          introLayer.classList.add('hidden-up');
          document.body.style.overflow = 'auto'; // Unlock scroll
        };

        const handleScroll = (e) => {
          // If user scrolls mouse wheel down
          if (e.deltaY > 0) {
            hideIntro();
          }
        };

        // Listen for wheel scroll or touch swipe
        window.addEventListener('wheel', handleScroll);

        let touchStartY = 0;
        window.addEventListener('touchstart', e => {
          touchStartY = e.changedTouches[0].screenY;
        });
        window.addEventListener('touchend', e => {
          const touchEndY = e.changedTouches[0].screenY;
          if (touchStartY - touchEndY > 20) { // Swiped up
            hideIntro();
          }
        });

        // Click on "Scroll to Trade" text also works
        const scrollPrompt = document.getElementById('scrollPrompt');
        if (scrollPrompt) {
          scrollPrompt.addEventListener('click', hideIntro);
        }
      }
    });
  </script>
</body>

</html>