/**
 * PMERIT Responsive Styles
 * Version: 2.1 (Fixed ID Selectors)
 * Last Updated: October 2025
 * 
 * Mobile-first responsive design with fixed kebab-case IDs
 */

/* ========== MOBILE HEADER ========== */
.pmerit-header {
  position: sticky;
  top: 0;
  width: 100%;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  z-index: 900;
  height: 64px;
}

.header-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 100%;
  height: 64px;
  padding: 0 16px;
}

/* Logo */
.header-left {
  display: flex;
  align-items: center;
}

.logo-link {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--primary);
  font-weight: 600;
  font-size: 20px;
}

.logo-icon {
  font-size: 24px;
}

/* Header Right */
.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: transparent;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-secondary);
}

.header-btn:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.header-btn:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Language Button - Special styling for text display */
.language-btn {
  gap: 6px;
}

.language-btn .language-btn-text {
  display: none;
}

.language-btn .language-btn-code {
  display: inline;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

/* Desktop: Show full language name, hide code */
@media (min-width: 768px) {
  .language-btn {
    width: auto;
    padding: 0 12px;
    border-radius: 22px;
  }

  .language-btn .language-btn-text {
    display: inline;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
  }

  .language-btn .language-btn-code {
    display: none;
  }
}

/* Pricing Link in Header */
.pricing-link {
  display: none;
  padding: 8px 16px;
  border-radius: 24px;
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
  transition: var(--transition);
  white-space: nowrap;
}

.pricing-link:hover {
  background: var(--bg-secondary);
  color: var(--primary);
}

/* Show pricing link on desktop */
@media (min-width: 768px) {
  .pricing-link.desktop-only {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    height: 44px;
  }
}

/* Hamburger Toggle */
#hamburger-toggle {
  position: relative;
  width: 44px;
  height: 44px;
  padding: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 6px;
}

.hamburger-line {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--text-primary);
  transition: var(--transition);
  border-radius: 2px;
}

#hamburger-toggle[aria-expanded="true"] .hamburger-line:nth-child(1) {
  transform: translateY(8px) rotate(45deg);
}

#hamburger-toggle[aria-expanded="true"] .hamburger-line:nth-child(2) {
  opacity: 0;
}

#hamburger-toggle[aria-expanded="true"] .hamburger-line:nth-child(3) {
  transform: translateY(-8px) rotate(-45deg);
}

/* Sign In Button */
.btn-sign-in {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: #FFFFFF !important; /* Force white text for visibility */
  border: none;
  padding: 8px 16px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 500;
  min-height: 44px;
  min-width: 80px;
  cursor: pointer;
  text-decoration: none;
  transition: var(--transition);
}

.btn-sign-in:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-sign-in:active {
  transform: translateY(0);
}

/* ========== HAMBURGER MENU ========== */
#menu-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

#menu-overlay.active {
  opacity: 1;
  visibility: visible;
}

#hamburger-menu {
  position: fixed;
  top: 0;
  left: -100%;
  width: 320px;
  max-width: 85vw;
  height: 100vh;
  background: var(--bg-primary);
  box-shadow: var(--shadow-lg);
  z-index: 1100;
  overflow-y: auto;
  transition: left 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
}

#hamburger-menu.active {
  left: 0;
}

/* Menu Header */
.menu-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  background: var(--bg-primary);
  z-index: 10;
}

.menu-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 18px;
  color: var(--primary);
}

#menu-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: transparent;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-secondary);
}

#menu-close-btn:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

/* Menu Content */
.menu-content {
  padding-bottom: 24px;
}

.menu-section {
  padding: 16px 0;
  border-bottom: 1px solid var(--border-color);
}

.menu-section:last-child {
  border-bottom: none;
}

.section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0 24px 8px;
  margin: 0;
}

/* User Section */
.user-section {
  background: var(--bg-secondary);
}

.user-status {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0 0 12px;
  padding: 0 24px;
}

#menu-sign-in {
  width: calc(100% - 48px);
  margin: 0 24px;
  background: var(--primary);
  color: var(--text-inverse);
  border: none;
  padding: 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

#menu-sign-in:hover {
  background: var(--primary-dark);
}

/* Menu Items */
.menu-item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 12px 24px;
  background: transparent;
  border: none;
  text-align: left;
  font-size: 14px;
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition);
  gap: 12px;
  min-height: 48px;
}

.menu-item:hover {
  background: var(--bg-secondary);
}

.menu-item.primary-action {
  background: var(--primary);
  color: var(--text-inverse);
  margin: 0 16px;
  border-radius: 8px;
  font-weight: 500;
}

.menu-item.primary-action:hover {
  background: var(--primary-dark);
}

.menu-icon {
  font-size: 20px;
  width: 24px;
  text-align: center;
}

.menu-text {
  flex: 1;
}

.menu-arrow {
  color: var(--text-secondary);
  font-size: 14px;
  margin-left: auto;
}

