/* styles.css - TWSE Similar Dates Chart Dashboard */

:root {
  --bg-dark: #0f172a;
  --card-bg: #1e293b;
  --card-border: #334155;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --primary-blue: #38bdf8;
  --accent-blue: #0284c7;
  --target-red: #f43f5e;
  --target-bg: rgba(244, 63, 94, 0.15);
  --success-green: #34d399;
  --warning-amber: #fbbf24;
  --font-family: 'Inter', system-ui, -apple-system, sans-serif;
  --font-heading: 'Outfit', var(--font-family);
  --font-mono: 'JetBrains Mono', monospace;
}

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

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-family);
  line-height: 1.5;
  min-height: 100vh;
  padding: 24px;
}

.app-container {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Header */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 18px 24px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

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

.logo-icon {
  font-size: 2rem;
  background: linear-gradient(135deg, #0284c7, #38bdf8);
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
}

.brand-text h1 {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-main);
}

.brand-text .subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.header-status {
  display: flex;
  align-items: center;
  gap: 16px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  background: rgba(52, 211, 153, 0.15);
  color: var(--success-green);
  border: 1px solid rgba(52, 211, 153, 0.3);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background-color: var(--success-green);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--success-green);
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

.update-time {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Metrics Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.metric-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 16px 20px;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.metric-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary-blue);
}

.metric-card.highlight-card {
  border-color: rgba(244, 63, 94, 0.5);
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.9), rgba(244, 63, 94, 0.08));
}

.card-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.card-value {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--primary-blue);
}

.highlight-card .card-value {
  color: var(--target-red);
}

.card-subtext {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Card Box Common */
.card-box {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

/* Chart Header */
.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 16px;
}

.chart-title-area h2 {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  color: var(--text-main);
  margin-bottom: 4px;
}

.chart-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.chart-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.styled-select {
  background: #0f172a;
  color: var(--text-main);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.85rem;
  outline: none;
  cursor: pointer;
}

.styled-select:focus {
  border-color: var(--primary-blue);
}

.btn {
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background 0.2s ease;
}

.btn-secondary {
  background: #334155;
  color: var(--text-main);
}

.btn-secondary:hover {
  background: #475569;
}

/* Chart Canvas */
.chart-canvas {
  width: 100%;
  height: 520px;
  border-radius: 8px;
}

/* Legend Bar */
.chart-legend-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 24px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px dashed var(--card-border);
  font-size: 0.82rem;
  color: var(--text-muted);
}

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

.legend-dot.target-dot { color: var(--target-red); font-size: 1.1rem; }
.legend-dot.top-dot { color: var(--primary-blue); font-size: 1rem; }
.legend-dot.sub-dot { color: #94a3b8; font-size: 0.9rem; }
.legend-line.price-line { width: 16px; height: 3px; background-color: #2b5c8f; border-radius: 2px; }

/* Table Section */
.section-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.section-title-row h3 {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  color: var(--text-main);
}

.info-tag {
  font-size: 0.78rem;
  color: var(--primary-blue);
  background: rgba(56, 189, 248, 0.1);
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid rgba(56, 189, 248, 0.2);
}

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

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  text-align: left;
}

.data-table th {
  background: #0f172a;
  color: var(--text-muted);
  font-weight: 600;
  padding: 12px 14px;
  border-bottom: 2px solid var(--card-border);
}

.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--card-border);
  vertical-align: middle;
}

.data-table tbody tr {
  transition: background 0.15s ease;
  cursor: pointer;
}

.data-table tbody tr:hover {
  background: rgba(56, 189, 248, 0.08);
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.8rem;
  background: #334155;
  color: var(--text-main);
}

.rank-badge.top-1 { background: #eab308; color: #000; }
.rank-badge.top-2 { background: #94a3b8; color: #000; }
.rank-badge.top-3 { background: #d97706; color: #fff; }

.similarity-bar-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 140px;
}

.similarity-progress {
  flex: 1;
  height: 8px;
  background: #334155;
  border-radius: 4px;
  overflow: hidden;
}

.similarity-fill {
  height: 100%;
  background: linear-gradient(90deg, #0284c7, #38bdf8);
  border-radius: 4px;
}

.similarity-score-text {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--primary-blue);
}

.return-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.82rem;
}

.return-badge.positive {
  background: rgba(244, 63, 94, 0.15);
  color: #f43f5e;
}

.return-badge.negative {
  background: rgba(52, 211, 153, 0.15);
  color: #34d399;
}

.features-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.feature-item-pill {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.8rem;
  line-height: 1.4;
}

.feature-item-pill .feature-name {
  font-weight: 600;
  color: var(--primary-blue);
  margin-right: 6px;
}

.feature-item-pill .feature-desc {
  color: var(--text-muted);
}

.loading-cell {
  text-align: center;
  color: var(--text-muted);
  padding: 40px !important;
}

/* Footer */
.footer {
  text-align: center;
  padding: 16px;
  color: var(--text-muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--card-border);
}

/* Global Controls Bar */
.global-controls-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 14px 20px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.controls-left, .controls-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.control-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
}

