/* ============================================================
   UNIC Home Furnishings — Admin Panel Styles
   ============================================================ */

.admin-layout {
  min-height: 100vh;
  background: var(--bg-primary, #f8f9fa);
  color: var(--text-primary, #333);
  font-family: 'Poppins', sans-serif;
}

.admin-header {
  background: #ffffff;
  border-bottom: 1px solid #e5e7eb;
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: 0 2px 10px rgba(0,0,0,0.02);
}

.admin-header-left {
  display: flex;
  align-items: center;
  gap: 24px;
}

.admin-header-left .logo {
  font-family: 'Playfair Display', serif;
  font-size: 1.5rem;
  font-weight: 700;
  text-decoration: none;
  color: #333;
}

.admin-header-left .logo span {
  color: var(--primary-color, #c19a6b);
}

.admin-header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.admin-user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: #f3f4f6;
  border-radius: 8px;
  font-size: 0.875rem;
  color: #4b5563;
}

.admin-user-avatar {
  width: 32px;
  height: 32px;
  background: var(--primary-color, #c19a6b);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.75rem;
  color: white;
}

.admin-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px;
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
  margin-bottom: 32px;
}

.admin-stat-card {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 24px;
  transition: all 0.3s ease;
  box-shadow: 0 4px 6px rgba(0,0,0,0.02);
}

.admin-stat-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 15px rgba(0,0,0,0.05);
}

.admin-stat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.admin-stat-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fef3c7;
  border-radius: 12px;
  font-size: 24px;
  color: #d97706;
}

.admin-stat-number {
  font-size: 2rem;
  font-weight: 700;
  color: #111827;
}

.admin-stat-label {
  font-size: 0.875rem;
  color: #6b7280;
  margin-top: 4px;
}

.admin-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

.admin-toolbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.admin-toolbar h3 {
  font-size: 1.5rem;
  color: #111827;
}

.admin-search {
  position: relative;
}

.admin-search input {
  padding: 10px 16px 10px 40px;
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  color: #111827;
  font-size: 0.875rem;
  width: 280px;
  transition: all 0.3s ease;
}

.admin-search input:focus {
  border-color: var(--primary-color, #c19a6b);
  outline: none;
  box-shadow: 0 0 0 3px rgba(193,154,107,0.1);
  width: 340px;
}

.admin-search .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #9ca3af;
}

.admin-table-container {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 6px rgba(0,0,0,0.02);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
}

.admin-table thead {
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
}

.admin-table th {
  padding: 16px 24px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6b7280;
}

.admin-table td {
  padding: 16px 24px;
  font-size: 0.875rem;
  color: #374151;
  border-bottom: 1px solid #e5e7eb;
  vertical-align: middle;
}

.admin-table tr:last-child td {
  border-bottom: none;
}

.admin-table tr:hover td {
  background: #f9fafb;
}

.admin-table-image {
  width: 64px;
  height: 64px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid #e5e7eb;
}

.admin-table-product {
  display: flex;
  align-items: center;
  gap: 16px;
}

.admin-table-product-info h4 {
  font-size: 0.875rem;
  font-weight: 600;
  color: #111827;
  margin-bottom: 4px;
}

.admin-table-product-info span {
  font-size: 0.75rem;
  color: #6b7280;
}

.admin-table-actions {
  display: flex;
  gap: 8px;
}

.admin-table-actions button {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  color: #6b7280;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 1rem;
}

.admin-table-actions .btn-edit:hover {
  background: #eff6ff;
  border-color: #3b82f6;
  color: #3b82f6;
}

.admin-table-actions .btn-delete:hover {
  background: #fef2f2;
  border-color: #ef4444;
  color: #ef4444;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 300;
  display: none;
  opacity: 0;
  transition: opacity 0.3s;
}

.modal-backdrop.active {
  display: block;
  opacity: 1;
}

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -40%);
  background: #ffffff;
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  border-radius: 16px;
  z-index: 400;
  display: none;
  opacity: 0;
  transition: all 0.3s;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
}

.modal.active {
  display: block;
  opacity: 1;
  transform: translate(-50%, -50%);
}

.modal-header {
  padding: 24px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: #111827;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.25rem;
  color: #9ca3af;
  cursor: pointer;
  transition: color 0.2s;
}

.modal-close:hover {
  color: #111827;
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 24px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  background: #f9fafb;
  border-radius: 0 0 16px 16px;
}

.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: #374151;
  margin-bottom: 8px;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 16px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #ffffff;
  color: #111827;
  font-size: 0.875rem;
  font-family: inherit;
  transition: all 0.2s;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--primary-color, #c19a6b);
  box-shadow: 0 0 0 3px rgba(193,154,107,0.1);
}

.form-error {
  color: #ef4444;
  font-size: 0.75rem;
  margin-top: 4px;
  display: none;
}

.form-group.error .form-input,
.form-group.error .form-select,
.form-group.error .form-textarea {
  border-color: #ef4444;
}

