/**
 * RADEXEL Design System - HR Profile Page
 *
 * Styles for the individual employee profile view/edit page.
 * Includes: header with avatar, section cards, field grid,
 * permission badges, save bar, and responsive layout.
 */

/* ==========================================================================
   Page Layout
   ========================================================================== */

.hr-profile {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--color-bg);
}

.hr-profile__scroll {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-6);
  padding-bottom: 100px; /* Space for save bar */
}


/* ==========================================================================
   Back Navigation
   ========================================================================== */

.hr-profile__back {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  font-family: var(--font-sans);
  color: var(--color-text-secondary);
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  margin-bottom: var(--space-4);
  transition:
    color var(--duration-fast) var(--ease-default),
    background-color var(--duration-fast) var(--ease-default);
}

.hr-profile__back svg {
  width: 16px;
  height: 16px;
}

.hr-profile__back:hover {
  color: var(--color-text);
  background: var(--color-bg-secondary);
}


/* ==========================================================================
   Profile Header
   ========================================================================== */

.hr-profile__header {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-6);
  border-bottom: 1px solid var(--color-border-light);
}

.hr-profile__avatar {
  position: relative;
  width: 88px;
  height: 88px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--rdx-blue-light), var(--rdx-blue));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-inverse);
  font-size: var(--font-size-3xl);
  font-weight: var(--font-weight-bold);
  flex-shrink: 0;
  overflow: hidden;
  user-select: none;
}

.hr-profile__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hr-profile__avatar-edit {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-surface);
  border: 2px solid var(--color-bg);
  border-radius: var(--radius-full);
  cursor: pointer;
  color: var(--color-text-secondary);
  transition: color var(--duration-fast) var(--ease-default);
}

.hr-profile__avatar-edit:hover {
  color: var(--rdx-blue);
}

.hr-profile__avatar-edit svg {
  width: 14px;
  height: 14px;
}

.hr-profile__info {
  flex: 1;
  min-width: 0;
}

.hr-profile__name {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-text);
  margin: 0 0 4px 0;
  line-height: var(--line-height-tight);
}

.hr-profile__subtitle {
  font-size: var(--font-size-base);
  color: var(--color-text-secondary);
  margin: 0 0 var(--space-3) 0;
}

.hr-profile__status {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-3);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  border-radius: var(--radius-full);
}

.hr-profile__status--active {
  background: var(--color-success-light);
  color: var(--color-success);
}

.hr-profile__status--inactive {
  background: var(--color-bg-tertiary);
  color: var(--color-text-muted);
}

.hr-profile__status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: currentColor;
}

.hr-profile__actions {
  display: flex;
  gap: var(--space-2);
  flex-shrink: 0;
}


/* ==========================================================================
   Edit / View Toggle Button
   ========================================================================== */

.hr-profile__edit-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  font-family: var(--font-sans);
  color: var(--color-text-inverse);
  background: var(--rdx-blue);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition:
    background-color var(--duration-fast) var(--ease-default),
    box-shadow var(--duration-fast) var(--ease-default);
}

.hr-profile__edit-btn svg {
  width: 14px;
  height: 14px;
}

.hr-profile__edit-btn:hover {
  background: var(--rdx-blue-dark);
  box-shadow: var(--shadow-sm);
}

.hr-profile__edit-btn--cancel {
  color: var(--color-text);
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
}

.hr-profile__edit-btn--cancel:hover {
  background: var(--color-surface-hover);
  box-shadow: none;
}


/* ==========================================================================
   Section Cards
   ========================================================================== */

.hr-profile__section {
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-4);
  overflow: hidden;
}

.hr-profile__section:last-child {
  margin-bottom: 0;
}

.hr-profile__section-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border-light);
}

.hr-profile__section-icon {
  width: 20px;
  height: 20px;
  color: var(--rdx-blue);
  flex-shrink: 0;
}

.hr-profile__section-icon svg {
  width: 100%;
  height: 100%;
}

.hr-profile__section-title {
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text);
  margin: 0;
}

.hr-profile__section-body {
  padding: var(--space-5);
}


/* ==========================================================================
   Field Grid (2-column on desktop, 1-column on mobile)
   ========================================================================== */

.hr-profile__fields {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-5);
}

.hr-profile__field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.hr-profile__field--full {
  grid-column: 1 / -1;
}

.hr-profile__field-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.hr-profile__field-badge {
  display: inline-flex;
  padding: 1px var(--space-1);
  font-size: 10px;
  font-weight: var(--font-weight-medium);
  border-radius: 3px;
  text-transform: none;
  letter-spacing: 0;
}

.hr-profile__field-badge--readonly {
  background: var(--color-bg-tertiary);
  color: var(--color-text-muted);
}

.hr-profile__field-badge--admin {
  background: rgba(139, 92, 246, 0.1);
  color: #8B5CF6;
}

