/* Landscape Orientation Support for Tablets and Mobile Devices */

/* Landscape mode untuk tablet (768px - 1024px) */
@media screen and (orientation: landscape) and (min-width: 768px) and (max-width: 1024px) {
  /* Adjust sidebar untuk landscape */
  .sidebar {
    width: 200px;
  }
  
  .sidebar.collapsed {
    width: 60px;
  }
  
  .main-content {
    margin-left: 200px;
  }
  
  .sidebar.collapsed ~ .main-content {
    margin-left: 60px;
  }
  
  /* Optimize table untuk landscape */
  .table-container {
    overflow-x: auto;
    max-width: 100%;
  }
  
  table {
    font-size: 12px;
  }
  
  /* Optimize cards grid */
  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .charts-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  /* Form layout optimization */
  .form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
  }
  
  /* Modal optimization */
  .modal-content {
    max-width: 70vw;
    max-height: 85vh;
    overflow-y: auto;
  }
}

/* Landscape mode untuk mobile (< 768px) */
@media screen and (orientation: landscape) and (max-width: 767px) {
  /* Hide sidebar by default in mobile landscape */
  .sidebar {
    transform: translateX(-100%);
  }
  
  .sidebar.active {
    transform: translateX(0);
  }
  
  .main-content {
    margin-left: 0;
    padding: 10px;
  }
  
  /* Compact header */
  .top-header {
    padding: 8px 15px;
    height: 50px;
  }
  
  .header-left h2 {
    font-size: 16px;
  }
  
  /* Compact tables */
  table {
    font-size: 11px;
  }
  
  th, td {
    padding: 6px 8px;
  }
  
  /* Compact cards */
  .card {
    margin-bottom: 15px;
  }
  
  .card-header {
    padding: 12px 15px;
  }
  
  .card-body {
    padding: 12px 15px;
  }
  
  /* Stack stats vertically in mobile landscape */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  
  .stat-card {
    padding: 12px;
  }
  
  /* Optimize buttons */
  .btn-group {
    flex-wrap: wrap;
    gap: 8px;
  }
  
  .btn {
    padding: 8px 12px;
    font-size: 13px;
  }
  
  /* Modal full width in mobile landscape */
  .modal-content {
    max-width: 95vw;
    max-height: 90vh;
    overflow-y: auto;
  }
}

/* Large tablets and small desktops in landscape */
@media screen and (orientation: landscape) and (min-width: 1025px) and (max-width: 1366px) {
  .sidebar {
    width: 240px;
  }
  
  .main-content {
    margin-left: 240px;
  }
  
  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .charts-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  table {
    font-size: 13px;
  }
}

/* Optimize specific components for landscape */
@media screen and (orientation: landscape) {
  /* Landing page optimization */
  .hero-section {
    min-height: 70vh;
  }
  
  .features-grid {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  }
  
  /* Login/Register page optimization */
  .auth-container {
    max-width: 600px;
    padding: 30px;
  }
  
  /* Member portal optimization */
  .member-dashboard {
    padding: 15px;
  }
  
  /* Laporan optimization */
  .filter-section {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: flex-end;
  }
  
  .filter-section .form-group {
    flex: 1;
    min-width: 150px;
  }
  
  /* Unit Usaha tiles */
  .unit-usaha-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  }
  
  /* Approval cards */
  .approval-grid {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  }
}

/* Prevent text from being too small */
@media screen and (orientation: landscape) {
  body {
    font-size: 14px;
  }
  
  h1 { font-size: 24px; }
  h2 { font-size: 20px; }
  h3 { font-size: 18px; }
  h4 { font-size: 16px; }
  h5 { font-size: 14px; }
  h6 { font-size: 13px; }
}

/* Improve touch targets in landscape */
@media screen and (orientation: landscape) and (max-width: 1024px) {
  button, .btn, a.nav-item {
    min-height: 40px;
    min-width: 40px;
  }
  
  input, select, textarea {
    min-height: 40px;
  }
}

/* Print optimization (landscape) */
@media print and (orientation: landscape) {
  @page {
    size: landscape;
    margin: 15mm;
  }
  
  body {
    font-size: 11px;
  }
  
  table {
    font-size: 10px;
  }
  
  .sidebar,
  .top-header,
  button,
  .btn-group {
    display: none !important;
  }
  
  .main-content {
    margin: 0;
    padding: 0;
  }
}
