/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: Arial, sans-serif;
  background-color: #f5f5f5;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  font-size: 14px;
}

/* Header Styles */
header {
  background: linear-gradient(135deg, #2c3e50, #34495e);
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 30px;
  box-shadow: 0 2px 15px rgba(0, 0, 0, 0.1);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo-title {
  display: flex;
  align-items: center;
  gap: 20px;
  flex: 1;
}

.logo {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3);
  transition: transform 0.3s ease;
}

.logo:hover {
  transform: scale(1.1);
}

.title-text h1 {
  font-size: 26px;
  font-weight: 700;
  margin: 0;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.title-text p {
  font-size: 16px;
  margin: 2px 0 0 0;
  opacity: 0.9;
  font-weight: 400;
}

.nav-container {
  position: relative;
}

.mobile-menu-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: 4px;
  transition: background-color 0.3s ease;
  width: 40px;
  height: 40px;
}

.mobile-menu-toggle:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.hamburger-line {
  width: 24px;
  height: 2px;
  background-color: white;
  margin: 3px 0;
  transition: all 0.3s ease;
  transform-origin: center;
  display: block;
}

.nav-menu {
  display: flex;
  align-items: center;
  gap: 25px;
}

.nav-menu a {
  color: white;
  text-decoration: none;
  font-weight: 500;
  font-size: 16px;
  padding: 8px 16px;
  border-radius: 25px;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-menu a:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Main Content */
main {
  flex: 1;
  padding: 15px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  background-color: #f5f5f5;
  min-height: calc(100vh - 140px);
  flex-direction: column;
}

.indexpage-container {
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  width: 100%;
  max-width: 1200px;
  min-height: 500px;
  padding: 20px;
  margin: 15px auto;
  position: relative;
  overflow: visible;
  border: 1px solid #e0e0e0;
  box-sizing: border-box;
}

.table-container {
  width: 100%;
  overflow: visible;
}

/* Table Styles - Clean and Efficient with Strong Border Rules */
#indexTable {
  width: 100%;
  border-collapse: collapse !important;
  table-layout: fixed;
  font-size: 17px;
  border: 1px solid #333 !important;
}

#indexTable th,
#indexTable td {
  border: 1px solid #333 !important;
  padding: 10px;
  text-align: center;
  vertical-align: middle;
  font-size: 16px;
  line-height: 1.3;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

#indexTable th {
  background: #f8f9fa;
  color: #333;
  font-weight: 600;
  font-size: 17px;
  padding: 15px;
  border: 1px solid #333 !important;
}

/* Ensure ALL table cells have borders - Maximum specificity */
#indexTable thead tr th,
#indexTable tbody tr td,
table#indexTable thead tr th,
table#indexTable tbody tr td,
body #indexTable thead tr th,
body #indexTable tbody tr td,
#indexTable > thead > tr > th,
#indexTable > tbody > tr > td {
  border: 1px solid #333 !important;
  border-collapse: inherit !important;
}

/* Column width distribution - Responsive */
#indexTable th:nth-child(1),
#indexTable td:nth-child(1) {
  width: 12%;
  min-width: 60px;
}

#indexTable th:nth-child(2),
#indexTable td:nth-child(2) {
  width: 58%;
  min-width: 200px;
}

#indexTable th:nth-child(3),
#indexTable td:nth-child(3) {
  width: 18%;
  min-width: 80px;
}

#indexTable th:nth-child(4),
#indexTable td:nth-child(4) {
  width: 12%;
  min-width: 60px;
}

/* Table input styles */
.table-input {
  width: 100%;
  border: none;
  padding: 10px;
  text-align: center;
  font-size: 16px;
  background: transparent;
  outline: none;
  resize: none;
  min-height: 32px;
  line-height: 1.4;
  font-family: Arial, sans-serif;
}

/* Allow scrolling for textareas only */
textarea.table-input {
  overflow-y: auto;
  overflow-x: hidden;
}

/* Keep overflow hidden for regular inputs */
input.table-input {
  overflow: hidden;
}

.table-input:focus {
  background: rgba(74, 144, 226, 0.08);
  box-shadow: inset 0 0 3px rgba(74, 144, 226, 0.4);
  border-radius: 2px;
}

.serial-input {
  background: #f8f9fa !important;
  color: #666;
  font-weight: 600;
  cursor: not-allowed;
}

.serial-input:focus {
  background: #f8f9fa !important;
  box-shadow: none !important;
}

