/* Checkout Popup Styles */

.checkout-popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.6);
  z-index: 999999; /* Higher than bottom action bar (99999) */
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  padding: 20px;
}

.checkout-popup-container {
  background: #ffffff;
  border-radius: 12px;
  max-width: 480px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  position: relative;
  animation: slideUp 0.3s ease-out;
}

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

.checkout-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #e5e5e5;
  background: #ffffff;
  position: sticky;
  top: 0;
  z-index: 10;
  gap: 12px; // Add gap between header elements
}

.checkout-popup-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  font-size: 18px;
  flex-shrink: 0; // Prevent logo from shrinking
  
  .back-arrow {
    cursor: pointer;
    font-size: 24px;
    color: #333;
    padding: 4px 8px;
    
    &:hover {
      background: #f5f5f5;
      border-radius: 4px;
    }
  }
}

.checkout-popup-security {
  font-size: 12px;
  color: #000;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: flex-end; /* Right align */
  flex: 1;
  white-space: nowrap;
  text-align: right;
}

.checkout-popup-close {
  background: transparent;
  border: none;
  font-size: 32px;
  color: #666;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s;
  
  &:hover {
    background: #f5f5f5;
    color: #333;
  }
}

.checkout-popup-body {
  padding: 20px;
  padding-bottom: 100px; // Extra padding to prevent fixed bottom buttons from covering content
  min-height: 200px;
}

.checkout-popup-footer {
  padding: 16px 20px;
  border-top: 1px solid #e5e5e5;
  text-align: center;
  font-size: 12px;
  color: #666;
}

/* Loader */
.checkout-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  
  .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
  }
  
  p {
    margin-top: 16px;
    color: #666;
  }
}

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

/* Order Summary Card */
.order-summary-card {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 20px;
  
  .order-summary-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-size: 14px;
    color: #666;
  }
  
  .order-summary-amount {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 18px;
    font-weight: 600;
    color: #111;
  }
}

/* Login Step */
.checkout-login-step {
  .login-section {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 24px;
    text-align: center;
    
    .section-icon {
      font-size: 48px;
      margin-bottom: 16px;
    }
    
    h3 {
      font-size: 20px;
      font-weight: 600;
      margin-bottom: 8px;
      color: #111;
    }
    
    p {
      font-size: 14px;
      color: #666;
      margin-bottom: 20px;
    }
  }
  
  .mobile-input-container {
    display: flex;
    align-items: center;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 16px 10px;
    margin-bottom: 20px;
    
    &:focus-within {
      border-color: #3b82f6;
      box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    }
    
    .country-code {
      font-weight: 500;
      color: #333;
      margin-right: 8px;
      padding-right: 8px;
      border-right: 1px solid #d1d5db;
    }
    
    input {
      border: none;
      outline: none;
      font-size: 16px;
      width: 100%;
      
      &::placeholder {
        color: #9ca3af;
      }
    }
  }
  
  #otp-section {
    margin-top: 24px;
  }
  
  .otp-inputs-container {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin: 16px 0;
  }
  
  .otp-input-box {
    width: 45px;
    height: 50px;
    text-align: center;
    font-size: 18px;
    font-weight: 600;
    border: 2px solid #d1d5db;
    border-radius: 8px;
    outline: none;
    transition: all 0.3s ease;
    
    &:focus {
      border-color: #3b82f6;
      box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    }
    
    &.error {
      border-color: #ef4444;
      background-color: #fef2f2;
    }
  }
}

/* Buttons */
.primary-button {
  width: 100%;
  background: #F56927;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 14px 24px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  
  &:hover:not(:disabled) {
    background: #E5541C;
    transform: translateY(-1px);
  }
  
  &:disabled {
    background: #d1d5db;
    cursor: not-allowed;
  }
}

.link-button {
  background: transparent;
  border: none;
  color: #3b82f6;
  font-size: 14px;
  cursor: pointer;
  text-decoration: underline;
  padding: 4px;
  
  &:hover {
    color: #2563eb;
  }
}

/* Address Step */
.address-list {
  margin-bottom: 20px;
  
  .address-card {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    position: relative;
    cursor: pointer;
    transition: all 0.2s;
    
    &:hover {
      border-color: #3b82f6;
      box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }
    
    &.selected {
      border-color: #3b82f6;
      background: #eff6ff;
    }
    
    .address-name {
      font-weight: 600;
      font-size: 16px;
      margin-bottom: 4px;
      
      .address-type {
        display: inline-block;
        background: #e0e7ff;
        color: #3730a3;
        font-size: 12px;
        padding: 2px 8px;
        border-radius: 4px;
        margin-left: 8px;
      }
    }
    
    .address-details {
      font-size: 14px;
      color: #666;
      line-height: 1.6;
      margin-bottom: 0px;
    }
    
    .address-contact {
      font-size: 14px;
      color: #666;
    }
    
    .select-address-btn {
      width: 100%;
      background: #111;
      color: #fff;
      border: none;
      border-radius: 6px;
      padding: 10px 16px;
      font-size: 14px;
      font-weight: 600;
      cursor: pointer;
      margin-top: 12px;
      
      &:hover {
        background: #333;
      }
    }
  }
}