.hr-profile__field-value {
  font-size: var(--font-size-base);
  color: var(--color-text);
  min-height: 24px;
  display: flex;
  align-items: center;
}

.hr-profile__field-value--empty {
  color: var(--color-text-muted);
  font-style: italic;
}


/* ==========================================================================
   Edit Mode — Input Fields
   ========================================================================== */

.hr-profile__input {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  font-size: var(--font-size-base);
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  transition:
    border-color var(--duration-fast) var(--ease-default),
    box-shadow var(--duration-fast) var(--ease-default);
}

.hr-profile__input:focus {
  outline: none;
  border-color: var(--color-border-focus);
  box-shadow: var(--shadow-focus);
}

.hr-profile__input::placeholder {
  color: var(--color-text-muted);
}

.hr-profile__input--error {
  border-color: var(--color-danger);
}

.hr-profile__input--error:focus {
  box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.2);
}

.hr-profile__textarea {
  min-height: 80px;
  resize: vertical;
}

.hr-profile__select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236C757D' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  padding-right: var(--space-8);
}

.hr-profile__field-error {
  font-size: var(--font-size-xs);
  color: var(--color-danger);
  margin-top: 2px;
}


/* ==========================================================================
   Save Bar (Fixed Bottom)
   ========================================================================== */

.hr-profile__save-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: var(--z-sticky);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-6);
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.08);
  transform: translateY(100%);
  transition: transform var(--duration-base) var(--ease-default);
}

.hr-profile__save-bar--visible {
  transform: translateY(0);
}

.hr-profile__save-bar__info {
  flex: 1;
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

.hr-profile__save-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-6);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  font-family: var(--font-sans);
  color: var(--color-text-inverse);
  background: var(--rdx-green);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition:
    background-color var(--duration-fast) var(--ease-default),
    opacity var(--duration-fast) var(--ease-default);
}

.hr-profile__save-btn:hover {
  background: var(--rdx-green-dark);
}

.hr-profile__save-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.hr-profile__save-btn svg {
  width: 14px;
  height: 14px;
}

.hr-profile__cancel-btn {
  display: inline-flex;
  align-items: center;
  padding: var(--space-2) var(--space-4);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  font-family: var(--font-sans);
  color: var(--color-text);
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition:
    background-color var(--duration-fast) var(--ease-default),
    border-color var(--duration-fast) var(--ease-default);
}

.hr-profile__cancel-btn:hover {
  background: var(--color-bg-secondary);
}


/* ==========================================================================
   Save Progress
   ========================================================================== */

.hr-profile__progress {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--color-border-light);
  overflow: hidden;
}

.hr-profile__progress-bar {
  height: 100%;
  background: var(--rdx-green);
  width: 0%;
  transition: width 0.6s var(--ease-out);
}

.hr-profile__progress-bar--complete {
  width: 100%;
  background: var(--color-success);
}


/* ==========================================================================
   Loading State
   ========================================================================== */

.hr-profile__loading {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-6);
}


/* ==========================================================================
   Error State
   ========================================================================== */

.hr-profile__error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-16);
  text-align: center;
}

.hr-profile__error h3 {
  margin: 0;
  font-size: var(--font-size-lg);
  color: var(--color-text);
}

.hr-profile__error p {
  margin: 0;
  color: var(--color-text-secondary);
}


/* ==========================================================================
   User Picker (Admin search)
   ========================================================================== */

.user-picker {
  position: relative;
  width: 280px;
  flex-shrink: 0;
}

.user-picker__input-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  transition:
    border-color var(--duration-fast) var(--ease-default),
    box-shadow var(--duration-fast) var(--ease-default);
}

.user-picker__input-wrap:focus-within {
  border-color: var(--color-border-focus);
  box-shadow: var(--shadow-focus);
  background: var(--color-bg);
}

.user-picker__input-wrap svg {
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.user-picker__input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: var(--font-size-sm);
  font-family: var(--font-sans);
  color: var(--color-text);
  outline: none;
  min-width: 0;
}

.user-picker__input::placeholder {
  color: var(--color-text-muted);
}

.user-picker__dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: var(--space-1);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-dropdown);
  max-height: 320px;
  overflow-y: auto;
}

.user-picker__loading,
.user-picker__empty {
  padding: var(--space-4);
  text-align: center;
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.user-picker__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
  transition: background-color var(--duration-fast) var(--ease-default);
}

.user-picker__item:hover,
.user-picker__item--active {
  background: var(--color-surface-hover);
}

.user-picker__item-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--rdx-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-inverse);
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-sm);
  flex-shrink: 0;
  overflow: hidden;
}

.user-picker__item-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-picker__item-info {
  flex: 1;
  min-width: 0;
}

.user-picker__item-name {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text);
}

