/* MarketVisionPlus Web — habillage Windows classique */

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

:root {
  --gray: #d4d0c8;
  --gray-light: #ffffff;
  --gray-dark: #808080;
  --gray-darker: #404040;
  --sel-blue: #2a5bd7;
  --title1: #0a246a;
  --title2: #a6caf0;
}

html, body { height: 100%; }
body {
  font-family: Tahoma, "MS Sans Serif", Arial, sans-serif;
  font-size: 11px;
  background: #3a6ea5;
  overflow: hidden;
  user-select: none;
  cursor: default;
}

#win {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--gray);
  border: 1px solid #0831d9;
  outline: 1px solid #001ea0;
}

/* ---- biseaux ---- */
.bevel-out, #toolbar .tb-btn, .side-btn, .tab, .market-combo, .db-btn {
  border-top: 1px solid var(--gray-light);
  border-left: 1px solid var(--gray-light);
  border-right: 1px solid var(--gray-dark);
  border-bottom: 1px solid var(--gray-dark);
}
.bevel-in {
  border-top: 1px solid var(--gray-dark);
  border-left: 1px solid var(--gray-dark);
  border-right: 1px solid var(--gray-light);
  border-bottom: 1px solid var(--gray-light);
}

/* ---- barre de titre ---- */
#titlebar {
  display: flex; align-items: center;
  height: 22px; padding: 0 3px;
  background: linear-gradient(90deg, var(--title1), var(--title2));
  color: #fff; font-weight: bold; font-size: 12px;
  flex: 0 0 auto;
}
.app-icon {
  width: 14px; height: 14px; margin-right: 4px;
  background:
    linear-gradient(45deg, #d02020 25%, transparent 25%, transparent 75%, #d02020 75%) 0 0/7px 7px,
    #f0f0f0;
  border: 1px solid #fff;
}
#title-text { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.title-btns { display: flex; gap: 2px; }
.tbtn {
  width: 18px; height: 16px; text-align: center; line-height: 14px;
  background: var(--gray); color: #000; font-weight: bold; font-size: 11px;
  border-top: 1px solid #fff; border-left: 1px solid #fff;
  border-right: 1px solid var(--gray-darker); border-bottom: 1px solid var(--gray-darker);
}
.tbtn-close { background: #c85050; color: #fff; }

/* ---- barre d'outils ---- */
#toolbar {
  display: flex; align-items: stretch; padding: 2px 3px; gap: 1px;
  border-bottom: 1px solid var(--gray-dark);
  flex: 0 0 auto; overflow: hidden;
}
.tb-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 52px; padding: 2px 4px 1px; gap: 1px;
  background: var(--gray); text-align: center; white-space: nowrap;
}
.tb-btn svg { width: 22px; height: 22px; }
.tb-btn.active {
  border-top: 1px solid var(--gray-dark); border-left: 1px solid var(--gray-dark);
  border-right: 1px solid var(--gray-light); border-bottom: 1px solid var(--gray-light);
  background: #e6e2da;
}
.tb-btn.disabled { opacity: 0.45; filter: grayscale(1); }
.tb-btn:not(.disabled):hover { background: #e2ded6; }
.tb-sep { width: 4px; }

/* ---- onglets marchés ---- */
.tabrow {
  display: flex; align-items: center; padding: 2px 3px; gap: 2px;
  border-bottom: 1px solid var(--gray-dark);
  flex: 0 0 auto; flex-wrap: nowrap; overflow: hidden;
}
.market-combo {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 4px; background: #fff; font-weight: bold;
  border: 1px solid var(--gray-dark);
}
.combo-arrow { font-size: 8px; background: var(--gray); padding: 1px 2px;
  border-top: 1px solid #fff; border-left: 1px solid #fff;
  border-right: 1px solid var(--gray-darker); border-bottom: 1px solid var(--gray-darker); }
.tab {
  padding: 2px 7px; background: var(--gray); white-space: nowrap;
}
.tab.active {
  background: #fff; font-weight: bold; color: #000;
  border: 1px solid var(--gray-darker);
}
.tab-disabled { opacity: 0.5; }
.tab:not(.tab-disabled):not(.active):hover { background: #e2ded6; }

/* ---- corps ---- */
#body { display: flex; flex: 1 1 auto; min-height: 0; }

/* ---- barre latérale ---- */
#sidebar {
  width: 64px; flex: 0 0 auto;
  display: flex; flex-direction: column; align-items: stretch;
  padding: 4px 2px; gap: 3px;
  border-right: 1px solid var(--gray-dark);
  overflow: hidden;
}
.side-btn {
  display: flex; flex-direction: column; align-items: center;
  padding: 3px 1px 2px; gap: 1px; background: var(--gray);
  text-align: center; font-size: 10px;
}
.side-btn svg { width: 18px; height: 18px; }
.side-btn.pressed {
  border-top: 1px solid var(--gray-dark); border-left: 1px solid var(--gray-dark);
  border-right: 1px solid var(--gray-light); border-bottom: 1px solid var(--gray-light);
  background: repeating-conic-gradient(#e8e4dc 0% 25%, #dcd8d0 0% 50%) 0 0/4px 4px;
}
.side-btn.disabled { opacity: 0.45; filter: grayscale(1); }
.side-btn:not(.disabled):not(.pressed):hover { background: #e2ded6; }
.side-sep { height: 4px; }

/* ---- zone principale ---- */
#main {
  flex: 1 1 auto; min-width: 0; position: relative;
  border-top: 1px solid var(--gray-dark); border-left: 1px solid var(--gray-dark);
  border-right: 1px solid var(--gray-light); border-bottom: 1px solid var(--gray-light);
  background: #fff;
  display: flex; flex-direction: column;
}

/* ---- vue cotes ---- */
#view-quotes { flex: 1; overflow: auto; background: #fff; display: none; }
#view-quotes.visible { display: block; }
#qtable {
  border-collapse: collapse; width: 100%;
  font-family: Arial, sans-serif; font-size: 13px;
}
#qtable thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--gray); font-weight: normal; text-align: left;
  padding: 2px 6px; font-size: 11px; font-family: Tahoma, sans-serif;
  border-right: 1px solid var(--gray-dark);
  border-bottom: 1px solid var(--gray-dark);
  box-shadow: inset 1px 1px 0 #fff;
  white-space: nowrap;
}
#qtable thead th.sortable:hover { background: #e2ded6; }
#qtable td {
  padding: 1px 6px; border-right: 1px solid #d8d8d8;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#qtable td.num { text-align: right; font-variant-numeric: tabular-nums; }
