/* Responsive Styles for Payroll Management System */

/* Mobile First Approach - Base styles for mobile */
/* Extra Small devices (phones, less than 576px) */
@media (max-width: 575.98px) {
  /* Tables - Make scrollable on mobile */
  .table-responsive {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .table {
    font-size: 0.875rem;
  }
  
  .table th,
  .table td {
    padding: 0.5rem 0.25rem;
    white-space: nowrap;
  }
  
  /* Cards - Full width on mobile */
  .card {
    margin-bottom: 1rem;
  }
  
  .row-cards > .col-sm-6,
  .row-cards > .col-lg-3,
  .row-cards > .col-md-4,
  .row-cards > .col-md-6 {
    margin-bottom: 1rem;
  }
  
  /* Modals - Full width on mobile */
  .modal-dialog {
    margin: 0.5rem;
    max-width: calc(100% - 1rem);
  }
  
  .modal-content {
    border-radius: 0.25rem;
  }
  
  .modal-header {
    padding: 1rem 0.75rem;
    flex-direction: column;
    align-items: flex-start !important;
  }
  
  .modal-header h5 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
  }
  
  .modal-header .close {
    position: absolute;
    right: 0.75rem;
    top: 1rem;
  }
  
  .modal-body {
    padding: 1rem 0.75rem;
  }
  
  .modal-footer {
    padding: 0.75rem;
    flex-direction: column;
  }
  
  .modal-footer .btn {
    width: 100%;
    margin: 0.25rem 0;
  }
  
  /* Forms - Stack inputs on mobile */
  .form-group {
    margin-bottom: 1rem;
  }
  
  .form-control,
  .custom-select {
    font-size: 16px; /* Prevents zoom on iOS */
  }
  
  /* Buttons - Stack on mobile when in groups */
  .btn-group {
    display: flex;
    flex-direction: column;
    width: 100%;
  }
  
  .btn-group .btn {
    width: 100%;
    margin: 0.25rem 0;
    border-radius: 0.25rem !important;
  }
  
  /* Search inputs - Full width */
  input[type="text"][placeholder*="Search"],
  input[type="search"] {
    width: 100% !important;
    margin: 0.5rem 0;
  }
  
  /* Header adjustments */
  .header {
    padding: 0.5rem 0;
  }
  
  .header .container-fluid {
    padding: 0 0.75rem;
  }
  
  /* Page header */
  .page-header {
    margin-bottom: 1rem;
  }
  
  /* Container padding */
  .container-fluid {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }
  
  /* Card body padding */
  .card-body {
    padding: 1rem;
  }
  
  /* Payslip adjustments */
  #printDataHolder .card {
    max-width: 100%;
  }
  
  #printDataHolder .row {
    margin: 0;
  }
  
  #printDataHolder .col-md-6 {
    flex: 0 0 100%;
    max-width: 100%;
    margin-bottom: 1rem;
  }
  
  /* Dashboard cards - Stack vertically */
  .row-cards .col-sm-6 {
    flex: 0 0 100%;
    max-width: 100%;
  }
  
  /* Action buttons in tables */
  .table .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    margin: 0.125rem;
  }
  
  /* Dropdown menus */
  .dropdown-menu {
    font-size: 0.875rem;
  }
  
  /* Breadcrumb */
  .breadcrumb {
    font-size: 0.875rem;
    flex-wrap: wrap;
  }
  
  /* Sidebar adjustments (if visible) */
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }
  
  .sidebar.show {
    transform: translateX(0);
  }
  
  /* Page content adjustments */
  .page {
    margin-left: 0;
  }
  
  .page-main {
    margin-left: 0;
  }
  
  /* Hide less important elements on mobile */
  .d-none-mobile {
    display: none !important;
  }
  
  /* Stats cards text size */
  .card h4 {
    font-size: 1.25rem;
  }
  
  .card small {
    font-size: 0.75rem;
  }
}

/* Small devices (landscape phones, 576px and up) */
@media (min-width: 576px) and (max-width: 767.98px) {
  .modal-dialog {
    max-width: 500px;
    margin: 1.75rem auto;
  }
  
  .row-cards .col-sm-6 {
    flex: 0 0 50%;
    max-width: 50%;
  }
  
  .table th,
  .table td {
    padding: 0.75rem 0.5rem;
  }
}

