/* ===== VARIABLES ===== */
:root {
  --primary-color: #700910;
  --secondary-color: #007bff;
  --success-color: #28a745;
  --danger-color: #dc3545;
  --warning-color: #ffc107;
  --light-color: #f8f9fa;
  --dark-color: #2c3e50;
  --border-color: #e0e0e0;
  --shadow-color: rgba(0, 0, 0, 0.1);
  --border-radius: 12px;
  --transition: all 0.3s ease;
}

/* ===== BASE STYLES ===== */
.op-order-form-container {
  background: var(--light-color);
  padding: 20px;
  margin: 20px 0;
  border-radius: var(--border-radius);
  border: 2px solid #e9ecef;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  direction: rtl;
  box-shadow: 0 5px 20px var(--shadow-color);
  width: 100%;
  box-sizing: border-box;
  max-width: 100%;
}

.op-order-form-container * {
  box-sizing: border-box; /* إضافة box-sizing لجميع العناصر */
  max-width: 100%;
}

/* ===== HEADER STYLES ===== */
.op-order-form-container h3 {
  text-align: center;
  margin-bottom: 20px;
  color: var(--primary-color);
  font-size: clamp(22px, 5vw, 26px);
  font-weight: bold;
  text-shadow: 0 2px 4px var(--shadow-color);
  padding: 0 10px;
}

/* ===== PRODUCT INFO - HIDDEN ===== */
.op-product-info {
  display: none !important;
}

/* ===== OFFERS STYLES - REDUCED SPACING ===== */
.op-offers-section {
  margin-bottom: 15px;
  width: 100%;
}

.op-offers-title {
  text-align: center;
  margin-bottom: 10px;
  color: var(--dark-color);
  font-size: clamp(16px, 4vw, 18px);
  font-weight: 600;
}

.op-offers-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}

.op-offer-item {
  background: linear-gradient(135deg, #ffffff, #f8f9fa);
  border: 2px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: clamp(8px, 2vw, 12px);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  box-sizing: border-box;
}

.op-offer-item:hover {
  border-color: var(--secondary-color);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 123, 255, 0.15);
}

.op-offer-item.active {
  border-color: var(--success-color);
  background: linear-gradient(135deg, #f0fff4, #e8f5e8);
  box-shadow: 0 4px 15px rgba(40, 167, 69, 0.25);
  position: relative;
}

.op-offer-item.active::before {
  content: '';
  position: absolute;
  top: -2px;
  right: -2px;
  bottom: -2px;
  left: -2px;
  border: 2px solid var(--success-color);
  border-radius: var(--border-radius);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { opacity: 1; }
  50% { opacity: 0.5; }
  100% { opacity: 1; }
}

.op-offer-content {
  flex: 1;
}

.op-offer-title {
  font-weight: bold;
  color: var(--dark-color);
  font-size: clamp(14px, 3.5vw, 16px);
  margin-bottom: 3px;
}

.op-offer-price {
  color: var(--primary-color);
  font-weight: 600;
  font-size: clamp(13px, 3vw, 15px);
}

.op-offer-check {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--success-color);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
  opacity: 0;
  transition: var(--transition);
}

.op-offer-item.active .op-offer-check {
  opacity: 1;
}

/* ===== FORM GROUPS ===== */
.op-input-group {
  margin-bottom: clamp(15px, 4vw, 20px);
  width: 100%;
}

.op-label {
  display: block;
  margin-bottom: clamp(8px, 2vw, 10px);
  font-weight: bold;
  color: var(--dark-color);
  font-size: clamp(14px, 3.5vw, 16px);
  text-align: right;
  padding: 0 5px;
}

/* ===== INPUT STYLES ===== */
.op-input-with-icon {
  position: relative;
  display: flex;
  align-items: center;
  background: white;
  border: 2px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: clamp(4px, 1.5vw, 5px);
  transition: var(--transition);
  direction: rtl;
  width: 100%;
  overflow: hidden;
}

.op-input-with-icon:focus-within {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(112, 9, 16, 0.1);
  transform: translateY(-2px);
}

.op-icon {
  padding: 0 clamp(10px, 3vw, 15px);
  font-size: clamp(18px, 4vw, 22px);
  color: var(--primary-color);
  min-width: clamp(40px, 10vw, 50px);
  text-align: center;
  order: 1;
  flex-shrink: 0;
}

.op-input-with-icon input {
  flex: 1;
  border: none;
  outline: none;
  padding: clamp(12px, 3.5vw, 16px) clamp(10px, 2.5vw, 12px);
  font-size: clamp(14px, 3.5vw, 16px);
  background: transparent;
  border-radius: 10px 0 0 10px;
  color: var(--dark-color);
  text-align: right;
  order: 2;
  min-width: 0;
  width: 100%;
}