.highlight-select {
  background: linear-gradient(135deg, #0f172a, #1e293b);
  border-color: var(--primary-blue);
  color: var(--primary-blue);
  font-weight: 600;
  padding: 8px 14px;
}

.highlight-select:focus {
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.3);
}

/* Tab Navigation Styles */
.tab-navigation {
  display: flex;
  gap: 10px;
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 0;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #0f172a;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 10px 18px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  text-align: left;
}

.tab-btn:hover {
  background: #1e293b;
  border-color: #475569;
  color: var(--text-main);
  transform: translateY(-1px);
}

.tab-btn.active {
  background: linear-gradient(135deg, rgba(2, 132, 199, 0.2), rgba(56, 189, 248, 0.1));
  border-color: var(--primary-blue);
  color: var(--text-main);
  box-shadow: 0 4px 14px rgba(56, 189, 248, 0.15);
}

.tab-icon {
  font-size: 1.3rem;
}

.tab-text {
  display: flex;
  flex-direction: column;
}

.tab-title {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.2;
}

.tab-btn.active .tab-title {
  color: var(--primary-blue);
}

.tab-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-top: 2px;
}

.tab-btn.active .tab-sub {
  color: #7dd3fc;
}

/* Tab Panels */
.tab-panel {
  animation: fadeIn 0.3s ease-in-out;
}

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

/* Fan Chart Specific Styles */
.btn-primary {
  background: linear-gradient(135deg, var(--accent-blue), var(--primary-blue));
  color: #fff;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #0369a1, #0284c7);
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.4);
}

.fan-chart-wrapper {
  background: #0f172a;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 16px;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 480px;
  overflow: hidden;
  margin-bottom: 20px;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.fan-chart-wrapper:hover {
  border-color: var(--primary-blue);
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.15);
}

.fan-chart-image {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  transition: transform 0.3s ease;
}

.fan-chart-wrapper:hover .fan-chart-image {
  transform: scale(1.008);
}

/* Fan Legend Info Cards */
.fan-legend-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 12px;
}

.fan-info-card {
  background: #0f172a;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 16px;
  transition: border-color 0.2s ease;
}

.fan-info-card:hover {
  border-color: #475569;
}

.fan-info-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.fan-info-header h4 {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
}

.fan-info-card p {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.fan-color-indicator {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  display: inline-block;
  flex-shrink: 0;
}

.fan-color-indicator.median-indicator {
  background-color: #1b4f72;
  border: 1px solid #38bdf8;
}

.fan-color-indicator.core-range-indicator {
  background-color: rgba(41, 128, 185, 0.6);
}

.fan-color-indicator.outer-range-indicator {
  background-color: rgba(41, 128, 185, 0.3);
}

/* Image Modal / Lightbox */
.image-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.image-modal.active {
  display: flex;
}

.image-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
}

.image-modal-content {
  position: relative;
  z-index: 1001;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 24px;
  max-width: 92vw;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  overflow: auto;
}

.image-modal-close {
  position: absolute;
  top: 16px;
  right: 20px;
  background: #334155;
  color: var(--text-main);
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}

.image-modal-close:hover {
  background: var(--target-red);
}

.image-modal-title {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  margin-bottom: 16px;
  color: var(--text-main);
  padding-right: 40px;
}

.image-modal-content img {
  max-width: 100%;
  max-height: 75vh;
  object-fit: contain;
  border-radius: 8px;
}

.image-error-box {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
}

.image-error-box code {
  color: var(--primary-blue);
  background: rgba(56, 189, 248, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
}

/* Login Page Specific Styles */
.login-body {
  background: radial-gradient(circle at 50% 30%, #1e293b 0%, #0f172a 70%);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.login-wrapper {
  width: 100%;
  max-width: 440px;
}

.glass-login-card {
  background: rgba(30, 41, 59, 0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: 16px;
  padding: 32px 28px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5), 0 0 20px rgba(56, 189, 248, 0.1);
}

.login-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.login-logo-icon {
  font-size: 2.2rem;
  background: linear-gradient(135deg, #0284c7, #38bdf8);
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.4);
}

.login-title-group h2 {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  color: var(--text-main);
}

.login-title-group .subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.default-cred-banner {
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.82rem;
  color: var(--primary-blue);
  margin-bottom: 20px;
  text-align: center;
}

.default-cred-banner code {
  background: rgba(15, 23, 42, 0.8);
  color: #fff;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

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

.form-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-main);
}

.form-input {
  background: #0f172a;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--text-main);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-input:focus {
  border-color: var(--primary-blue);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.25);
}

.btn-block {
  width: 100%;
  padding: 12px;
  font-size: 0.95rem;
  margin-top: 6px;
}

.error-banner {
  background: rgba(244, 63, 94, 0.15);
  border: 1px solid rgba(244, 63, 94, 0.4);
  color: var(--target-red);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
}

.login-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.btn-logout {
  background: rgba(244, 63, 94, 0.15);
  color: var(--target-red);
  border: 1px solid rgba(244, 63, 94, 0.3);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-logout:hover {
  background: rgba(244, 63, 94, 0.3);
  color: #fff;
}
