/* Custom styles for Signature Verification System */

/* Ensure full height layouts */
html, body {
    height: 100%;
}

/* Smooth transitions */
* {
    transition-property: background-color, border-color, color, fill, stroke, opacity, box-shadow, transform;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 150ms;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f3f4f6;
}

::-webkit-scrollbar-thumb {
    background: #9ca3af;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #6b7280;
}

/* Loading spinner */
.spinner {
    border: 2px solid #f3f4f6;
    border-top: 2px solid #3b82f6;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Form focus styles */
input:focus, textarea:focus, select:focus {
    outline: none;
    ring: 2px;
    ring-color: #3b82f6;
    border-color: transparent;
}

/* Button disabled state */
button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Alert animations */
@keyframes slideIn {
    from {
        transform: translateY(-10px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

[role="alert"] {
    animation: slideIn 0.3s ease-out;
}

/* Responsive table container */
.table-responsive, .bg-white.shadow-md.rounded-lg.overflow-hidden, .bg-white.shadow.rounded-lg.overflow-hidden {
    overflow-x: auto;
    width: 100%;
}

/* Responsive table styles */
table {
    width: 100%;
    min-width: 0; /* changed: allow table to shrink for card-mode on small screens */
    border-collapse: collapse;
}

table th, table td {
    font-size: 0.95rem;
    white-space: normal;
    word-break: break-word;
    padding: 0.5rem 0.75rem;
    max-width: 180px;
    box-sizing: border-box;
}

table th {
    font-weight: 600;
}

/* Responsive adjustments for small screens */
@media (max-width: 700px) {
    table, thead, tbody, th, td, tr {
        display: block;
        width: 100%;
    }
    table th, table td {
        font-size: 0.85rem;
        padding: 0.4rem 0.5rem;
        max-width: 100%;
    }
    table th {
        background: #f3f4f6;
    }
    table td {
        border-bottom: 1px solid #e5e7eb;
    }
}

/* Optional: Make table headers sticky on scroll */
@media (max-width: 700px) {
    table th {
        position: sticky;
        top: 0;
        z-index: 2;
    }
}

/* Responsive table wrapper + mobile "card" view when data-label exists */

/* Make table containers horizontally scrollable on small screens */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Default table look (keeps desktop behaviour) */
.table-responsive table {
  width: 100%;
  border-collapse: collapse;
  min-width: 0; /* changed: no forcing horizontal scroll */
}

/* Nice spacing */
.table-responsive th,
.table-responsive td {
  padding: 0.75rem 1rem;
  vertical-align: top;
  border-bottom: 1px solid #eef2f6;
}

/* Optional sticky header for better UX when scrolling horizontally */
.table-responsive thead th {
  background: #fafafa;
  position: sticky;
  top: 0;
  z-index: 3;
}

/* MOBILE: switch to card-like rows if data-label attributes are present.
   Fallback: horizontal scroll remains available for tables without data-label. */
@media (max-width: 700px) {
  /* hide header to use labels inside cells */
  .table-responsive thead {
    display: none;
  }

  .table-responsive table,
  .table-responsive tbody,
  .table-responsive tr,
  .table-responsive td {
    display: block;
    width: 100%;
  }

  .table-responsive tr {
    margin-bottom: 0.9rem;
    border: 1px solid #f1f5f9;
    border-radius: 8px;
    padding: 0.5rem;
    background: #fff;
  }

  .table-responsive td {
    padding: 0.6rem 1rem 0.6rem 45%;
    text-align: left;
    position: relative;
    border: none;
    min-height: 38px;
    display: flex;
    align-items: center;
  }

  /* if a cell provides a data-label attribute, show it before the value */
  .table-responsive td::before {
    content: attr(data-label);
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 40%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 600;
    color: #6b7280; /* gray-500 */
    font-size: 0.85rem;
  }

  /* Make action buttons wrap nicely */
  .table-responsive td .btn,
  .table-responsive td a,
  .table-responsive td button {
    margin: 0.15rem 0.25rem 0.15rem 0;
    flex-shrink: 0;
  }

  /* ensure long texts break and don't overflow */
  .table-responsive td span,
  .table-responsive td p {
    word-break: break-word;
    white-space: normal;
  }
}

/* ---- Responsive enhancements (append) ----
   - meilleure gestion des boutons/actions en mobile
   - pagination et filtres qui se réorganisent
   - modals full-width sur petits écrans
   - assure que les tableaux passent en mode "card" proprement
*/
.table-responsive { -webkit-overflow-scrolling: touch; }

/* ensure dashboard-table can become card-like on small screens */
.dashboard-table { min-width: 0 !important; } /* allow card mode */

/* Buttons inside tables: compact, wrap and readable */
.table-responsive td a,
.table-responsive td button {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.6rem;
  font-size: 0.875rem;
  line-height: 1;
  white-space: nowrap;
  border-radius: 0.375rem;
  box-sizing: border-box;
}

/* Ensure icons remain visible and labels wrap */
.table-responsive td a i,
.table-responsive td button i { margin-right: 0.35rem; }

/* Make action cell flexible on small screens */
@media (max-width: 700px) {
  /* Card-like rows (keep if data-label attr exists) */
  .table-responsive thead { display: none; }
  .table-responsive table,
  .table-responsive tbody,
  .table-responsive tr,
  .table-responsive td { display: block; width: 100%; }

  .table-responsive tr {
    margin-bottom: 0.7rem;
    border-radius: 10px;
    padding: 0.45rem;
    border: 1px solid rgba(0,0,0,0.04);
    background: #fff;
  }

  .table-responsive td {
    padding: 0.6rem 1rem 0.6rem 45%;
    position: relative;
    display: flex;
    align-items: center;
    min-height: 40px;
    border: none;
  }

  .table-responsive td::before {
    content: attr(data-label);
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 38%;
    font-weight: 600;
    color: #6b7280;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Actions: wrap to multiple lines and use full width items if necessary */
  .table-responsive td[data-label="Actions"],
  .table-responsive td[data-label="Actions"] > span {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
    /* do NOT override padding-left here (keep 45% from .table-responsive td) */
  }

  .table-responsive td[data-label="Actions"] a,
  .table-responsive td[data-label="Actions"] button {
    flex: 1 1 46%;
    min-width: 46%;
    justify-content: center;
    padding: 0.45rem 0.5rem;
    font-size: 0.9rem;
  }

  /* small buttons (icons) keep size */
  .table-responsive td[data-label="Actions"] a.small,
  .table-responsive td[data-label="Actions"] button.small {
    flex: 0 0 auto;
    min-width: 36px;
    padding: 0.35rem;
  }

  /* Make other long text break instead of overflow */
  .table-responsive td span,
  .table-responsive td p {
    word-break: break-word;
    white-space: normal;
  }

  /* Filters / buttons / pagination stack nicely */
  .filter-btn { white-space: normal; padding: 0.55rem 0.75rem; font-size: 0.9rem; }
  .table-responsive + #pagination-controls,
  #pagination-controls {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: center;
  }
  #pagination-controls button {
    width: 100%;
    max-width: 260px;
  }
}

/* Modal responsiveness */
@media (max-width: 900px) {
  .modal-dialog, .modal-content {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 0.75rem;
    border-radius: 8px;
  }
  #pdf-viewer { height: 60vh !important; }
}

/* Make search inputs and control groups adapt */
@media (max-width: 700px) {
  .flex.flex-col.md\\:flex-row { flex-direction: column !important; gap: 0.5rem; }
  .mb-6 .w-full.md\\:w-1\\/3 { width: 100% !important; }
}

/* small polish for scrollbars in responsive wrappers */
.table-responsive::-webkit-scrollbar { height: 8px; }
.table-responsive::-webkit-scrollbar-thumb { background: rgba(99,102,241,0.35); border-radius: 8px; }

/* Filters / buttons tweak for mobile */
@media (max-width: 700px) {
  .filter-btn {
    display: block;
    width: 100%;
    text-align: center;
    padding: 0.6rem 0.75rem;
    box-sizing: border-box;
  }
  /* ensure filter container wraps */
  .bg-white.shadow.rounded-lg.p-4 .flex,
  .bg-white.shadow.rounded-lg.p-4 .flex > .flex {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
}