/* ============================================
   AJUSTES APENAS PARA MOBILE (<= 768px)
   ============================================ */
@media (max-width: 768px) {
  
  *, *::before, *::after {
    box-sizing: border-box !important;
  }

  html, body {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  body {
    flex-direction: column !important;
    min-height: auto !important;
    height: auto !important;
    padding: 16px !important;
  }

  /* BARRA FIXA SUPERIOR NO MOBILE */
  .sidebar {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 0 14px 0 !important;
    min-height: auto !important;
    height: auto !important;
    padding: 10px 14px !important;
    position: relative !important;
    top: 0 !important;
    z-index: 100 !important;
    background: var(--card-bg, #12131a) !important;
    border: 1px solid var(--border-color, rgba(255, 255, 255, .08)) !important;
    border-radius: 16px !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    box-sizing: border-box !important;
  }

  .sidebar-top {
    display: contents !important;
  }

  /* LOGO */
  .logo {
    order: 1 !important;
    font-size: 22px !important;
    margin: 0 !important;
    position: static !important;
    transform: none !important;
    line-height: 1 !important;
  }

  /* TEMA + IDIOMA */
  .sidebar-actions {
    order: 2 !important;
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    margin: 0 !important;
  }

  /* HAMBÚRGUER */
  .menu-toggle {
    order: 3 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 32px !important;
    height: 32px !important;
    background: var(--card-bg, rgba(255, 255, 255, .04)) !important;
    border: 1px solid var(--border-color, rgba(255, 255, 255, .08)) !important;
    border-radius: 8px !important;
    cursor: pointer !important;
    flex-shrink: 0 !important;
    position: static !important;
    margin: 0 !important;
    transition: .2s ease !important;
  }

  .menu-toggle span {
    display: block !important;
    width: 13px !important;
    height: 1.5px !important;
    background: var(--text-muted, #9ca3af) !important;
    border-radius: 2px !important;
    position: relative !important;
    transition: .25s ease !important;
  }

  .menu-toggle span::before,
  .menu-toggle span::after {
    content: '' !important;
    display: block !important;
    width: 13px !important;
    height: 1.5px !important;
    background: var(--text-muted, #9ca3af) !important;
    border-radius: 2px !important;
    position: absolute !important;
    left: 0 !important;
    transition: .25s ease !important;
  }

  .menu-toggle span::before { top: -4px !important; }
  .menu-toggle span::after { top: 4px !important; }

  .menu-toggle.open span {
    background: transparent !important;
  }

  .menu-toggle.open span::before {
    transform: rotate(45deg) !important;
    top: 0 !important;
  }

  .menu-toggle.open span::after {
    transform: rotate(-45deg) !important;
    top: 0 !important;
  }

  /* ESCONDE ELEMENTOS SECUNDÁRIOS DA SIDEBAR E GIFS DO TOPO NO MOBILE */
  .subtitle,
  .sidebar-block,
  .sidebar-gif,
  .sidebar img,
  .sidebar-top img,
  .sidebar-top .matrix-text,
  .sidebar .light-only,
  .sidebar .dark-only {
    display: none !important;
  }

  /* DROPDOWN DO MENU MOBILE (FIXED LOGO ABAIXO DA BARRA SUPERIOR) */
  .sidebar-nav-mobile {
    display: none;
    flex-direction: column;
    gap: 2px;
    position: fixed !important;
    top: 68px !important; /* Aparece logo abaixo do header */
    left: 16px !important;
    right: 16px !important;
    background: var(--card-bg, #12131a) !important;
    border: 1px solid var(--border-color, rgba(255, 255, 255, .1)) !important;
    border-radius: 14px !important;
    padding: 8px !important;
    z-index: 9999 !important;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
  }

  .sidebar-nav-mobile.open {
    display: flex !important;
  }

  .sidebar-nav-mobile a {
    display: grid !important;
    grid-template-columns: 16px 1fr !important;
    align-items: center !important;
    column-gap: 12px !important;
    text-decoration: none !important;
    color: var(--text-primary, #eaeaea) !important;
    font-size: 13px !important;
    font-family: 'JetBrains Mono', monospace !important;
    padding: 10px 12px !important;
    border-radius: 8px !important;
    transition: .2s ease !important;
    border-bottom: 1px solid var(--border-color, rgba(255, 255, 255, .04)) !important;
  }

  .sidebar-nav-mobile a:last-child {
    border-bottom: none !important;
  }

  .sidebar-nav-mobile a i {
    font-size: 13px !important;
    color: var(--text-muted, #7f849c) !important;
    text-align: center !important;
  }

  .sidebar-nav-mobile a:hover,
  .sidebar-nav-mobile a.active {
    background: rgba(139, 92, 246, .12) !important;
    color: #a78bfa !important;
  }

  .sidebar-nav-mobile a:hover i,
  .sidebar-nav-mobile a.active i {
    color: #a78bfa !important;
  }

  /* CONTAINERS */
  main, 
  .rightbar {
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 14px !important;
    height: auto !important;
    min-height: auto !important;
    box-sizing: border-box !important;
  }

  main {
    margin-bottom: 14px !important;
  }

  .box,
  .rightbar-block,
  .github-section,
  .setup-box,
  .footer-box {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    box-sizing: border-box !important;
  }

  .rightbar > .rightbar-block:first-child,
  .rightbar > .rightbar-block:nth-child(4) {
    display: none !important;
  }

  .github-section { order: 1 !important; }
  .setup-box { order: 2 !important; }
  .footer-box { order: 3 !important; }

  /* FOOTER MOBILE */
  .mobile-footer {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 12px !important;
    padding: 24px 0 12px !important;
    text-align: center !important;
    width: 100% !important;
    margin-top: 20px !important;
  }

  .mobile-footer-gif {
    width: 125px !important;
    height: auto !important;
    object-fit: contain !important;
  }

  /* TROCA DOS GIFS DO FOOTER MOBILE POR TEMA */
  body:not(.light-mode) .mobile-footer .light-only { display: none !important; }
  body:not(.light-mode) .mobile-footer .dark-only { display: block !important; }
  body.light-mode .mobile-footer .dark-only { display: none !important; }
  body.light-mode .mobile-footer .light-only { display: block !important; }

  .mobile-footer .matrix-text {
    display: block !important;
    font-size: 13px !important;
    color: var(--text-muted, #10b981) !important;
    font-family: 'JetBrains Mono', monospace !important;
  }

  .hero h2 { font-size: 36px !important; }
  .hero p { font-size: 13px !important; }
  .stack-grid { gap: 8px !important; }

  .about-hero {
    flex-direction: column !important;
    align-items: center !important;
    text-align: center !important;
  }

  .about-intro { align-items: center !important; }
  .about-tagline { text-align: center !important; }
  .facts-grid { grid-template-columns: 1fr !important; }
  .about-socials { justify-content: center !important; }
  .cv-btn { margin: 0 auto !important; }

  .pcf-header {
    flex-wrap: wrap !important;
    gap: 8px !important;
  }

  /* CORREÇÃO DO CURSOR PISCANTE NO HERO SUBTITLE */
  .hero-subtitle {
    position: relative !important;
    display: inline-block !important;
  }

  .hero-subtitle .cursor {
    display: inline-block !important;
    width: 8px !important;
    height: 1em !important;
    background-color: currentColor !important;
    margin-left: 4px !important;
    vertical-align: middle !important;
    animation: blink 1s infinite !important;
  }

  @keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
  }

  /* OVERRIDES EXPLÍCITOS DE TEMA LIGHT (MOBILE) */
  body.light-mode .sidebar {
    background: #ffffff !important;
    border-color: #e4e4e7 !important;
  }

  body.light-mode .sidebar-nav-mobile {
    background: #ffffff !important;
    border-color: #e4e4e7 !important;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08) !important;
  }

  body.light-mode .sidebar-nav-mobile a {
    color: #27272a !important;
    border-color: #f4f4f5 !important;
  }

  body.light-mode .sidebar-nav-mobile a i {
    color: #71717a !important;
  }

  body.light-mode .sidebar-nav-mobile a:hover,
  body.light-mode .sidebar-nav-mobile a.active {
    background: rgba(139, 92, 246, .08) !important;
    color: #7c3aed !important;
  }

  body.light-mode .sidebar-nav-mobile a:hover i,
  body.light-mode .sidebar-nav-mobile a.active i {
    color: #7c3aed !important;
  }

  body.light-mode .menu-toggle {
    background: rgba(0, 0, 0, 0.04) !important;
    border-color: rgba(0, 0, 0, 0.08) !important;
  }

  body.light-mode .menu-toggle span,
  body.light-mode .menu-toggle span::before,
  body.light-mode .menu-toggle span::after {
    background: #27272a !important;
  }
}

/* REGRAS FORA DO MOBILE */
.sidebar-nav-mobile,
.menu-toggle,
.mobile-footer {
  display: none;
}

/* TABLET */
@media (min-width: 769px) and (max-width: 1100px) {
  .rightbar {
    display: none !important;
  }
}