/**
 * Profile Edit Modal Styles
 * Nintendo × Kashiwa Sato Design System
 */

/* Modal Backdrop */
.profile-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.profile-modal-backdrop.active {
  opacity: 1;
}

.profile-modal-backdrop.hidden {
  display: none;
}

/* Modal Container */
.profile-modal {
  background: #fff;
  border-radius: 24px;
  max-width: 500px;
  width: 100%;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  transform: translateY(20px) scale(0.95);
  transition: transform 0.3s ease;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  /* Hide scrollbar but keep scroll functionality */
  scrollbar-width: none;        /* Firefox */
  -ms-overflow-style: none;     /* IE/Edge */
}

.profile-modal::-webkit-scrollbar {
  display: none;                /* Chrome/Safari/Opera */
}

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

/* Modal Header */
.profile-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid #E5E5E5;
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
}

.profile-modal-title {
  font-size: 18px;
  font-weight: 600;
  color: #171717;
}

.profile-modal-close {
  width: 36px;
  height: 36px;
  border: none;
  background: #F5F5F5;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #525252;
  transition: background 0.2s;
}

.profile-modal-close:hover {
  background: #E5E5E5;
}

/* Modal Body */
.profile-modal-body {
  padding: 24px;
}

/* Avatar Section */
.profile-avatar-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 32px;
}

.profile-avatar-preview {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: #F5F5F5;
  overflow: hidden;
  border: 3px solid #E5E5E5;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.profile-avatar-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-avatar-placeholder {
  color: #A3A3A3;
}

.profile-avatar-upload-btn {
  padding: 10px 20px;
  background: #171717;
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.profile-avatar-upload-btn:hover {
  background: #404040;
}

.profile-avatar-upload-btn:active {
  transform: scale(0.98);
}

/* Form Groups */
.profile-form-group {
  margin-bottom: 20px;
}

.profile-form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #525252;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.profile-form-input {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid #E5E5E5;
  border-radius: 12px;
  font-size: 16px;
  color: #171717;
  background: #FAFAFA;
  transition: border-color 0.2s, background 0.2s;
}

.profile-form-input:focus {
  outline: none;
  border-color: #171717;
  background: #fff;
}

.profile-form-input::placeholder {
  color: #A3A3A3;
}

.profile-form-textarea {
  resize: vertical;
  min-height: 100px;
  font-family: inherit;
}

.profile-form-hint {
  font-size: 12px;
  color: #A3A3A3;
  margin-top: 6px;
}

/* Social Links Section */
.profile-social-section {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid #E5E5E5;
}

.profile-social-title {
  font-size: 14px;
  font-weight: 600;
  color: #171717;
  margin-bottom: 16px;
}

.profile-social-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.profile-social-item {
  display: flex;
  align-items: center;
  gap: 12px;
}

.profile-social-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #F5F5F5;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.profile-social-input {
  flex: 1;
  padding: 12px 14px;
  border: 2px solid #E5E5E5;
  border-radius: 10px;
  font-size: 14px;
  color: #171717;
  background: #FAFAFA;
  transition: border-color 0.2s, background 0.2s;
}

.profile-social-input:focus {
  outline: none;
  border-color: #171717;
  background: #fff;
}

.profile-social-input::placeholder {
  color: #A3A3A3;
}

/* Custom Links Section */
.profile-custom-links {
  margin-top: 20px;
}

