/* --- Professional Admin Panel CSS --- */
:root {
  --bg-color: #f4f7f9;
  --card-bg: #ffffff;
  --text-color: #34495e;
  --text-muted: #7f8c8d;
  --primary-color: #3498db;
  --primary-hover: #2980b9;
  --danger-color: #e74c3c;
  --success-color: #2ecc71;
  --border-color: #e1e5e8;
  --shadow-color: rgba(0, 0, 0, 0.05);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  margin: 0;
  line-height: 1.6;
}

header {
  background-color: var(--card-bg);
  box-shadow: 0 2px 4px var(--shadow-color);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem 1.5rem;
}

header h1 {
  margin: 0;
  font-size: 1.5rem;
}

.header-actions {
  display: flex;
  align-items: center;
}

.container {
  max-width: 1400px;
  margin: 2rem auto;
  padding: 0 1.5rem;
}

/* Language specific alignment */
html[dir="rtl"] {
  text-align: right;
}
html[dir="ltr"] {
  text-align: left;
}

/* --- Buttons --- */
button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  transition: background-color 0.2s, color 0.2s, box-shadow 0.2s, transform 0.1s;
}
.primary-btn {
  background-color: var(--primary-color);
  color: white;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.primary-btn:hover {
  background-color: var(--primary-hover);
  box-shadow: 0 4px 10px rgba(52, 152, 219, 0.3);
}
.primary-btn:active {
  transform: translateY(1px);
}
.primary-btn:disabled {
  background-color: #bdc3c7;
  cursor: not-allowed;
  box-shadow: none;
}
.primary-btn .loader-sm {
  border-top-color: var(--primary-color);
}
.wide-btn {
  width: 100%;
  text-align: center;
  justify-content: center;
}

.secondary-btn {
  background-color: var(--card-bg);
  color: var(--text-color);
  border: 1px solid var(--border-color);
  padding: 0.6rem 1.2rem;
}
.secondary-btn:hover {
  background-color: var(--bg-color);
}

.danger-btn {
  background-color: var(--danger-color);
  color: white;
  padding: 0.6rem 1.2rem;
}
.danger-btn:hover {
  background-color: #c0392b;
}
.danger-btn:disabled {
  background-color: #e6b2af;
  cursor: not-allowed;
}

.danger-icon-btn {
  background-color: transparent;
  color: var(--danger-color);
  padding: 0.5rem;
  font-size: 1.5rem;
  line-height: 1;
}
.danger-icon-btn:hover {
  background-color: rgba(231, 76, 60, 0.1);
}
.danger-icon-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background-color: transparent;
}

.small-btn {
  font-size: 0.9rem;
  padding: 0.5rem 1rem;
}

/* --- Product List --- */
#product-list-section h2 {
  margin-bottom: 1rem;
}
#product-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}

.product-card {
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 2px 8px var(--shadow-color);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.2s, opacity 0.3s;
}
.product-card:hover {
  box-shadow: 0 6px 15px var(--shadow-color);
}
.product-card.inactive {
  opacity: 0.6;
}
.product-image {
  width: 100%;
  height: 180px;
  object-fit: cover;
}
.product-details {
  padding: 1rem;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}
.product-details h3 {
  margin: 0 0 0.5rem;
  font-size: 1.2rem;
}
.product-prices {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0.5rem 0;
  flex-grow: 1;
}
.product-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
  margin-top: 1rem;
}
.product-controls .actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.visibility-control {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.visibility-status {
  font-size: 0.8rem;
  font-weight: bold;
  color: var(--text-muted);
  min-width: 60px; /* Ensure space for text */
}
.visibility-status.visible {
  color: var(--success-color);
}

/* --- Toggle Switch --- */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}
.switch input {
  display: none;
}
.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--text-muted);
  transition: 0.4s;
  border-radius: 24px;
}
.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.4s;
  border-radius: 50%;
}
input:checked + .slider {
  background-color: var(--success-color);
}
input:checked + .slider:before {
  transform: translateX(20px);
}

/* --- Modal (Bottom Sheet on Mobile & Standard on Desktop) --- */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: none; /* Controlled by JS */
  align-items: flex-end; /* Mobile: slide up from bottom */
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}
.modal.show {
  display: flex;
  opacity: 1;
  visibility: visible;
}
.modal-content {
  background-color: var(--card-bg);
  border-radius: 16px 16px 0 0; /* Mobile: rounded top corners */
  box-shadow: 0 -5px 30px rgba(0, 0, 0, 0.2);
  width: 100%;
  max-width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  transform: translateY(100%); /* Start off-screen */
  transition: transform 0.3s ease-out;
}
.modal.show .modal-content {
  transform: translateY(0);
} /* Slide in */

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}
.modal-header h2 {
  margin: 0;
  font-size: 1.3rem;
}
.close-btn {
  background: none;
  border: none;
  font-size: 2rem;
  color: var(--text-muted);
  cursor: pointer;
}
.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
}

