﻿/* ===== MODULE: _layout.css ===== */
    /* ===== RESET & BASE ===== */
    html{overflow-y:scroll;overflow-x:hidden} 
    html,body{min-height:100%;margin:0;background:#f3f4f6}
    *{box-sizing:border-box;min-width:0}
    .hide{display:none !important;} 
    .sub-block.hide{display:none !important;} 
    
    /* ===== GENERAL ELEMENT STYLES ===== */
    h4 {
      margin-bottom: 0 !important;
      font-size: 0.7em !important; 
    }
    


    /* ===== HEADER (FIXED) ===== */
    .app-header{
      position:fixed; top:0; left:0; right:0; z-index:var(--z-header);
      background:#e8fff3; 
      padding-top:var(--safe-area-top);
    }

    /* ===== WELCOME BANNER ===== */
    .welcome-banner {
      position: fixed;
      top: var(--header-h);
      left: var(--sidebar-width);
      right: 0;
      z-index: var(--z-banner);
      margin: 0 !important;
      padding: 6px 0 !important;
      background: linear-gradient(135deg, #025b48 0%, #00e0e5 100%);
      color: white;
      text-align: center;
      font-weight: 700;
      font-size: clamp(10px, 2.5vw, 16px);
      display: none; 
      box-shadow: none;
      line-height: 1.2;
      pointer-events: none; 
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    
    /* ===== MOBILE UPDATE DATE ===== */
    .mobile-update-date {
      position: fixed;
      top: var(--mobile-update-top);
      left: 0;
      right: 0;
      z-index: var(--z-toc);
      background: #fff;
      color: #0b3d2c;
      padding: 6px 0;
      margin: 0;
      text-align: center;
      font-weight: 700;
      font-size: 14px;
      border: none;
      box-shadow: none;
      display: none;
    }
    
    
    body.logged-in .mobile-update-date {
      display: block;
    }

    .mobile-viewing-info {
      position: fixed;
      top: var(--mobile-viewing-top);
      left: 0;
      right: 0;
      z-index: var(--z-content); 
      background: linear-gradient(135deg, #0ea35b 0%, #025b48 100%);
      color: white;
      padding: 0;
      margin: 0;
      text-align: center;
      font-weight: 700;
      font-size: 16px;
      display: none;
      box-shadow: none;
      line-height: 1.2;
      pointer-events: none;
    }
    
    /* ===== DESKTOP UPDATE DATE ===== */
    .desktop-update-date {
      display: none;
      color: #0b3d2c;
      font-weight: 700;
      font-size: 14px;
      padding: 8px 12px;
      margin: 8px 0;
      background: #f8fafc;
      border-radius: 1.8px;
      border-left: 3px solid #0ea35b;
      text-align: center;
    }
    
    /* ===== SIDEBAR UPDATE INFO ===== */
    .sidebar-update-info {
      color: #0b3d2c;
      font-weight: 600;
      font-size: 13px;
      padding: 8px 12px;
      margin: 8px 0;
        background: #00e0e5;
      border-radius: 1.8px;
      border-left: 3px solid #0ea5e9;
      text-align: center;
      line-height: 1.4;
    }

    /* ===== VIEWING AGENT INFO ===== */
    .viewing-agent-info {
      color: #0b3d2c;
      font-weight: 600;
      font-size: 13px;
      padding: 8px 12px;
      margin: 8px 0;
      background: #f0fdf4;
      border-radius: 1.8px;
      border-left: 3px solid #0ea35b;
      text-align: center;
      line-height: 1.4;
    }

    /* ===== VIEW OTHER AGENT BUTTON (DESKTOP) ===== */
    .view-other-agent-btn {
      width: 100%;
      height: 44px;
      margin: 8px 0;
      padding: 0 12px;
      background: #f59e0b;
      color: #fff;
      border: none;
      border-radius: 2.4px;
      font-weight: 800;
      font-size: 14px;
      cursor: pointer;
      transition: all 0.3s ease;
      text-transform: uppercase;
    }

    .view-other-agent-btn:hover {
      background: #d97706;
      transform: translateY(-1px);
    }

    
    
    body.logged-out .welcome-banner {
      display: none !important;
    }
    
    
    body.logged-in .welcome-banner {
      display: block;
    }
    
    
    body.logged-in.special-user .mobile-update-date {
      display: none !important;
    }

    
    body.logged-out .welcome-banner,
    body:not(.sidebar-open) .welcome-banner {
      left: 0;
    }

    
    /* ===== LANDSCAPE welcome banner ===== */
    @media (min-width: 1024px) {
      body.logged-in .welcome-banner {
        display: block !important;
      }
      
      body.logged-in.sidebar-open .welcome-banner {
        left: var(--sidebar-width);
      }
    }
        .header-grid{
      display:grid; grid-template-columns: 1fr auto;
      align-items:center; gap:12px; padding:10px 12px;
      min-width:0; /* Cho phip grid co din */
    }
    .brand-row{ 
      display:flex; 
      align-items:center; 
      gap:10px; 
      min-width:0; 
      flex:1; /* Cho phip co din */
      overflow:hidden; 
    }
    .logo-d{ 
      height:70px; 
      width:auto; 
      display:block; 
      flex:0 0 auto; 
      max-width:70px; 
    }

    .title-wrap{ 
      display:flex; 
      flex-direction:column; 
      gap:2px; 
      min-width:0; 
      flex:1; /* Cho phip co din */
      overflow:hidden; 
    }
    .title-top,.title-main{
      font-family:'Manulife JH Sans','ManulifeJHSans',system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
      color:var(--brand); 
      font-weight:800;
      white-space:nowrap; 
      overflow:hidden; 
      text-overflow:ellipsis; 
      line-height:1.2; 
      padding-block:2px;
      width:100%; 
    }
    .title-top{  
      font-size: clamp(11px, 1vw + 7px, 16px); 
      text-transform: uppercase;
      /* Tránh tràn dòng khi tiêu đề dài */
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      max-width: 100%;
    }
    .title-main{ 
      font-size: clamp(16px, 1.4vw + 9px, 22px);
      /* Cho phép xuống dòng nếu quá chờ, tránh tràn */
      overflow-wrap: break-word;
      word-break: break-word;
    }

    /* ===== LOGIN / LOGOUT ===== */
    .login-cluster{ 
      display: flex; 
      gap: 16px; 
      align-items: flex-end;
      justify-self: end;
    }

    
    .input-group {
      display: flex;
      flex-direction: column;
      gap: 12px;
    }
    
    .password-input-wrapper {
      position: relative;
      display: inline-block;
    }
    
    .login-cluster input{ 
      height: 44px; 
      padding: 0 12px; 
      font-size: 16px; 
      border: 1.3px solid #b7e7ce; 
      border-radius: 3px; 
      background: #effaf3; 
      font-weight: 600; 
      color: #0d7233; 
      outline: none; 
      width: 180px;
    }
    
    .toggle-password {
      position: absolute;
      right: 8px;
      top: 50%;
      transform: translateY(-50%);
      background: none;
      border: none;
      cursor: pointer;
      padding: 4px;
      border-radius: 1.2px;
      font-size: 16px;
      color: #666;
      transition: background-color 0.2s;
    }
    
    .toggle-password:hover {
      background-color: rgba(0, 0, 0, 0.1);
    }
    
    .password-input-wrapper input[type="password"] {
      padding-right: 40px;
    }
    
    
    body.logged-in .toggle-password {
      display: none !important;
    }
    
    
    body.logged-in .password-input-wrapper input {
      padding-right: 12px;
    }
    
    .login-cluster input::placeholder{ 
      color: #666; 
    }
    
    .login-btn{ 
      height: 44px; 
      padding: 0 18px; 
      background: #008a53; 
      color: #fff; 
      border: none; 
      border-radius: 3px; 
      font-weight: 800; 
      cursor: pointer; 
      touch-action: manipulation;
      min-width: 140px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      display: inline-flex;
      align-items: center;
      justify-content: center;
    }
    
    .login-btn:hover{ background: #025b48; }
    .logout-only{ display:none !important; }
    body.logged-in .login-only{ display:none !important; }
    body.logged-in .logout-only{ display:block !important; }
    
    
    body:not(.logged-in) .print-btn {
      display: none !important;
    }

    /* ===== SIDEBAR (DESKTOP) ===== */
    #sidebar{ position:fixed; left:0; top:var(--header-h); bottom:var(--footer-h); width:var(--sidebar-width); background:#fff; border-right:1px solid #e5e7eb; z-index:var(--z-sidebar); overflow-y:auto; overflow-x:hidden; display:none; }
    body.logged-in #sidebar{ top:var(--header-h); }
    .sidebar-inner{ padding:12px; }
    .menu-title{ font-weight:900; color:#065f46; margin:6px 8px 8px; white-space:normal; line-height:1.25; }
    .menu-group{ margin:12px 0 6px 8px; font-weight:900; color:#0b3d2c; white-space:normal; line-height:1.25; }
    .menu-item{ display:block; padding:.55rem .75rem; border-radius:.55rem; font-weight:800; color:#0b3d2c; white-space:normal; overflow-wrap:anywhere; word-break:break-word; line-height:1.25; font-size:0.96rem; }
    .menu-item:hover{ background:#e5f7ee; }
    .menu-item.active{ background:#0ea35b; color:#fff; }
    .submenu{ margin:.25rem 0 .5rem .75rem; }
    .submenu .menu-item{ padding:.45rem .6rem; }

    @media (min-width: 1024px) and (hover: hover) and (pointer: fine) {
      .sidebar-inner {
        width: max-content;
        min-width: 0;
      }

      .menu-title,
      .menu-group,
      .menu-item {
        white-space: nowrap;
        overflow-wrap: normal;
        word-break: normal;
      }
    }

    
    #tocMobile{ position:fixed; top:var(--toc-mobile-top); left:0; right:0; z-index:var(--z-toc); background:#fff; padding:10px 15px; margin:0; border:none; display:none; }
    body.logged-in #tocMobile{ top:var(--toc-mobile-logged-in-top); }
    
    
    #tocMobile .row {
      display: flex;
      gap: 8px;
    }
    
    #tocMobile .row button {
      font-size: clamp(10px, 2.5vw, 14px);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      min-width: 0;
      flex: 1;
      padding: 1px 8px;
    }
    
    
    #tocMobile {
      top: var(--toc-mobile-logged-in-top);
    }
    
    
    body.logged-out #tocMobile {
      top: var(--toc-mobile-top);
    }
    
    
    .mobile-viewing-info {
      top: var(--mobile-viewing-top);
    }
    
    
    body.logged-out .mobile-viewing-info {
      top: var(--mobile-viewing-logged-out-top);
    }
    

    #tocMobile .row{ display:flex; gap:10px; position: relative; }
    
    
    @media (min-width: 1024px) and (hover: hover) and (pointer: fine) {
      #tocMobile {
        display: none !important;
      }
      .mobile-viewing-info {
        display: none !important;
      }
    }

    /* Thiet bi cam ung (tablet/phone) du rong >= bp-landscape van dung TOC mobile */
    @media (min-width: 1024px) and (hover: none) and (pointer: coarse) {
      body.logged-in #tocMobile {
        display: block !important;
      }

      #sidebar {
        display: none !important;
      }
    }
    
    
    .mobile-menu-btn {
      flex: 1;
      height: 44px;
      border: 1px solid #c7d5e6;
      border-radius: 3px;
      padding: 1px 15px;
      font-weight: 800;
      color: #00519c;
      background: #eff5ff;
      font-size: 16px;
      cursor: pointer;
      transition: all 0.3s ease;
    }
    
    .mobile-menu-btn:hover {
      background: #e0f2fe;
      border-color: #0ea5e9;
    }
    
    
    .mobile-view-other-btn {
      height: 36px;
      border: 1px solid #f59e0b;
      border-radius: 3px;
      padding: 1px 15px;
      font-weight: 800;
      color: #fff;
      background: #f59e0b;
      font-size: 16px;
      cursor: pointer;
      transition: all 0.3s ease;
      white-space: nowrap;
    }
    
    .mobile-view-other-btn:hover {
      background: #d97706;
      border-color: #d97706;
    }
    
    
    .mobile-logout-btn {
      height: 36px;
      border: 1px solid #dc2626;
      border-radius: 3px;
      padding: 1px 15px;
      font-weight: 800;
      color: #fff;
      background: #dc2626;
      font-size: 16px;
      cursor: pointer;
      transition: all 0.3s ease;
      white-space: nowrap;
    }
    
    .mobile-logout-btn:hover {
      background: #b91c1c;
      border-color: #b91c1c;
    }
    
    /* Mobile menu dropdown */
    .mobile-menu-dropdown {
      position: absolute;
      top: 100%;
      left: 0;
      right: 0;
      background: #fff;
      border: 1px solid #e5e7eb;
      border-radius: 3px;
      box-shadow: 0 4px 12px rgba(0,0,0,0.15);
      z-index: var(--z-overlay);
      margin-top: 5px;
    }

    /* Dam bao dropdown Danh muc khong bi che tren mobile/tablet */
    /* ===== PORTRAIT dropdown z-index override ===== */
    @media (max-width: 1023px) {
      #tocMobile {
        z-index: var(--z-dropdown) !important;
        overflow: visible !important;
      }

      #tocMobile .row {
        overflow: visible !important;
      }

      .mobile-menu-dropdown {
        z-index: var(--z-dropdown-menu) !important;
      }
    }
    
    .mobile-menu-content {
      padding: 40px 10px 10px 10px;
      max-height: 400px;
      overflow-y: auto;
    }
    
    .mobile-menu-item {
      display: block;
      padding: 12px 15px;
      color: #0b3d2c;
      text-decoration: none;
      font-weight: 700;
      font-size: 15px;
      border-radius: 2.4px;
      transition: all 0.3s ease;
      border-bottom: 1px solid #f3f4f6;
    }
    
    .mobile-menu-item:last-child {
      border-bottom: none;
    }
    
    .mobile-menu-item:hover {
      background: #e5f7ee;
      color: #0ea35b;
    }
    
    
    .mobile-menu-item {
      text-transform: uppercase;
    }
    
    .mobile-menu-item.fa-hide {
      display: block;
    }
    
    body.is-fa-or-sa .mobile-menu-item.fa-hide {
      display: none !important;
    }

    /* ===== REFACTOR: BO CUC RESPONSIVE TOKEN ===== */
    body.logged-out .welcome-banner {
      display: none !important;
    }

    body.logged-in .welcome-banner {
      display: block;
    }

    @media (min-width: 1024px) and (hover: hover) and (pointer: fine) {
      body.logged-in #sidebar {
        display: block;
      }

      body.logged-in #tocMobile,
      .mobile-update-date,
      .mobile-viewing-info {
        display: none !important;
      }

      body.logged-in.sidebar-open .welcome-banner {
        left: var(--sidebar-width);
      }

      body.logged-in:not(.sidebar-open) .welcome-banner {
        left: 0;
      }
    }

    @media (max-width: 1023px), (min-width: 1024px) and (hover: none) and (pointer: coarse) {
      #sidebar {
        display: none !important;
      }

      body.logged-in #tocMobile,
      body.logged-in .mobile-update-date,
      body.logged-in .mobile-viewing-info {
        display: block;
      }

      body.logged-in .welcome-banner {
        left: 0;
      }
    }

    @media (max-width: 767px) {
      .app-header,
      .welcome-banner,
      .mobile-update-date,
      #tocMobile,
      .mobile-viewing-info {
        box-shadow: none;
        margin: 0;
      }

      .mobile-update-date {
        top: var(--mobile-update-top) !important;
      }

      #tocMobile {
        top: var(--toc-mobile-logged-in-top);
      }

      .mobile-viewing-info {
        top: var(--mobile-viewing-top);
      }
    }

    @media (min-aspect-ratio: 9/10) and (max-aspect-ratio: 11/10) and (max-width: 1023px) {
      #tocMobile .row {
        gap: 6px;
      }

      #tocMobile .row button {
        font-size: clamp(10px, 2.1vw, 13px);
      }
    }

    @media (min-width: 1024px) and (min-aspect-ratio: 9/10) and (max-aspect-ratio: 11/10) {
      body.logged-in .welcome-banner {
        left: 0 !important;
        right: 0;
      }
    }

    /* Force desktop UI for touch devices in landscape orientation. */
    body.force-desktop-landscape.logged-in #sidebar {
      display: block !important;
    }

    body.force-desktop-landscape.logged-in #tocMobile,
    body.force-desktop-landscape.logged-in .mobile-update-date,
    body.force-desktop-landscape.logged-in .mobile-viewing-info {
      display: none !important;
    }

    body.force-desktop-landscape.logged-in.sidebar-open .welcome-banner {
      left: var(--sidebar-width) !important;
    }

    body.force-desktop-landscape.logged-in:not(.sidebar-open) .welcome-banner {
      left: 0 !important;
    }



