/* 
  DRISHTI (Digital Risk Intelligence & Social Threat Intelligence)
  Responsive Breakpoint Stylesheet (css/responsive.css)
*/

/* Laptop Breakpoint (Under 1366px) */
@media (max-width: 1366px) {
  .content-body {
    padding: 1.5rem;
  }
  .page-title {
    font-size: 1.5rem;
  }
}



/* Medium Screens & Tablets (Under 1024px) - Collapses sidebar automatically on tablet and mobile */
@media (max-width: 1024.98px) {
  /* Sidebar behaves as a slide-out drawer on mobile/tablet */
  .drishti-sidebar {
    position: fixed;
    transform: translateX(-100%);
    box-shadow: none;
    z-index: 1100;
  }
  
  .drishti-sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 5px 0 25px rgba(0, 0, 0, 0.6);
  }
  
  /* Force sidebar to be fully expanded on mobile, even if collapsed on desktop */
  .drishti-sidebar.collapsed {
    width: 290px !important;
  }
  
  .drishti-sidebar.collapsed .sidebar-brand span,
  .drishti-sidebar.collapsed .sidebar-menu-link span {
    opacity: 1 !important;
    pointer-events: auto !important;
    display: inline-block !important;
  }
  
  .drishti-sidebar.collapsed .sidebar-header {
    justify-content: flex-start !important;
    padding: 0 1.5rem !important;
  }
  
  .drishti-sidebar.collapsed .sidebar-menu-link {
    justify-content: flex-start !important;
    padding: 0.55rem 0.75rem !important;
  }
  
  .main-content {
    margin-left: 0 !important;
  }
  
  .sidebar-overlay.active {
    display: block;
    opacity: 1;
  }
  
  .drishti-header {
    padding: 0 1.25rem;
  }
  
  /* Show hamburger toggle on mobile */
  .mobile-menu-toggle {
    display: flex !important;
  }
  
  .sidebar-toggle-btn {
    display: none;
  }
}

/* Tablet Screens (Under 768px) */
@media (max-width: 767.98px) {
  .page-header {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 0.75rem;
  }
  .drishti-header {
    height: 64px;
  }
  .sidebar-header {
    height: 64px;
  }
  .content-body {
    padding: 1.25rem;
  }
  
  /* Hide search bar on header on small tablet/mobile, or expand as dropdown */
  .header-search {
    display: none; /* Can be toggled or simplified */
  }
  
  .header-actions {
    gap: 0.75rem;
  }
  
  .user-meta {
    display: none; /* Hide textual role details next to avatar */
  }
  
  .stat-number {
    font-size: 1.85rem;
  }
  
  .profile-header-card {
    flex-direction: column;
    text-align: center;
    padding: 1.5rem;
    gap: 1.25rem;
  }
  
  .profile-avatar-large {
    width: 100px;
    height: 100px;
  }
  
  /* Hide columns in table on mobile to prevent squishing */
  .table-drishti th:nth-child(2),
  .table-drishti td:nth-child(2),
  .table-drishti th:nth-child(3),
  .table-drishti td:nth-child(3) {
    display: none;
  }
  
  /* Stack 4-column stats cards vertically to 100% width on mobile */
  .main-content .col-xl-3 {
    width: 100% !important;
    max-width: 100% !important;
  }
}

/* Mobile Screens (Under 480px / 375px) */
@media (max-width: 480px) {
  .page-header {
    margin-bottom: 1.5rem;
  }
  
  .page-title {
    font-size: 1.35rem;
  }
  
  .content-body {
    padding: 1rem;
  }
  
  .card-body {
    padding: 1rem !important;
  }
  
  .card-header {
    padding: 1rem !important;
  }
  
  .stat-card {
    padding: 1rem;
  }
  
  .stat-icon-wrapper {
    width: 40px;
    height: 40px;
    font-size: 1.25rem;
    margin-bottom: 1rem;
  }
  
  /* Quick action buttons spacing */
  .btn {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
  }
  
  .modal-dialog {
    margin: 0.5rem;
  }
  
  .modal-content {
    border-radius: 10px;
  }
  
  .modal-header, .modal-footer {
    padding: 1rem !important;
  }
  
  .modal-body {
    padding: 1rem !important;
  }
  
  .auth-card {
    padding: 1.5rem !important;
  }
  
  .notification-panel-dropdown {
    width: calc(100vw - 30px) !important;
    max-width: 320px;
  }
  
  /* Header spacing optimization for small screens */
  .drishti-header {
    padding: 0 1rem !important;
    height: 60px !important;
  }
  .header-actions {
    gap: 0.5rem !important;
  }
  .profile-dropdown-trigger {
    padding: 0.25rem !important;
  }
  .profile-dropdown-trigger .bi-chevron-down {
    display: none !important;
  }
  .mobile-menu-toggle {
    width: 36px !important;
    height: 36px !important;
    font-size: 1.25rem !important;
  }
  .header-btn {
    width: 36px !important;
    height: 36px !important;
    font-size: 1.25rem !important;
  }
}

/* ==========================================
   GLOBAL RESPONSIVENESS & LAYOUT SAFEGUARDS
   ========================================== */

/* Universal text wrap safeguard to prevent overflows */
p, span, td, th, h1, h2, h3, h4, h5, h6, .card-title, .badge, .btn {
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* Ensure images, icons and SVGs scale proportionally */
img, svg {
  max-width: 100%;
  height: auto;
}

/* Forms & control inputs scaling safeguard */
input, select, textarea, .form-control, .form-select, .input-group {
  max-width: 100% !important;
}

/* Prevent button wrapping overlapping on small screens */
.btn-group, .btn-toolbar, .d-flex {
  flex-wrap: wrap;
}

/* Global Table Responsiveness & Sticky Headers */
.table-responsive {
  display: block;
  width: 100%;
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch;
}

/* Sticky header format where appropriate */
.table-responsive.sticky-header,
.table-sticky-container {
  max-height: 500px;
  overflow-y: auto;
}

.table-responsive.sticky-header thead th,
.table-sticky-container table thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  background-color: #F1F5F9 !important;
}

[data-bs-theme="dark"] .table-responsive.sticky-header thead th,
[data-bs-theme="dark"] .table-sticky-container table thead th {
  background-color: #1e293b !important;
}

/* Modals viewport fit and scrollable body */
.modal-dialog {
  max-width: 95% !important;
  margin: 1.75rem auto;
}
@media (min-width: 576px) {
  .modal-dialog {
    max-width: 500px !important;
  }
  .modal-dialog.modal-lg {
    max-width: 800px !important;
  }
  .modal-dialog.modal-xl {
    max-width: 1140px !important;
  }
}

.modal-content {
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.modal-body {
  overflow-y: auto !important;
  max-height: calc(90vh - 150px) !important;
}

/* Map sizing constraints on mobile/tablet */
@media (max-width: 1024.98px) {
  .gis-map-container, #map, #leaflet-map {
    height: 400px !important;
    max-height: 60vh !important;
  }
}

/* Chart Canvas scaling safeguard */
canvas {
  max-width: 100% !important;
  height: auto !important;
}
.chart-container {
  position: relative;
  width: 100%;
  height: 100%;
}