.profile-custom-link-item {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.profile-custom-link-label {
  width: 100px;
  padding: 12px 14px;
  border: 2px solid #E5E5E5;
  border-radius: 10px;
  font-size: 14px;
  background: #FAFAFA;
}

.profile-custom-link-label:focus {
  outline: none;
  border-color: #171717;
  background: #fff;
}

.profile-custom-link-url {
  flex: 1;
  padding: 12px 14px;
  border: 2px solid #E5E5E5;
  border-radius: 10px;
  font-size: 14px;
  background: #FAFAFA;
}

.profile-custom-link-url:focus {
  outline: none;
  border-color: #171717;
  background: #fff;
}

/* Prevent iOS Safari/WKWebView focus-zoom on URL/social inputs */
@supports (-webkit-touch-callout: none) {
  .profile-social-input,
  .profile-custom-link-label,
  .profile-custom-link-url {
    font-size: 16px;
  }
}

.profile-custom-link-remove {
  width: 40px;
  height: 40px;
  border: none;
  background: #FEE2E2;
  color: #DC2626;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  flex-shrink: 0;
}

.profile-custom-link-remove:hover {
  background: #FECACA;
}

.profile-add-custom-link {
  width: 100%;
  padding: 12px;
  border: 2px dashed #E5E5E5;
  background: transparent;
  border-radius: 10px;
  color: #525252;
  font-size: 14px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

.profile-add-custom-link:hover {
  border-color: #A3A3A3;
  color: #171717;
}

/* Modal Footer */
.profile-modal-footer {
  display: flex;
  gap: 12px;
  padding: 20px 24px;
  border-top: 1px solid #E5E5E5;
  background: #FAFAFA;
  border-radius: 0 0 24px 24px;
}

.profile-btn {
  flex: 1;
  padding: 14px 20px;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.profile-btn:active {
  transform: scale(0.98);
}

.profile-btn-cancel {
  background: #E5E5E5;
  color: #525252;
}

.profile-btn-cancel:hover {
  background: #D4D4D4;
}

.profile-btn-save {
  background: #FF3B30;
  color: #fff;
}

.profile-btn-save:hover {
  background: #E53528;
}

.profile-btn-save:disabled {
  background: #A3A3A3;
  cursor: not-allowed;
}

/* Loading state */
.profile-btn-save.loading {
  position: relative;
  color: transparent;
}

.profile-btn-save.loading::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  top: 50%;
  left: 50%;
  margin: -10px 0 0 -10px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Error state */
.profile-form-input.error,
.profile-social-input.error {
  border-color: #DC2626;
}

.profile-error-message {
  background: #FEE2E2;
  color: #DC2626;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  margin-bottom: 16px;
}

/* Mobile: Full-screen modal */
@media (max-width: 480px) {
  .profile-modal-backdrop {
    padding: 0;
    background: #fff;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .profile-modal {
    border-radius: 0;
    max-height: 100%;
    height: 100%;
    max-width: 100%;
    box-shadow: none;
    display: flex;
    flex-direction: column;
  }

  .profile-modal-backdrop.active .profile-modal {
    transform: none;
  }

  .profile-modal-header {
    padding: 12px 16px;
    border-bottom: 1px solid #E5E5E5;
  }

  .profile-modal-body {
    padding: 20px 16px;
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .profile-modal-footer {
    border-radius: 0;
    padding: 16px;
    /* Safe area for devices with home indicator */
    padding-bottom: max(16px, var(--page-safe-bottom, env(safe-area-inset-bottom, 0px)));
  }

  .profile-social-item {
    flex-wrap: wrap;
  }

  .profile-social-icon {
    width: 36px;
    height: 36px;
    font-size: 14px;
  }

  .profile-custom-link-item {
    flex-wrap: wrap;
  }

  .profile-custom-link-label {
    width: 100%;
  }

  .profile-custom-link-url {
    flex: 1;
    min-width: 0;
  }
}

/* ========================================
   MyPage Social Links - Kashiwa Sato Style
   ======================================== */

.mypage-social-links {
  display: flex;
  justify-content: flex-start;
  gap: 8px;
  margin-top: 16px;
}

.mypage-social-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: transparent;
  border: 1.5px solid #E5E5E5;
  color: #525252;
  text-decoration: none;
  font-size: 13px;
  transition: all 0.2s ease;
}

.mypage-social-link:hover {
  border-color: #171717;
  color: #171717;
}

.mypage-social-link.mypage-social-custom {
  width: auto;
  padding: 0 12px;
  border-radius: 16px;
  font-size: 11px;
  font-weight: 500;
}

/* ========================================
   Username Input - @username field
   ======================================== */

.profile-username-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.profile-username-prefix {
  position: absolute;
  left: 16px;
  font-size: 16px;
  font-weight: 500;
  color: #525252;
  pointer-events: none;
}

.profile-username-input {
  padding-left: 32px !important;
  padding-right: 100px !important;
}

.profile-username-status {
  position: absolute;
  right: 16px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.profile-username-status.status-checking {
  color: #A3A3A3;
}

.profile-username-status.status-available {
  color: #16A34A;
}

.profile-username-status.status-current {
  color: #3B82F6;
}

.profile-username-status.status-error {
  color: #DC2626;
}

/* Username URL display */
.profile-username-url {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 8px;
  padding: 4px 8px;
  background: #F5F5F5;
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, monospace;
  font-size: 11px;
  color: #525252;
}

.profile-username-copy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
  border: none;
  background: transparent;
  color: #525252;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.2s, color 0.2s;
}

.profile-username-copy:hover {
  background: #E5E5E5;
  color: #171717;
}

.profile-username-copy svg {
  display: block;
}
