:root {
  --primary-color: #007bff;
  --secondary-color: #28a745;
  --text-color: #333;
  --light-gray: #f4f4f4;
  --medium-gray: #ddd;
  --dark-gray: #888;
  --background-color: #fff;
  --star-color: #ffc107;
  --danger-color: #dc3545;
  --font-family: 'Tajawal', sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--light-gray);
  color: var(--text-color);
  direction: rtl;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#root {
  max-width: 480px;
  margin: 0 auto;
  background-color: var(--background-color);
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.1);
  min-height: 100vh;
}

.container {
  padding: 16px;
}

/* --- Loading Overlay --- */
.loading-overlay {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background-color: var(--background-color);
}
.loading-overlay .loader {
  width: 48px;
  height: 48px;
  border: 5px solid var(--primary-color);
  border-bottom-color: transparent;
}


/* --- Hero Images --- */
.hero-images-container {
  font-size: 0;
  line-height: 0;
}
.hero-images-container img {
  display: block;
  width: 100%;
  height: auto;
}

/* --- Product Gallery & Carousel --- */
.product-gallery {
  display: flex;
  flex-direction: column;
  gap: 8px; /* Space between main image and thumbnails */
  margin-top: 24px;
}

.main-image-container {
  overflow: hidden;
  position: relative;
  width: 100%;
  border-radius: 8px;
  background-color: var(--light-gray);
}

.discount-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  background-color: var(--danger-color);
  color: #fff;
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 16px;
  font-weight: 700;
  z-index: 10;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  transform: rotate(-2deg);
}


.main-image-container img {
  width: 100%;
  height: auto;
  display: block;
  animation: fadeIn 0.5s ease-in-out;
}

.thumbnail-container {
  display: flex;
  overflow-x: auto;
  gap: 8px;
  padding: 4px 16px; /* Some padding for focus rings and alignment */
  /* Hide scrollbar for a cleaner look */
  scrollbar-width: none; /* Firefox */
}

.thumbnail-container::-webkit-scrollbar {
  display: none; /* Safari and Chrome */
}

.thumbnail-item {
  flex: 0 0 70px; /* Fixed width for thumbnails */
  height: 70px;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.2s ease, transform 0.2s ease;
  will-change: transform, border-color;
}

.thumbnail-item:hover {
  transform: scale(1.05);
}

.thumbnail-item.active {
  border-color: var(--primary-color);
  box-shadow: 0 0 5px rgba(0, 123, 255, 0.5);
}

.thumbnail-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}


/* --- Product Info --- */
.product-title {
  font-size: 26px;
  font-weight: 700;
  margin-top: 16px;
}

.reviews {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.stars {
  color: var(--star-color);
  font-size: 20px;
}

.review-text {
  color: var(--dark-gray);
  font-weight: 500;
}

.price-box {
  margin-top: 16px;
  background-color: #f9f9f9;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid #eee;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.price-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.price-display {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.price {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-color);
}

.old-price {
  font-size: 18px;
  color: var(--danger-color);
  text-decoration: line-through;
}

.inline-discount-badge {
  font-size: 16px;
  font-weight: 700;
  color: var(--secondary-color);
  background-color: #e4f8e9;
  padding: 2px 8px;
  border-radius: 6px;
  margin: 4px 0;
}

.centim-price {
    font-size: 14px;
    color: #000;
    font-weight: 700;
}

.currency {
  font-size: 16px;
  font-weight: 500;
}

.total-price-line {
    border-top: 1px dashed var(--medium-gray);
    padding-top: 12px;
}

.total-price-label {
    font-size: 20px;
    font-weight: 700;
}

.total-price-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--secondary-color);
}


.description {
  margin-top: 20px;
  line-height: 1.8;
  font-size: 17px;
  content-visibility: auto;
  contain-intrinsic-size: 800px;
}

.description h3 {
  font-size: 19px;
  font-weight: 700;
  margin-top: 16px;
  margin-bottom: 8px;
}

.description img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin-top: 16px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

/* --- Description Image Gallery --- */
.description-gallery {
  margin: 20px 0;
}

