  /* public/css/tables.css */

  /* =====================
    Base Table Styles
    ===================== */

    .scrollable-div {
      overflow-x: auto;
      overflow-y: hidden;  /* Hides vertical scroll */
      -webkit-overflow-scrolling: touch; /* For smooth scrolling on iOS */
      white-space: nowrap;
      padding: 10px 0;
    }

    .mathjax-wrapper {
      display: block;        /* Make it a block element */
      white-space: normal;   /* Allow natural wrapping/height */
    }

    .scrollable-table td {
      padding:5px 10px;
    }
    
    .scrollable-table {
      overflow-x: auto;
      -webkit-overflow-scrolling: touch; /* for smooth scrolling on iOS */
      white-space: nowrap; /* prevents the table cells from wrapping */
    }

    .scrollable-table table {
      width: auto;      /* Let the table size itself */
    }
    

  /* Base styling for all editable tables */
  .editable-table {
  border-collapse: collapse;
  background-color: transparent;
  margin-bottom: 0px; 
  page-break-inside: auto !important;
  position: relative; /* For dropdown positioning */
  }

  /* Remove borders by default */
  .editable-table th,
  .editable-table td {
  border: none;
  padding:5px 15px;
  text-align: left;
  vertical-align: top;
  font-size: 16px;
  color: #333;
  }

  /* ========== ADDED FOR CELL CORNER HOVER ========== */
td {
  position: relative; /* So we can place the corner zone */
}


/* The real corner hotspot: a small 16×16 absolutely positioned area */
.corner-hotspot {
  position: absolute;
  width: 16px;
  height: 16px;
  bottom: 0;
  right: 0;
  cursor: crosshair; /* shows a + shaped cursor on hover */
}


.selected-cell {
  outline: 2px solid red !important;
}


