/* ═══════════════════════════════════════════════════════════════
   BULLSTAFF — Shared Styles
   Используется во всех страницах: journal.html, analytics.html, library.html
═══════════════════════════════════════════════════════════════ */

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

:root {
  --bg: #fcfaf8;
  --sidebar: #f5f2ed;
  --accent: #4a7fa5;
  --accent-light: #e8f0f7;
  --text-h: #1a1a1a;
  --text: #4b5563;
  --text-muted: #9ca3af;
  --border: #e8e4df;
  --card-radius: 20px;
  --btn-radius: 8px;
  --sidebar-w: 260px;
  --win: #5ba08a;
  --loss: #d95f5f;
  --c-asian: #7c6fcd; --c-london: #4a7fa5; --c-win1: #5ba08a;
  --c-prem: #e8a838;  --c-news: #d95f5f;   --c-am1: #4a90d9;
  --c-am2: #5cb85c;   --c-am3: #6ba3d9;    --c-am4: #7bb3e9;
  --c-lunch: #a0a0a0; --c-win2: #7ab8c4;   --c-pm1: #9b6bb5;
  --c-pm2: #6b9bd2;   --c-winf: #c4956a;
}

html, body {
  height: 100%;
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

/* ── LAYOUT ── */
.app { display: flex; height: 100vh; min-width: 1024px; overflow: hidden; }

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  transition: transform 0.3s ease-out, width 0.3s ease-out;
}
.sidebar.collapsed { transform: translateX(-100%); width: 0; min-width: 0; }

.sidebar-logo { padding: 28px 24px 20px; border-bottom: 1px solid var(--border); }
.sidebar-logo h1 {
  font-family: 'Playfair Display', serif;
  font-size: 22px; font-weight: 700;
  color: var(--text-h); letter-spacing: -0.3px;
}
.sidebar-logo p { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ── LANG SWITCHER ── */
.lang-switcher {
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; gap: 8px; align-items: center;
}
.lang-btn {
  padding: 4px 12px; border-radius: 6px;
  border: 1px solid var(--border); background: transparent;
  font-size: 12px; font-weight: 500; color: var(--text); cursor: pointer;
  transition: all 0.15s;
}
.lang-btn:hover { background: var(--bg); }
.lang-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── NAV ── */
.sidebar-nav { padding: 16px 12px; flex: 1; display: flex; flex-direction: column; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--btn-radius);
  cursor: pointer; font-size: 14px; font-weight: 500;
  color: var(--text); transition: all 0.15s; user-select: none;
  text-decoration: none;
}
.nav-item:hover { background: rgba(74,127,165,0.08); color: var(--accent); }
.nav-item.active { background: var(--accent-light); color: var(--accent); }
.nav-item .icon { flex-shrink: 0; opacity: 0.75; }
.nav-item.active .icon { opacity: 1; }

/* ── ACCORDION ── */
.nav-accordion { margin-top: 4px; }
.accordion-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 10px 12px; border-radius: var(--btn-radius);
  cursor: pointer; font-size: 14px; font-weight: 500;
  color: var(--text); transition: all 0.15s; user-select: none;
}
.accordion-header:hover { background: rgba(74,127,165,0.08); color: var(--accent); }
.accordion-header.active { background: var(--accent-light); color: var(--accent); }
.accordion-icon { transition: transform 0.2s; }
.accordion-header.open .accordion-icon { transform: rotate(90deg); }
.accordion-content { max-height: 0; overflow: hidden; transition: max-height 0.3s ease-out; padding-left: 24px; }
.accordion-content.open { max-height: 500px; }
.accordion-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: 6px;
  cursor: pointer; font-size: 13px; color: var(--text);
  transition: all 0.15s; margin-top: 2px;
  text-decoration: none;
}
.accordion-item:hover { background: rgba(74,127,165,0.06); color: var(--accent); }
.accordion-item.active { background: var(--accent-light); color: var(--accent); font-weight: 500; }

/* ── AUTH SECTION ── */
.sidebar-auth {
  margin-top: auto;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}
.auth-user-info {
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
  display: none;
}

/* ── MAIN ── */
.main { flex: 1; overflow-y: auto; overflow-x: hidden; background: var(--bg); position: relative; }