#qtable tbody tr { height: 21px; }
#qtable tbody tr.sel { background: var(--sel-blue); color: #fff; }
#qtable tbody tr.sel td.var-neg, #qtable tbody tr.sel td.var-pos { color: inherit; }
#qtable tbody tr.idxrow:not(.sel) { background: #dce6f8; font-weight: bold; }
td.var-neg { background: #8b0000; color: #ffff00 !important; }
td.var-pos { background: #007000; color: #ffffff !important; }
tr.sel td.var-neg { background: #8b0000; }
tr.sel td.var-pos { background: #007000; }
td.err { color: #999; font-style: italic; }

/* ---- vue graphique ---- */
#view-chart { flex: 1; display: none; flex-direction: column; min-height: 0; }
#view-chart.visible { display: flex; }
#chart-head {
  display: flex; align-items: stretch; height: 24px; flex: 0 0 auto;
  background: var(--gray); font-family: Arial, sans-serif; font-size: 15px;
  border-bottom: 1px solid var(--gray-dark);
}
.ch-cell {
  display: flex; align-items: center; padding: 0 8px;
  border-right: 1px solid var(--gray-dark);
  box-shadow: inset 1px 1px 0 #fff;
  white-space: nowrap; overflow: hidden;
}
.ch-name { flex: 0 1 auto; min-width: 160px; max-width: 34%; }
.ch-cat { font-weight: bold; }
#ch-cat:empty { display: none; }
.ch-sec { flex: 1; border-right: none; }
.ch-up { color: #007000; font-weight: bold; }
.ch-down { color: #b00000; font-weight: bold; }
#chart-wrap { flex: 1; min-height: 0; position: relative; background: #0000a0; }
#chart { position: absolute; inset: 0; width: 100%; height: 100%; }

/* ---- barre de dessin ---- */
#drawbar {
  display: flex; align-items: stretch; padding: 2px 3px; gap: 1px;
  border-top: 1px solid var(--gray-light);
  flex: 0 0 auto; overflow: hidden;
}
.db-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 44px; padding: 1px 4px; gap: 0;
  background: var(--gray); font-size: 10px; white-space: nowrap;
}
.db-btn svg { width: 16px; height: 14px; }
.db-btn.disabled { opacity: 0.45; filter: grayscale(1); }
.db-btn:not(.disabled):hover { background: #e2ded6; }
.db-sep { width: 6px; }

/* ---- barre d'état ---- */
#statusbar {
  display: flex; align-items: center; height: 20px; padding: 1px 2px; gap: 2px;
  flex: 0 0 auto; font-size: 11px;
}
.st-cell {
  padding: 1px 8px; height: 16px; line-height: 14px;
  border-top: 1px solid var(--gray-dark); border-left: 1px solid var(--gray-dark);
  border-right: 1px solid var(--gray-light); border-bottom: 1px solid var(--gray-light);
  white-space: nowrap;
}
.st-fill { flex: 1; }
.st-fixed { min-width: 70px; text-align: center; }
#st-online.online { color: #007000; font-weight: bold; }

/* ---- ouverture de session ---- */
#login-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(58, 110, 165, 0.6);
  display: flex; align-items: center; justify-content: center;
}
#login-win {
  width: 320px; background: var(--gray);
  border-top: 2px solid var(--gray-light); border-left: 2px solid var(--gray-light);
  border-right: 2px solid var(--gray-darker); border-bottom: 2px solid var(--gray-darker);
  box-shadow: 4px 4px 12px rgba(0,0,0,0.5);
}
.login-title {
  display: flex; align-items: center; height: 22px; padding: 0 4px;
  background: linear-gradient(90deg, var(--title1), var(--title2));
  color: #fff; font-weight: bold; font-size: 12px;
}
.login-body { padding: 14px 16px 12px; display: flex; flex-direction: column; gap: 3px; }
.login-body label { margin-top: 6px; }
.login-body input {
  font: inherit; padding: 3px 4px; background: #fff;
  border-top: 1px solid var(--gray-dark); border-left: 1px solid var(--gray-dark);
  border-right: 1px solid var(--gray-light); border-bottom: 1px solid var(--gray-light);
  outline: none;
}
#login-err { color: #b00000; min-height: 14px; margin-top: 6px; }
.login-btns { display: flex; justify-content: center; gap: 10px; margin-top: 4px; }
#note-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(58, 110, 165, 0.35);
  display: flex; align-items: center; justify-content: center;
}
#note-win {
  width: 340px; background: var(--gray);
  border-top: 2px solid var(--gray-light); border-left: 2px solid var(--gray-light);
  border-right: 2px solid var(--gray-darker); border-bottom: 2px solid var(--gray-darker);
  box-shadow: 4px 4px 12px rgba(0,0,0,0.5);
}
.note-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.note-body textarea {
  font: inherit; padding: 3px 4px; background: #fff; resize: vertical;
  border-top: 1px solid var(--gray-dark); border-left: 1px solid var(--gray-dark);
  border-right: 1px solid var(--gray-light); border-bottom: 1px solid var(--gray-light);
  outline: none;
}
.note-count { text-align: right; color: #555; }
#ma-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(58, 110, 165, 0.35);
  display: flex; align-items: center; justify-content: center;
}
#ma-win {
  width: 280px; background: var(--gray);
  border-top: 2px solid var(--gray-light); border-left: 2px solid var(--gray-light);
  border-right: 2px solid var(--gray-darker); border-bottom: 2px solid var(--gray-darker);
  box-shadow: 4px 4px 12px rgba(0,0,0,0.5);
}
.ma-body { padding: 12px 16px 12px; display: flex; flex-direction: column; gap: 6px; }
.ma-hint { margin-bottom: 6px; }
.ma-row { display: flex; align-items: center; gap: 8px; }
.ma-swatch {
  width: 22px; height: 4px; flex: 0 0 auto;
  outline: 1px solid #808080;
}
.ma-row input {
  font: inherit; width: 60px; padding: 3px 4px; background: #fff;
  border-top: 1px solid var(--gray-dark); border-left: 1px solid var(--gray-dark);
  border-right: 1px solid var(--gray-light); border-bottom: 1px solid var(--gray-light);
  outline: none;
}
.ma-row select {
  font: inherit; flex: 1; padding: 2px;
  background: #fff; border: 1px solid var(--gray-dark);
}
.login-btns button {
  font: inherit; width: 80px; padding: 3px 0; background: var(--gray); cursor: default;
  border-top: 1px solid var(--gray-light); border-left: 1px solid var(--gray-light);
  border-right: 1px solid var(--gray-darker); border-bottom: 1px solid var(--gray-darker);
  outline: 1px solid #000;
}
.login-btns button:active {
  border-top: 1px solid var(--gray-darker); border-left: 1px solid var(--gray-darker);
  border-right: 1px solid var(--gray-light); border-bottom: 1px solid var(--gray-light);
}