/* Desktop view for modal */
@media (min-width: 768px) {
  .modal {
    align-items: flex-start;
    padding-top: 5vh;
  } /* Desktop: align to top */
  .modal-content {
    max-width: 600px;
    border-radius: 8px;
    transform: translateY(0);
  } /* Standard desktop modal */
}

/* --- Camera Modal Specific Styles --- */
.camera-modal .modal-content {
  border-radius: 8px; /* Standard border-radius for camera modal even on mobile */
  max-width: 90%; /* Smaller on mobile */
  height: auto; /* Auto height based on content */
  align-self: center; /* Center vertically in the viewport */
}
.camera-modal .modal-body {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}
#camera-feed {
  width: 100%;
  max-width: 400px; /* Limit camera feed width */
  height: auto;
  background-color: #000;
  border-radius: 8px;
  transform: scaleX(-1); /* Mirror camera feed for selfie-like experience */
}
#camera-canvas {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  max-width: 100%;
  height: auto;
  display: block; /* Hide by default and show when needed */
}

/* Styles for delete confirmation modal */
.modal-content.small-modal {
  max-width: 400px;
  border-radius: 8px;
  padding: 1.5rem;
  text-align: center;
  transform: translateY(0);
  align-self: center;
}
.small-modal h2 {
  margin-bottom: 1rem;
}
.small-modal p {
  margin-bottom: 1.5rem;
}
.modal-footer {
  display: flex;
  justify-content: center;
  gap: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}
.modal-footer button {
  flex-grow: 1;
}

/* --- Form Styles (in Modal) --- */
.form-group {
  margin-bottom: 1.5rem;
}
label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  font-size: 0.9rem;
}
input[type="text"],
input[type="number"],
textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  box-sizing: border-box;
  font-size: 1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}
input:focus,
textarea:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
  outline: none;
}
textarea {
  resize: vertical;
}

.image-upload-area {
  border: 2px dashed var(--border-color);
  border-radius: 6px;
  padding: 1rem;
  text-align: center;
  position: relative;
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden; /* To contain image preview */
}
#image-preview {
  max-width: 100%;
  max-height: 150px;
  border-radius: 4px;
  object-fit: contain;
} /* Changed to contain */
#image-upload-placeholder {
  color: var(--text-muted);
}
#image-upload-placeholder .icon {
  font-size: 2rem;
  display: block;
}
.image-buttons {
  display: flex;
  gap: 1rem;
  margin-top: 1rem;
}
.image-buttons .secondary-btn {
  flex-grow: 1;
}

fieldset {
  border: 1px solid var(--border-color);
  padding: 1rem;
  border-radius: 6px;
}
legend {
  font-weight: 600;
  padding: 0 0.5rem;
}
.pricing-tier {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1rem;
}
.pricing-tier .form-group {
  margin-bottom: 0;
  flex-grow: 1;
}
.form-actions {
  text-align: right;
  margin-top: 1rem;
}
html[dir="ltr"] .form-actions {
  text-align: left;
}

/* --- Utility & Notification --- */
.hidden {
  display: none !important;
}
.loader {
  border: 4px solid var(--bg-color);
  border-top: 4px solid var(--primary-color);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin: 4rem auto;
}
.loader-sm {
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top: 2px solid #fff;
  width: 16px;
  height: 16px;
  animation: spin 1s linear infinite;
}
@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.notification {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  padding: 1rem 2rem;
  border-radius: 6px;
  color: white;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s, transform 0.3s;
  z-index: 1001;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
  transform: translateY(-20px) translateX(-50%);
}
.notification.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) translateX(-50%);
}
.notification.success {
  background-color: var(--success-color);
}
.notification.error {
  background-color: var(--danger-color);
}

/*
--- NEW STYLES FOR MULTI-IMAGE PREVIEW ---
*/
.image-preview-container {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;
}

.img-preview-wrapper {
  position: relative;
  width: 100px;
  height: 100px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
}

.img-preview-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.remove-img-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  background-color: rgba(0, 0, 0, 0.6);
  color: white;
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  font-size: 14px;
  line-height: 24px;
  text-align: center;
  cursor: pointer;
  font-weight: bold;
  transition: background-color 0.2s;
}

.remove-img-btn:hover {
  background-color: var(--danger-color);
}