/* Medium devices (tablets, 768px and up) */
@media (min-width: 768px) and (max-width: 991.98px) {
  .modal-dialog {
    max-width: 600px;
  }
  
  .row-cards .col-md-4 {
    flex: 0 0 33.333333%;
    max-width: 33.333333%;
  }
  
  .row-cards .col-md-6 {
    flex: 0 0 50%;
    max-width: 50%;
  }
  
  /* Sidebar can be visible but narrower */
  .sidebar {
    width: 200px;
  }
  
  .page {
    margin-left: 200px;
  }
}

/* Large devices (desktops, 992px and up) */
@media (min-width: 992px) {
  /* Full desktop layout */
  .modal-dialog.modal-lg {
    max-width: 800px;
  }
  
  .modal-dialog.modal-xl {
    max-width: 1140px;
  }
}

/* Extra large devices (large desktops, 1280px and up) */
@media (min-width: 1280px) {
  .container-fluid {
    max-width: 1400px;
  }
}

/* Print styles - Hide sidebar and adjust layout */
@media print {
  .sidebar,
  .header,
  .page-header,
  .btn,
  .dropdown,
  .breadcrumb {
    display: none !important;
  }
  
  .page {
    margin-left: 0 !important;
  }
  
  .page-main {
    margin-left: 0 !important;
  }
  
  .card {
    border: none !important;
    box-shadow: none !important;
  }
}

/* Utility classes for responsive behavior */
@media (max-width: 767.98px) {
  .mobile-full-width {
    width: 100% !important;
  }
  
  .mobile-stack {
    flex-direction: column !important;
  }
  
  .mobile-center {
    text-align: center !important;
  }
  
  .mobile-hide {
    display: none !important;
  }
  
  .mobile-show {
    display: block !important;
  }
}

/* Fix for DataTables on mobile */
@media (max-width: 767.98px) {
  .dataTables_wrapper .dataTables_length,
  .dataTables_wrapper .dataTables_filter {
    margin-bottom: 1rem;
  }
  
  .dataTables_wrapper .dataTables_length select,
  .dataTables_wrapper .dataTables_filter input {
    width: 100%;
    margin: 0.5rem 0;
  }
  
  .dataTables_wrapper .dataTables_info,
  .dataTables_wrapper .dataTables_paginate {
    margin-top: 1rem;
    text-align: center;
  }
  
  .dataTables_wrapper .dataTables_paginate .pagination {
    justify-content: center;
    flex-wrap: wrap;
  }
}

/* Fix for forms on mobile - prevent zoom on input focus (iOS) */
@media (max-width: 767.98px) {
  input[type="text"],
  input[type="email"],
  input[type="number"],
  input[type="password"],
  input[type="date"],
  input[type="time"],
  select,
  textarea {
    font-size: 16px !important;
  }
  
  /* Ensure buttons are touch-friendly */
  .btn {
    min-height: 44px;
    padding: 0.5rem 1rem;
  }
  
  /* Make action buttons in tables more accessible */
  .table .btn-sm {
    min-height: 36px;
    padding: 0.375rem 0.75rem;
  }
}

/* Responsive images */
img {
  max-width: 100%;
  height: auto;
}

/* Responsive video embeds */
iframe,
embed,
object,
video {
  max-width: 100%;
}

/* Fix for flexbox on older browsers */
.row {
  display: flex;
  flex-wrap: wrap;
}

/* Ensure proper spacing on all screen sizes */
.container-fluid {
  width: 100%;
  padding-right: 15px;
  padding-left: 15px;
  margin-right: auto;
  margin-left: auto;
}

/* Modal search inputs in header */
.modal-header input[type="text"] {
  width: 100%;
  margin-top: 0.5rem;
}

@media (min-width: 768px) {
  .modal-header {
    flex-direction: row;
    align-items: center !important;
  }
  
  .modal-header input[type="text"] {
    width: auto;
    margin-top: 0;
    margin-left: 15px;
  }
}