.user-picker__item-dept {
  display: block;
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

.user-picker__item-badge {
  font-size: var(--font-size-xs);
  padding: 1px var(--space-2);
  background: var(--color-bg-tertiary);
  color: var(--color-text-muted);
  border-radius: var(--radius-full);
  flex-shrink: 0;
}


/* ==========================================================================
   Responsive — Tablet
   ========================================================================== */

@media (max-width: 1024px) {
  .hr-profile__scroll {
    padding: var(--space-4);
    padding-bottom: 100px;
  }
}


/* ==========================================================================
   Responsive — Mobile
   ========================================================================== */

@media (max-width: 768px) {
  .hr-profile__scroll {
    padding: var(--space-3);
    padding-bottom: 100px;
  }

  .hr-profile__header {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: var(--space-3);
  }

  .hr-profile__avatar {
    width: 72px;
    height: 72px;
    font-size: var(--font-size-2xl);
  }

  .hr-profile__actions {
    justify-content: center;
  }

  .hr-profile__fields {
    grid-template-columns: 1fr;
  }

  .hr-profile__section-body {
    padding: var(--space-4);
  }

  .hr-profile__save-bar {
    padding: var(--space-3) var(--space-4);
  }
}


/* ==========================================================================
   Responsive — Small Mobile
   ========================================================================== */

@media (max-width: 480px) {
  .hr-profile__name {
    font-size: var(--font-size-xl);
  }

  .hr-profile__section-header {
    padding: var(--space-3) var(--space-4);
  }
}


/* ==========================================================================
   File Upload Box (GAS ^^ pattern)
   ========================================================================== */

.hr-file-box {
  min-height: 42px;
  padding: var(--space-2) var(--space-1) var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  cursor: default;
  transition:
    border-color var(--duration-fast) var(--ease-default),
    background-color var(--duration-fast) var(--ease-default);
}

.hr-file-box:not(.hr-file-box--readonly):hover,
.hr-file-box--dragover {
  border-color: var(--rdx-blue);
  background-color: var(--color-bg-secondary);
}

.hr-file-box--readonly {
  background: var(--color-bg);
  cursor: default;
}

.hr-file-box--readonly:hover {
  border-color: var(--color-border);
  background: var(--color-bg);
}

.hr-file__list {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
}

.hr-file__item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 2px 0;
}

.hr-file__icon {
  width: 16px;
  height: 16px;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.hr-file__icon svg {
  width: 100%;
  height: 100%;
}

.hr-file__name {
  flex: 1;
  min-width: 0;
  font-size: var(--font-size-sm);
  color: var(--rdx-blue);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hr-file__name:hover {
  text-decoration: underline;
}

.hr-file__size {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.hr-file__delete {
  width: 20px;
  height: 20px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-muted);
  font-size: var(--font-size-base);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition:
    color var(--duration-fast) var(--ease-default),
    background-color var(--duration-fast) var(--ease-default);
}

.hr-file__delete:hover {
  color: var(--color-danger);
  background: rgba(220, 53, 69, 0.1);
}

.hr-file__empty {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  font-style: italic;
  padding: var(--space-1) 0;
}

.hr-file__actions {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.hr-file__upload-btn {
  cursor: pointer;
}

.hr-file__upload-btn .btn-mini {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-3);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  font-family: var(--font-sans);
  color: var(--color-text-secondary);
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition:
    background-color var(--duration-fast) var(--ease-default),
    color var(--duration-fast) var(--ease-default);
}

.hr-file__upload-btn:hover .btn-mini {
  background: var(--color-surface-hover);
  color: var(--color-text);
}


/* ==========================================================================
   Save Modal with FluidProgress (GAS pattern)
   ========================================================================== */

.hr-save-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s var(--ease-default);
}

.hr-save-modal--show {
  opacity: 1;
  visibility: visible;
}

.hr-save-modal__card {
  background: var(--color-surface);
  width: 90%;
  max-width: 400px;
  padding: var(--space-8) var(--space-6);
  border-radius: var(--radius-xl);
  text-align: center;
  box-shadow: var(--shadow-xl);
  transform: translateY(20px);
  transition: transform 0.3s var(--ease-default);
}

.hr-save-modal--show .hr-save-modal__card {
  transform: translateY(0);
}

.hr-save-modal__spinner {
  width: 40px;
  height: 40px;
  margin: 0 auto var(--space-5);
  border: 4px solid var(--color-border);
  border-top-color: var(--rdx-blue);
  border-radius: var(--radius-full);
  animation: spin 1s linear infinite;
}

.hr-save-modal__title {
  margin: 0 0 var(--space-2);
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-bold);
  color: var(--color-text);
}

.hr-save-modal__desc {
  margin: 0 0 var(--space-6);
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

.hr-save-modal__track {
  height: 6px;
  background: var(--color-border-light);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: var(--space-2);
}

.hr-save-modal__fill {
  height: 100%;
  background: var(--rdx-blue);
  width: 0%;
  /* No CSS transition — FluidProgress controls via rAF */
}

.hr-save-modal__count {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  color: var(--rdx-blue);
  text-align: right;
}

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