/* Profile Panel */
.profile-panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(4px);
  z-index: 1002;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s, visibility 0.25s;
}

.profile-panel-overlay.active {
  opacity: 1;
  visibility: visible;
}

.profile-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 320px;
  height: 100vh;
  background: var(--bg-glass);
  /* border-left: 1px solid var(--border-light); */
  box-shadow: -8px 0 32px rgba(0,0,0,0.12);
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
  display: flex;
  flex-direction: column;
}

.profile-panel-overlay.active .profile-panel {
  transform: translateX(0);
}

/* Close button */
.profile-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 30px;
  height: 30px;
  border: none;
  background: var(--bg-secondary);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--text-secondary);
  transition: background 0.2s, color 0.2s;
  z-index: 10;
  line-height: 1;
}

.profile-close:hover {
  background: var(--danger);
  color: white;
}

/* Scrollable content */
.profile-content {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* ── Avatar / Info ── */
.profile-info-section {
  padding: 36px 24px 20px;
  text-align: center;
  border-bottom: 1px solid var(--border-light);
}

.profile-avatar-large {
  width: 72px;
  height: 72px;
  margin: 0 auto 12px;
  position: relative;
  border-radius: 50%;
  background: var(--primary);
  border: 3px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
}

.profile-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  overflow: hidden;
}

.profile-initials {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
  color: white;
}

.camera-btn {
  position: absolute !important;
  bottom: -2px !important;
  right: -2px !important;
  width: 24px !important;
  height: 24px !important;
  background: var(--primary) !important;
  border: 2px solid var(--bg-primary) !important;
  border-radius: 50% !important;
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  color: white !important;
  transition: background 0.2s !important;
  z-index: 5 !important;
}

.camera-btn i { font-size: 10px; color: white; }
.camera-btn:hover { background: var(--primary-dark) !important; }
.camera-btn.hidden { display: none !important; }

.profile-display-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 4px;
}

.profile-email {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin: 0 0 10px;
  word-break: break-all;
}

.profile-role-badge {
  display: inline-block;
  padding: 3px 10px;
  background: var(--primary);
  color: white;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: capitalize;
}

/* ── Sections ── */
.profile-section {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
}

.profile-section:last-child { border-bottom: none; }

.profile-section h4 {
  margin: 0 0 12px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

/* ── Profile picture actions ── */
.profile-picture-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.profile-picture-close {
  width: 22px;
  height: 22px;
  border: none;
  background: var(--bg-tertiary);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--text-secondary);
  transition: background 0.2s, color 0.2s;
}

.profile-picture-close:hover { background: var(--danger); color: white; }

.profile-picture-actions { display: flex; gap: 8px; }

.btn-upload, .btn-remove {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 500;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.btn-upload:hover { background: var(--primary); color: white; border-color: var(--primary); }
.btn-remove:hover { background: var(--danger); color: white; border-color: var(--danger); }

/* ── Theme options ── */
.theme-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.theme-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 10px 6px;
  border: 1.5px solid var(--border-light);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: var(--bg-secondary);
  min-height: 56px;
}

.theme-option input { display: none; }

.theme-option i { font-size: 15px; }
.theme-option span { font-size: 0.72rem; font-weight: 600; color: var(--text-secondary); }

.theme-light { background: linear-gradient(135deg,#fff 0%,#f8fafc 100%); }
.theme-light i { color: #f59e0b; }
.theme-light span { color: #374151; }

.theme-dark { background: linear-gradient(135deg,#1e293b 0%,#0f172a 100%); }
.theme-dark i { color: #60a5fa; }
.theme-dark span { color: #e2e8f0; }

.theme-system { background: linear-gradient(135deg,#fff 50%,#1e293b 50%); }
.theme-system i { color: #6b7280; }
.theme-system span { color: #6b7280; }

.theme-option:has(input:checked) {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37,99,235,0.15);
}

/* ── Notification toggle ── */
.notification-toggles {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toggle-switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: default;
}

.toggle-switch input { display: none; }

.toggle-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  flex: 1;
  order: -1;
}

.toggle-slider {
  position: relative;
  width: 40px;
  height: 22px;
  background: var(--bg-tertiary);
  border-radius: 11px;
  border: 1px solid var(--border-light);
  cursor: pointer;
  pointer-events: auto;
  flex-shrink: 0;
  transition: background 0.2s, border-color 0.2s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--primary);
  border-color: var(--primary);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(18px);
}

/* ── Sign out ── */
.profile-actions {
  padding: 16px 20px 24px !important;
  border-bottom: none !important;
}

.btn-logout {
  width: 100%;
  padding: 10px 16px;
  background: var(--danger);
  border: 1.5px solid var(--danger);
  border-radius: 10px;
  color: white;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.2s, color 0.2s;
}

.btn-logout:hover { background: white; color: var(--danger); border: 1.5px solid var(--danger);}

/* ── Mobile ── */
@media (max-width: 768px) {
  .profile-panel { width: 100%; }
}

/* ── Dark theme ── */
[data-theme="dark"] .profile-panel {
  background: var(--bg-glass);
  border-left-color: var(--border-medium);
}

[data-theme="dark"] .camera-btn {
  background: var(--accent) !important;
  border-color: var(--bg-primary) !important;
}

[data-theme="dark"] .toggle-slider {
  background: var(--bg-tertiary);
  border-color: var(--border-medium);
}

[data-theme="dark"] .toggle-switch input:checked + .toggle-slider {
  background: var(--accent);
  border-color: var(--accent);
}

/* ── Crop Modal ── */
@media (max-width: 768px) {
  .crop-modal-content {
    width: 95% !important;
    height: 90vh !important;
    max-width: none !important;
    max-height: 90vh !important;
    display: flex !important;
    flex-direction: column !important;
  }
  .crop-modal-content .modal-body {
    flex: 1 !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
  }
  .crop-modal-content .img-container { flex: 1 !important; min-height: 0 !important; }
}

@media (min-width: 769px) {
  .crop-modal-content {
    position: fixed !important;
    top: 0 !important; right: 0 !important;
    width: 400px !important;
    height: 100vh !important;
    max-width: none !important;
    max-height: none !important;
    margin: 0 !important;
    border-radius: 0 !important;
    transform: translateX(100%) !important;
    transition: transform var(--transition-base) !important;
  }
  .modal-overlay.active .crop-modal-content { transform: translateX(0) !important; }
}

.crop-modal-content .modal-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 16px 20px;
  border-top: 1px solid var(--border-light);
}

.crop-modal-content .btn {
  padding: 8px 20px;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s;
  min-width: 72px;
}

.crop-modal-content .btn.secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.crop-modal-content .btn.secondary:hover { background: var(--bg-tertiary); }

.crop-modal-content .btn.primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.crop-modal-content .btn.primary:hover { background: var(--primary-dark); }

.crop-modal-content .btn#resetCropBtn {
  background: var(--warning);
  color: white;
  border-color: var(--warning);
}

.crop-modal-content .btn#resetCropBtn:hover { background: #d97706; border-color: #d97706; }

[data-theme="dark"] .crop-modal-content .btn.secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--border-medium);
}

/* Loading / spinner */
.btn-loading { position: relative; pointer-events: none; opacity: 0.7; }
.btn-loading::after {
  content: '';
  position: absolute;
  width: 12px; height: 12px;
  top: 50%; left: 50%;
  margin: -6px 0 0 -6px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.profile-avatar img, .profile-avatar-large img { transition: opacity 0.2s; }

.profile-initials-small {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  text-transform: uppercase;
}