.op-input-with-icon input::placeholder {
  color: #6c757d;
  font-size: clamp(12px, 3vw, 14px);
}

.op-input-with-icon input:valid {
  background-color: rgba(40, 167, 69, 0.05);
}

.op-input-with-icon input:invalid:not(:placeholder-shown) {
  background-color: rgba(220, 53, 69, 0.05);
}

/* ===== QUANTITY CONTROLS - HIDDEN ===== */
.op-quantity-container {
  display: none !important;
}

/* ===== PRICE SUMMARY - REDUCED SPACING ===== */
.op-price-summary {
  background: linear-gradient(135deg, #ffffff, var(--light-color));
  border: 3px solid var(--primary-color);
  border-radius: var(--border-radius);
  padding: clamp(10px, 3vw, 15px);
  margin: clamp(10px, 3vw, 15px) 0;
  box-shadow: 0 4px 15px var(--shadow-color);
  direction: rtl;
  width: 100%;
  box-sizing: border-box;
}

.op-price-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: clamp(5px, 1.5vw, 8px) 0;
  border-bottom: 1px solid #dee2e6;
  font-size: clamp(13px, 3vw, 15px);
  gap: 10px;
  direction: rtl;
  width: 100%;
  box-sizing: border-box;
}

.op-price-row:last-child {
  border-bottom: none;
}

.op-price-label {
  font-weight: 600;
  color: var(--dark-color);
  text-align: right;
  flex-shrink: 0;
  min-width: min-content;
  font-size: clamp(13px, 3vw, 15px);
  order: 1;
}

.op-price-value {
  font-weight: bold;
  color: var(--primary-color);
  text-align: left;
  flex-shrink: 0;
  min-width: min-content;
  font-size: clamp(13px, 3vw, 15px);
  word-break: break-word;
  hyphens: auto;
  order: 2;
}

.op-unit-price-row .op-price-value {
  color: var(--success-color);
}

.op-price-row.op-total {
  font-size: clamp(16px, 4vw, 20px);
  padding-top: clamp(8px, 2vw, 12px);
  margin-top: clamp(8px, 2vw, 12px);
  border-top: 2px dashed var(--primary-color);
  background: linear-gradient(135deg, var(--light-color), #e9ecef);
  border-radius: 8px;
  padding: clamp(8px, 2vw, 12px);
}

.op-price-row.op-total .op-price-value {
  font-size: clamp(18px, 4.5vw, 24px);
  color: var(--secondary-color);
}

/* ===== BUTTON STYLES - LARGER ON SMALL SCREENS ===== */
.op-submit-btn {
  background: linear-gradient(135deg, var(--primary-color), var(--danger-color));
  color: white;
  border: none;
  padding: clamp(20px, 5vw, 35px) clamp(20px, 5vw, 35px);
  border-radius: var(--border-radius);
  cursor: pointer;
  width: 100%;
  font-size: clamp(20px, 5vw, 25px);
  font-weight: bold;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 3.5vw, 15px);
  margin-top: clamp(15px, 4vw, 18px);
  box-shadow: 0 6px 15px rgba(112, 9, 16, 0.3);
  direction: rtl;
  overflow: hidden;
  box-sizing: border-box;
}