/* ── CONTENT ── */
.content { padding: 24px 32px; max-width: 1600px; margin: 0 auto; }

/* ── PAGE HEADER ── */
.page-header { margin-bottom: 24px; }
.page-title {
  font-family: 'Playfair Display', serif;
  font-size: 28px; font-weight: 700;
  color: var(--text-h); margin-bottom: 8px;
}
.page-subtitle { font-size: 14px; color: var(--text-muted); }

/* ── HEADER ACTIONS ── */
.header-actions {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: #fff;
  flex-wrap: wrap;
}

/* ── CARDS ── */
.cards-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.card { background: #fff; border: 1px solid var(--border); border-radius: var(--card-radius); padding: 20px; }
.card-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-muted); margin-bottom: 8px; }
.card-value { font-family: 'Playfair Display', serif; font-size: 28px; font-weight: 700; color: var(--accent); line-height: 1; }
.card-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ── SECTION BLOCK ── */
.section-block { background: #fff; border: 1px solid var(--border); border-radius: var(--card-radius); padding: 24px; margin-bottom: 24px; }
.section-title { font-family: 'Playfair Display', serif; font-size: 16px; font-weight: 600; color: var(--text-h); margin-bottom: 16px; }

/* ── CHART ── */
.chart-container { position: relative; height: 320px; }
.charts-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px; margin-bottom: 24px; }

/* ── BUTTONS ── */
.btn {
  padding: 8px 16px; border-radius: var(--btn-radius);
  font-size: 13px; font-weight: 500; font-family: 'Inter', sans-serif;
  cursor: pointer; transition: all 0.15s; border: none;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn-primary { background: var(--accent); color: #fff; border: 1px solid var(--accent); }
.btn-primary:hover { background: #3d6a8a; border-color: #3d6a8a; }
.btn-secondary { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-secondary:hover { background: var(--sidebar); border-color: var(--text-muted); }
.btn-danger { background: transparent; border: 1px solid var(--loss); color: var(--loss); }
.btn-danger:hover { background: rgba(217,95,95,0.08); }

/* ── ICON BUTTON ── */
.icon-btn {
  background: transparent; border: none; color: var(--text-muted);
  cursor: pointer; padding: 4px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 4px; transition: all 0.15s;
}
.icon-btn:hover { background: var(--sidebar); color: var(--accent); }

/* ── TABLE ── */
.table-wrap { overflow-x: auto; position: relative; }
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; table-layout: fixed; }
.data-table th {
  padding: 10px 12px; text-align: left;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-muted); border-bottom: 1.5px solid var(--border);
  border-right: 1px solid var(--border); white-space: nowrap;
  background: var(--bg); position: relative; resize: horizontal; overflow: hidden;
}
.data-table th:last-child { border-right: none; }
.data-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); color: var(--text); white-space: nowrap; }
.data-table td:last-child { border-right: none; }
.data-table tr:hover td { background: var(--sidebar); }

/* Month separator */
.month-separator { background: var(--accent-light) !important; font-weight: 600; color: var(--accent); }
.month-separator td { padding: 12px !important; font-size: 14px; font-family: 'Playfair Display', serif; border-top: 2px solid var(--accent) !important; border-bottom: 2px solid var(--accent) !important; }
.month-separator:hover td { background: var(--accent-light) !important; }

/* Editable table */
.editable-table td input, .editable-table td select {
  border: 1px solid var(--border); padding: 6px 8px; border-radius: 4px;
  outline: none; background: transparent; font-size: 13px;
  font-family: 'Inter', sans-serif; color: var(--text-h); width: 100%; transition: all 0.15s;
}
.editable-table td input:focus, .editable-table td select:focus { background: #fff; border-color: var(--accent); }

/* ── BADGES ── */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.badge-win { background: rgba(91,160,138,0.15); color: var(--win); }
.badge-loss { background: rgba(217,95,95,0.15); color: var(--loss); }
.badge-buy { background: rgba(74,127,165,0.15); color: var(--accent); }
.badge-sell { background: rgba(217,95,95,0.15); color: var(--loss); }

/* ── EMPTY STATE ── */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-muted); font-size: 14px; }
.empty-row { background: var(--sidebar) !important; }
.empty-row td { text-align: center; color: var(--text-muted); font-size: 12px; padding: 16px !important; }