/* Toggle Switches */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  margin-left: auto;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--border-color);
  transition: var(--transition);
  border-radius: 24px;
  cursor: pointer;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 20px;
  width: 20px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  transition: var(--transition);
  border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
  background-color: var(--primary);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

.toggle-switch input:focus + .toggle-slider {
  box-shadow: 0 0 0 2px var(--primary-light);
}

/* ========== LANGUAGE DROPDOWN ========== */
#language-dropdown {
  position: fixed;
  top: 64px;
  right: 16px;
  width: 280px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  z-index: 950;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.3s ease;
}

#language-dropdown.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.language-dropdown-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
}

.language-dropdown-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

#close-language-dropdown {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-secondary);
}

#close-language-dropdown:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.language-list {
  list-style: none;
  margin: 0;
  padding: 8px 0;
}

.language-option {
  display: block;
  width: 100%;
  padding: 12px 16px;
  background: transparent;
  border: none;
  text-align: left;
  font-size: 14px;
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition);
}

.language-option:hover {
  background: var(--bg-secondary);
}

.language-option.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 500;
}

/* ========== TABLET (768px+) ========== */
@media (min-width: 768px) {
  .header-container {
    padding: 0 32px;
  }

  #hamburger-menu {
    width: 360px;
  }

  #language-dropdown {
    right: 32px;
  }
}

/* ========== DESKTOP (1024px+) ========== */
@media (min-width: 1024px) {
  /* Hide mobile menu on desktop */
  #hamburger-toggle {
    display: none;
  }

  #menu-overlay {
    display: none;
  }

  #hamburger-menu {
    display: none;
  }

  /* Show desktop navigation */
  .desktop-nav {
    display: flex;
    align-items: center;
    gap: 24px;
    margin-left: auto;
    margin-right: 24px;
  }

  .desktop-nav a {
    color: var(--text-primary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 8px;
    transition: var(--transition);
  }

  .desktop-nav a:hover {
    background: var(--bg-secondary);
    color: var(--primary);
  }

  .desktop-nav a.active {
    background: var(--primary-light);
    color: var(--primary);
  }
}

/* ========== LARGE DESKTOP (1440px+) ========== */
@media (min-width: 1440px) {
  .header-container {
    max-width: 1400px;
    margin: 0 auto;
  }
}

/* ========================================
   PHASE 8.1 - RESPONSIVE LAYOUT SYSTEM
   ======================================== */

/* Responsive Container System */
.responsive-container {
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    padding-left: var(--space-mobile-gutter);
    padding-right: var(--space-mobile-gutter);
}

@media (min-width: 480px) {
    .responsive-container {
        max-width: 480px;
    }
}

@media (min-width: 768px) {
    .responsive-container {
        max-width: 768px;
        padding-left: var(--space-desktop-gutter);
        padding-right: var(--space-desktop-gutter);
    }
}

@media (min-width: 1024px) {
    .responsive-container {
        max-width: 1024px;
    }
}

@media (min-width: 1280px) {
    .responsive-container {
        max-width: 1280px;
    }
}

/* Responsive Grid System */
.responsive-grid {
    display: grid;
    gap: var(--space-4);
    width: 100%;
}

.responsive-grid-1 {
    grid-template-columns: 1fr;
}

