/* =========================================================
   TQMS CORE CSS
   FINAL • LOCKED • SYSTEM LEVEL
   ========================================================= */

/* ===============================
   THEME VARIABLES
   =============================== */

/* LIGHT MODE */
:root[data-theme="light"] {
  --bg-main: #ffffff;
  --bg-surface: #f0f0f0;
  --bg-header: #ffcc00;
  --bg-footer: #e5e7eb;

  --text-main: #1e1e1e;
  --text-muted: #808080;
  --text-title: #4b5563;
  --text-invert: #ffffff;

  --accent-primary: #ffcc00;
  --accent-link: #2563eb;

  --border-soft: #d1d5db;
  --shadow-soft: 0 6px 16px rgba(0,0,0,0.12);
}

/* DARK MODE */
:root[data-theme="dark"] {
  --bg-main: #121212;
  --bg-surface: #1e1e1e;
  --bg-header: #121212;
  --bg-footer: #121212;

  --text-main: #ffffff;
  --text-muted: #9ca3af;
  --text-title: #ffcc00;
  --text-invert: #121212;

  --accent-primary: #ffcc00;
  --accent-link: #93c5fd;

  --border-soft: #1f2937;
  --shadow-soft: 0 10px 28px rgba(0,0,0,0.45);
}

/* ===============================
   RESET & BASE
   =============================== */

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

@media (max-width: 1024px) {
  html { font-size: 15px; }
}

@media (max-width: 640px) {
  html { font-size: 14px; }
}

body {
  margin: 0;
  min-height: 100vh;
  padding-bottom: 96px;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg-main);
  color: var(--text-main);
  line-height: 1.55;
}

/* ===============================
   HEADER LAYOUT
   =============================== */

.tqms-header {
  background: var(--bg-header);
  border-bottom: 1px solid var(--border-soft);
  position: relative; /* ✅ REQUIRED */
  z-index: 1000;
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 12px 20px;

  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.header-left img {
  height: 36px;
}

.header-nav {
  display: flex;
  gap: 18px;
}

.header-nav a {
  font-weight: 600;
  color: #000;
}

[data-theme="dark"] .header-nav a {
  color: #fff;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ===============================
   MOBILE MENU
   =============================== */

.menu-toggle {
  display: none;
  font-size: 1.4rem;
  padding: 0.4rem 0.6rem;
  border: none;
  background: none;
  cursor: pointer;

  position: relative;
  z-index: 1100;
  pointer-events: auto;
}

/* =========================================================
   MOBILE NAVIGATION (HEADER)
   ========================================================= */

@media (max-width: 768px) {

  .header-nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;

    background: var(--bg-surface);
    border-top: 1px solid var(--border-soft);

    display: none;
    flex-direction: column;

    z-index: 1050;
  }

  .header-nav.is-open {
    display: flex;
  }

  .header-nav a {
    padding: 0.9rem 1.25rem;
    display: block;
  }
}

/* Lock body scroll when mobile menu open */
body.menu-open {
  overflow: hidden;
}

/* ===============================
   LINKS
   =============================== */

a {
  color: var(--accent-link);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ===============================
   GLOBAL PAGE CONTRACT
   =============================== */

html, body {
  overflow-x: hidden;
}

.tqms-header {
  position: sticky;
  top: 0;
  z-index: 1000;
}

.header-inner {
  position: relative;
}

/* =========================================================
   GLOBAL MEDIA SAFETY — PREVENT MOBILE OVERFLOW
   IMPORTANT NOTES:
   - Images should scale naturally => max-width:100%; height:auto;
   - Iframes must keep height (PDF viewer) => do NOT force height:auto globally
   ========================================================= */

img {
  max-width: 100%;
  height: auto;
}

/* Allow embeds/objects to stay within container width */
embed,
object {
  max-width: 100%;
}

/* Default iframe safety: full width, but keep height controlled by page/viewer */
iframe {
  max-width: 100%;
}

/* =========================================================
   DOCUMENT VIEWER (GLOBAL STANDARD)
   Use this wrapper around PDF iframe or images:
   <div class="document-viewer"><iframe ...></iframe></div>
   <div class="document-viewer"><img ...></div>
   ========================================================= */

.document-viewer {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  background: var(--bg-surface);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  box-shadow: var(--shadow-soft);
}

/* PDF iframe inside viewer */
.document-viewer iframe {
  width: 100%;
  height: 85vh; /* desktop default */
  border: none;
  display: block;
}

/* Image inside viewer */
.document-viewer img {
  width: 100%;
  max-width: 100%;
  height: auto;
  display: block;
}

/* Mobile tuning */
@media (max-width: 640px) {
  .document-viewer iframe {
    height: 80vh;
  }
}

/* =========================================
   HEADER USER ICON
========================================= */

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-entry {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  font-size: 18px;
  border-radius: 50%;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease;
}

.user-entry:hover {
  background: rgba(0,0,0,0.08);
  transform: scale(1.05);
}

html[data-theme="dark"] .user-entry:hover {
  background: rgba(255,255,255,0.15);
}

.user-entry {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 600;
}

.user-entry:hover {
  background: rgba(0,0,0,0.05);
}

[data-theme="dark"] .user-entry:hover {
  background: rgba(255,255,255,0.08);
}

.user-label {
  font-size: 0.85rem;
}

@media (max-width: 768px) {
  .user-label {
    display: none;
  }
}