.experiment-name {
  text-align: left !important;
  min-height: 36px;
  padding-left: 14px;
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: normal;
}

.page-input {
  text-align: center;
  font-weight: 500;
}

/* Table row styling */
#indexTable tbody tr:nth-child(even) {
  background-color: #f9f9f9;
}

#indexTable tbody tr:hover {
  background-color: #f0f8ff;
}

/* Action column and delete button */
.action-column {
  width: 10%;
  text-align: center;
}

.delete-btn {
  background: none;
  border: none;
  color: #666;
  cursor: pointer;
  font-size: 18px;
  font-weight: bold;
  border-radius: 3px;
  transition: all 0.2s ease;
  line-height: 1;
  width: 28px;
  height: 28px;
}

.delete-btn:hover {
  background: #ff4444;
  color: white;
  transform: scale(1.1);
}

/* Control buttons */
.table-controls {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 12px;
  width: 100%;
}

.add-row-btn {
  background: #1976d2;
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 500;
  transition: all 0.2s ease;
  box-shadow: 0 2px 6px rgba(25, 118, 210, 0.3);
  display: flex;
  align-items: center;
  gap: 6px;
}

.add-row-btn:hover {
  background: #1565c0;
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(25, 118, 210, 0.4);
}

.button-container {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin: 18px auto 0;
}

