/* Layouts */
.category-page {
  display: flex;
  flex-direction: column;
  gap: 15px;
  padding: 20px;
}

.card {
  background: white;
  padding: 20px;
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

.form-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.form-grid input {
  flex: 1 1 200px;
  padding: 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
}

.btn-green {
  background: #10b981;
  color: white;
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

.btn-red {
  background: #ef4444;
  color: white;
  padding: 10px 16px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

.category-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Search */
.search-box input[type="text"] {
  padding: 0.5rem 1rem;
  border: 1px solid #ccc;
  border-radius: 8px;
  width: 100%;
  font-size: 0.95rem;
}


/* Table */
.category-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.category-table th,
.category-table td {
  padding: 12px 14px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid #e5e7eb;
}

.cat-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}


.icon-btn {
  cursor: pointer;
  margin-right: 8px;
  display: inline-flex;
  align-items: center;
}

.category-table td:last-child {
  white-space: nowrap;
}

.category-table th:first-child,
.category-table td:first-child {
  width: 40px;
  text-align: center;
}

.category-table td img.cat-icon {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: 6px;
  display: block;
}


.category-table th input[type="checkbox"],
.category-table td input[type="checkbox"] {
  transform: scale(1.2);
}

/* Status Toggle */
.status-label {
  display: inline-block;
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 4px;
  text-transform: uppercase;
}

.status-label.green {
  background-color: #dcfce7;
  color: #15803d;
}

.status-label.red {
  background-color: #fee2e2;
  color: #b91c1c;
}

/* Pagination */
.pagination-controls {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.pagination-controls button {
  background-color: #f4f4f4;
  border: 1px solid #ccc;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background-color 0.3s ease;
}

.pagination-controls button:hover {
  background-color: #e0e0e0;
}

.pagination-controls button.active-page {
  background-color: #007bff;
  color: white;
  font-weight: bold;
  border-color: #007bff;
}

.cat-icon:empty {
  background-color: #f3f4f6;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: inline-block;
}



/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: white;
  padding: 20px;
  border-radius: 10px;
  width: 300px;
  text-align: center;
}

.modal-close {
  position: absolute;
  top: 5px;
  right: 10px;
  cursor: pointer;
  font-size: 20px;
}

.hidden {
  display: none;
}




/* Toggle Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 20px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0;
  right: 0; bottom: 0;
  background-color: #ccc;
  transition: 0.4s;
  border-radius: 20px;
}

.slider::before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  transition: 0.4s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: #10b981;
}

input:checked + .slider::before {
  transform: translateX(20px);
}





/* ============ Mobile table → real cards (scoped) ============ */
@media (max-width: 768px){
  .table-cards .table-responsive{ overflow: visible; }

  /* Hide header row; we’ll label via layout */
  .table-cards .category-table thead{ display:none; }

  /* Each row becomes a card with a 3-row grid layout */
  .table-cards .category-table tbody tr{
    display: grid;
    gap: 10px;
    padding: 12px;
    margin: 10px 0;
    background:#fff;
    border:1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(0,0,0,.04);
    grid-template-columns: 56px 1fr auto auto; /* icon | text | select | id */
    grid-template-areas:
      "icon name  sel  id"
      "icon desc  desc desc"
      "status status actions actions";
  }

  /* Make cells flex rows and remove default table padding/borders */
  .table-cards .category-table tbody td{
    display:flex; align-items:center; gap:8px;
    padding:0; border:0; min-height:36px;
    font-size:14px; line-height:1.35;
  }

  /* Assign areas */
  .table-cards .category-table tbody tr > td:nth-child(1){ grid-area: sel; justify-content:flex-end; }
  .table-cards .category-table tbody tr > td:nth-child(2){ grid-area: id;  justify-content:flex-end; color:#6b7280; font-size:12px; }
  .table-cards .category-table tbody tr > td:nth-child(3){ grid-area: icon; justify-content:center; align-self:start; }
  .table-cards .category-table tbody tr > td:nth-child(4){ grid-area: name; font-weight:700; font-size:15px; }
  .table-cards .category-table tbody tr > td:nth-child(5){ grid-area: desc; color:#374151; align-items:flex-start; }
  .table-cards .category-table tbody tr > td:nth-child(6){ grid-area: status; gap:10px; }
  .table-cards .category-table tbody tr > td:nth-child(7){ grid-area: actions; justify-content:flex-end; gap:8px; }

  /* Icon sizing */
  .table-cards .category-table .cat-icon{
    width: 44px; height: 44px; border-radius:10px; object-fit:cover;
    box-shadow: 0 0 0 1px #e5e7eb;
  }

  /* Select + ID micro-meta */
  .table-cards #select-all{ transform: scale(1); } /* leave header checkbox elsewhere */
  .table-cards .category-table tbody tr > td:nth-child(1) input[type="checkbox"]{
    width:18px; height:18px;
  }

  /* Description: allow wrap, trim crazy long text */
  .table-cards .category-table .cat-desc{
    display:block; max-height:none; overflow:visible; word-break:break-word;
  }

  /* Status row: inline switch + pill */
  .table-cards .category-table tbody tr > td:nth-child(6) .toggle-switch{ margin-right:8px; }
  .table-cards .category-table .status-label{
    display:inline-flex; align-items:center; padding:4px 8px; border-radius:8px;
    font-size:12px; text-transform:capitalize; line-height:1;
  }

  /* Actions: horizontal, equal touch targets */
  .table-cards .category-table .icon-btn{
    width:30px; height:30px; display:inline-grid; place-items:center;
    border:1px solid #e5e7eb; border-radius:10px;
  }

  /* Remove generated labels from earlier mobile styles (if any) */
  .table-cards .category-table tbody td::before{ content:none !important; }
}

/* Ultra-small phones: compress spacing slightly */
@media (max-width: 380px){
  .table-cards .category-table tbody tr{
    grid-template-columns: 48px 1fr auto auto;
    gap:8px; padding:10px;
  }
  .table-cards .category-table .icon-btn{ width:36px; height:36px; }
}


