html {
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

html {
  position: relative;
  min-height: 100%;
}

body {
  margin-bottom: 60px;
}

/* ========================================
   SORTING AND TABLE ENHANCEMENTS
   ======================================== */

/* Sortable column headers */
.sortable a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: white !important;
  text-decoration: none;
  transition: color 0.2s ease;
}

.sortable a:hover {
  color: #f8f9fa !important;
  text-decoration: none;
}

.sortable .fas.fa-sort {
  opacity: 0.5;
  transition: opacity 0.2s ease;
}

.sortable .fas.fa-sort-up,
.sortable .fas.fa-sort-down {
  opacity: 1;
}

/* Enhanced table responsive design */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 0.375rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Custom scrollbar for better UX */
.table-responsive::-webkit-scrollbar {
  height: 8px;
}

.table-responsive::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

/* Compact table styles */
.compact-table {
  font-size: 0.9rem;
  margin-bottom: 0;
}

.compact-table th {
  border-bottom: 2px solid #dee2e6;
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.75rem 0.5rem;
  white-space: nowrap;
  background-color: #343a40;
  color: white;
  position: sticky;
  top: 0;
  z-index: 10;
}

.compact-table td {
  padding: 0.75rem 0.5rem;
  vertical-align: middle;
  border-bottom: 1px solid #dee2e6;
}

.compact-table tbody tr:hover {
  background-color: #f8f9fa;
  transition: background-color 0.2s ease;
}

/* Table column width utilities */
.col-id, .col-sno {
  width: 8%;
  min-width: 60px;
}

.col-company {
  width: 25%;
  min-width: 200px;
}

.col-contact {
  width: 25%;
  min-width: 180px;
}

.col-depository {
  width: 12%;
  min-width: 100px;
}

.col-isin {
  width: 15%;
  min-width: 120px;
}

.col-status {
  width: 15%;
  min-width: 120px;
}

.col-stage {
  width: 10%;
  min-width: 80px;
}

.col-modified {
  width: 15%;
  min-width: 120px;
}

.col-remarks {
  width: 20%;
  min-width: 150px;
}

.col-actions {
  width: 15%;
  min-width: 200px;
}

/* Button group improvements */
.btn-group .btn {
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
  border-radius: 0.25rem;
}

.btn-group .btn:not(:last-child) {
  margin-right: 0.25rem;
}

/* Search highlight */
.highlight {
  background-color: #fff3cd;
  color: #856404;
  padding: 1px 2px;
  border-radius: 2px;
  font-weight: bold;
}

/* ========================================
   MOBILE RESPONSIVE ENHANCEMENTS
   ======================================== */

/* Global Mobile Improvements */
@media (max-width: 767.98px) {
  /* Ensure proper spacing on mobile */
  .container-fluid {
    padding-left: 15px;
    padding-right: 15px;
  }
  
  /* Better mobile typography */
  h1 { font-size: 1.75rem; }
  h2 { font-size: 1.5rem; }
  h3 { font-size: 1.25rem; }
  h4 { font-size: 1.1rem; }
  h5 { font-size: 1rem; }
  
  /* Mobile-friendly buttons */
  .btn {
    min-height: 44px; /* Touch-friendly minimum */
    padding: 0.5rem 1rem;
  }
  
  .btn-sm {
    min-height: 38px;
    padding: 0.375rem 0.75rem;
  }
  
  /* Stack button groups vertically on mobile */
  .btn-group {
    flex-direction: column;
  }
  
  .btn-group .btn {
    border-radius: 0.375rem !important;
    margin-bottom: 0.25rem;
  }
  
  .btn-group .btn:last-child {
    margin-bottom: 0;
  }

  /* Mobile table adjustments */
  .compact-table {
    font-size: 0.8rem;
    min-width: 800px; /* Ensure minimum width for scrolling */
  }

  .compact-table th,
  .compact-table td {
    padding: 0.5rem 0.25rem;
  }

  .col-company {
    min-width: 150px;
  }

  .col-contact {
    min-width: 120px;
  }

  .col-remarks {
    min-width: 120px;
  }

  .btn-group .btn {
    padding: 0.2rem 0.4rem;
    font-size: 0.75rem;
  }

  .company-info .company-name {
    font-size: 0.85rem;
  }
}

