/* =====================================================================
   ICT PWA Scanner — Premium Glassmorphic Dark Style
   ===================================================================== */

:root {
  --bg:        #06060c;
  --bg2:       #0a0a16;
  --surface:   #121226;
  --surface2:  #1b1c3a;
  --border:    #242654;
  --accent:    #ff9f1c; /* Neon Orange (Order Block) */
  --accent2:   #2ec4b6; /* Neon Cyan (FVG) */
  --mss:       #e0115f; /* Neon Ruby/Magenta (MSS) */
  --eq:        #39ff14; /* Neon Green (Equilibrium) */
  --red:       #ff4d6d; /* Red (Stop Loss / Error) */
  --blue:      #00b4d8;
  --yellow:    #ffea00;
  --text:      #e2e8f0;
  --text-dim:  #8b8da9;
  --radius:    14px;
  --radius-sm: 8px;
  --shadow:    0 8px 32px rgba(0, 0, 0, 0.6);
  --glow:      0 0 24px rgba(255, 159, 28, 0.15);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', 'Malgun Gothic', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ===== HEADER ===== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(6,6,12,0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-icon {
  font-size: 2rem;
  animation: pulse-glow 3s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% { filter: drop-shadow(0 0 6px rgba(255, 159, 28, 0.5)); }
  50%       { filter: drop-shadow(0 0 16px rgba(46, 196, 182, 0.8)); }
}

.brand-title {
  font-size: 1.25rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 50%, var(--mss) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.2;
}

.brand-sub {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-top: 1px;
  font-weight: 400;
}

.header-badges {
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.badge-ob { background: rgba(255,159,28,0.12); color: var(--accent); border: 1px solid rgba(255,159,28,0.3); }
.badge-fvg { background: rgba(46,196,182,0.12); color: var(--accent2); border: 1px solid rgba(46,196,182,0.3); }
.badge-mss { background: rgba(224,17,95,0.12); color: var(--mss); border: 1px solid rgba(224,17,95,0.3); }

.help-btn {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  margin-left: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.help-btn:hover { background: var(--accent2); color: #000; border-color: var(--accent2); }

.pwa-install-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, var(--accent2) 0%, var(--eq) 100%);
  color: #000;
  border: none;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 0 12px rgba(46,196,182,0.3);
  margin-right: 6px;
}
.pwa-install-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 20px rgba(46,196,182,0.6);
}
.pwa-install-btn:active {
  transform: translateY(0);
}
.pwa-install-btn.hidden {
  display: none !important;
}

/* ===== MAIN LAYOUT ===== */
.app-main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 20px;
  min-height: calc(100vh - 68px);
}

/* ===== PANEL ===== */
.panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ===== CARD ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  transition: box-shadow 0.3s;
}

.card:hover { box-shadow: var(--shadow), var(--glow); }

.card-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent2);
  margin-bottom: 14px;
  letter-spacing: 0.5px;
}

/* ===== CONTROLS ===== */
.control-row {
  display: flex;
  gap: 12px;
  align-items: stretch;
}

.select-wrapper {
  flex: 1;
  position: relative;
}

.select-wrapper::after {
  content: '▾';
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  pointer-events: none;
  font-size: 0.8rem;
}

#market-select {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 0.88rem;
  padding: 10px 32px 10px 14px;
  border-radius: var(--radius-sm);
  appearance: none;
  cursor: pointer;
  transition: border-color 0.2s;
  outline: none;
}
#market-select:focus { border-color: var(--accent2); }

.btn-scan {
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, var(--accent) 0%, #ffbe53 100%);
  color: #000;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 22px;
  font-family: 'Inter', sans-serif;
  font-size: 0.88rem;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  box-shadow: 0 4px 16px rgba(255,159,28,0.3);
  letter-spacing: 0.3px;
}
.btn-scan:hover  { transform: translateY(-1px); box-shadow: 0 6px 24px rgba(255,159,28,0.5); }
.btn-scan:active { transform: translateY(0); }
.btn-scan:disabled {
  background: var(--surface2);
  color: var(--text-dim);
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}
.btn-scan .btn-icon { font-size: 1.1rem; }