.download-btn,
.print-btn {
  background: linear-gradient(45deg, #007bff, #0056b3);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 20px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.download-btn:hover,
.print-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
}

.download-btn {
  background: linear-gradient(45deg, #28a745, #20c997);
}

/* Footer */
footer {
  background: linear-gradient(135deg, #2c3e50, #34495e);
  color: white;
  text-align: center;
  padding: 10px 20px;
  margin-top: auto;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
}

.footer-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: bold;
}

.footer-content p {
  font-size: 16px;
  margin-top: -10px;
}

.footer-logo img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

.footer-bottom {
  font-size: 14px;
  color: #bdc3c7;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Print hide class - Elements to hide during printing */
.print-hide {
  /* Elements with this class will be hidden in print media */
  visibility: visible;
}

/* Notification System Styles */
.notification {
  position: fixed;
  top: 20px;
  right: 20px;
  background: #4caf50;
  color: white;
  padding: 12px 20px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 300px;
  max-width: 500px;
  transform: translateX(100%);
  opacity: 0;
  transition: all 0.3s ease;
  font-size: 14px;
  font-weight: 500;
}

.notification.show {
  transform: translateX(0);
  opacity: 1;
}

.notification.success {
  background: linear-gradient(135deg, #4caf50, #45a049);
}

.notification.error {
  background: linear-gradient(135deg, #f44336, #d32f2f);
}

.notification.info {
  background: linear-gradient(135deg, #2196f3, #1976d2);
}

.notification-message {
  flex: 1;
  line-height: 1.4;
}

.notification-close {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  font-size: 18px;
  font-weight: bold;
  padding: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background-color 0.2s ease;
}

.notification-close:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

/* Specific textarea styles for experiment names */
textarea.experiment-name {
  text-align: left !important;
  padding-left: 14px;
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: normal;
  resize: none;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 36px;
  max-height: 120px;
}

/* Custom scrollbar for webkit browsers */
textarea.experiment-name::-webkit-scrollbar {
  width: 6px;
}

textarea.experiment-name::-webkit-scrollbar-track {
  background: transparent;
}

textarea.experiment-name::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 3px;
}

textarea.experiment-name::-webkit-scrollbar-thumb:hover {
  background: #999;
}

/* Row animation styles */
#indexTable tbody tr {
  transition: all 0.2s ease;
}

#indexTable tbody tr:hover {
  background-color: #f0f8ff;
  transform: translateX(2px);
}

/* Print Styles - A4 Optimized */
@media print {
  @page {
    size: A4;
    margin: 15mm 0 0 0;
  }

  /* Override for first page */
  @page :first {
    margin: 0;
  }

  .print-hide {
    display: none !important;
    visibility: hidden !important;
  }

  .notification {
    display: none !important;
  }

  body {
    margin: 0;
    padding: 0;
  }

  main {
    padding: 0 !important;
    margin: 0 !important;
  }

  .indexpage-container {
    width: 210mm !important;
    max-width: 210mm !important;
    min-height: 297mm !important;
    padding: 15mm !important;
    margin: 0 auto !important;
    box-shadow: none !important;
    border: none !important;
    overflow: visible !important;
    box-sizing: border-box !important;
    background: white !important;
    page-break-inside: avoid;
  }

  .table-container {
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
  }

  #indexTable {
    width: 100% !important;
    border-collapse: collapse !important;
    background: white !important;
    page-break-inside: auto;
    margin: 0 !important;
  }

  #indexTable th,
  #indexTable td {
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    page-break-inside: avoid;
  }

  textarea.experiment-name {
    scrollbar-width: none;
    overflow: visible !important;
  }

  /* Hide action column in print */
  .action-column,
  #indexTable th:nth-child(4),
  #indexTable td:nth-child(4) {
    display: none !important;
  }

  /* Adjust column widths for 3 columns in print */
  #indexTable th:nth-child(1),
  #indexTable td:nth-child(1) {
    width: 15% !important;
  }

  #indexTable th:nth-child(2),
  #indexTable td:nth-child(2) {
    width: 65% !important;
  }

  #indexTable th:nth-child(3),
  #indexTable td:nth-child(3) {
    width: 20% !important;
  }

  /* Page break for rows starting from serial number 15 */
  tr.page-break-before {
    page-break-before: always !important;
  }

  /* Ensure the table header is repeated on new pages */
  #indexTable thead {
    display: table-header-group;
  }

  #indexTable tbody {
    display: table-row-group;
  }
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .mobile-menu-toggle {
    display: flex;
  }

  .nav-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: rgba(44, 62, 80, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 8px;
    padding: 15px;
    gap: 10px;
    flex-direction: column;
    min-width: 200px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  }

  .nav-menu.active {
    display: flex;
  }

  .title-text h1 {
    font-size: 20px;
  }

  .title-text p {
    font-size: 14px;
  }

  main {
    padding: 10px;
  }

  .indexpage-container {
    width: 100%;
    max-width: 100%;
    padding: 15px;
    margin: 10px auto;
    border-radius: 4px;
  }

  #indexTable {
    font-size: 14px;
    table-layout: auto;
  }

  #indexTable th,
  #indexTable td {
    padding: 8px 4px;
    font-size: 13px;
  }

  .table-input {
    font-size: 13px;
    padding: 6px 4px;
  }

  .delete-btn {
    width: 24px;
    height: 24px;
    font-size: 16px;
  }

  /* Adjust column widths for mobile */
  #indexTable th:nth-child(1),
  #indexTable td:nth-child(1) {
    width: 15%;
  }

  #indexTable th:nth-child(2),
  #indexTable td:nth-child(2) {
    width: 50%;
  }

  #indexTable th:nth-child(3),
  #indexTable td:nth-child(3) {
    width: 20%;
  }

  #indexTable th:nth-child(4),
  #indexTable td:nth-child(4) {
    width: 15%;
  }

  /* Mobile notification styles */
  .notification {
    top: 10px;
    right: 10px;
    left: 10px;
    min-width: auto;
    max-width: none;
    font-size: 13px;
    padding: 10px 15px;
  }

  .notification-close {
    width: 18px;
    height: 18px;
    font-size: 16px;
  }

  /* Stack buttons vertically on very small screens */
  .button-container {
    flex-direction: column;
    gap: 10px;
    align-items: center;
  }

  .download-btn,
  .print-btn {
    width: 100%;
    max-width: 200px;
  }
}

/* Tablet responsive */
@media (max-width: 1024px) and (min-width: 769px) {
  .indexpage-container {
    max-width: 95%;
    padding: 18px;
  }

  #indexTable {
    font-size: 15px;
  }

  #indexTable th,
  #indexTable td {
    padding: 10px 8px;
    font-size: 15px;
  }
}

/* Extra small mobile devices */
@media (max-width: 480px) {
  header {
    padding: 10px 15px;
  }

  .logo {
    width: 45px;
    height: 45px;
  }

  .title-text h1 {
    font-size: 18px;
  }

  .title-text p {
    font-size: 12px;
  }

  .indexpage-container {
    padding: 10px;
    margin: 5px auto;
  }

  #indexTable th,
  #indexTable td {
    padding: 6px 2px;
    font-size: 12px;
  }

  .table-input {
    font-size: 12px;
    padding: 4px 2px;
  }

  .add-row-btn {
    padding: 10px 16px;
    font-size: 14px;
  }

  .download-btn,
  .print-btn {
    padding: 10px 16px;
    font-size: 14px;
  }
}
