/* Mobile Responsive Fixes - Added for phone compatibility */

/* Prevent horizontal scrolling on all devices */
html,
body {
  overflow-x: hidden;
  max-width: 100%;
  width: 100%;
}

/* Mobile-first approach for phones (up to 640px) */
@media (max-width: 640px) {
  body {
    padding: 0;
    margin: 0;
    font-size: 14px;
  }

  /* Container padding fixes */
  .container {
    padding-left: 12px;
    padding-right: 12px;
    max-width: 100% !important;
    width: 100%;
  }

  .container-fluid {
    padding-left: 12px;
    padding-right: 12px;
  }

  /* Navbar fixes */
  #mainNav {
    padding: 0.4rem 0 !important;
    background: linear-gradient(135deg, #b50444, #f9056c) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2) !important;
  }

  #mainNav.navbar-shrink {
    background: linear-gradient(135deg, #94003f, #f9056c) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2) !important;
  }

  .navbar-brand {
    padding: 0.3rem 0;
  }

  .logo-img,
  #mainNav .navbar-brand img {
    max-width: 250px;
    height: 5rem !important;
    /* Increased mobile logo size */
    transition: none;
  }

  /* Navbar Toggler */
  .navbar-toggler {
    padding: 0.5rem 0.75rem !important;
    border: none !important;
    background: transparent !important;
    transition: all 0.3s ease;
  }

  .navbar-toggler:hover {
    transform: scale(1.1);
  }

  .navbar-toggler:focus {
    box-shadow: none !important;
    background: rgba(249, 5, 108, 0.1) !important;
    border-radius: 8px;
  }

  .navbar-toggler-icon {
    width: 1.5rem;
    height: 1.5rem;
  }

  .navbar-collapse {
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
    padding: 0 !important;
  }

  .navbar-collapse.show {
    background: rgba(0, 0, 0, 0.85) !important;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(249, 5, 108, 0.3);
    border-radius: 12px;
    margin-top: 0.8rem;
    padding: 1.2rem !important;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3);
  }

  .navbar-nav {
    flex-direction: column;
    align-items: center;
  }

  .navbar-nav .nav-item {
    margin: 0.4rem 0;
    width: 100%;
  }

  .navbar-nav .nav-link {
    color: white !important;
    font-weight: 600;
    padding: 0.4rem 0.7rem !important;
    border-radius: 8px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: center;
    width: 100%;
  }

  .navbar-nav .nav-link:hover,
  .navbar-nav .nav-link.active {
    background: rgba(249, 5, 108, 0.2) !important;
    color: #f9056c !important;
    transform: scale(1.05);
  }

  /* Hero section */
  .masthead {
    padding: 2rem 1.2rem 1.5rem;
  }

  .masthead .container {
    align-items: center !important;
  }

  .masthead-heading {
    font-size: 1.75rem;
    line-height: 1.2;
    white-space: nowrap;
    overflow: visible;
    font-weight: 700;
    text-align: center !important;
  }

  .masthead-subheading {
    font-size: 0.95rem;
    line-height: 1.4;
    text-align: center !important;
  }

  .btn-start-hero {
    display: block;
    margin-left: auto;
    margin-right: auto;
  }

  /* Mobile Header Background - uncomment when puiu-mobile.png exists */
  /* header.masthead {
    background-image: url("../assets/img/puiu-mobile.png") !important;
    background-position: center bottom;
  } */

  /* Page sections */
  .page-section {
    padding: 3.5rem 0;
  }

  .section-heading {
    font-size: 1.4rem;
    margin-bottom: 0.5rem;
  }

  .section-subheading {
    font-size: 0.9rem;
    margin-bottom: 2rem;
  }

  /* Text content */
  p {
    font-size: 0.95rem;
    line-height: 1.6;
  }

  h4 {
    font-size: 1.1rem;
  }

  /* Portfolio & Grid items */
  .portfolio-item {
    margin-bottom: 1.5rem;
  }

  .col-lg-4,
  .col-md-6,
  .col-sm-6 {
    padding: 0.75rem 0;
  }

  .portfolio-caption-heading {
    font-size: 0.9rem;
  }

  /* Timeline layout */
  .timeline {
    padding-left: 0;
  }

  .timeline li {
    margin-bottom: 2rem;
    padding: 0;
    margin-left: 0;
    text-align: left;
    position: relative;
  }

  .timeline-image {
    position: relative;
    width: 50px;
    height: 50px;
    min-width: 50px;
    margin: 0 auto 1rem;
    left: auto;
  }

  .timeline-panel {
    position: relative;
    float: none;
    padding: 0.4rem 0.6rem;
    margin-left: 0;
    width: 100%;
    text-align: left;
  }

  .timeline-heading h4 {
    font-size: 0.9rem;
  }

  .timeline-body .text-muted {
    font-size: 0.82rem;
    line-height: 1.45;
    text-align: left;
  }

  /* Blog carousel */
  .blog-carousel-container {
    padding: 0 12px;
    max-width: 100%;
  }

  .blog-cards-wrapper {
    gap: 8px;
  }

  .blog-card {
    min-width: 85vw;
    max-width: calc(100vw - 32px);
    height: auto;
    flex-shrink: 0;
    left: 50%;
    transform: translateX(-50%);
  }

  .blog-carousel-btn {
    width: 40px;
    height: 40px;
    font-size: 16px;
    border-width: 2px;
  }

  .blog-carousel-btn.prev-btn {
    left: 5px;
  }

  .blog-carousel-btn.next-btn {
    right: 5px;
  }

  .blog-card-image {
    height: 180px;
  }

  .blog-card-content {
    padding: 16px 18px !important;
  }

  .blog-card-title {
    font-size: 0.95rem;
    line-height: 1.3;
  }

  .blog-card-description {
    font-size: 0.82rem;
    line-height: 1.4;
  }

  .blog-carousel-btn {
    width: 32px;
    height: 32px;
    font-size: 14px;
  }

  /* Buttons */
  .btn {
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
    display: inline-block;
    width: auto;
  }

  .btn-xl {
    padding: 0.8rem 1.6rem;
    font-size: 0.95rem;
  }

  .btn-primary {
    width: auto;
  }

  /* Images */
  img {
    max-width: 100%;
    height: auto;
    display: block;
  }

  .img-fluid {
    max-width: 100%;
    height: auto;
  }

  /* Footer */
  .footer-section {
    margin-bottom: 1.5rem;
    text-align: center;
  }

  .footer-title {
    font-size: 1rem;
  }

  .footer-heading {
    font-size: 0.95rem;
  }

  .footer-links,
  .footer-contact {
    text-align: center;
  }

  .footer-links li,
  .footer-contact li {
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
  }

  .footer-social {
    justify-content: center;
    gap: 1rem;
  }

  .footer-bottom {
    text-align: center;
  }

  /* Remove tap highlight */
  button,
  a {
    -webkit-tap-highlight-color: transparent;
  }

  /* Flexbox adjustments */
  .d-flex {
    flex-wrap: wrap;
  }

  .row {
    margin-left: 0;
    margin-right: 0;
  }
}