.add-address-button {
  width: 100%;
  background: transparent;
  color: #3b82f6;
  border: 2px dashed #3b82f6;
  border-radius: 8px;
  padding: 14px 24px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  
  &:hover {
    background: #eff6ff;
    border-color: #2563eb;
    color: #2563eb;
  }
}

/* Add Address Form */
.add-address-form {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 20px;
  margin-top: 20px;
  
  h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
  }
  
  .form-group {
    margin-bottom: 16px;
    
    label {
      display: block;
      font-size: 14px;
      font-weight: 500;
      color: #374151;
      margin-bottom: 6px;
      
      .required {
        color: #ef4444;
      }
    }
    
    input, textarea {
      width: 100%;
      border: 1px solid #d1d5db;
      border-radius: 6px;
      padding: 10px 12px;
      font-size: 14px;
      transition: all 0.2s;
      
      &:focus {
        outline: none;
        border-color: #3b82f6;
        box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
      }
      
      &::placeholder {
        color: #9ca3af;
      }
    }
    
    textarea {
      resize: vertical;
      min-height: 60px;
    }
  }
  
  .form-row {
    display: flex;
    gap: 12px;
    
    .form-group {
      flex: 1;
    }
  }
  
  .address-type-selector {
    display: flex;
    gap: 12px;
    
    label {
      flex: 1;
      border: 1px solid #d1d5db;
      border-radius: 6px;
      padding: 10px 16px;
      text-align: center;
      cursor: pointer;
      transition: all 0.2s;
      
      input {
        display: none;
      }
      
      &:hover {
        border-color: #3b82f6;
        background: #eff6ff;
      }
      
      input:checked + span {
        color: #3b82f6;
        font-weight: 600;
      }
      
      input:checked ~ & {
        border-color: #3b82f6;
        background: #eff6ff;
      }
    }
  }
}

/* Payment Step */
.payment-methods {
  .payment-method {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: space-between;
    
    &:hover {
      border-color: #3b82f6;
      box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }
    
    .method-left {
      display: flex;
      align-items: center;
      gap: 12px;
      
      .method-icon {
        font-size: 24px;
      }
      
      .method-info {
        h4 {
          font-size: 16px;
          font-weight: 600;
          margin-bottom: 2px;
        }
        
        p {
          font-size: 12px;
          color: #666;
        }
      }
    }
    
    .method-right {
      display: flex;
      flex-direction: column;
      align-items: flex-end;
      
      .method-amount {
        font-size: 16px;
        font-weight: 600;
      }
      
      .method-badge {
        font-size: 11px;
        background: #dcfce7;
        color: #166534;
        padding: 2px 8px;
        border-radius: 4px;
        margin-top: 4px;
      }
      
      .arrow {
        font-size: 20px;
        color: #9ca3af;
      }
    }
    
    &.disabled {
      opacity: 0.5;
      cursor: not-allowed;
      
      &:hover {
        border-color: #e5e7eb;
        box-shadow: none;
      }
    }
  }
}

.cod-fee-note {
  font-size: 12px;
  color: #666;
  padding: 12px;
  background: #fef3c7;
  border-radius: 6px;
  margin-top: 12px;
}

/* Security Footer */
.security-footer {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid #e5e7eb;
  
  .security-badges-image {
    max-width: 100%;
    height: auto;
    max-height: 60px;
    object-fit: none;
  }
  
  .security-badge {
    display: flex;
    align-items: center;
    font-size: 11px;
    color: #666;
    white-space: nowrap; // Prevent line breaks
    
    &::before {
      margin-right: 4px;
    }
  }
}

/* Messages */
.error-message {
  background: #fef2f2;
  color: #dc2626;
  padding: 12px;
  border-radius: 6px;
  font-size: 14px;
  margin: 12px 0;
  border-left: 3px solid #dc2626;
}

.success-message {
  background: #f0fdf4;
  color: #16a34a;
  padding: 12px;
  border-radius: 6px;
  font-size: 14px;
  margin: 12px 0;
  border-left: 3px solid #16a34a;
}

/* Mobile Responsive */
@media (max-width: 640px) {
  .checkout-popup-overlay {
    padding: 0;
    align-items: flex-end;
    z-index: 999999; /* Ensure it's higher than all fixed elements including bottom bar */
    height: 100vh; /* Force full viewport height */
    min-height: 100vh; /* Prevent any height collapse */
  }
  
  .checkout-popup-container {
    max-width: 100%;
    max-height: 95vh;
    border-radius: 12px 12px 0 0;
    animation: slideUpMobile 0.3s ease-out;
    z-index: 1000000; /* Container should be above overlay */
  }
  
  .checkout-popup-close {
    display: none; /* Hide close button on mobile - use back button instead */
  }
  
  @keyframes slideUpMobile {
    from {
      transform: translateY(100%);
    }
    to {
      transform: translateY(0);
    }
  }
  
  .checkout-popup-header {
    padding: 12px 16px;
  }
  
  .checkout-popup-body {
    padding: 16px;
    padding-bottom: 120px; // Extra padding for mobile to prevent fixed bottom buttons from covering content
  }
  
  .form-row {
    flex-direction: column;
  }
  
  .security-footer {
    flex-direction: column;
    gap: 8px;
  }
}

/* Print - hide popup when printing */
@media print {
  .checkout-popup-overlay {
    display: none !important;
  }
}

