/* ==========================================================================
   TimChart Dashboard Styling - Premium Glassmorphism Theme
   ========================================================================== */

/* 1. CSS VARIABLES & SYSTEM TOKENS */
:root {
  --font-primary: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display: 'Outfit', var(--font-primary);
  
  /* Color Palette */
  --bg-app: #090d16;
  --bg-sidebar: rgba(15, 23, 42, 0.75);
  --bg-card: rgba(30, 41, 59, 0.45);
  --bg-card-hover: rgba(30, 41, 59, 0.65);
  --bg-input: rgba(15, 23, 42, 0.6);
  
  --border-glass: rgba(255, 255, 255, 0.07);
  --border-glass-hover: rgba(255, 255, 255, 0.15);
  --border-active: rgba(99, 102, 241, 0.4);
  
  --accent-primary: #6366f1; /* Indigo */
  --accent-primary-glow: rgba(99, 102, 241, 0.35);
  --accent-cyan: #0ea5e9; /* Sky Blue */
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dark: #64748b;
  
  /* Position Badge Colors */
  --color-no-pos: #64748b;      /* Slate */
  --color-buy-entry: #10b981;   /* Emerald */
  --color-buy-exit: #34d399;    /* Mint */
  --color-sell-entry: #ef4444;   /* Red */
  --color-sell-exit: #fb7185;    /* Rose/Coral */
  
  /* Shadows & Blurs */
  --blur-glass: 16px;
  --shadow-premium: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  --shadow-inset: inset 0 1px 1px 0 rgba(255, 255, 255, 0.05);
  --shadow-glow-buy: 0 0 15px rgba(16, 185, 129, 0.25);
  --shadow-glow-sell: 0 0 15px rgba(239, 68, 68, 0.25);
  
  /* Transitions */
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* 2. BASE RESET */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background-color: var(--bg-app);
  color: var(--text-main);
  font-family: var(--font-primary);
  height: 100vh;
  overflow: hidden;
  background-image: 
    radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.12) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(14, 165, 233, 0.08) 0px, transparent 50%),
    radial-gradient(at 50% 50%, rgba(15, 23, 42, 0.5) 0px, transparent 100%);
  background-attachment: fixed;
}

/* Custom scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.3);
}
::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.2);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.4);
}

/* 3. APP STRUCTURE LAYOUT */
.app-container {
  display: flex;
  width: 100vw;
  height: 100vh;
  position: relative;
}

/* SIDEBAR STYLES */
.sidebar {
  width: 290px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-glass);
  backdrop-filter: blur(var(--blur-glass));
  -webkit-backdrop-filter: blur(var(--blur-glass));
  display: flex;
  flex-direction: column;
  padding: 24px;
  flex-shrink: 0;
  z-index: 10;
  box-shadow: var(--shadow-premium);
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border-glass);
  margin-bottom: 24px;
}

.brand-logo {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-cyan));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px var(--accent-primary-glow);
}

.logo-icon {
  width: 20px;
  height: 20px;
  color: white;
}

.brand-info h1 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.2;
  background: linear-gradient(to right, #ffffff, #e2e8f0);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-tagline {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.navigation-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0; /* Important for inner scroll */
  margin-bottom: 24px;
}

.section-title {
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dark);
  margin-bottom: 12px;
  padding-left: 8px;
}

.dates-list-container {
  flex: 1;
  overflow-y: auto;
  padding-right: 4px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Date Item styling */
.date-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(30, 41, 59, 0.25);
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition-smooth);
  font-weight: 500;
  font-size: 0.9rem;
}

.date-item:hover {
  background: rgba(30, 41, 59, 0.45);
  color: var(--text-main);
  border-color: var(--border-glass-hover);
}

.date-item.active {
  background: rgba(99, 102, 241, 0.15);
  border-color: var(--border-active);
  color: var(--text-main);
  box-shadow: var(--shadow-inset);
}

.date-badge {
  background: rgba(148, 163, 184, 0.15);
  color: var(--text-main);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 9999px;
  border: 1px solid var(--border-glass);
}

.date-item.active .date-badge {
  background: var(--accent-primary);
  color: white;
  border-color: transparent;
}

/* Filter Options */
.filters-panel {
  margin-bottom: 24px;
}

.filter-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.filter-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text-muted);
  font-family: var(--font-primary);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: var(--transition-smooth);
}

.filter-btn:hover {
  background: rgba(30, 41, 59, 0.3);
  color: var(--text-main);
}

.filter-btn.active {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--border-glass-hover);
  color: var(--text-main);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot.all { background: white; }
.dot.no-pos { background: var(--color-no-pos); }
.dot.buy-entry { background: var(--color-buy-entry); box-shadow: 0 0 8px var(--color-buy-entry); }
.dot.buy-exit { background: var(--color-buy-exit); }
.dot.sell-entry { background: var(--color-sell-entry); box-shadow: 0 0 8px var(--color-sell-entry); }
.dot.sell-exit { background: var(--color-sell-exit); }