/* Tablet adjustments (640px to 1024px) */
@media (min-width: 641px) and (max-width: 1024px) {
  .container {
    padding-left: 16px;
    padding-right: 16px;
  }

  .masthead {
    padding: 6rem 1.5rem 4rem;
  }

  .masthead-heading {
    font-size: 2.2rem;
  }

  .page-section {
    padding: 4rem 1.5rem;
  }

  .section-heading {
    font-size: 1.75rem;
  }

  .blog-card {
    min-width: 300px;
  }
}

/* Ensure no overflow on all widths */
* {
  box-sizing: border-box;
}

/* Fix for potential overflow issues */
body {
  word-break: break-word;
  word-wrap: break-word;
}

table {
  table-layout: auto;
  max-width: 100%;
  overflow-x: auto;
  display: block;
}

/* Prevent images from overflowing */
img,
video,
iframe {
  max-width: 100%;
  height: auto;
}

/* === BLOG.HTML SPECIFIC MOBILE FIXES === */

@media (max-width: 640px) {

  /* Fix member description box (pink box with member description) */
  .member-description-box {
    padding: 16px !important;
    min-height: 280px !important;
    border-radius: 16px !important;
  }

  .description-content {
    top: 16px !important;
    left: 16px !important;
    right: 16px !important;
  }

  .description-content h3 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
  }

  .description-content p {
    font-size: 0.85rem;
    line-height: 1.5;
  }

  /* Fix team carousel on mobile */
  .team-carousel-container {
    padding: 0 8px;
  }

  .team-card {
    min-width: 180px;
    max-width: 200px;
  }

  .member-photo {
    width: 100px;
    height: 100px;
  }

  .member-name {
    font-size: 0.9rem;
  }

  .member-department {
    font-size: 0.75rem;
  }

  /* Fix season folders grid */
  .season-grid {
    grid-template-columns: 1fr !important;
    gap: 30px;
    padding: 10px;
  }

  .folder-item {
    width: 100%;
    max-width: 100%;
  }

  .folder-wrapper {
    width: 100%;
    max-width: 260px;
    height: 200px;
    margin: 0 auto;
  }

  .folder-year {
    font-size: 1.3rem;
  }

  .folder-icon {
    font-size: 2.5rem;
  }

  /* Fix modal (seasons popup) */
  .modal-window {
    width: 96%;
    height: 92vh;
    border-radius: 16px;
    max-width: none;
  }

  .modal-header {
    padding: 16px 14px;
  }

  .modal-title {
    font-size: 1.2rem;
  }

  .modal-close {
    width: 36px;
    height: 36px;
    font-size: 1rem;
  }

  /* Fix modal tabs (Proba, Robot, Activitati, Meeturi buttons) */
  .modal-tabs {
    padding: 8px 10px 0;
    overflow-x: auto;
    overflow-y: hidden;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .modal-tabs::-webkit-scrollbar {
    display: none;
  }

  .tab-btn {
    padding: 10px 14px;
    font-size: 0.85rem;
    white-space: nowrap;
    margin-right: 4px;
    flex-shrink: 0;
    min-width: fit-content;
  }

  .tab-btn.active {
    border: 1px solid #eee;
    border-bottom-color: white;
  }

  .modal-body {
    padding: 20px 14px;
  }

  /* Fix robot section layout */
  .robot-section {
    padding: 14px 16px;
    border-radius: 12px;
    gap: 16px;
  }

  .robot-media {
    width: 100%;
  }

  .robot-viewer,
  .robot-image {
    height: 280px;
    border-radius: 8px;
  }

  .robot-title {
    font-size: 1.1rem;
  }

  .robot-content p {
    font-size: 0.85rem;
    line-height: 1.6;
    margin-bottom: 10px;
  }

  /* Fix file grid (robot features cards) */
  .file-grid {
    grid-template-columns: 1fr !important;
    gap: 14px;
  }

  .file-card {
    padding: 18px;
    border-radius: 14px;
  }

  .file-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
  }

  .file-name {
    font-size: 0.95rem;
    margin-bottom: 6px;
  }

  .file-desc {
    font-size: 0.8rem;
    line-height: 1.4;
  }

  /* Fix activity grid */
  .activity-grid {
    grid-template-columns: 1fr !important;
    gap: 16px;
  }

  .activity-card {
    border-radius: 14px;
  }

  .activity-title {
    font-size: 0.95rem;
  }

  .activity-text,
  .activity-meta {
    font-size: 0.85rem;
  }

  .activity-body {
    padding: 12px 14px 14px;
  }

  /* Fix accordion/cards in meeturi section */
  .card {
    border-radius: 14px !important;
    margin-bottom: 12px;
  }

  .card-header {
    padding: 12px 14px !important;
  }

  .card-header h5 {
    font-size: 0.95rem;
  }

  .card-body {
    padding: 14px !important;
  }

  .card-body p {
    font-size: 0.85rem;
    line-height: 1.5;
    margin-bottom: 10px;
  }

  .badge {
    font-size: 0.75rem !important;
    padding: 6px 12px !important;
  }
}

/* Tablet fixes for blog elements */
@media (min-width: 641px) and (max-width: 1024px) {
  .member-description-box {
    padding: 30px !important;
    min-height: 380px !important;
  }

  .modal-window {
    width: 95%;
    max-width: 800px;
  }

  .modal-tabs {
    padding: 12px 20px 0;
  }

  .tab-btn {
    padding: 12px 22px;
    font-size: 0.95rem;
  }

  .season-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 40px;
  }

  .robot-viewer {
    height: 350px;
  }

  .activity-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Small phone landscape fixes */
@media (max-width: 640px) and (orientation: landscape) {
  .modal-window {
    height: 96vh;
  }

  .robot-viewer,
  .robot-image {
    height: 220px;
  }

  .member-description-box {
    min-height: 200px !important;
  }
}