.op-submit-btn:hover {
  background: linear-gradient(135deg, var(--secondary-color), #0056b3);
  transform: translateY(-3px);
  box-shadow: 0 10px 25px rgba(0, 123, 255, 0.4);
}

.op-submit-btn:disabled {
  background: #6c757d;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.op-btn-icon {
  font-size: clamp(20px, 5vw, 26px);
  order: -1;
  flex-shrink: 0;
}

/* ===== STATUS MESSAGES ===== */
.op-status-msg {
  margin-top: clamp(12px, 3vw, 15px);
  color: white;
  font-weight: bold;
  font-size: clamp(14px, 3.5vw, 16px);
  width: 100%;
  background: linear-gradient(135deg, var(--danger-color), var(--primary-color));
  text-align: center;
  border-radius: 8px;
  padding: clamp(12px, 3vw, 15px);
  box-shadow: 0 4px 12px rgba(220, 53, 69, 0.3);
}

/* ===== MODAL STYLES ===== */
.op-modal {
  display: none;
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 9999;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(4px);
  padding: 15px;
}

.op-modal-content {
  background: linear-gradient(135deg, #ffffff, var(--light-color));
  padding: clamp(15px, 3vw, 25px);
  border-radius: 16px;
  text-align: center;
  max-width: min(380px, 85vw);
  width: 100%;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
  border: 2px solid var(--primary-color);
  animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.op-modal-icon {
  font-size: clamp(40px, 8vw, 50px);
  margin-bottom: clamp(12px, 2.5vw, 15px);
  animation: bounce 1s ease infinite;
}

@keyframes bounce {
  0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-15px); }
  60% { transform: translateY(-8px); }
}

.op-modal-content p {
  font-size: clamp(14px, 3.2vw, 16px);
  line-height: 1.5;
  color: var(--dark-color);
  margin-bottom: clamp(12px, 2.5vw, 15px);
  word-wrap: break-word;
  padding: 0 5px;
}

.op-modal-content b {
  color: var(--primary-color);
  font-weight: 600;
}

.op-modal-btn {
  background: linear-gradient(135deg, var(--success-color), #20c997);
  color: white;
  border: none;
  padding: clamp(10px, 2.5vw, 12px) clamp(15px, 3.5vw, 20px);
  border-radius: 10px;
  cursor: pointer;
  font-size: clamp(14px, 3.2vw, 16px);
  font-weight: 600;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(6px, 1.5vw, 8px);
  margin: 0 auto;
  box-shadow: 0 4px 12px rgba(40, 167, 69, 0.25);
  direction: rtl;
  max-width: 100%;
}

.op-modal-btn:hover {
  background: linear-gradient(135deg, #20c997, var(--success-color));
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(40, 167, 69, 0.35);
}

.op-modal-btn .op-btn-icon {
  font-size: clamp(16px, 3.5vw, 18px);
  order: -1;
}

/* ===== SPINNER ===== */
.spinner {
  width: clamp(18px, 4.5vw, 24px);
  height: clamp(18px, 4.5vw, 24px);
  border: 3px solid #ffffff;
  border-top: 3px solid transparent;
  border-radius: 50%;
  display: inline-block;
  margin-left: clamp(8px, 2.5vw, 12px);
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== RESPONSIVE DESIGN - IMPROVED ===== */
@media (max-width: 768px) {
  .op-order-form-container {
    padding: 15px;
    margin: 15px 0;
  }
  
  .op-input-with-icon {
    flex-direction: row;
  }
  
  .op-icon {
    min-width: 35px;
    font-size: 16px;
  }
  
  .op-input-with-icon input {
    padding: 12px 10px;
    font-size: 14px;
  }
  
  /* زر الطلب أكبر في الشاشات الصغيرة */
  .op-submit-btn {
    padding: 22px 25px;
    font-size: 22px;
    min-height: 70px;
  }
}

@media (max-width: 480px) {
  .op-order-form-container {
    padding: 12px;
    margin: 10px 0;
    border-radius: 10px;
  }
  
  .op-input-with-icon {
    border-radius: 10px;
  }
  
  .op-input-with-icon input {
    padding: 10px 8px;
    font-size: 14px;
    border-radius: 8px 0 0 8px;
  }
  
  .op-icon {
    min-width: 30px;
    font-size: 14px;
    padding: 0 6px;
  }
  
  /* زر الطلب أكبر في الشاشات الصغيرة جداً */
  .op-submit-btn {
    padding: 25px 20px;
    font-size: 20px;
    min-height: 65px;
    margin-top: 12px;
  }
  
  .op-price-row {
    gap: 8px;
  }
}

@media (max-width: 320px) {
  .op-order-form-container {
    padding: 10px;
  }
  
  .op-input-with-icon input {
    padding: 8px 6px;
    font-size: 13px;
  }
  
  .op-icon {
    min-width: 25px;
    font-size: 12px;
    padding: 0 4px;
  }
  
  /* زر الطلب أكبر في الشاشات الصغيرة جداً */
  .op-submit-btn {
    padding: 20px 15px;
    font-size: 18px;
    min-height: 60px;
    margin-top: 10px;
  }
  
  .op-price-summary {
    padding: 8px;
  }
  
  .op-price-row {
    font-size: 12px;
    padding: 4px 0;
    gap: 6px;
  }
}

/* ===== RESPONSIVE OFFERS ===== */
@media (max-width: 480px) {
  .op-offer-item {
    flex-direction: column;
    text-align: center;
    gap: 8px;
    padding: 6px 8px;
  }
  
  .op-offer-check {
    align-self: center;
  }
}

/* ===== TOUCH DEVICE OPTIMIZATION ===== */
@media (hover: none) and (pointer: coarse) {
  .op-submit-btn,
  .op-modal-btn {
    min-height: 50px;
    min-width: 50px;
    font-size: 18px;
  }
  
  .op-input-with-icon input {
    font-size: 16px;
  }
}

/* ===== ACCESSIBILITY ===== */
@media (prefers-reduced-motion: reduce) {
  .op-input-with-icon,
  .op-submit-btn,
  .op-modal-btn,
  .spinner {
    transition: none;
    animation: none;
  }
  
  .op-modal-content {
    animation: none;
  }
}