/*!
 * hnav — vtiger 8.x 横並びヘッダーメニュー テーマ
 * 設置先: layouts/v7/skins/hnav/hnav.css
 *
 * 色や高さは :root の変数だけ変えれば調整できます。
 * 横並びにする画面幅は hnav.js の CFG.minWidth と下の @media を揃えてください。
 */

:root {
  --hnav-fg: inherit;                 /* メニュー文字色（ヘッダーの文字色を継承） */
  --hnav-hover-bg: rgba(127, 127, 127, .12);
  --hnav-accent: #2f80ed;             /* 選択中のアプリの下線色 */
  --hnav-font-size: 13px;
  --hnav-gap: 2px;                    /* 項目同士の間隔 */
  --hnav-pad-x: 10px;                 /* 項目の左右余白 */

  --hnav-drop-bg: #ffffff;
  --hnav-drop-fg: #2b2f33;
  --hnav-drop-muted: #6b7280;
  --hnav-drop-hover: #f1f5fb;
  --hnav-drop-border: rgba(0, 0, 0, .08);
  --hnav-drop-shadow: 0 10px 28px rgba(15, 23, 42, .16), 0 2px 6px rgba(15, 23, 42, .08);
  --hnav-radius: 8px;
}

/* JS が出すまでは非表示。狭い画面では従来どおりハンバーガーのみ */
.hnav { display: none; }
.hnav [hidden] { display: none !important; }

@media (min-width: 1200px) {

  /* ---- ヘッダー行をフレックスに組み替え ---- */
  .hnav-row {
    display: flex !important;
    flex-wrap: nowrap;
    align-items: center;
  }
  .hnav-row::before,
  .hnav-row::after { display: none !important; } /* bootstrap の clearfix 無効化 */

  .hnav-row > * {
    float: none !important;
    width: auto !important;
    max-width: none;
    flex: 0 0 auto;
  }

  /*
   * ロゴ／ハンバーガー部分: 折り返さない横一列にする。
   * ハンバーガー枠は元の画面で測った幅（hnav.js が設定）に固定し、色・高さは vtiger のまま。
   * ロゴは画像の幅なりに表示（読み込みタイミングに関係なくずれない）。
   */
  .hnav-row > .hnav-brand { align-self: stretch; }
  .hnav-brand > .row {
    display: flex !important;
    flex-wrap: nowrap;
    align-items: stretch;
    height: 100%;
  }
  .hnav-brand > .row::before,
  .hnav-brand > .row::after { display: none !important; }
  .hnav-brand > .row > * {
    float: none !important;
    flex: 0 0 auto;
  }
  .hnav-brand .app-switcher-container { width: var(--hnav-switcher-w, 50px) !important; }
  .hnav-brand .logo-container {
    width: auto !important;
    padding-right: 20px;
  }

  .hnav-row > .hnav-search { flex: 0 0 220px !important; }
  .hnav-row > .hnav-actions { margin-left: auto; }

  html.hnav-enabled .hnav-hamburger { display: none !important; }

  /* ---- メニュー本体 ---- */
  .hnav {
    display: block;
    flex: 1 1 auto !important;
    min-width: 0;
    align-self: stretch;
    padding: 0 8px;
  }

  .hnav-list {
    display: flex;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: var(--hnav-gap);
    height: 100%;
    margin: 0;
    padding: 0;
    list-style: none;
    white-space: nowrap;
  }

  .hnav-item {
    position: relative;
    display: flex;
    flex: 0 0 auto;
  }

  .hnav-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 var(--hnav-pad-x);
    color: var(--hnav-fg);
    font-size: var(--hnav-font-size);
    font-weight: normal;
    letter-spacing: .02em;
    text-decoration: none !important;
    border-radius: 6px;
    transition: background-color .15s ease, color .15s ease;
  }
  .hnav-link:hover,
  .hnav-link:focus-visible,
  .hnav-item:hover > .hnav-link,
  .hnav-item.is-open > .hnav-link {
    background: var(--hnav-hover-bg);
    color: var(--hnav-fg);
    outline: none;
  }

  /* 選択中のアプリ: 下線 */
  .hnav-item.is-active > .hnav-link::after {
    content: "";
    position: absolute;
    left: var(--hnav-pad-x);
    right: var(--hnav-pad-x);
    bottom: 4px;
    height: 3px;
    border-radius: 3px;
    background: var(--hnav-accent);
  }

  .hnav-icon { font-size: 14px; opacity: .85; width: 16px; text-align: center; }

  .hnav-caret {
    width: 0;
    height: 0;
    margin-left: 2px;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid currentColor;
    opacity: .6;
    transition: transform .15s ease;
  }
  .hnav-item:hover > .hnav-link .hnav-caret,
  .hnav-item.is-open > .hnav-link .hnav-caret { transform: rotate(180deg); }

  /* ---- ドロップダウン ---- */
  .hnav-sub {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1050;
    display: none;
    min-width: 220px;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    margin: 0;
    padding: 6px;
    list-style: none;
    background: var(--hnav-drop-bg);
    color: var(--hnav-drop-fg);
    border: 1px solid var(--hnav-drop-border);
    border-radius: var(--hnav-radius);
    box-shadow: var(--hnav-drop-shadow);
    white-space: nowrap;
    text-align: left;
  }
  .hnav-item:hover > .hnav-sub,
  .hnav-item:focus-within > .hnav-sub,
  .hnav-item.is-open > .hnav-sub {
    display: block;
    animation: hnav-drop .14s ease-out;
  }

  .hnav-sub-link,
  .hnav-group-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    color: var(--hnav-drop-fg) !important;
    font-size: 13px;
    text-decoration: none !important;
    border-radius: 6px;
  }
  .hnav-sub-link:hover,
  .hnav-sub-link:focus-visible,
  .hnav-group-head:hover,
  .hnav-group-head:focus-visible {
    background: var(--hnav-drop-hover);
    outline: none;
  }
  .hnav-sub-link.is-current {
    box-shadow: inset 3px 0 0 var(--hnav-accent);
  }
  .hnav-sub-icon {
    display: inline-flex;
    justify-content: center;
    width: 18px;
    color: var(--hnav-drop-muted);
    font-size: 14px;
  }

  /* 「その他」: 右端に寄せ、項目ごとに見出し＋配下 */
  .hnav-more > .hnav-sub,
  .hnav-pinned > .hnav-sub { left: auto; right: 0; min-width: 260px; }
  .hnav-group + .hnav-group { border-top: 1px solid var(--hnav-drop-border); margin-top: 4px; padding-top: 4px; }
  .hnav-group-head { font-weight: 700; }
  .hnav-group-head .hnav-icon { color: var(--hnav-drop-muted); }
  .hnav-group-sub { margin: 0; padding: 0 0 2px 14px; list-style: none; }

  @keyframes hnav-drop {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: none; }
  }
}

@media (min-width: 1200px) and (prefers-reduced-motion: reduce) {
  .hnav-item:hover > .hnav-sub,
  .hnav-item:focus-within > .hnav-sub,
  .hnav-item.is-open > .hnav-sub { animation: none; }
}