.slider-container {
  position: relative;
  width: 100%;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  background-color: var(--light-gray);
}

.slider-image {
  width: 100%;
  display: block;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  animation: fadeIn 0.4s ease-in-out;
}

.slider-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background-color: rgba(0, 0, 0, 0.5);
  color: white;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 24px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  line-height: 1;
  transition: background-color 0.2s;
  z-index: 10;
  -webkit-tap-highlight-color: transparent; /* Disable tap highlight on mobile */
}

.slider-btn:hover {
  background-color: rgba(0, 0, 0, 0.7);
}

.prev-btn {
  left: 10px;
}

.next-btn {
  right: 10px;
}

.slider-dots {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--medium-gray);
  border: none;
  cursor: pointer;
  padding: 0;
  transition: background-color 0.2s, transform 0.2s;
}

.dot:hover {
  background-color: var(--dark-gray);
  transform: scale(1.1);
}

.dot.active {
  background-color: var(--primary-color);
  transform: scale(1.2);
}


.video-container {
  margin-top: 20px;
  position: relative;
  padding-bottom: 56.25%; /* 16:9 aspect ratio */
  height: 0;
  overflow: hidden;
  border-radius: 8px;
  background-color: #000;
  content-visibility: auto;
  contain-intrinsic-size: 250px;
}

.video-container iframe,
.video-container video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* --- Quantity Selector --- */
.quantity-selector {
  display: flex;
  align-items: center;
  background-color: #fff;
  border: 1px solid var(--medium-gray);
  border-radius: 25px; /* Pill shape */
  overflow: hidden;
  height: 40px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.quantity-btn {
  width: 44px;
  height: 100%;
  border: none;
  background-color: transparent;
  color: var(--primary-color);
  font-size: 22px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  line-height: 1;
  transition: background-color 0.2s, color 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.quantity-btn:hover:not(:disabled) {
  background-color: #f0f0f0;
}

.quantity-btn:active:not(:disabled) {
  background-color: #e8e8e8;
}

.quantity-btn:disabled {
  color: #ccc;
  cursor: not-allowed;
}

.quantity-display {
  font-size: 18px;
  font-weight: 700;
  min-width: 40px;
  text-align: center;
  color: var(--text-color);
  user-select: none;
  border-left: 1px solid #eee;
  border-right: 1px solid #eee;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}


/* --- Scarcity Indicator --- */
.scarcity-indicator-container {
  margin: 20px 0;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid #fce8b2;
  background-color: #fffbeb;
  text-align: center;
}
.scarcity-title {
  font-size: 18px;
  font-weight: 700;
  color: #c77c00;
  margin-bottom: 8px;
}
.progress-bar {
  width: 100%;
  height: 10px;
  background-color: #f0f0f0;
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: 8px;
}
.progress-bar-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.5s ease-in-out, background-color 0.5s ease;
}
.progress-bar-fill.green {
  background-color: #28a745;
}
.progress-bar-fill.orange {
  background-color: #fd7e14;
}
.progress-bar-fill.red {
  background-color: #dc3545;
}
.stock-text {
  font-size: 15px;
  font-weight: 500;
}
.stock-text strong {
  font-weight: 700;
}

/* --- Countdown Timer --- */
.countdown-timer-container {
  margin: 24px 0;
  padding: 16px;
  background-color: #fff4e6;
  border: 1px solid #ffd5a7;
  border-radius: 12px;
  text-align: center;
}

.countdown-title {
  font-size: 18px;
  font-weight: 700;
  color: #d9534f;
  margin-bottom: 12px;
}

.timer-segments {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.timer-segment {
  display: flex;
  flex-direction: column;
  align-items: center;
  background-color: #ffffff;
  padding: 8px;
  border-radius: 6px;
  min-width: 60px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.timer-number {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-color);
}

.timer-label {
  font-size: 12px;
  color: var(--dark-gray);
  font-weight: 500;
}

/* --- Order Form --- */
.form-container {
  margin-top: 24px;
  padding: 20px;
  background-color: #f0f8ff;
  border-radius: 12px;
  border: 2px dashed var(--primary-color);
}

.form-title {
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--primary-color);
}

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

.form-group label {
  display: block;
  font-weight: 500;
  margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--medium-gray);
  border-radius: 8px;
  font-size: 16px;
  font-family: var(--font-family);
  background-color: var(--background-color);
}

.form-group select:disabled {
  background-color: #e9ecef;
  cursor: not-allowed;
}

.submit-btn {
  width: 100%;
  padding: 14px;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(90deg, var(--secondary-color), #20c997);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.2s;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  will-change: transform;
}

.submit-btn:hover {
  transform: scale(1.02);
}

.cta-button-container {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--medium-gray);
}


/* --- Related Products --- */
.related-products {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--medium-gray);
  content-visibility: auto;
  contain-intrinsic-size: 250px;
}

