/* ============================================
   WATCHLIST MODULE STYLES
   Isolated & Non-conflicting with Base
   ============================================ */

:root {
  --wl-primary: #0066ff;
  --wl-primary-dark: #0052cc;
  --wl-secondary: #6c757d;
  --wl-success: #10b981;
  --wl-danger: #ef4444;
  --wl-warning: #f59e0b;
  --wl-info: #3b82f6;
  --wl-bg: #f8fafc;
  --wl-bg-light: #ffffff;
  --wl-border: #e2e8f0;
  --wl-text: #1e293b;
  --wl-text-light: #64748b;
  --wl-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  --wl-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --wl-radius: 8px;
  --wl-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.watchlist-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 16px;
  background-color: var(--wl-bg);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', sans-serif;
  color: var(--wl-text);
}

.watchlist-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
  flex-wrap: wrap;
  gap: 16px;
}

.watchlist-title-section {
  flex: 1;
  min-width: 250px;
}

.watchlist-title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 28px;
  font-weight: 700;
  margin: 0 0 8px 0;
  line-height: 1.2;
}

.watchlist-icon {
  width: 32px;
  height: 32px;
  color: var(--wl-primary);
  stroke-linecap: round;
  stroke-linejoin: round;
}

.watchlist-stats {
  display: flex;
  gap: 12px;
  font-size: 14px;
  color: var(--wl-text-light);
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-label {
  color: var(--wl-text-light);
  font-weight: 500;
}

.stat-value {
  color: var(--wl-text);
  font-weight: 700;
  font-size: 16px;
}

.alert-badge {
  background-color: var(--wl-danger);
  color: white;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  min-width: 20px;
  text-align: center;
}

.stat-divider {
  color: var(--wl-border);
}

.watchlist-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border: none;
  border-radius: var(--wl-radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--wl-transition);
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

.btn svg {
  width: 18px;
  height: 18px;
}

.btn-primary {
  background-color: var(--wl-primary);
  color: white;
}

.btn-primary:hover {
  background-color: var(--wl-primary-dark);
  box-shadow: var(--wl-shadow-lg);
}

.btn-secondary {
  background-color: white;
  color: var(--wl-text);
  border: 1px solid var(--wl-border);
}

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

.btn-danger {
  background-color: var(--wl-danger);
  color: white;
}

.btn-danger:hover {
  background-color: #dc2626;
}

.watchlist-search-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.search-input-wrapper {
  flex: 1;
  min-width: 250px;
  position: relative;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--wl-text-light);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 10px 12px 10px 40px;
  border: 1px solid var(--wl-border);
  border-radius: var(--wl-radius);
  font-size: 14px;
  background-color: white;
  transition: var(--wl-transition);
}

.search-input:focus {
  outline: none;
  border-color: var(--wl-primary);
  box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.1);
}

.btn-clear-search {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--wl-text-light);
  padding: 4px;
  transition: var(--wl-transition);
}

.btn-clear-search:hover {
  color: var(--wl-text);
}

.btn-clear-search svg {
  width: 16px;
  height: 16px;
}

.ticker-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid var(--wl-border);
  border-top: none;
  border-radius: 0 0 var(--wl-radius) var(--wl-radius);
  z-index: 10;
  max-height: 250px;
  overflow-y: auto;
  box-shadow: var(--wl-shadow-lg);
}

.ticker-suggestion-item {
  padding: 12px;
  border-bottom: 1px solid var(--wl-border);
  cursor: pointer;
  transition: background-color 0.2s;
}

.ticker-suggestion-item:hover {
  background-color: var(--wl-bg);
}

.ticker-suggestion-item:last-child {
  border-bottom: none;
}

.view-toggle {
  display: flex;
  gap: 4px;
  background-color: white;
  padding: 4px;
  border-radius: var(--wl-radius);
  border: 1px solid var(--wl-border);
}

.view-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: var(--wl-transition);
  color: var(--wl-text-light);
}