/* ── LOADING ── */
.loading-overlay { display: none; position: fixed; inset: 0; background: rgba(252,250,248,0.7); z-index: 100; align-items: center; justify-content: center; }
.loading-overlay.visible { display: flex; }
.spinner { width: 32px; height: 32px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── DRAWER ── */
.drawer-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 300; }
.drawer-overlay.visible { display: block; }

.drawer {
  position: fixed; top: 0; right: -600px; width: 560px;
  min-width: 400px; max-width: 80vw; height: 100vh;
  background: var(--bg); border-left: 1px solid var(--border);
  box-shadow: -4px 0 24px rgba(0,0,0,0.08); z-index: 301;
  display: flex; flex-direction: column;
  transition: right 280ms cubic-bezier(0.4,0,0.2,1);
}
.drawer.visible { right: 0; }
.drawer.resizing { transition: none; }

.drawer-resize-handle {
  position: absolute; left: 0; top: 0; bottom: 0; width: 8px;
  cursor: ew-resize; z-index: 302; background: transparent; transition: background 0.15s;
}
.drawer-resize-handle:hover, .drawer-resize-handle.resizing { background: rgba(74,127,165,0.2); }

.drawer-header { padding: 28px 32px 0; flex-shrink: 0; position: relative; }
.drawer-title { font-family: 'Playfair Display', serif; font-size: 22px; font-weight: 700; color: var(--text-h); letter-spacing: -0.3px; margin-bottom: 2px; }
.drawer-date { font-size: 13px; color: var(--text-muted); }

.modal-close-btn {
  position: absolute; top: 14px; right: 14px; width: 30px; height: 30px;
  border-radius: 6px; border: none; background: transparent; color: var(--text-muted);
  cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.15s;
}
.modal-close-btn:hover { background: var(--sidebar); color: var(--text-h); }

.drawer-tabs {
  display: flex; gap: 0; padding: 0 32px; margin-top: 16px;
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.drawer-tab {
  padding: 8px 14px; font-size: 13px; font-weight: 500; color: var(--text-muted);
  cursor: pointer; border: none; border-bottom: 2px solid transparent;
  background: transparent; margin-bottom: -1px; transition: all 0.15s; user-select: none;
}
.drawer-tab:hover { color: var(--text); }
.drawer-tab.active { color: var(--text-h); border-bottom-color: var(--text-h); }

.drawer-body { flex: 1; overflow-y: auto; padding: 24px 32px 80px; }
.drawer-tab-content { display: none; }
.drawer-tab-content.active { display: block; }

.drawer-section { margin-bottom: 28px; }
.drawer-section-title { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-muted); margin-bottom: 10px; }

.drawer-field { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.drawer-field:last-child { border-bottom: none; }
.drawer-field-label { color: var(--text-muted); font-weight: 500; min-width: 100px; }
.drawer-field-value { color: var(--text-h); font-weight: 600; text-align: right; }

.drawer-footer {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 14px 32px; border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg);
}
.drawer-paste-hint { font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }

/* ── NOTES EDITOR ── */
.notes-editor {
  display: block; width: 100%; min-height: 200px; max-height: 500px;
  overflow-y: auto; padding: 14px 16px;
  border: 1px solid var(--border); border-radius: 8px;
  background: #fff; font-size: 14px; font-family: 'Inter', sans-serif;
  color: var(--text-h); outline: none; line-height: 1.7;
  transition: border-color 0.15s; cursor: text;
  word-break: break-word; white-space: pre-wrap; overflow-wrap: break-word;
}
.notes-editor:hover { border-color: var(--text-muted); }
.notes-editor:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(74,127,165,0.1); }
.notes-editor:empty:before { content: attr(data-placeholder); color: var(--text-muted); pointer-events: none; display: block; }
.notes-editor img, .notes-editor video { max-width: 100%; border-radius: 6px; margin: 10px 0; display: block; }
.notes-editor img { cursor: zoom-in; }

