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

body {
  background: #0a0e17;
  color: #e1e4e8;
  font-family:
    "Segoe UI",
    -apple-system,
    sans-serif;
  overflow: hidden;
  height: 100vh;
}

/* Mobile: permite scroll e mostra sidebar */
@media (max-width: 768px) {
  body {
    overflow-x: hidden;
    overflow-y: auto;
    height: auto;
  }
}

/* === HEADER === */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: #111827;
  border-bottom: 1px solid #1e2a3a;
  height: 48px;
}
.header-left,
.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}
.logo {
  font-size: 18px;
  font-weight: 700;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: 1px;
}
.asset-selector {
  background: #1a2332;
  border: 1px solid #2d3748;
  color: #e1e4e8;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  min-width: 200px;
}
.asset-selector:focus {
  border-color: #3b82f6;
  outline: none;
}
.asset-selector option {
  background: #1a2332;
}

.current-price {
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.price-change {
  font-size: 13px;
  margin-left: 8px;
}
.price-up {
  color: #22c55e;
}
.price-down {
  color: #ef4444;
}

.ws-status {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 12px;
  min-width: 180px;
  text-align: center;
}
.ws-status.connected {
  color: #22c55e;
  background: rgba(34, 197, 94, 0.1);
}
.ws-status.disconnected {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

.timeframe-group {
  display: flex;
  gap: 4px;
}
.tf-btn {
  background: #1a2332;
  border: 1px solid #2d3748;
  color: #9ca3af;
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
}
.tf-btn.active {
  background: #3b82f6;
  color: #fff;
  border-color: #3b82f6;
}

/* === MAIN LAYOUT === */
.main-layout {
  display: flex;
  height: calc(100vh - 48px);
}
.chart-container {
  flex: 1;
  position: relative;
  background: #0a0e17;
  min-width: 0;
}
#chart {
  width: 100%;
  height: 100%;
}

.chart-overlay {
  position: absolute;
  inset: 0;
  background: rgba(10, 14, 23, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 14px;
  color: #9ca3af;
  z-index: 10;
}
.chart-overlay.hidden {
  display: none;
}
.overlay-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #2d3748;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* === SIDEBAR === */
.sidebar {
  width: 300px;
  background: #111827;
  border-left: 1px solid #1e2a3a;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.panel-title {
  font-size: 13px;
  font-weight: 600;
  padding: 12px 16px 8px;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* === AI PANEL === */
.ai-panel {
  padding: 0 16px 16px;
  border-bottom: 1px solid #1e2a3a;
}
.btn-predict {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  border: none;
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition:
    opacity 0.2s,
    transform 0.1s;
}
.btn-predict:hover:not(:disabled) {
  opacity: 0.9;
  transform: translateY(-1px);
}
.btn-predict:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.btn-icon {
  font-size: 16px;
}

.prediction-result {
  margin-top: 12px;
}
.prediction-result.hidden {
  display: none;
}

.signal-badge {
  text-align: center;
  padding: 10px;
  border-radius: 8px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 1px;
  margin-bottom: 12px;
}
.signal-badge.buy {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
  border: 1px solid rgba(34, 197, 94, 0.3);
}
.signal-badge.sell {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
}
.signal-badge.neutral {
  background: rgba(234, 179, 8, 0.15);
  color: #eab308;
  border: 1px solid rgba(234, 179, 8, 0.3);
}

.prediction-details {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.detail-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
}
.detail-label {
  color: #6b7280;
}
.detail-value {
  font-weight: 600;
}
.detail-value.buy {
  color: #22c55e;
}
.detail-value.sell {
  color: #ef4444;
}

.confluencia,
.conclusao,
.pos-entrada {
  margin-top: 10px;
  font-size: 12px;
  color: #9ca3af;
  line-height: 1.5;
  padding: 8px;
  background: #0d1117;
  border-radius: 6px;
  border: 1px solid #1e2a3a;
}
.conclusao {
  color: #e1e4e8;
  font-weight: 600;
  font-size: 13px;
}

.prediction-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 20px;
  color: #9ca3af;
  font-size: 13px;
}
.prediction-loading.hidden {
  display: none;
}
.loading-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid #2d3748;
  border-top-color: #8b5cf6;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* === INFO PANEL === */
.info-panel {
  padding: 0 16px 16px;
}
.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.info-item {
  background: #0d1117;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid #1e2a3a;
}
.info-label {
  display: block;
  font-size: 11px;
  color: #6b7280;
  margin-bottom: 2px;
}
.info-value {
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.info-value.high {
  color: #22c55e;
}
.info-value.low {
  color: #ef4444;
}

/* === ALERT BOX === */
.alert-box {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0 0 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(234, 179, 8, 0.1);
  border: 1px solid rgba(234, 179, 8, 0.3);
  animation: alertPulse 2s ease-in-out infinite;
  cursor: pointer;
  transition: all 0.3s;
}
.alert-box:hover {
  background: rgba(234, 179, 8, 0.2);
}
.alert-box.hidden {
  display: none;
}
.alert-box.bullish {
  background: rgba(34, 197, 94, 0.1);
  border-color: rgba(34, 197, 94, 0.3);
  animation: alertPulseGreen 1.5s ease-in-out infinite;
}
.alert-box.bearish {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
  animation: alertPulseRed 1.5s ease-in-out infinite;
}
.alert-box.volume {
  background: rgba(139, 92, 246, 0.1);
  border-color: rgba(139, 92, 246, 0.3);
  animation: alertPulsePurple 1.5s ease-in-out infinite;
}
.alert-icon {
  font-size: 20px;
  flex-shrink: 0;
}
.alert-title {
  font-size: 12px;
  font-weight: 700;
  color: #e1e4e8;
}
.alert-msg {
  font-size: 11px;
  color: #9ca3af;
  line-height: 1.4;
  margin-top: 2px;
}

@keyframes alertPulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(234, 179, 8, 0.2);
  }
  50% {
    box-shadow: 0 0 12px 2px rgba(234, 179, 8, 0.3);
  }
}
@keyframes alertPulseGreen {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.2);
  }
  50% {
    box-shadow: 0 0 12px 2px rgba(34, 197, 94, 0.4);
  }
}
@keyframes alertPulseRed {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.2);
  }
  50% {
    box-shadow: 0 0 12px 2px rgba(239, 68, 68, 0.4);
  }
}
@keyframes alertPulsePurple {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.2);
  }
  50% {
    box-shadow: 0 0 12px 2px rgba(139, 92, 246, 0.4);
  }
}