/* Responsive Tables - Mobile Card Layout */
@media (max-width: 767.98px) {
  .table-responsive-mobile {
    border: none;
  }
  
  .table-responsive-mobile table,
  .table-responsive-mobile thead,
  .table-responsive-mobile tbody,
  .table-responsive-mobile th,
  .table-responsive-mobile td,
  .table-responsive-mobile tr {
    display: block;
  }
  
  .table-responsive-mobile thead tr {
    position: absolute;
    top: -9999px;
    left: -9999px;
  }
  
  .table-responsive-mobile tr {
    border: 1px solid #dee2e6;
    margin-bottom: 1rem;
    padding: 1rem;
    border-radius: 0.5rem;
    background: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  }
  
  .table-responsive-mobile td {
    border: none;
    position: relative;
    padding: 0.5rem 0.5rem 0.5rem 40%;
    white-space: normal;
    text-align: left;
  }
  
  .table-responsive-mobile td:before {
    content: attr(data-label);
    position: absolute;
    left: 6px;
    width: 35%;
    padding-right: 10px;
    white-space: nowrap;
    font-weight: bold;
    color: #495057;
    font-size: 0.875rem;
  }
  
  /* Mobile card headers */
  .table-responsive-mobile tr:first-child td:first-child {
    background-color: #f8f9fa;
    font-weight: bold;
    border-radius: 0.375rem;
    margin-bottom: 0.5rem;
    padding: 0.75rem;
    text-align: center;
  }
  
  .table-responsive-mobile tr:first-child td:first-child:before {
    display: none;
  }
}

/* Very small screen table stacking */
@media (max-width: 576px) {
  /* Stack table content for very small screens */
  .compact-table,
  .compact-table thead,
  .compact-table tbody,
  .compact-table th,
  .compact-table td,
  .compact-table tr {
    display: block;
  }

  .compact-table thead tr {
    position: absolute;
    top: -9999px;
    left: -9999px;
  }

  .compact-table tr {
    border: 1px solid #ccc;
    margin-bottom: 1rem;
    padding: 0.5rem;
    border-radius: 0.375rem;
    background: white;
  }

  .compact-table td {
    border: none;
    position: relative;
    padding: 0.5rem 0.5rem 0.5rem 35%;
    white-space: normal;
    text-align: left;
  }

  .compact-table td:before {
    content: attr(data-label);
    position: absolute;
    left: 6px;
    width: 30%;
    padding-right: 10px;
    white-space: nowrap;
    font-weight: bold;
    color: #666;
  }

  /* Specific column labels for very small screens */
  .col-id:before { content: "ID: "; }
  .col-sno:before { content: "SNO: "; }
  .col-company:before { content: "Company: "; }
  .col-contact:before { content: "Contact: "; }
  .col-depository:before { content: "Depository: "; }
  .col-isin:before { content: "ISIN: "; }
  .col-status:before { content: "Status: "; }
  .col-stage:before { content: "Stage: "; }
  .col-modified:before { content: "Last Modified: "; }
  .col-remarks:before { content: "Remarks: "; }
  .col-actions:before { content: "Actions: "; }
}

/* Header and Navigation Mobile Improvements */
@media (max-width: 767.98px) {
  .navbar-brand {
    font-size: 1.1rem;
  }
  
  .navbar-nav .nav-link {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
  }
  
  .navbar-nav .nav-link:last-child {
    border-bottom: none;
  }
  
  /* Better mobile dropdown */
  .dropdown-menu {
    position: static !important;
    float: none;
    width: 100%;
    margin-top: 0;
    background-color: rgba(255,255,255,0.95);
    border: none;
    border-radius: 0;
  }
}