/* Sidebar footer */
.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid var(--border-glass);
  padding-top: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sidebar-footer p {
  font-size: 0.7rem;
  color: var(--text-dark);
}

.status-indicator {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-indicator::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: #10b981;
  box-shadow: 0 0 6px #10b981;
}

/* MAIN CONTENT AREA */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 36px 40px;
}

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

.breadcrumb {
  font-size: 0.75rem;
  color: var(--text-dark);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
}

.current-date-title {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-main);
  margin-top: 4px;
}

.btn-refresh {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: 8px;
  color: var(--text-main);
  font-family: var(--font-primary);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-smooth);
  box-shadow: var(--shadow-inset);
}

.btn-refresh:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-glass-hover);
}

.refresh-icon {
  width: 15px;
  height: 15px;
}

/* STATS CONTAINERS */
.stats-container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  backdrop-filter: blur(var(--blur-glass));
  -webkit-backdrop-filter: blur(var(--blur-glass));
  box-shadow: var(--shadow-premium), var(--shadow-inset);
  transition: var(--transition-smooth);
}

.stat-card:hover {
  border-color: var(--border-glass-hover);
  transform: translateY(-2px);
}

.stat-icon-wrapper {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-glass);
}

.stat-icon-wrapper.total { color: var(--accent-cyan); background: rgba(14, 165, 233, 0.08); }
.stat-icon-wrapper.buy { color: var(--color-buy-entry); background: rgba(16, 185, 129, 0.08); }
.stat-icon-wrapper.sell { color: var(--color-sell-entry); background: rgba(239, 68, 68, 0.08); }

.stat-icon {
  width: 22px;
  height: 22px;
}

.stat-info {
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 4px;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
}

.text-success { color: var(--color-buy-entry); }
.text-danger { color: var(--color-sell-entry); }

/* GRID LAYOUT SECTION */
.grid-section {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.grid-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 24px;
  flex: 1;
}

/* Empty State / Loading State styling */
.loading-state, .empty-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  text-align: center;
  color: var(--text-muted);
  background: var(--bg-card);
  border: 1px dashed var(--border-glass);
  border-radius: 16px;
  backdrop-filter: blur(var(--blur-glass));
  font-size: 0.95rem;
  min-height: 240px;
}

.empty-state-icon {
  width: 48px;
  height: 48px;
  color: var(--text-dark);
  margin-bottom: 16px;
}

/* CHART CARD COMPONENTS */
.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: 14px;
  overflow: hidden;
  backdrop-filter: blur(var(--blur-glass));
  -webkit-backdrop-filter: blur(var(--blur-glass));
  box-shadow: var(--shadow-premium), var(--shadow-inset);
  display: flex;
  flex-direction: column;
  transition: var(--transition-bounce);
  animation: cardFadeIn 0.4s ease-out forwards;
}

.chart-card:hover {
  transform: translateY(-5px);
  border-color: var(--border-glass-hover);
  box-shadow: 0 12px 30px 0 rgba(0, 0, 0, 0.45), var(--shadow-inset);
}

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

.chart-card-image-box {
  width: 100%;
  aspect-ratio: 16/10;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  background: #000;
  border-bottom: 1px solid var(--border-glass);
}

.chart-card-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: var(--transition-smooth);
}

.chart-card:hover .chart-card-image {
  transform: scale(1.05);
}

.chart-card-overlay {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
}

.badge-position {
  font-family: var(--font-primary);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.badge-position.pos-0 { background-color: rgba(100, 116, 139, 0.8); }
.badge-position.pos-1 { background-color: rgba(16, 185, 129, 0.8); border-color: rgba(16, 185, 129, 0.3); box-shadow: var(--shadow-glow-buy); }
.badge-position.pos-2 { background-color: rgba(52, 211, 153, 0.8); border-color: rgba(52, 211, 153, 0.3); }
.badge-position.pos-3 { background-color: rgba(239, 68, 68, 0.8); border-color: rgba(239, 68, 68, 0.3); box-shadow: var(--shadow-glow-sell); }
.badge-position.pos-4 { background-color: rgba(251, 113, 133, 0.8); border-color: rgba(251, 113, 133, 0.3); }

.badge-time {
  background-color: rgba(15, 23, 42, 0.75);
  color: var(--text-main);
  font-size: 0.7rem;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid var(--border-glass);
}

.chart-card-details {
  padding: 16px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.chart-card-memo {
  font-size: 0.88rem;
  color: var(--text-main);
  line-height: 1.5;
  margin-bottom: 16px;
  flex: 1;
  word-break: break-all;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.chart-card-memo.empty {
  color: var(--text-dark);
  font-style: italic;
}

.chart-card-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  padding-top: 12px;
}

.btn-delete {
  background: transparent;
  border: none;
  color: var(--text-dark);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  font-family: var(--font-primary);
  transition: var(--transition-smooth);
}

.btn-delete:hover {
  color: var(--color-sell-entry);
  background: rgba(239, 68, 68, 0.08);
}

.delete-icon {
  width: 14px;
  height: 14px;
}

/* LIGHTBOX MODAL STYLES */
.lightbox-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(5, 8, 16, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.lightbox-overlay.show {
  display: flex;
  opacity: 1;
}

.lightbox-close {
  position: absolute;
  top: 24px;
  right: 28px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glass);
  color: var(--text-main);
  font-size: 2rem;
  line-height: 1;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
  z-index: 102;
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: rotate(90deg);
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-glass);
  color: var(--text-main);
  width: 54px;
  height: 54px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
  z-index: 102;
}

.lightbox-nav svg {
  width: 24px;
  height: 24px;
}

.lightbox-nav:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--border-glass-hover);
}