.view-btn:hover {
  background-color: var(--wl-bg);
  color: var(--wl-text);
}

.view-btn.active {
  background-color: var(--wl-primary);
  color: white;
}

.view-btn svg {
  width: 20px;
  height: 20px;
}

.watchlist-content {
  min-height: 400px;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
}

.empty-state-icon {
  width: 80px;
  height: 80px;
  margin-bottom: 20px;
  color: var(--wl-text-light);
  opacity: 0.5;
}

.empty-state-icon svg {
  width: 100%;
  height: 100%;
}

.empty-state-title {
  font-size: 24px;
  font-weight: 700;
  margin: 0 0 12px 0;
  color: var(--wl-text);
}

.empty-state-text {
  font-size: 14px;
  color: var(--wl-text-light);
  max-width: 400px;
  margin: 0 0 24px 0;
  line-height: 1.6;
}

.watchlist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.watchlist-grid.list-view {
  grid-template-columns: 1fr;
}

.ticker-card {
  background: white;
  border: 1px solid var(--wl-border);
  border-radius: var(--wl-radius);
  padding: 16px;
  transition: var(--wl-transition);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.ticker-card:hover {
  border-color: var(--wl-primary);
  box-shadow: var(--wl-shadow-lg);
  transform: translateY(-2px);
}

.ticker-card.alert {
  border-left: 4px solid var(--wl-warning);
}

.ticker-card.positive {
  border-top: 3px solid var(--wl-success);
}

.ticker-card.negative {
  border-top: 3px solid var(--wl-danger);
}

.ticker-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.ticker-symbol {
  font-size: 18px;
  font-weight: 700;
  color: var(--wl-text);
}

.ticker-name {
  font-size: 12px;
  color: var(--wl-text-light);
  margin-top: 2px;
}

.ticker-actions {
  display: flex;
  gap: 4px;
}

.btn-card-action {
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  color: var(--wl-text-light);
  transition: var(--wl-transition);
}

.btn-card-action:hover {
  background-color: var(--wl-bg);
  color: var(--wl-text);
}

.btn-card-action svg {
  width: 18px;
  height: 18px;
}

.ticker-price-section {
  margin-bottom: 12px;
}

.ticker-price {
  font-size: 20px;
  font-weight: 700;
  color: var(--wl-text);
}

.ticker-change {
  font-size: 13px;
  font-weight: 600;
  margin-top: 4px;
}

.ticker-change.positive {
  color: var(--wl-success);
}

.ticker-change.negative {
  color: var(--wl-danger);
}

.ticker-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 12px;
  background-color: var(--wl-bg);
  border-radius: 6px;
  margin-bottom: 12px;
}

.stat {
  text-align: center;
}

.ticker-stat-label {
  font-size: 11px;
  color: var(--wl-text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
  display: block;
}

.ticker-stat-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--wl-text);
}

.ticker-alerts-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  padding: 4px 8px;
  background-color: #fef3c7;
  color: #92400e;
  border-radius: 4px;
  width: 100%;
  justify-content: center;
}

.ticker-alerts-badge svg {
  width: 14px;
  height: 14px;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 40px 10px 16px 16px; /* 27 02  */
}

.modal.active {
  display: flex;
}

.modal-content {
  background: white;
  border-radius: var(--wl-radius);
  box-shadow: var(--wl-shadow-lg);
  max-width: 500px;
  width: 100%;
  max-height: calc(100vh - 100px);          /* 27 02  */
  overflow-y: auto;
  animation: slideUp 0.3s ease-out;
}

.modal-content.modal-lg {
  max-width: 600px;
}

.modal-content.modal-xl {
  max-width: 800px;
}

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

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid var(--wl-border);
  position: sticky;
  top: 0;
  background: white;
   z-index: 10; /* ✅ THÊM DÒNG NÀY fixed button on top bar*/
}

.ticker-header-info {
  flex: 1;
}