.related-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 16px;
}

.related-scroll {
  display: flex;
  overflow-x: auto;
  gap: 12px;
  padding-bottom: 12px;
  scrollbar-width: none; /* Firefox */
}

.related-scroll::-webkit-scrollbar {
  display: none; /* Safari and Chrome */
}

.related-card {
  flex: 0 0 150px;
  border: 1px solid #eee;
  border-radius: 8px;
  overflow: hidden;
  text-align: center;
  cursor: pointer;
  transition: box-shadow 0.2s ease;
}

.related-card:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.related-card img {
  width: 100%;
  height: 120px;
  object-fit: cover;
}

.related-card-info {
  padding: 8px;
}

.related-card-title {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.related-card-price {
  font-size: 16px;
  font-weight: 700;
  color: var(--secondary-color);
  margin-top: 4px;
}

/* --- Footer --- */
.app-footer {
    text-align: center;
    padding: 20px 0;
    margin-top: 20px;
    cursor: pointer;
    color: var(--dark-gray);
    font-size: 14px;
    transition: background-color 0.2s;
}
.app-footer:hover {
    background-color: #fafafa;
}
.app-footer p {
    user-select: none; /* Prevent text selection */
}


/* --- Thank You Page --- */
.thank-you-page {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 40px 20px;
  min-height: 100vh;
}

.thank-you-icon {
  font-size: 80px;
}

.thank-you-title {
  font-size: 28px;
  font-weight: 700;
  margin-top: 20px;
}

.thank-you-text {
  font-size: 16px;
  margin-top: 12px;
  line-height: 1.6;
  max-width: 350px;
}

.back-btn {
  margin-top: 24px;
  padding: 12px 24px;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  background-color: var(--primary-color);
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

/* Loader */
.loader {
    width: 18px;
    height: 18px;
    border: 2px solid #FFF;
    border-bottom-color: transparent;
    border-radius: 50%;
    display: inline-block;
    box-sizing: border-box;
    animation: rotation 1s linear infinite;
}

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

/* --- Login Page --- */
.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.login-form {
    width: 100%;
    max-width: 350px;
    padding: 24px;
    background-color: var(--background-color);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.login-title {
    text-align: center;
    font-size: 22px;
    margin-bottom: 20px;
}

.login-error {
    color: var(--danger-color);
    text-align: center;
    margin-top: 12px;
    font-size: 14px;
}


/* --- Dashboard --- */
.dashboard-container {
    padding: 16px;
    min-height: 100vh;
    background-color: var(--background-color);
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.dashboard-header h1 {
    font-size: 24px;
}

.dashboard-nav {
    display: flex;
    border-bottom: 1px solid var(--medium-gray);
    margin-bottom: 20px;
}

.dashboard-nav button {
    padding: 10px 16px;
    border: none;
    background-color: transparent;
    cursor: pointer;
    font-size: 16px;
    font-family: var(--font-family);
    color: var(--dark-gray);
    border-bottom: 3px solid transparent;
    transition: all 0.2s ease;
}

.dashboard-nav button.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    font-weight: 700;
}

.dashboard-content {
    animation: fadeIn 0.5s;
}

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

.dashboard-placeholder {
    text-align: center;
    color: var(--dark-gray);
    padding: 40px 0;
}

/* Orders View */
.orders-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.order-card {
    background-color: #fff;
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 16px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.order-card p {
    margin: 0 0 8px 0;
    font-size: 14px;
    line-height: 1.5;
}

.order-card p:last-child {
    margin-bottom: 0;
}

.order-card strong {
    font-weight: 700;
    min-width: 100px;
    display: inline-block;
}

/* Products View */
.add-product-btn {
    width: 100%;
    padding: 12px;
    margin-bottom: 16px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
}

.product-manage-card {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--medium-gray);
    border-radius: 8px;
    margin-bottom: 12px;
}
.product-manage-img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
}
.product-manage-info {
    flex-grow: 1;
    min-width: 0;
}
.product-manage-info p {
    margin: 0;
}
.product-manage-info p:first-child {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.product-manage-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
}
.edit-btn, .delete-btn {
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    border: 1px solid transparent;
    transition: opacity 0.2s;
    width: 80px;
    text-align: center;
}
.edit-btn:hover, .delete-btn:hover {
    opacity: 0.85;
}
.edit-btn {
    background-color: var(--light-gray);
    border-color: var(--medium-gray);
    color: var(--text-color);
}
.delete-btn {
    background-color: var(--danger-color);
    border-color: var(--danger-color);
    color: white;
}

.product-edit-form {
    padding: 16px;
    border: 1px solid var(--medium-gray);
    border-radius: 8px;
    background-color: #fcfcfc;
}
.product-edit-form h3 {
    margin-bottom: 16px;
}
.form-helper-text {
    font-size: 12px;
    color: var(--dark-gray);
    display: block;
    margin-top: 4px;
}
.form-helper-text code {
    background-color: #e9ecef;
    padding: 2px 6px;
    border-radius: 4px;
    direction: ltr;
    display: inline-block;
}
.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}
.form-actions .cancel-btn {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    background-color: var(--medium-gray);
    color: var(--text-color);
    border: none;
    border-radius: 8px;
    cursor: pointer;
}
.form-actions .submit-btn {
    margin-top: 0;
    font-size: 16px;
}

/* --- Tracking View --- */
.tracking-section {
    background-color: #f9f9f9;
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 24px;
}
.tracking-section h3 {
    font-size: 18px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--medium-gray);
    padding-bottom: 8px;
}
.add-item-form {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}
.add-item-form input {
    flex-grow: 1;
    padding: 8px;
    border: 1px solid var(--medium-gray);
    border-radius: 6px;
    font-size: 14px;
    direction: ltr;
}
.add-item-form button {
    padding: 8px 16px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}
