/**
 * Digital Crazy Hub — Secure Company Profile Download Modal
 * File: css/components/profile-modal.css
 * Follows Digital Crazy Hub Brand Design Tokens (PROJECT_RULES.md)
 */

/* ==============================================================================
   1. Modal Backdrop & Layout
   ============================================================================== */
.profile-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(11, 23, 48, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.28s cubic-bezier(0.16, 1, 0.3, 1),
              visibility 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.profile-modal-backdrop.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* ==============================================================================
   2. Modal Card Container
   ============================================================================== */
.profile-modal-card {
  position: relative;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--color-bg, #FFFFFF);
  border: 1px solid var(--color-border, #E5E8F0);
  border-radius: 18px;
  padding: 36px 32px 28px;
  box-shadow: 0 24px 60px rgba(11, 23, 48, 0.35);
  box-sizing: border-box;
  transform: translateY(16px) scale(0.96);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.profile-modal-backdrop.is-open .profile-modal-card {
  transform: translateY(0) scale(1);
}

/* Custom scrollbar for long screens */
.profile-modal-card::-webkit-scrollbar {
  width: 6px;
}
.profile-modal-card::-webkit-scrollbar-track {
  background: transparent;
}
.profile-modal-card::-webkit-scrollbar-thumb {
  background: var(--color-border, #E5E8F0);
  border-radius: 3px;
}

/* ==============================================================================
   3. Close Button
   ============================================================================== */
.profile-modal-close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--color-border, #E5E8F0);
  background: var(--color-bg-soft, #F8F9FD);
  color: var(--color-text-secondary, #5E687C);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: background-color 0.2s, color 0.2s, transform 0.2s;
}

.profile-modal-close:hover {
  background: var(--color-primary-soft, #F3F6FF);
  color: var(--color-primary, #0755C9);
  transform: scale(1.06);
}

.profile-modal-close:focus-visible {
  outline: 2px solid var(--color-primary, #0755C9);
  outline-offset: 2px;
}

/* ==============================================================================
   4. Header & Typography
   ============================================================================== */
.profile-modal-header {
  margin-bottom: 24px;
}

.profile-modal-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: var(--color-primary-soft, #F3F6FF);
  color: var(--color-primary, #0755C9);
  border: 1px solid var(--color-primary-light, #E5ECFF);
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.3px;
  margin-bottom: 12px;
}

.profile-modal-title {
  margin: 0 0 8px;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.25;
  color: var(--color-navy, #0B1730);
  letter-spacing: -0.3px;
}

.profile-modal-desc {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--color-text-secondary, #5E687C);
}

/* ==============================================================================
   5. Alert Banner
   ============================================================================== */
.profile-modal-alert {
  display: none;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13.5px;
  line-height: 1.45;
  margin-bottom: 20px;
}

.profile-modal-alert.is-visible {
  display: flex;
}

.profile-modal-alert-error {
  background: #FEF2F2;
  border: 1px solid #FCA5A5;
  color: #991B1B;
}

.profile-modal-alert-success {
  background: #ECFDF5;
  border: 1px solid #6EE7B7;
  color: #065F46;
}

.profile-modal-alert a {
  color: inherit;
  font-weight: 700;
  text-decoration: underline;
}

/* ==============================================================================
   6. Form Elements
   ============================================================================== */
.profile-modal-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.profile-form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.profile-form-label {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--color-text, #18233B);
  display: flex;
  align-items: center;
  gap: 4px;
}

.required-star {
  color: #DC2626;
  font-weight: 700;
}

.profile-form-input {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  font-size: 14.5px;
  color: var(--color-text, #18233B);
  background: var(--color-bg, #FFFFFF);
  border: 1.5px solid var(--color-border, #E5E8F0);
  border-radius: 10px;
  box-sizing: border-box;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.profile-form-input:hover {
  border-color: var(--color-text-muted, #8992A5);
}

.profile-form-input:focus {
  outline: none;
  border-color: var(--color-primary, #0755C9);
  box-shadow: 0 0 0 3px rgba(7, 85, 201, 0.15);
}

.profile-form-group.has-error .profile-form-input {
  border-color: #DC2626;
  background-color: #FFF5F5;
}

.profile-form-group.has-error .profile-form-input:focus {
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15);
}

/* Phone input row with country code selector */
.profile-phone-input-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 10px;
}

.profile-phone-code-select {
  cursor: pointer;
  background-position: right 10px center;
  font-size: 13.5px;
}

/* Inline Field Errors */
.profile-field-error {
  display: none;
  font-size: 12px;
  font-weight: 500;
  color: #DC2626;
  line-height: 1.3;
  margin-top: 2px;
}

.profile-form-group.has-error .profile-field-error {
  display: block;
}

/* ==============================================================================
   7. Consent Checkbox
   ============================================================================== */
.profile-checkbox-group {
  margin-top: 4px;
}

.profile-checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1.45;
  color: var(--color-text-secondary, #5E687C);
  user-select: none;
}

.profile-checkbox-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.profile-checkbox-custom {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin-top: 2px;
  border: 1.5px solid var(--color-border, #E5E8F0);
  border-radius: 4px;
  background: var(--color-bg, #FFFFFF);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.profile-checkbox-input:checked + .profile-checkbox-custom {
  background: var(--color-primary, #0755C9);
  border-color: var(--color-primary, #0755C9);
}

.profile-checkbox-input:checked + .profile-checkbox-custom::after {
  content: "";
  width: 4px;
  height: 8px;
  border: solid #FFFFFF;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  margin-bottom: 2px;
}

.profile-checkbox-input:focus-visible + .profile-checkbox-custom {
  outline: 2px solid var(--color-primary, #0755C9);
  outline-offset: 2px;
}

.profile-form-group.has-error .profile-checkbox-custom {
  border-color: #DC2626;
  background: #FFF5F5;
}

/* ==============================================================================
   8. Submit Button
   ============================================================================== */
.profile-submit-btn {
  width: 100%;
  height: 48px;
  background: linear-gradient(135deg, var(--color-primary, #0755C9) 0%, var(--color-secondary, #6547F5) 100%);
  color: #FFFFFF;
  border: none;
  border-radius: 9999px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  margin-top: 8px;
  box-shadow: 0 4px 14px rgba(7, 85, 201, 0.28);
  transition: transform 0.2s, box-shadow 0.2s, filter 0.2s;
}

.profile-submit-btn:hover:not(:disabled) {
  transform: translateY(-1.5px);
  box-shadow: 0 8px 22px rgba(101, 71, 245, 0.35);
}

.profile-submit-btn:active:not(:disabled) {
  transform: translateY(0);
}

.profile-submit-btn:focus-visible {
  outline: 2px solid var(--color-primary, #0755C9);
  outline-offset: 3px;
}

.profile-submit-btn:disabled {
  opacity: 0.75;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.profile-btn-spinner {
  display: none;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #FFFFFF;
  border-radius: 50%;
  animation: profile-spin 0.8s linear infinite;
}

.profile-submit-btn.is-loading .profile-btn-spinner {
  display: inline-block;
}

.profile-submit-btn.is-loading .profile-btn-icon {
  display: none;
}

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

/* ==============================================================================
   9. Footer Note
   ============================================================================== */
.profile-modal-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 18px;
  font-size: 11.5px;
  color: var(--color-text-muted, #8992A5);
  text-align: center;
}

.profile-modal-footer svg {
  flex-shrink: 0;
  opacity: 0.8;
}

/* ==============================================================================
   10. Responsive Adaptations
   ============================================================================== */
@media (max-width: 480px) {
  .profile-modal-card {
    padding: 28px 20px 22px;
    border-radius: 14px;
  }

  .profile-modal-title {
    font-size: 20px;
  }

  .profile-form-input {
    font-size: 14px;
  }
}