.modal-title {
  font-size: 20px;
  font-weight: 700;
  margin: 0;
  color: var(--wl-text);
}

.ticker-badge {
  display: inline-block;
  padding: 4px 12px;
  background-color: var(--wl-info);
  color: white;
  border-radius: 12px;
  font-size: 12px;
  margin-top: 4px;
}

.modal-close {
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--wl-text-light);
  transition: var(--wl-transition);
  border-radius: 4px;
}

.modal-close:hover {
  background-color: var(--wl-bg);
  color: var(--wl-text);
}

.modal-close svg {
  width: 20px;
  height: 20px;
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 20px;
  border-top: 1px solid var(--wl-border);
  background-color: var(--wl-bg);
}

/* Form Elements */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--wl-text);
}

.form-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--wl-border);
  border-radius: var(--wl-radius);
  font-size: 14px;
  transition: var(--wl-transition);
}

.form-input:focus {
  outline: none;
  border-color: var(--wl-primary);
  box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.1);
}

.form-input:disabled {
  background-color: var(--wl-bg);
  cursor: not-allowed;
}

.form-select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--wl-border);
  border-radius: var(--wl-radius);
  font-size: 14px;
  background-color: white;
  cursor: pointer;
  transition: var(--wl-transition);
}

.form-select:focus {
  outline: none;
  border-color: var(--wl-primary);
  box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.1);
}

.form-hint {
  display: block;
  font-size: 12px;
  color: var(--wl-text-light);
  margin-top: 4px;
}

.threshold-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.threshold-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.threshold-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.threshold-checkbox {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.checkbox-group {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  background-color: var(--wl-bg);
  border-radius: var(--wl-radius);
  cursor: pointer;
}

.checkbox-group input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  cursor: pointer;
}

.checkbox-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--wl-text);
}

.checkbox-hint {
  display: block;
  font-size: 12px;
  color: var(--wl-text-light);
  margin-top: 2px;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  margin-bottom: 8px;
  cursor: pointer;
  border-radius: 4px;
  transition: var(--wl-transition);
}

.checkbox-item:hover {
  background-color: var(--wl-bg);
}

.checkbox-item input {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

/* Filter Sections */
.filter-section {
  margin-bottom: 20px;
}

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

.filter-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--wl-text-light);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--wl-border);
}

/* Ticker Details Modal */
.ticker-details-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
  padding: 16px;
  background-color: var(--wl-bg);
  border-radius: var(--wl-radius);
}

.details-section {
  padding: 12px;
  background: white;
  border-radius: 6px;
  border: 1px solid var(--wl-border);
}

.section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--wl-text-light);
  margin: 0 0 12px 0;
}

.price-display {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.price-value {
  font-size: 12px;
  font-weight: 700;
  color: var(--wl-text);
}

.price-change {
  font-size: 12px;
  font-weight: 600;
}

.analysis-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--wl-border);
}

.analysis-item:last-child {
  border-bottom: none;
}

.analysis-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--wl-text-light);
}

.analysis-value {
  font-size: 12px;
  font-weight: 700;
  color: var(--wl-text);
}

.alerts-section,
.ai-analysis-section {
  margin-bottom: 20px;
}

.alerts-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.alert-item {
  padding: 12px;
  background-color: var(--wl-bg);
  border-left: 3px solid var(--wl-warning);
  border-radius: 4px;
}

.alert-item-time {
  font-size: 11px;
  color: var(--wl-text-light);
  margin-bottom: 4px;
}

.alert-item-message {
  font-size: 13px;
  color: var(--wl-text);
}

.analysis-content {
  padding: 12px;
  background-color: var(--wl-bg);
  border-radius: var(--wl-radius);
  line-height: 1.6;
  font-size: 14px;
}

.empty-text {
  text-align: center;
  color: var(--wl-text-light);
  font-size: 12px;
}