/* ---- outil Texte (commentaires sur le graphique) ---- */
#chart-wrap.text-tool { cursor: text; }
#chart-wrap.move-tool { cursor: move; }
#chart-wrap.draw-tool { cursor: crosshair; }
.db-btn.active {
  border-top: 1px solid var(--gray-dark); border-left: 1px solid var(--gray-dark);
  border-right: 1px solid var(--gray-light); border-bottom: 1px solid var(--gray-light);
  background: repeating-conic-gradient(#e8e4dc 0% 25%, #dcd8d0 0% 50%) 0 0/4px 4px;
}

/* ---- menu « Ajouter dans » ---- */
#sublist-menu {
  position: fixed; z-index: 90; min-width: 150px;
  background: var(--gray);
  border-top: 1px solid var(--gray-light); border-left: 1px solid var(--gray-light);
  border-right: 1px solid var(--gray-darker); border-bottom: 1px solid var(--gray-darker);
  box-shadow: 3px 3px 8px rgba(0,0,0,0.4);
}
.sm-head {
  padding: 3px 8px; font-weight: bold; background: #e6e2da;
  border-bottom: 1px solid var(--gray-dark); white-space: nowrap;
}
.sm-opt { padding: 4px 12px; white-space: nowrap; }
.sm-opt:hover { background: var(--sel-blue); color: #fff; }
.sm-new { border-top: 1px solid var(--gray-dark); font-style: italic; }

/* ---- téléphone / petit écran ---- */
@media (max-width: 700px), (pointer: coarse) and (max-width: 1000px) {
  #win { height: 100dvh; border: none; outline: none; }
  #titlebar .title-btns { display: none; }
  /* barres défilantes au doigt au lieu d'être coupées */
  #toolbar, .tabrow, #drawbar, #sidebar {
    overflow-x: auto; overflow-y: hidden; flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch; scrollbar-width: none;
  }
  #toolbar::-webkit-scrollbar, .tabrow::-webkit-scrollbar,
  #drawbar::-webkit-scrollbar, #sidebar::-webkit-scrollbar { display: none; }
  #toolbar .tb-btn.disabled, #drawbar .db-btn.disabled { display: none; }
  #toolbar .tb-btn { min-width: 56px; padding: 4px 6px 3px; }
  .tab { padding: 6px 9px; font-size: 12px; }
  #tabs { display: inline-flex; gap: 2px; }
  .market-combo, .tabrow .tab-disabled { display: none; }
  /* barre latérale : devient une rangée sous les onglets */
  #body { flex-direction: column; }
  #sidebar {
    width: auto; flex-direction: row; padding: 3px; gap: 3px;
    border-right: none; border-bottom: 1px solid var(--gray-dark);
  }
  .side-btn { min-width: 58px; padding: 4px 3px 3px; flex: 0 0 auto; }
  .side-sep { width: 4px; height: auto; }
  /* tableau : lignes plus hautes, défilement latéral */
  #view-quotes { overflow: auto; -webkit-overflow-scrolling: touch; }
  #qtable { width: max-content; min-width: 100%; font-size: 14px; }
  #qtable tbody tr { height: 30px; }
  #qtable td { padding: 3px 7px; }
  #qtable td:nth-child(3), #qtable th:nth-child(3) { max-width: 120px; }
  #qtable thead th { padding: 5px 7px; font-size: 12px; }
  /* graphique */
  #chart-head { height: auto; flex-wrap: wrap; font-size: 13px; }
  .ch-cell { padding: 2px 6px; }
  .ch-name { min-width: 0; max-width: 50%; }
  .ch-sec { display: none; }
  #chart-wrap { touch-action: pan-y; }
  .db-btn { min-width: 50px; padding: 3px 5px; }
  #statusbar .st-fixed { display: none; }
  #statusbar { font-size: 12px; }
  /* fenêtres modales pas plus larges que l'écran */
  #login-win, #ma-win, #note-win { max-width: 92vw; }
}