@media (min-width: 360px) {
    .responsive-grid-2 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 768px) {
    .responsive-grid-3 {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1024px) {
    .responsive-grid-4 {
        grid-template-columns: repeat(4, 1fr);
    }
}

.responsive-grid-auto {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

/* Prevent horizontal scroll (Critical) */
html,
body {
    overflow-x: hidden;
    max-width: 100vw;
}

/* Chat and avatar layout - no overlap */
.chat-stream,
.chat-messages {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.chat-message,
.bubble {
    max-width: 100%;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* ========================================
   PHASE 8.4 - SAFE AREA SUPPORT
   ======================================== */

.safe-area-bottom {
    padding-bottom: calc(var(--space-4) + var(--safe-area-bottom));
}

/* Chat input with safe area */
.chat-input-container {
    padding-bottom: calc(var(--space-4) + var(--safe-area-bottom));
}

.pmerit-footer {
    padding-bottom: calc(var(--space-3) + var(--safe-area-bottom));
}

/* ========================================
   PHASE 8.5 - AVATAR CANVAS RESPONSIVE
   ======================================== */

.vh-root,
.avatar-canvas-container,
#vh-canvas {
    width: 100%;
    max-width: 100%;
    height: auto;
    max-height: 40vh;
}

@media (min-width: 768px) {
    .vh-root,
    .avatar-canvas-container,
    #vh-canvas {
        max-height: 50vh;
    }
}

@media (min-width: 1024px) {
    .vh-root,
    .avatar-canvas-container,
    #vh-canvas {
        max-height: 60vh;
    }
}

.vh-root.focus-mode {
    max-height: 70vh;
    z-index: var(--z-modal);
}

/* ========================================
   PHASE 8.6 - RESPONSIVE TYPOGRAPHY
   ======================================== */

body {
    font-size: var(--text-mobile-body);
    line-height: var(--leading-normal);
}

@media (min-width: 768px) {
    body {
        font-size: var(--text-base);
    }
}

h1, .h1 {
    font-size: var(--text-mobile-hero);
    line-height: var(--leading-tight);
    margin-bottom: var(--space-4);
}

@media (min-width: 768px) {
    h1, .h1 {
        font-size: var(--text-3xl);
    }
}

h2, .h2 {
    font-size: var(--text-mobile-heading);
    line-height: var(--leading-tight);
    margin-bottom: var(--space-3);
}

@media (min-width: 768px) {
    h2, .h2 {
        font-size: var(--text-2xl);
    }
}

h3, .h3 {
    font-size: var(--text-lg);
    line-height: var(--leading-tight);
    margin-bottom: var(--space-2);
}

@media (min-width: 768px) {
    h3, .h3 {
        font-size: var(--text-xl);
    }
}

/* ========================================
   PHASE 8.7 - RESPONSIVE IMAGES
   ======================================== */

img,
picture,
video {
    max-width: 100%;
    height: auto;
}

img[loading="lazy"] {
    opacity: 0;
    transition: opacity 0.3s ease-in;
}

img[loading="lazy"].loaded {
    opacity: 1;
}

/* ========================================
   PHASE 8.9 - LAYOUT SHIFT PREVENTION
   ======================================== */

.avatar-placeholder {
    min-height: 200px;
    background: var(--bg-secondary);
}

.image-placeholder {
    min-height: 150px;
    background: var(--bg-secondary);
}

/* ========================================
   FOOTER PARTIAL STYLES
   For partials/footer.html used by sub-pages
   ======================================== */

/* === MOBILE FOOTER (Default: <1024px) === */
.mobile-footer {
  display: block;
  background-color: var(--bg-card);
  border-top: 1px solid var(--border-color);
  padding: 12px 16px;
  padding-bottom: calc(12px + var(--safe-area-bottom, 0px));
}

.mobile-footer-content {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

.mobile-footer .footer-link {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.2s;
}

.mobile-footer .footer-link:hover {
  color: var(--primary);
}

.mobile-footer .footer-separator {
  color: var(--text-tertiary);
}

.mobile-footer .footer-status {
  display: flex;
  align-items: center;
  gap: 6px;
}

.mobile-footer .status-indicator {
  display: inline !important; /* Override global hide */
  font-size: 6px;
  color: var(--success, #28a745);
}

/* === DESKTOP FOOTER (≥1024px) === */
.desktop-footer {
  display: none;
  background-color: var(--bg-card);
  border-top: 1px solid var(--border-color);
}

@media (min-width: 1024px) {
  .mobile-footer {
    display: none;
  }

  .desktop-footer {
    display: block;
  }
}

.desktop-footer-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 48px 32px 24px;
}

/* Footer Top: 4-Column Grid */
.footer-top {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 32px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--border-color);
}

@media (max-width: 1200px) {
  .footer-top {
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
  }
}

@media (max-width: 768px) {
  .footer-top {
    grid-template-columns: 1fr;
    gap: 24px;
  }
}

/* Footer Columns */
.footer-column {
  display: flex;
  flex-direction: column;
}

.footer-column-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.footer-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.footer-links li {
  margin: 0;
}

.desktop-footer .footer-link {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  padding: 4px 0;
  transition: color 0.2s, transform 0.2s;
}

.desktop-footer .footer-link:hover {
  color: var(--primary);
  transform: translateX(4px);
}

.desktop-footer .footer-link i {
  font-size: 12px;
  width: 16px;
  text-align: center;
  opacity: 0.7;
}

/* Footer Bottom */
.footer-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  padding-top: 24px;
}

@media (max-width: 768px) {
  .footer-bottom {
    flex-direction: column;
    text-align: center;
  }
}

.footer-bottom-left {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

@media (max-width: 768px) {
  .footer-bottom-left {
    align-items: center;
  }
}

.footer-copyright {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0;
}

.footer-legal-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.footer-link-sm {
  font-size: 12px;
  color: var(--text-tertiary);
  text-decoration: none;
  transition: color 0.2s;
}

.footer-link-sm:hover {
  color: var(--primary);
}

.footer-separator {
  color: var(--text-tertiary);
  font-size: 10px;
}

.footer-bottom-right {
  display: flex;
  align-items: center;
  gap: 24px;
}

@media (max-width: 768px) {
  .footer-bottom-right {
    flex-direction: column;
    gap: 16px;
  }
}

.desktop-footer .footer-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

.desktop-footer .status-indicator {
  display: inline !important; /* Override global hide */
  font-size: 8px;
  color: var(--success, #28a745);
}

/* Social Links */
.footer-social {
  display: flex;
  gap: 12px;
}

.social-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: var(--bg-secondary);
  color: var(--text-secondary);
  text-decoration: none;
  transition: all 0.2s;
}

.social-link:hover {
  background-color: var(--primary);
  color: white;
  transform: translateY(-2px);
}

.social-link i {
  font-size: 16px;
}