/* === SOUND TOGGLE === */
.btn-sound {
  background: #1a2332;
  border: 1px solid #2d3748;
  color: #e1e4e8;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-sound:hover {
  border-color: #3b82f6;
}
.btn-sound.on {
  background: rgba(34, 197, 94, 0.15);
  border-color: rgba(34, 197, 94, 0.4);
}
.btn-sound.off {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
  opacity: 0.6;
}

/* === ALERT ACTION === */
.alert-action {
  margin-top: 6px;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 8px;
  border-radius: 4px;
  text-align: center;
}
.alert-action.buy {
  background: rgba(34, 197, 94, 0.2);
  color: #22c55e;
  border: 1px solid rgba(34, 197, 94, 0.3);
}
.alert-action.sell {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
}
.alert-action.agent {
  background: rgba(139, 92, 246, 0.2);
  color: #a78bfa;
  border: 1px solid rgba(139, 92, 246, 0.3);
}
.alert-reason {
  margin-top: 4px;
  font-size: 10px;
  color: #6b7280;
  font-style: italic;
  line-height: 1.3;
}

/* === LOGOUT === */
.btn-logout {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #ef4444;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-logout:hover {
  background: rgba(239, 68, 68, 0.25);
}

/* ============================================================
   RESPONSIVO
   ============================================================ */

.mobile-only {
  display: none;
}
.desktop-only {
  display: flex;
}

/* === TABLET (≤ 1024px) === */
@media (max-width: 1024px) {
  .sidebar {
    width: 260px;
  }
  .asset-selector {
    min-width: 150px;
  }
  .ws-status {
    min-width: 130px;
    font-size: 11px;
  }
  .current-price {
    font-size: 17px;
  }
}