/* ========== END ADDITION ========== */


  /* Header Styling */
  .editable-table th {
  background-color: #f2f2f2;
  font-weight: bold;
  }

  /* Hover Effects */
  .editable-table tr:hover {
  background-color: #f1f1f1;
  }

  /* =====================
    Bordered Table Styles
    ===================== */

    .editable-table.table-bordered {
      border: 1px solid #ddd !important;
    }
    
    .editable-table.table-bordered th,
    .editable-table.table-bordered td {
      border: 1px solid #ddd !important;
    }
    
  .editable-table:focus {
  outline: 2px solid blue;
  }


  /* =====================
    Alignment Row Styles
    ===================== */

  /* Alignment Row */
  .alignment-row {
  background-color: #f0f0f0;
  }

  /* Alignment Cell */
  .alignment-cell {
  position: relative; /* Positioning context for dropdown */
  overflow: visible; /* Prevent dropdown from being clipped */
  }

  /* Alignment Classes for Table Columns */
  .left-align {
  text-align: left !important;
  }

  .center-align {
  text-align: center !important;
  }

  .right-align {
  text-align: right !important;
  }

  /* =====================
    Dropdown Menu Styles
    ===================== */

  /* Dropdown Menu Styles */
  .col-actions-menu,
  .row-dropdown-menu {
  display: none; /* Hidden by default */
  position: absolute; /* Position absolutely within parent */ 
  margin-top: 5px; /* Add some spacing */
  background-color: #fff;
  border: 1px solid #ccc;
  min-width: 150px; /* Adjusted width for better fit */
  z-index: 1000; /* Ensure it's on top */
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  overflow: visible;
  border-radius: 4px;
  }


  /* Show dropdown menu when .visible is added */
  .col-actions-menu.visible,
  .row-dropdown-menu.visible {
  display: block; /* Show when .visible is added */
  }

  /* Dropdown Items */
  .col-actions-item,
  .row-dropdown-item {
  padding: 8px 16px;
  cursor: pointer;
  font-size: 14px;
  white-space: nowrap;
  }

  .col-actions-item:hover,
  .row-dropdown-item:hover {
  background-color: #f0f0f0;
  }

  /* Dropdown Button */
  .col-actions-btn,
  .row-edit-btn {
  width: 100%;
  background-color: transparent;
  color: #000;
  border: none;
  cursor: pointer;
  font-size: 14px;
  text-align: center;
  position: relative;
  border-radius: 4px;
  }

  .col-actions-btn:hover,
  .row-edit-btn:hover {
  background-color: rgba(0, 0, 0, 0.5);
  }

  /* =====================
    Resizer Styles
    ===================== */

  /* Column Resizer */
  .col-resizer {
  width: 5px;
  cursor: col-resize;
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  background-color: transparent;
  z-index: 1;
  }

  .col-resizer:hover {
  background-color: #ccc;
  }

  /* =====================
    Selected Table Outline
    ===================== */

  .selected-table {
  border: none;
  }

  /* =====================
    Dropdown Menu Arrow Indicators
    ===================== */

  /* Arrow below the dropdown */
  .col-actions-menu::before,
  .row-dropdown-menu::before {
  content: '';
  position: absolute;
  top: -5px;
  left: 15px;
  border-width: 5px;
  border-style: solid;
  border-color: transparent transparent #ccc transparent;
  }

  .row-dropdown-menu::before {
  top: auto;
  bottom: -5px;
  border-color: #ccc transparent transparent transparent;
  }

  /* =====================
    General Enhancements
    ===================== */

  /* Ensure parent containers allow overflow for dropdown menus */
  .editor-container,
  .table-container,
  .editable-div {
  position: relative; /* Positioning context for dropdown */
  overflow: visible !important; /* Prevent dropdowns from being clipped */
  }

  /* Row resizer at the bottom of each row’s edit column */
  .edit-column {
    position: relative; /* for the .row-resizer absolute positioning */
  }

  /* The row resizing handle itself */
  .row-resizer {
    height: 4px;
    cursor: row-resize;
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;         /* sit at the bottom edge of the .edit-column cell */
    background-color: transparent;
  }

  /* Change color on hover to indicate it's draggable */
  .row-resizer:hover {
    background-color: #ccc;
  }

  .border-toggle-checkbox {
    /* Let it fill the cell, minus some small padding */
    display: inline-block;   /* or block, either works */
    width: calc(100% - 4px); /* fill nearly all horizontal space, but leave a tiny margin */
    height: calc(100% - 4px);
    cursor: pointer;
    box-sizing: border-box;  /* so padding, width, etc. are consistent */
  }

  /* =====================
    Responsive Design
    ===================== */

  @media (max-width: 1100px) {

     .scrollable-table {
      display: block;
      overflow-x: auto;
      -webkit-overflow-scrolling: touch; /* for smooth scrolling on iOS */
      white-space: nowrap; /* prevents the table cells from wrapping */
    }

    .scrollable-div {
      display: block;
      overflow-x: auto;
      -webkit-overflow-scrolling: touch; /* for smooth scrolling on iOS */
      white-space: nowrap; /* prevents the table cells from wrapping */
      padding: 10px 0;
    }
    
  
  /* Adjust dropdown menu position for smaller screens */
  .col-actions-menu.dropdown-up,
  .row-dropdown-menu.dropdown-up {
    bottom: 100%;
    top: auto;
  }

  /* Responsive table adjustments */
  .editable-table {
    overflow-x: auto;
    display: block;
  }

  /* Adjust padding and font sizes for better readability on small screens */
  .editable-table th,
  .editable-table td {
    padding: 8px 10px;
    font-size: 14px;
  }

  /* Adjust dropdown menu width */
  .col-actions-menu,
  .row-dropdown-menu {
    min-width: 120px;
  }
  }

  /* =====================
    Accessibility Enhancements
    ===================== */

  /* Focus Styles for Dropdown Buttons */
  .col-actions-btn:focus,
  .row-edit-btn:focus {
  outline: 2px solid #66afe9;
  outline-offset: -2px;
  }

  /* Tooltip Enhancements */
  .editor-btn {
  position: relative;
  }

  .editor-btn::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: -30px; /* Position the tooltip below the button */
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(0, 0, 0, 0.75); /* Semi-transparent background */
  color: #fff;
  padding: 5px 8px;
  border-radius: 4px;
  white-space: nowrap;
  font-size: 12px;
  opacity: 0; /* Make tooltip invisible by default */
  pointer-events: none; /* Prevent mouse events */
  transition: opacity 0.2s ease-in-out;
  z-index: 1001;
  }

  .editor-btn:hover::after {
  opacity: 1;
  }

  .editor-btn::before {
  content: '';
  position: absolute;
  bottom: -20px; /* Position the arrow */
  left: 50%;
  transform: translateX(-50%);
  border-width: 5px;
  border-style: solid;
  border-color: rgba(0, 0, 0, 0.75) transparent transparent transparent;
  opacity: 0;
  transition: opacity 0.2s ease-in-out;
  }

  .editor-btn:hover::before {
  opacity: 1;
  }
  @media print {
    .scrollable-table {
      overflow-x: visible !important;
      white-space: normal !important;
    }
  }
  
  @media (max-width:400px){
    .scrollable-div {
      overflow-x: auto;
      -webkit-overflow-scrolling: touch; /* for smooth scrolling on iOS */
      white-space: nowrap; /* prevents the table cells from wrapping */
    }
  }