/* ================================================
   MASTER RESPONSIVE CSS - DIPERBAIKI
   Untuk semua komponen: global, hero, kategori, skill, testimoni, portfolio modal
   ================================================ */

/* RESET DASAR UNTUK MOBILE */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

/* TABLET RESPONSIF (769px - 1024px) */
@media (max-width: 1024px) and (min-width: 769px) {
  
  /* GLOBAL - Masonry Grid */
  .masonry-grid {
    column-count: 2;
    column-gap: 15px;
  }
  
  .main-content-scrollable {
    padding: 25px;
  }
  
  .skill-logos img {
    height: 45px;
  }
  
  /* HERO Navigation */
  .hero-nav a {
    font-size: 15px;
    padding: 0 10px;
  }
  
  /* KATEGORI Grid */
  .category-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    padding: 0 20px;
  }
  
  .category-item {
    padding: 25px;
    font-size: 0.9rem;
  }
  
  /* SKILL Grid */
  .skill-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 12px;
  }
  
  .skill-item {
    padding: 12px;
    font-size: 0.9rem;
  }
  
  /* TESTIMONI Cards */
  .testimonial-card {
    flex: 0 0 calc(50% - 10px);
    padding: 18px;
  }
  
  .avatar {
    width: 70px;
    height: 70px;
  }
  
  /* PORTFOLIO MODAL */
  .modal-content {
    max-width: 90vw;
    width: 800px;
  }
  
  .gallery-wrapper {
    min-height: 400px;
  }
  
  .gallery-image {
    max-height: 400px;
  }
}

/* MOBILE LANDSCAPE (481px - 768px) */
@media (max-width: 768px) and (min-width: 481px) and (orientation: landscape) {
  
  /* GLOBAL Layout - Tetap Horizontal */
  .container {
    display: flex !important;
    flex-direction: row !important;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
  }
  
  .sidebar {
    width: 35% !important;
    min-width: 280px !important;
    max-width: 350px !important;
    height: 100vh !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 15px;
    position: relative !important;
    flex-shrink: 0;
  }
  
  .profile-img {
    width: 100px;
    height: 100px;
  }
  
  .bio-description {
    font-size: 0.8rem;
  }
  
  .konten-scroll {
    width: 65% !important;
    height: 100vh !important;
    flex: 1 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
  }
  
  .main-content-scrollable {
    padding: 20px;
    height: auto !important;
  }
  
  /* HERO Navigation */
  .hero {
    height: 6vh;
  }
  
  .hero-nav a {
    font-size: 14px;
  }
  
  /* MASONRY */
  .masonry-grid {
    column-count: 2;
  }
  
  /* KATEGORI */
  .category-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 0 15px;
  }
  
  .category-item {
    padding: 20px;
    font-size: 0.85rem;
  }
  
  /* SKILL */
  .skill-grid {
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 10px;
  }
  
  .skill-item {
    padding: 10px;
    font-size: 0.8rem;
  }
  
  /* TESTIMONI */
  .testimonial-container {
    gap: 15px;
  }
  
  .testimonial-card {
    flex: 0 0 calc(60% - 10px);
    padding: 15px;
  }
}