.items-list {
    list-style: none;
    padding: 0;
}
.items-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--background-color);
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid var(--light-gray);
    margin-bottom: 8px;
    font-family: monospace;
    direction: ltr;
}
.delete-item-btn {
    padding: 4px 8px;
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-family: var(--font-family);
    direction: rtl;
}
.token-display {
    word-break: break-all;
}

/* --- Sticky Discount Badge --- */
.sticky-discount-badge {
  position: fixed;
  top: 16px;
  left: 16px; /* Positioned for RTL layout */
  background: linear-gradient(45deg, var(--danger-color), #ff6b6b);
  color: #fff;
  padding: 8px 16px;
  border-radius: 50px;
  font-size: 16px;
  font-weight: 700;
  z-index: 999;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  opacity: 0;
  transform: translateY(-20px) scale(0.9);
  transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out;
  pointer-events: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent; /* Disable tap highlight on mobile */
}

.sticky-discount-badge.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* --- WhatsApp Floating Action Button --- */
.whatsapp-fab {
  position: fixed;
  width: 60px;
  height: 60px;
  bottom: 25px;
  right: 25px;
  background-color: #25d366;
  color: #FFF;
  border-radius: 50px;
  text-align: center;
  font-size: 30px;
  box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.3);
  z-index: 100;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: transform 0.2s ease-in-out;
  will-change: transform;
}

.whatsapp-fab:hover {
    transform: scale(1.05);
}

.whatsapp-icon {
    width: 32px;
    height: 32px;
    fill: #fff;
}