.form-group.error .form-error {
  display: block;
}

/* Toggle Switch */
.form-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

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

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #d1d5db;
  transition: .4s;
  border-radius: 24px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

input:checked + .toggle-slider {
  background-color: var(--primary-color, #c19a6b);
}

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

/* Color Pickers */
.color-swatch-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.color-swatch-item {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.color-swatch-item .remove-color {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  background: #ef4444;
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: bold;
  border: none;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
}

.color-swatch-item:hover .remove-color {
  opacity: 1;
}

.admin-color-swatch {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid #e5e7eb;
  margin-right: -4px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* Toast Notification */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.toast {
  background: #ffffff;
  border-left: 4px solid var(--primary-color, #c19a6b);
  border-radius: 8px;
  box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
  padding: 16px 20px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 300px;
  max-width: 400px;
  animation: slideInRight 0.3s ease forwards;
}

.toast.success { border-left-color: #10b981; }
.toast.error { border-left-color: #ef4444; }
.toast.warning { border-left-color: #f59e0b; }

.toast-icon {
  font-size: 1.25rem;
}

.toast-content h4 {
  font-size: 0.875rem;
  font-weight: 600;
  color: #111827;
  margin-bottom: 4px;
}

.toast-content p {
  font-size: 0.875rem;
  color: #4b5563;
}

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* Auth Page */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  background: #f9fafb;
}

.login-card {
  width: 100%;
  max-width: 440px;
  background: #ffffff;
  border-radius: 16px;
  padding: 48px 32px;
  box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-back {
  text-align: center;
  margin-top: 32px;
  font-size: 0.875rem;
}

.login-back a {
  color: #6b7280;
  text-decoration: none;
  transition: color 0.2s;
}

.login-back a:hover {
  color: #111827;
}

/* ============================================================
   Mobile Responsiveness
   ============================================================ */
@media (max-width: 992px) {
  .admin-stats {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .admin-header {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
  }
  
  .admin-header-left {
    width: auto;
  }

  .admin-header-left span {
    display: none; /* Hide "| Admin Panel" subtitle to save space */
  }
  
  .admin-header-right {
    width: auto;
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }

  #adminUserEmail {
    display: none; /* Hide the long email address on mobile to prevent crowding */
  }

  .admin-user-info {
    margin-right: 0;
    gap: 0;
  }

  .admin-content {
    padding: 16px;
  }

  .admin-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  
  .admin-toolbar-left {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .admin-search input {
    width: 100%;
  }

  .admin-search input:focus {
    width: 100%;
  }

  /* Table-to-Card Layout Conversion for Mobile */
  .admin-table-container {
    background: transparent;
    border: none;
    box-shadow: none;
    overflow-x: visible;
  }
  
  .admin-table {
    min-width: 100% !important;
    display: block;
    background: transparent;
  }

  .admin-table thead {
    display: none; /* Hide table headers */
  }

  .admin-table tbody {
    display: block;
    width: 100%;
  }
  
  .admin-table tr {
    display: block;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.02);
  }
  
  .admin-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px dashed #f3f4f6;
    white-space: normal;
    background-color: transparent !important;
    position: static !important;
    box-shadow: none !important;
  }

  /* First TD holds the product visual & title, formatted as a card header */
  .admin-table td:first-child {
    display: block;
    padding: 0 0 12px 0;
    border-bottom: 1px solid #e5e7eb;
  }

  .admin-table-product {
    gap: 12px;
  }

  .admin-table-image {
    width: 60px;
    height: 60px;
  }

  /* Generate mobile labels using CSS pseudo-elements */
  .admin-table td:nth-child(2)::before {
    content: "Price";
    font-weight: 600;
    color: #6b7280;
    font-size: 0.75rem;
    text-transform: uppercase;
  }

  .admin-table td:nth-child(3)::before {
    content: "Colors";
    font-weight: 600;
    color: #6b7280;
    font-size: 0.75rem;
    text-transform: uppercase;
  }

  .admin-table td:nth-child(4)::before {
    content: "Added";
    font-weight: 600;
    color: #6b7280;
    font-size: 0.75rem;
    text-transform: uppercase;
  }

  .admin-table td:nth-child(5)::before {
    content: "Actions";
    font-weight: 600;
    color: #6b7280;
    font-size: 0.75rem;
    text-transform: uppercase;
  }
  
  .admin-table td:last-child {
    border-bottom: none;
    padding-bottom: 0;
    margin-top: 4px;
  }

  .modal {
    width: 95%;
  }

  .modal-header, .modal-body {
    padding: 20px 16px;
  }
  
  .modal-footer {
    padding: 20px 16px 28px 16px; /* Extra bottom padding */
    flex-direction: column;
    gap: 12px;
  }
  
  .modal-footer .btn {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .admin-stats {
    grid-template-columns: 1fr;
  }
  
  .login-card {
    padding: 32px 20px;
  }
}