/* Form Mobile Improvements */
@media (max-width: 767.98px) {
  .form-control {
    font-size: 16px; /* Prevents zoom on iOS */
    min-height: 44px;
  }
  
  .form-select {
    font-size: 16px;
    min-height: 44px;
  }
  
  .input-group {
    flex-direction: column;
  }
  
  .input-group .form-control,
  .input-group .btn {
    border-radius: 0.375rem !important;
    margin-bottom: 0.5rem;
  }
  
  .input-group .btn:last-child {
    margin-bottom: 0;
  }
  
  /* Stack form elements */
  .row .col-md-6,
  .row .col-md-4,
  .row .col-md-3 {
    margin-bottom: 1rem;
  }
}

/* Card Mobile Improvements */
@media (max-width: 767.98px) {
  .card {
    margin-bottom: 1rem;
  }
  
  .card-header {
    padding: 1rem;
  }
  
  .card-body {
    padding: 1rem;
  }
  
  /* Stack card header content */
  .card-header .d-flex {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 1rem;
  }
  
  .card-header .btn-group {
    align-self: stretch;
  }
}

/* Alert Mobile Improvements */
@media (max-width: 767.98px) {
  .alert {
    border-radius: 0.5rem;
    padding: 1rem;
  }
  
  .alert h4,
  .alert h5,
  .alert h6 {
    font-size: 1.1rem;
  }
}

/* Badge and Status Mobile Improvements */
@media (max-width: 767.98px) {
  .badge {
    font-size: 0.8rem;
    padding: 0.4rem 0.6rem;
  }
}

/* Pagination Mobile Improvements */
@media (max-width: 767.98px) {
  .pagination {
    justify-content: center;
  }
  
  .page-link {
    min-height: 44px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

/* Modal Mobile Improvements */
@media (max-width: 767.98px) {
  .modal-dialog {
    margin: 1rem;
    max-width: calc(100% - 2rem);
  }
  
  .modal-header,
  .modal-body,
  .modal-footer {
    padding: 1rem;
  }
}

/* Search and Filter Mobile Improvements */
@media (max-width: 767.98px) {
  .search-container {
    width: 100% !important;
    margin-bottom: 1rem;
  }
  
  .search-container .input-group {
    width: 100% !important;
  }
  
  /* Stack search and action elements */
  .d-flex.justify-content-between {
    flex-direction: column;
    gap: 1rem;
  }
  
  .d-flex.justify-content-between > * {
    width: 100%;
  }
}

/* Notification Mobile Improvements */
@media (max-width: 767.98px) {
  .notification-dropdown {
    width: 95vw !important;
    max-width: 350px;
    left: 50% !important;
    transform: translateX(-50%) !important;
    right: auto !important;
  }
  
  .notification-item {
    padding: 1rem;
  }
  
  .notification-title {
    font-size: 0.9rem;
  }
  
  .notification-message {
    font-size: 0.8rem;
  }
}

/* Dashboard Stats Mobile Improvements */
@media (max-width: 767.98px) {
  .row .col-md-3,
  .row .col-md-4 {
    margin-bottom: 1rem;
  }
  
  .card .fa-2x {
    font-size: 1.5rem !important;
  }
}

/* Document Upload Mobile Improvements */
@media (max-width: 767.98px) {
  .file-upload-area {
    padding: 2rem 1rem;
    text-align: center;
  }
  
  .file-upload-area .btn {
    width: 100%;
    margin-bottom: 0.5rem;
  }
}

/* Utility Classes for Mobile */
@media (max-width: 767.98px) {
  .mobile-hidden {
    display: none !important;
  }
  
  .mobile-visible {
    display: block !important;
  }
  
  .mobile-stack {
    flex-direction: column !important;
  }
  
  .mobile-center {
    text-align: center !important;
  }
  
  .mobile-full-width {
    width: 100% !important;
  }
}