/* === MOBILE APP (≤ 768px) === */
@media (max-width: 768px) {
  body {
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
  }

  .mobile-only {
    display: flex;
  }
  .desktop-only {
    display: none !important;
  }

  /* ---- TOP BAR ---- */
  .mobile-topbar {
    height: 52px;
    background: #111827;
    border-bottom: 1px solid #1e2a3a;
    padding: 0 14px;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    z-index: 10;
  }
  .mobile-topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
  }
  .mobile-topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .mobile-price-block {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
  }
  .mobile-price-block .current-price {
    font-size: 15px;
  }
  .mobile-price-block .price-change {
    font-size: 11px;
    margin-left: 0;
  }

  /* Status dot */
  .ws-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
  }
  .ws-dot.connected {
    background: #22c55e;
    box-shadow: 0 0 6px #22c55e;
  }
  .ws-dot.disconnected {
    background: #ef4444;
  }

  /* ---- MOBILE APP CONTAINER ---- */
  .mobile-app {
    flex-direction: column;
    height: calc(100vh - 52px);
    height: calc(100dvh - 52px);
    overflow: hidden;
  }

  /* ---- TABS ---- */
  .mobile-tab-content {
    display: none;
    flex: 1;
    overflow: hidden;
    flex-direction: column;
    min-height: 0;
  }
  .mobile-tab-content.active {
    display: flex;
  }

  /* ---- CHART TAB ---- */
  .mobile-chart-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #111827;
    border-bottom: 1px solid #1e2a3a;
    flex-shrink: 0;
  }
  .mobile-asset-select {
    flex: 1;
    min-width: 0;
    font-size: 13px;
    padding: 5px 8px;
  }
  .mobile-chart-wrap {
    flex: 1;
    position: relative;
    background: #0a0e17;
    overflow: hidden;
    min-height: 0;
  }
  #chartMobile {
    width: 100%;
    height: 100%;
  }

  /* ---- AI + INFO TABS ---- */
  .mobile-panel-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    -webkit-overflow-scrolling: touch;
  }

  /* ---- BOTTOM NAV ---- */
  .mobile-bottom-nav {
    display: flex;
    height: 60px;
    background: #111827;
    border-top: 1px solid #1e2a3a;
    flex-shrink: 0;
  }
  .nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    background: none;
    border: none;
    color: #6b7280;
    cursor: pointer;
    transition: color 0.2s;
    padding: 6px 0;
  }
  .nav-btn.active {
    color: #3b82f6;
  }
  .nav-btn.active .nav-icon {
    filter: drop-shadow(0 0 4px #3b82f6);
  }
  .nav-icon {
    font-size: 20px;
    line-height: 1;
  }
  .nav-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.3px;
  }

  /* Info grid mobile */
  .info-grid-mobile {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .info-grid-mobile .info-item {
    padding: 12px;
  }
  .info-grid-mobile .info-value {
    font-size: 16px;
    margin-top: 4px;
    display: block;
  }
}

/* ============================================================
   MOBILE ALERT MODAL
   ============================================================ */
@media (max-width: 768px) {
  .alert-modal {
    position: fixed;
    bottom: 72px;
    left: 12px;
    right: 12px;
    z-index: 200;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
    animation: slideUp 0.3s ease;
  }
  .alert-modal.hidden {
    display: none;
  }

  .alert-modal-content {
    padding: 14px 16px;
    background: #111827;
    border: 1px solid #2d3748;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  .alert-modal.bullish .alert-modal-content {
    border-color: rgba(34, 197, 94, 0.5);
    background: linear-gradient(135deg, #111827, rgba(34, 197, 94, 0.08));
  }
  .alert-modal.bearish .alert-modal-content {
    border-color: rgba(239, 68, 68, 0.5);
    background: linear-gradient(135deg, #111827, rgba(239, 68, 68, 0.08));
  }
  .alert-modal.volume .alert-modal-content {
    border-color: rgba(139, 92, 246, 0.5);
    background: linear-gradient(135deg, #111827, rgba(139, 92, 246, 0.08));
  }

  .alert-modal-header {
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .alert-modal-header .alert-title {
    flex: 1;
    font-size: 13px;
    font-weight: 700;
    color: #e1e4e8;
  }
  .alert-modal-close {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #e1e4e8;
    font-size: 14px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    line-height: 1;
  }

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