/* ===== PROGRESS ===== */
.progress-wrap {
  margin-top: 14px;
}

.progress-bar {
  background: var(--bg2);
  border-radius: 4px;
  height: 6px;
  overflow: hidden;
  margin-bottom: 6px;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 4px;
  transition: width 0.2s ease;
  background-size: 200% 100%;
}

.progress-label {
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* ===== STATS ROW ===== */
.stats-row {
  display: flex;
  align-items: center;
  gap: 0;
  margin-top: 14px;
  background: var(--bg2);
  border-radius: var(--radius-sm);
  padding: 12px 20px;
}

.stat-item {
  flex: 1;
  text-align: center;
}

.stat-val {
  display: block;
  font-size: 1.4rem;
  font-weight: 800;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text);
}

.stat-val.stat-match { color: var(--eq); }

.stat-lbl {
  display: block;
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-top: 2px;
  letter-spacing: 0.5px;
}

.stat-divider {
  width: 1px;
  height: 36px;
  background: var(--border);
  flex-shrink: 0;
}

/* ===== LOG AREA ===== */
.log-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.log-clear-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.72rem;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}
.log-clear-btn:hover { border-color: var(--red); color: var(--red); }

.log-area {
  flex: 1;
  overflow-y: auto;
  background: #040409;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  line-height: 1.7;
  color: var(--accent2);
  min-height: 280px;
  max-height: calc(100vh - 400px);
}

.log-line { display: block; animation: fadeIn 0.2s ease; }
.log-line.match  { color: var(--yellow); font-weight: 600; }
.log-line.error  { color: var(--red); }
.log-line.info   { color: var(--text-dim); }
.log-line.system { color: var(--blue); }

@keyframes fadeIn { from { opacity: 0; transform: translateX(-6px); } to { opacity: 1; } }

/* ===== RESULTS PANEL ===== */
.results-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 8px;
}

.results-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.action-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.72rem;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.action-btn:hover:not(:disabled) {
  border-color: var(--accent2);
  color: var(--accent2);
  background: rgba(46,196,182,0.1);
}
.action-btn:active:not(:disabled) {
  transform: scale(0.97);
}
.action-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.action-btn.success {
  border-color: var(--eq);
  color: var(--eq);
  background: rgba(57,255,20,0.1);
}

.result-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent2);
  color: #000;
  font-size: 0.7rem;
  font-weight: 750;
  border-radius: 50%;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  margin-left: 6px;
}

.results-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px;
  color: var(--text-dim);
  gap: 10px;
}

.empty-icon { font-size: 3rem; opacity: 0.3; }
.results-empty p { font-size: 0.85rem; }
.empty-hint { font-size: 0.75rem; color: var(--text-dim); opacity: 0.7; }

.results-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: calc(100vh - 200px);
}

/* ===== RESULT CARD ===== */
.result-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  cursor: pointer;
  transition: all 0.22s;
  animation: slideIn 0.3s ease;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

.result-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--accent), var(--accent2));
  border-radius: 2px 0 0 2px;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

.result-card:hover {
  border-color: var(--accent2);
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(46,196,182,0.15);
}

.result-card-ticker {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1rem;
  font-weight: 700;
  color: var(--yellow);
  margin-bottom: 6px;
}