/* Toast Notification */
.toast-container {
  position: fixed;
  top: 80px;            /* ✅← Tăng từ 20px lên 80px để tránh header */
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.toast {
  background: white;
  padding: 16px;
  border-radius: var(--wl-radius);
  box-shadow: var(--wl-shadow-lg);
  display: flex;
  align-items: center;
  gap: 12px;
  animation: slideIn 0.3s ease-out;
  min-width: 300px;
}

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

.toast.success {
  border-left: 4px solid var(--wl-success);
}

.toast.error {
  border-left: 4px solid var(--wl-danger);
}

.toast.warning {
  border-left: 4px solid var(--wl-warning);
}

.toast.info {
  border-left: 4px solid var(--wl-info);
}

.toast-message {
  flex: 1;
  font-size: 14px;
  color: var(--wl-text);
}

.toast-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--wl-text-light);
  padding: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toast-close svg {
  width: 16px;
  height: 16px;
}

/* Responsive */
@media (max-width: 768px) {
  .watchlist-container {
    padding: 16px 12px;
  }

  .watchlist-header {
    flex-direction: column;
    align-items: flex-start;
    margin-bottom: 24px;
  }

  .watchlist-controls {
    width: 100%;
  }

  .watchlist-controls .btn {
    flex: 1;
  }

  .watchlist-search-bar {
    flex-direction: column;
  }

  .search-input-wrapper,
  .view-toggle {
    width: 100%;
  }

  .watchlist-grid {
    grid-template-columns: 1fr;
  }

  .modal-content {
    max-width: 95vw;
  }

  .threshold-row {
    grid-template-columns: 1fr;
  }

  .ticker-details-grid {
    grid-template-columns: 1fr;
  }

  .toast-container {
    right: 12px;
    left: 12px;
  }

  .toast {
    min-width: auto;
  }
}

/* nhẹ & subtle like placeholder */
.wl-show-more {
  margin-top: 8px;
  color: var(--muted, #7a7a7a); /* muted color */
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  opacity: 0.85;
}
.wl-show-more:hover { opacity: 1; text-decoration: underline; color: var(--g-blue, #1a73e8); }


/* Update button spinner */
#btn-update-ticker:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}
#btn-update-ticker {
  margin-right: auto;
}


/* watchlist.css - Additions for Alert Settings */

.alert-settings-container {
    background-color: var(--wl-bg);
    padding: 16px;
    border-radius: 8px;
    margin-top: 10px;
    border: 1px solid var(--wl-border);
}

.settings-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px dashed var(--wl-border);
}

.settings-row:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.settings-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--wl-text);
}

.settings-desc {
    font-size: 12px;
    color: var(--wl-text-light);
    display: block;
    margin-top: 2px;
}

/* Switch Toggle Style */
.switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #ccc;
  transition: .4s;
  border-radius: 22px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--wl-primary);
}

input:checked + .slider:before {
  transform: translateX(18px);
}

/* Alert Config Options (Hidden by default) */
.alert-options-details {
    display: none; /* JS will toggle this */
    margin-top: 12px;
    padding-top: 12px;
    animation: slideDown 0.3s ease-out;
}

.alert-options-details.active {
    display: block;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.config-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* ✅ THÊM: Badge ON/OFF cạnh section title — giống hình new_trend_out.png */
.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-status-badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--wl-success);       /* xanh lá khi ON */
  background-color: #d1fae5;
  padding: 2px 8px;
  border-radius: 10px;
  letter-spacing: 0.3px;
  margin-left: auto; /* ✅ THÊM DÒNG NÀY */
}

.section-status-badge.off {
  color: var(--wl-text-light);
  background-color: var(--wl-bg);
}

/* ✅ Giới hạn: chỉ badge trong details-section (3 ô nhỏ) mới căn phải */
.details-section .section-status-badge {
  margin-left: auto;
}

/* ✅ Badge trong ai-analysis-section: sát ngay cạnh chữ, không đẩy xa */
.ai-analysis-section .section-status-badge {
  margin-left: 8px;
}