/*
 * TABLES
 * Stiluri pentru tabele și rapoarte
 */

.table-wrapper {
  overflow-x: auto;
  border: 1px solid #eee;
  border-radius: 8px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
  margin-top: 20px;
}

/* When pagination follows the table, connect them visually */
.table-wrapper:has(+ .pagination-wrapper:not(:empty)) {
  border-radius: 8px 8px 0 0;
  border-bottom: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

table {
  width: 100%;
  border-collapse: collapse;
  background-color: #fff;
  border-radius: 8px;
  overflow: hidden;
}

table.large {
  min-width: 1000px;
}

th,
td {
  padding: 15px;
  border-bottom: 1px solid #eee;
  text-align: left;
  vertical-align: top;
}

th {
  background-color: #d12627;
  color: #fff;
  font-weight: 600;
}

tbody tr:nth-child(even) {
  background-color: #fafafa;
}

tbody tr:hover {
  background-color: #f7e7a3;
}

tbody tr.modified-row {
  background-color: #fffacd !important;
  border-left: 4px solid #28a745;
}

/* Status cells */
td[class^="status-"],
.status-cell {
  text-align: center;
  font-weight: 600;
  color: white;
}

.status-aprobat {
  background-color: #28a745;
  color: white;
}

.status-respins {
  background-color: #d12627;
  color: white;
}

.status-in-curs {
  background-color: #e1b922;
  color: #222;
}

.status-trimis {
  background-color: #20c997;
  color: white;
}

/* Editable cells */
td.editable {
  cursor: pointer;
  position: relative;
  transition: background-color 0.2s;
}

td.editable:hover {
  background-color: #e8f5e9;
}

td.editable.editing {
  background-color: #fff3cd;
  border: 2px solid #e1b922;
}

td.non-editable {
  cursor: default;
  opacity: 0.8;
}

td.non-editable:hover {
  background-color: transparent;
}

.cell-input {
  width: 100%;
  padding: 8px;
  border: 2px solid #28a745;
  border-radius: 4px;
  font-size: 14px;
  font-family: inherit;
}

.cell-input:focus {
  outline: none;
  box-shadow: 0 0 5px rgba(40, 167, 69, 0.5);
}

/* Products list */
.produse-list {
  list-style-type: none;
  padding-left: 0;
  margin: 0;
}

.produse-list li {
  margin-bottom: 5px;
  font-size: 0.9em;
}

/* Loading spinner overlay */
.table-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  gap: 16px;
}

.table-loading .spinner {
  width: 44px;
  height: 44px;
  border: 4px solid #eee;
  border-top: 4px solid #d12627;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.table-loading .loading-text {
  font-size: 15px;
  color: #666;
  font-weight: 500;
}

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

.table-loading.hidden {
  display: none;
}

/* Pagination */
.pagination-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 20px 16px;
  flex-wrap: wrap;
  background: #fff;
  border: 1px solid #eee;
  border-top: none;
  border-radius: 0 0 8px 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.pagination-info {
  color: #d12627;
  font-size: 13px;
  font-weight: 600;
  margin-right: 16px;
  padding: 6px 14px;
  background: #fff8e1;
  border: 1px solid #e1b922;
  border-radius: 6px;
}

.btn-pagination {
  min-width: 36px;
  height: 36px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  border: 1.5px solid #e1b922;
  border-radius: 6px;
  background: #fff;
  color: #333;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-pagination:hover:not(:disabled):not(.active-page) {
  background: #e1b922;
  color: #222;
  border-color: #e1b922;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(225, 185, 34, 0.3);
}

.btn-pagination:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  background: #f9f9f9;
}

.btn-pagination.active-page {
  background: #d12627;
  color: #fff;
  font-weight: 700;
  border-color: #d12627;
  box-shadow: 0 2px 8px rgba(209, 38, 39, 0.3);
}

.pagination-ellipsis {
  padding: 0 4px;
  color: #aaa;
  font-weight: 600;
  font-size: 14px;
  user-select: none;
}

.pagination-size-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.pagination-size-label {
  color: #666;
  font-size: 13px;
  font-weight: 500;
}

.pagination-size-select {
  height: 36px;
  padding: 0 12px;
  border-radius: 6px;
  border: 1.5px solid #e1b922;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  color: #d12627;
  background: #fff8e1;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23d12627'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

.pagination-size-select:hover {
  background: #e1b922;
  color: #222;
  border-color: #e1b922;
}

.pagination-size-select:focus {
  outline: none;
  border-color: #d12627;
  box-shadow: 0 0 0 2px rgba(209, 38, 39, 0.15);
}

@media (max-width: 768px) {
  .pagination-wrapper {
    gap: 4px;
    padding: 12px 8px;
  }

  .pagination-info {
    width: 100%;
    text-align: center;
    margin-right: 0;
    margin-bottom: 8px;
  }

  .pagination-size-select {
    margin-left: 8px;
  }

  .btn-pagination {
    min-width: 32px;
    height: 32px;
    font-size: 12px;
  }
}

@media (max-width: 768px) {
  th,
  td {
    padding: 10px;
    font-size: 14px;
  }
}
