/* =========================================================
   MODAL EDIT - FIXED: Centered & Proper Size
   Tambahkan CSS ini ke drop_modal.css atau file CSS terpisah
   ========================================================= */

/* ===== BASE MODAL - ENSURE CENTERING ===== */
.modal {
  display: none;
  position: fixed;
  z-index: 10000;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  overflow-y: auto;
  /* CRITICAL: Flex untuk centering */
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease-in-out;
  padding: 20px; /* Spacing dari edge */
}

.modal.show {
  display: flex !important;
}

/* ===== MODAL CONTENT - CONTROLLED SIZE ===== */
.modal-content {
  position: relative;
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.98) 0%,
    rgba(255, 255, 255, 0.95) 100%
  );
  backdrop-filter: blur(20px);
  padding: 30px;
  border-radius: 16px;

  /* FIXED: Controlled width */
  width: 90%;
  max-width: 900px; /* Maximum width */

  /* FIXED: Controlled height */
  max-height: 85vh;
  overflow-y: auto;

  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.3);
  animation: slideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);

  /* CRITICAL: Remove margin auto since flex handles centering */
  margin: 0;
}

/* ===== LARGE MODAL (for edit) - OPTIMIZED SIZE ===== */
.modal-content.large {
  width: 95%;
  max-width: 1100px; /* Slightly larger but controlled */
  max-height: 90vh;
}

/* ===== MODAL HEADER ===== */
.modal-content h2 {
  font-size: 24px;
  font-weight: 800;
  color: #1e293b;
  margin: 0 0 24px 0;
  padding-bottom: 16px;
  border-bottom: 3px solid #e2e8f0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-content h2 i {
  color: #3b82f6;
  font-size: 28px;
}

/* ===== CLOSE BUTTON - PROPER POSITIONING ===== */
.close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: bold;
  cursor: pointer;
  color: #64748b;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 2px solid rgba(0, 0, 0, 0.05);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  z-index: 10;
}

.close:hover {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: white;
  transform: rotate(90deg) scale(1.1);
  box-shadow: 0 4px 16px rgba(239, 68, 68, 0.4);
}

/* ===== SCROLLBAR STYLING ===== */
.modal-content::-webkit-scrollbar {
  width: 8px;
}

.modal-content::-webkit-scrollbar-track {
  background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
  border-radius: 10px;
}

.modal-content::-webkit-scrollbar-thumb {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  border-radius: 10px;
}

.modal-content::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
}

/* ===== ANIMATION ===== */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(40px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 1400px) {
  .modal-content.large {
    width: 95%;
    max-width: 1000px;
  }
}

@media (max-width: 1200px) {
  .modal-content {
    width: 92%;
    max-width: 800px;
    padding: 24px;
  }

  .modal-content.large {
    width: 95%;
    max-width: 900px;
  }
}

@media (max-width: 768px) {
  .modal {
    padding: 10px;
    align-items: flex-start; /* Allow scrolling on mobile */
  }

  .modal-content {
    width: 95%;
    max-width: 100%;
    padding: 20px;
    margin: 20px 0; /* Add margin for mobile scrolling */
  }

  .modal-content.large {
    width: 98%;
  }

  .modal-content h2 {
    font-size: 20px;
    margin-bottom: 20px;
  }

  .close {
    width: 32px;
    height: 32px;
    font-size: 20px;
    top: 15px;
    right: 15px;
  }
}

@media (max-width: 480px) {
  .modal-content {
    padding: 16px;
  }

  .modal-content h2 {
    font-size: 18px;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
}

/* ===== PREVENT BODY SCROLL WHEN MODAL OPEN ===== */
body.modal-open {
  overflow: hidden;
}

/* ===== FORM SECTIONS INSIDE MODAL - COMPACT ===== */
.modal-content .customer-info-section,
.modal-content .payment-section,
.modal-content .order-summary {
  padding: 20px;
  margin-bottom: 20px;
  border-radius: 12px;
}

.modal-content .item-group {
  padding: 20px;
  margin-bottom: 20px;
  border-radius: 12px;
}

/* ===== BUTTON CONTAINER - OPTIMIZED ===== */
.modal-content .button-container {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 24px;
  flex-wrap: wrap;
}

.modal-content .button-container button {
  flex: 1;
  min-width: 180px;
  max-width: 250px;
  padding: 14px 24px;
  font-size: 15px;
  font-weight: 700;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

@media (max-width: 600px) {
  .modal-content .button-container {
    flex-direction: column;
  }

  .modal-content .button-container button {
    width: 100%;
    max-width: 100%;
  }
}

/* ===== ENSURE EDIT MODAL SHOWS PROPERLY ===== */
#editModal.show {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

#editModal .modal-content {
  position: relative;
  /* Remove any absolute positioning that might interfere */
  top: auto;
  left: auto;
  transform: none;
}