/* ── MEDIA GRID ── */
.drawer-media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; margin-top: 12px; }
.drawer-media-item { position: relative; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); aspect-ratio: 16/9; background: var(--sidebar); transition: all 0.2s; }
.drawer-media-item:hover { border-color: var(--accent); box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
.drawer-media-item img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.drawer-media-item video { width: 100%; height: 100%; object-fit: cover; }
.drawer-media-remove { position: absolute; top: 6px; right: 6px; width: 22px; height: 22px; border-radius: 4px; background: rgba(0,0,0,0.65); border: none; color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity 0.15s; font-size: 12px; }
.drawer-media-item:hover .drawer-media-remove { opacity: 1; }

/* ── LIGHTBOX ── */
.lightbox { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.92); z-index: 400; align-items: center; justify-content: center; }
.lightbox.visible { display: flex; }
.lightbox-content { position: relative; max-width: 95vw; max-height: 95vh; }
.lightbox-image { max-width: 100%; max-height: 95vh; object-fit: contain; border-radius: 6px; }
.lightbox-close { position: absolute; top: -40px; right: 0; width: 32px; height: 32px; border-radius: 50%; background: rgba(255,255,255,0.15); border: none; color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background 0.15s; }
.lightbox-close:hover { background: rgba(255,255,255,0.3); }

/* ── LOGIN MODAL ── */
.login-modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 500; align-items: center; justify-content: center; }
.login-modal-overlay.visible { display: flex; }
.login-modal { background: #fff; border-radius: 16px; padding: 40px; width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,0.15); }
.login-modal h2 { font-family: 'Playfair Display', serif; font-size: 22px; font-weight: 700; color: var(--text-h); margin-bottom: 8px; }
.login-modal p { font-size: 13px; color: var(--text-muted); margin-bottom: 24px; }
.login-field { margin-bottom: 16px; }
.login-field label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.login-field input { width: 100%; padding: 10px 14px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; font-family: 'Inter', sans-serif; outline: none; transition: border-color 0.15s; }
.login-field input:focus { border-color: var(--accent); }
.login-error { font-size: 13px; color: var(--loss); margin-bottom: 12px; display: none; }
.login-error.visible { display: block; }

/* ── SAVE STATUS ── */
.save-status { font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 4px; }
.save-status.saving { color: var(--accent); }
.save-status.saved  { color: var(--win); }
.save-status.error  { color: var(--loss); }

/* ── TRADE NUMBER ── */
.trade-number { color: var(--text-muted); font-weight: 600; font-size: 12px; }

/* ── SETUP BADGE ── */
.setup-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 10px;
  font-size: 11px; font-weight: 600;
  background: var(--accent-light); color: var(--accent);
  white-space: nowrap;
}

/* ── LIBRARY CARD ── */
.library-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }
.library-card {
  background: #fff; border: 1px solid var(--border); border-radius: var(--card-radius);
  padding: 20px; cursor: pointer; transition: all 0.2s;
}
.library-card:hover { border-color: var(--accent); box-shadow: 0 4px 16px rgba(74,127,165,0.1); }
.library-card-name { font-family: 'Playfair Display', serif; font-size: 16px; font-weight: 600; color: var(--text-h); margin-bottom: 4px; }
.library-card-category { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); margin-bottom: 8px; }
.library-card-desc { font-size: 13px; color: var(--text); line-height: 1.5; }
.library-card-stats { display: flex; gap: 16px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.library-card-stat { font-size: 12px; color: var(--text-muted); }
.library-card-stat strong { color: var(--text-h); font-weight: 600; }

@media (max-width: 768px) {
  .drawer { width: 100%; right: -100%; }
  .cards-row { grid-template-columns: repeat(2, 1fr); }
  .charts-grid { grid-template-columns: 1fr; }
}

/* ── QUICK LINK CARDS ── */
.quick-link-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  text-decoration: none;
  transition: all 0.2s;
  cursor: pointer;
}

.quick-link-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(74, 127, 165, 0.1);
  transform: translateY(-2px);
}

.quick-link-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  flex-shrink: 0;
}

.quick-link-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-h);
  margin-bottom: 4px;
}

.quick-link-desc {
  font-size: 13px;
  color: var(--text-muted);
}