.result-card-setups {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.setup-tag {
  display: inline-block;
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 600;
  width: fit-content;
}

.setup-tag.s1 { background: rgba(46,196,182,0.12); color: var(--accent2); border: 1px solid rgba(46,196,182,0.3); }
.setup-tag.s2 { background: rgba(57,255,20,0.12); color: var(--eq); border: 1px solid rgba(57,255,20,0.3); }
.setup-tag.s3 { background: rgba(255,159,28,0.12); color: var(--accent); border: 1px solid rgba(255,159,28,0.3); }
.setup-tag.s4 { background: rgba(224,17,95,0.12); color: var(--mss); border: 1px solid rgba(224,17,95,0.3); }
.setup-tag.s5 { background: rgba(0,180,216,0.12); color: var(--blue); border: 1px solid rgba(0,180,216,0.3); }

.result-card-time {
  font-size: 0.68rem;
  color: var(--text-dim);
  margin-top: 8px;
}

.result-card-action {
  font-size: 0.72rem;
  color: var(--accent2);
  margin-top: 6px;
  opacity: 0;
  transition: opacity 0.2s;
}
.result-card:hover .result-card-action { opacity: 1; }

/* ===== MODAL ===== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal.hidden { display: none !important; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.8);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  z-index: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: min(90vw, 950px);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0,0,0,0.8);
  animation: modalIn 0.25s ease;
}

.modal-help {
  width: min(90vw, 680px);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(20px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent2);
}

.modal-close {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  width: 28px; height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.2s;
  display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { border-color: var(--red); color: var(--red); }

.modal-body {
  overflow-y: auto;
  padding: 20px 22px;
  flex: 1;
}

.modal-interactive-chart {
  width: 100%;
  height: 480px;
  background: #06060c;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  overflow: hidden;
  position: relative;
}

.modal-setups {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

/* ===== HELP MODAL ===== */
.help-body { font-size: 0.88rem; line-height: 1.7; }
.help-body h4 { color: var(--accent2); margin: 18px 0 8px; font-size: 0.88rem; border-left: 3px solid var(--accent); padding-left: 8px; }
.help-body ul, .help-body ol { padding-left: 20px; color: var(--text); }
.help-body li { margin-bottom: 6px; }
.help-body p { color: var(--text); margin-bottom: 8px; }
.help-body strong { color: var(--yellow); }
.help-body em { color: var(--accent); }

.setup-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.setup-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
}
.setup-item strong { font-size: 0.85rem; }
.setup-item span { color: var(--text-dim); font-size: 0.78rem; }
.setup-item.s1 { background: rgba(46,196,182,0.08); border-left: 3px solid var(--accent2); }
.setup-item.s2 { background: rgba(57,255,20,0.08); border-left: 3px solid var(--eq); }
.setup-item.s3 { background: rgba(255,159,28,0.08); border-left: 3px solid var(--accent); }
.setup-item.s4 { background: rgba(224,17,95,0.08); border-left: 3px solid var(--mss); }
.setup-item.s5 { background: rgba(0,180,216,0.08); border-left: 3px solid var(--blue); }

.help-tip {
  background: rgba(255,159,28,0.06);
  border: 1px solid rgba(255,159,28,0.15);
  border-left: 3px solid var(--accent);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-top: 16px;
  font-size: 0.82rem;
  color: var(--text);
  line-height: 1.7;
}

/* ===== LOADING SPINNER ===== */
.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(0,0,0,0.2);
  border-top-color: #000;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== UTILITY ===== */
.hidden { display: none !important; }

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .app-main {
    grid-template-columns: 1fr;
  }
  .header-badges .badge { display: none; }
  .log-area { max-height: 250px; }
  .results-list { max-height: 400px; }
}

@media (max-width: 600px) {
  .modal-content {
    width: 95vw;
    max-height: 95vh;
  }
  .modal-header {
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
    padding: 12px;
  }
  .modal-interactive-chart {
    height: 320px;
  }
  .modal-body {
    padding: 10px;
  }
  .app-header {
    padding: 0 12px;
    position: static;
  }
  .header-inner {
    height: auto;
    padding: 10px 0;
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
  }
  .brand-title {
    font-size: 1.1rem;
  }
  .app-main {
    padding: 12px;
  }
  .card {
    padding: 12px;
  }
  .control-row {
    flex-direction: column;
  }
  .btn-scan {
    width: 100%;
    justify-content: center;
  }
}