.lightbox-nav.prev { left: 36px; }
.lightbox-nav.next { right: 36px; }

.lightbox-container {
  display: flex;
  width: 86%;
  height: 84%;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-glass);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: var(--shadow-premium);
  max-width: 1400px;
  animation: lightboxScaleUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes lightboxScaleUp {
  from {
    transform: scale(0.92);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.lightbox-image-wrapper {
  flex: 3;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  border-right: 1px solid var(--border-glass);
}

#lightbox-image {
  max-width: 95%;
  max-height: 95%;
  object-fit: contain;
  transition: transform 0.25s ease-out;
  border-radius: 4px;
}

.lightbox-details {
  flex: 1;
  padding: 36px;
  display: flex;
  flex-direction: column;
  min-width: 320px;
  background: rgba(15, 23, 42, 0.45);
}

.lightbox-header {
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-bottom: 1px solid var(--border-glass);
  padding-bottom: 24px;
  margin-bottom: 24px;
}

.lightbox-date {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

.lightbox-badge {
  align-self: flex-start;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 8px;
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.lightbox-badge.pos-0 { background-color: var(--color-no-pos); }
.lightbox-badge.pos-1 { background-color: var(--color-buy-entry); box-shadow: var(--shadow-glow-buy); }
.lightbox-badge.pos-2 { background-color: var(--color-buy-exit); }
.lightbox-badge.pos-3 { background-color: var(--color-sell-entry); box-shadow: var(--shadow-glow-sell); }
.lightbox-badge.pos-4 { background-color: var(--color-sell-exit); }

.lightbox-memo-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

.lightbox-memo-wrapper h3 {
  font-family: var(--font-display);
  font-size: 0.9rem;
  text-transform: uppercase;
  color: var(--text-dark);
  font-weight: 700;
  letter-spacing: 0.05em;
}

.lightbox-memo {
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text-main);
  overflow-y: auto;
  padding-right: 6px;
  white-space: pre-wrap;
  word-break: break-all;
}

.lightbox-memo.empty {
  color: var(--text-dark);
  font-style: italic;
}

.lightbox-actions {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--border-glass);
}

.btn-delete-lightbox {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: #f87171;
  padding: 12px;
  border-radius: 10px;
  font-family: var(--font-primary);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-delete-lightbox:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.4);
  color: #ef4444;
}

/* TOAST SYSTEM STYLES */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 1000;
}

.toast {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--border-glass-hover);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-premium);
  border-radius: 10px;
  padding: 14px 20px;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 300px;
  max-width: 420px;
  animation: toastSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  transition: var(--transition-smooth);
}

.toast.removing {
  opacity: 0;
  transform: translateX(30px);
}

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

.toast-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.toast-success { border-left: 4px solid var(--color-buy-entry); }
.toast-success .toast-icon { color: var(--color-buy-entry); }

.toast-error { border-left: 4px solid var(--color-sell-entry); }
.toast-error .toast-icon { color: var(--color-sell-entry); }

.toast-info { border-left: 4px solid var(--accent-cyan); }
.toast-info .toast-icon { color: var(--accent-cyan); }

.toast-message {
  font-size: 0.85rem;
  font-weight: 500;
  line-height: 1.4;
}

/* RESPONSIVE DESIGN */
@media (max-width: 1024px) {
  .stats-container {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  
  .lightbox-container {
    flex-direction: column;
    height: 90%;
    width: 90%;
  }
  
  .lightbox-image-wrapper {
    flex: 2;
    border-right: none;
    border-bottom: 1px solid var(--border-glass);
  }
  
  .lightbox-details {
    flex: 1.2;
    padding: 24px;
  }
  
  .lightbox-nav {
    width: 44px;
    height: 44px;
  }
  .lightbox-nav.prev { left: 12px; }
  .lightbox-nav.next { right: 12px; }
}

@media (max-width: 768px) {
  .app-container {
    flex-direction: column;
  }
  
  .sidebar {
    width: 100%;
    height: auto;
    max-height: 300px;
    border-right: none;
    border-bottom: 1px solid var(--border-glass);
  }
  
  .main-content {
    padding: 24px;
  }
}