/* MOBILE PORTRAIT - LAYOUT VERTIKAL UTAMA */
@media (max-width: 768px) and (orientation: portrait) {
  
  /* GLOBAL - Reset Complete untuk Layout Vertikal */
  html, body {
    width: 100% !important;
    height: auto !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
  }
  
  body {
    display: block !important;
  }
  
  .container {
    display: block !important;
    flex-direction: column !important;
    height: auto !important;
    min-height: 100vh !important;
    width: 100% !important;
    overflow: visible !important;
    position: relative !important;
  }
  
  /* SIDEBAR - Jadi Header di Atas */
  .sidebar {
    display: block !important;
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    min-height: auto !important;
    position: static !important;
    float: none !important;
    flex: none !important;
    padding: 20px !important;
    box-sizing: border-box !important;
    overflow: visible !important;
    order: 1;
  }
  
  .profile-img {
    width: 120px;
    height: 120px;
    margin: 0 auto 15px auto;
    display: block;
  }
  
  .bio-description {
    text-align: center;
    font-size: 0.85rem;
    margin: 15px 0;
  }
  
  .btn-hire {
    display: block;
    text-align: center;
    margin: 15px auto;
    width: fit-content;
  }
  
  .skills, .trusted {
    margin: 15px 0;
    padding: 20px;
  }
  
  .skill-logos {
    justify-content: center;
  }
  
  .skill-logos img {
    height: 40px;
  }
  
  /* KONTEN - Jadi Body di Bawah */
  .konten-scroll {
    display: block !important;
    width: 100% !important;
    height: auto !important;
    min-height: auto !important;
    overflow: visible !important;
    overflow-x: hidden !important;
    overflow-y: visible !important;
    margin: 0 !important;
    padding: 0 !important;
    position: static !important;
    float: none !important;
    flex: none !important;
    order: 2;
  }
  
  .main-content-scrollable {
    display: block !important;
    height: auto !important;
    min-height: auto !important;
    overflow: visible !important;
    flex: none !important;
    padding: 20px !important;
    box-sizing: border-box !important;
    width: 100% !important;
  }
  
  /* HERO Navigation */
  .hero {
    height: auto;
    min-height: 8vh;
  }
  
  .hero-nav {
    flex-wrap: wrap;
    display: flex;
  }
  
  .hero-nav a {
    flex: 1 1 50%;
    font-size: 14px;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  /* MASONRY - 1 Kolom */
  .masonry-grid {
    column-count: 1 !important;
    column-gap: 0 !important;
    display: block !important;
  }
  
  .masonry-item {
    display: block !important;
    width: 100% !important;
    margin-bottom: 15px !important;
    break-inside: auto !important;
    page-break-inside: avoid !important;
  }
  
  /* KATEGORI Grid */
  .category-section {
    margin-top: 30px;
    width: 100%;
  }
  
  .category-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    padding: 0 15px;
    width: 100%;
  }
  
  .category-item {
    padding: 20px;
    font-size: 0.85rem;
  }
  
  /* SKILL Grid */
  .skill-section {
    margin-top: 30px;
    width: 100%;
  }
  
  .skill-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    padding: 0 15px;
    width: 100%;
  }
  
  .skill-item {
    padding: 12px;
    font-size: 0.85rem;
  }
  
  /* TESTIMONI */
  .testimonial-section {
    padding: 30px 15px;
    width: 100%;
  }
  
  .testimonial-container {
    gap: 15px;
    flex-direction: column;
    display: flex;
  }
  
  .testimonial-card {
    flex: none !important;
    width: 100% !important;
    flex-direction: column;
    text-align: center;
    gap: 15px;
    padding: 20px;
    display: flex;
  }
  
  .avatar {
    width: 80px;
    height: 80px;
    align-self: center;
    margin: 0 auto;
  }
  
  .testimonial-content {
    text-align: center;
  }
  
  /* PORTFOLIO MODAL */
  .modal-content {
    max-width: 95vw;
    max-height: 95vh;
    margin: 10px;
  }
  
  .modal-header h2 {
    font-size: 20px;
    padding-right: 50px;
  }
  
  .gallery-wrapper {
    min-height: 300px;
  }
  
  .gallery-image {
    max-height: 350px;
  }
  
  .gallery-nav {
    width: 40px;
    height: 40px;
    font-size: 24px;
  }
  
  .gallery-prev {
    left: 10px;
  }
  
  .gallery-next {
    right: 10px;
  }
  
  .project-description {
    padding: 15px;
  }
}

/* MOBILE LANDSCAPE KECIL (max-width: 480px) */
@media (max-width: 480px) and (orientation: landscape) {
  
  .container {
    display: flex !important;
    flex-direction: row !important;
    height: 100vh;
  }
  
  .sidebar {
    width: 40% !important;
    min-width: 200px !important;
    height: 100vh !important;
    overflow-y: auto !important;
    padding: 10px !important;
  }
  
  .konten-scroll {
    width: 60% !important;
    height: 100vh !important;
    overflow-y: auto !important;
  }
  
  .profile-img {
    width: 80px;
    height: 80px;
  }
  
  .bio-description {
    font-size: 0.75rem;
  }
  
  .hero-nav a {
    font-size: 12px;
    padding: 5px;
  }
}

/* MOBILE KECIL PORTRAIT (max-width: 480px) */
@media (max-width: 480px) and (orientation: portrait) {
  
  /* GLOBAL */
  .sidebar {
    padding: 15px !important;
  }
  
  .profile-img {
    width: 100px;
    height: 100px;
  }
  
  .bio-description {
    font-size: 0.8rem;
  }
  
  .skills, .trusted {
    padding: 15px;
    margin: 10px 0;
  }
  
  .skill-logos img {
    height: 35px;
  }
  
  .main-content-scrollable {
    padding: 15px !important;
  }
  
  /* HERO */
  .hero {
    height: auto;
    min-height: 10vh;
  }
  
  .hero-nav a {
    flex: 1 1 100%;
    font-size: 16px;
    min-height: 50px;
  }
  
  /* MASONRY */
  .masonry-item {
    margin-bottom: 12px;
  }
  
  .masonry-item p {
    padding: 12px;
    font-size: 0.9rem;
  }
  
  /* KATEGORI */
  .category-grid {
    grid-template-columns: 1fr;
    padding: 0 10px;
  }
  
  .category-item {
    padding: 18px;
  }
  
  /* SKILL */
  .skill-grid {
    grid-template-columns: 1fr;
    padding: 0 10px;
  }
  
  /* TESTIMONI */
  .testimonial-section {
    padding: 20px 10px;
  }
  
  .testimonial-card {
    padding: 15px;
  }
  
  .avatar {
    width: 60px;
    height: 60px;
  }
  
  /* PORTFOLIO MODAL */
  .modal-content {
    max-width: 100vw;
    max-height: 100vh;
    border-radius: 0;
  }
  
  .gallery-wrapper {
    min-height: 250px;
  }
  
  .gallery-image {
    max-height: 300px;
  }
  
  .gallery-nav {
    width: 35px;
    height: 35px;
    font-size: 20px;
  }
  
  .modal-header {
    padding: 15px 15px 10px;
  }
  
  .modal-close {
    top: 10px;
    right: 15px;
    width: 35px;
    height: 35px;
    font-size: 24px;
  }
}

/* MOBILE SANGAT KECIL (max-width: 360px) */
@media (max-width: 360px) {
  
  .profile-img {
    width: 80px;
    height: 80px;
  }
  
  .bio-description {
    font-size: 0.75rem;
  }
  
  .skill-logos img {
    height: 30px;
  }
  
  .main-content-scrollable {
    padding: 12px !important;
  }
  
  .masonry-item {
    margin-bottom: 10px;
    border-radius: 6px;
  }
  
  .masonry-item p {
    padding: 10px;
    font-size: 0.85rem;
  }
  
  .category-item,
  .skill-item {
    padding: 15px;
    font-size: 0.8rem;
  }
  
  .testimonial-card {
    padding: 12px;
  }
  
  .avatar {
    width: 50px;
    height: 50px;
  }
}

/* LANDSCAPE KHUSUS UNTUK DEVICE SANGAT PENDEK */
@media (max-height: 500px) and (orientation: landscape) {
  
  .sidebar {
    padding: 8px !important;
  }
  
  .profile-img {
    width: 60px;
    height: 60px;
  }
  
  .bio-description {
    font-size: 0.7rem;
    margin: 8px 0;
  }
  
  .skills, .trusted {
    padding: 8px;
    margin: 5px 0;
  }
  
  .hero {
    height: 5vh;
  }
  
  .hero-nav a {
    font-size: 12px;
    min-height: 35px;
  }
}

/* PRINT STYLES */
@media print {
  
  .container {
    display: block !important;
  }
  
  .sidebar {
    width: 100% !important;
    page-break-inside: avoid;
  }
  
  .konten-scroll {
    width: 100% !important;
  }
  
  .masonry-grid {
    column-count: 2;
  }
  
  .masonry-item {
    page-break-inside: avoid;
  }
  
  .portfolio-modal {
    display: none !important;
  }
}

/* FALLBACK DAN OVERRIDE KHUSUS */
@media (max-width: 768px) {
  
  /* Pastikan tidak ada elemen yang menggunakan float */
  * {
    float: none !important;
  }
  
  /* Override untuk container yang keras kepala */
  body.mobile-view {
    display: block !important;
  }
  
  .container.mobile-view {
    display: block !important;
    flex-direction: column !important;
  }
  
  .sidebar.mobile-view {
    width: 100% !important;
    height: auto !important;
  }
  
  .konten-scroll.mobile-view {
    width: 100% !important;
    height: auto !important;
  }
}

/* FORCE OVERRIDE UNTUK ELEMEN YANG SUSAH */
@media (max-width: 768px) and (orientation: portrait) {
  
  /* Force semua flex container jadi block */
  .container,
  .sidebar,
  .konten-scroll,
  .main-content-scrollable {
    display: block !important;
    width: 100% !important;
    height: auto !important;
    position: static !important;
    float: none !important;
    flex: none !important;
  }
  
  /* Khusus untuk container */
  .container {
    flex-direction: column !important;
  }
}