/* ═══════════════════════════════════════════════════════
   华联香百 — SHARED STYLES
   Loaded by portal (shared.css) and HR app (/shared.css)
═══════════════════════════════════════════════════════ */

/* ── Reset ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; }

/* ── Design tokens ──────────────────────────────────── */
:root {
  /* Primary (blue) */
  --primary:       #1A4B9B;
  --primary-dark:  #153d84;
  --primary-light: #e8eef8;
  /* Accent (red) */
  --accent:        #DC1F26;
  --accent-dark:   #be1a19;
  --accent-light:  #fde8e8;
  /* Semantic */
  --success:       #057a55;
  --success-light: #def7ec;
  --warning:       #c27803;
  --warning-light: #fef3c7;
  --danger:        #DC1F26;
  --danger-light:  #fde8e8;
  /* Neutral */
  --neutral:       #374151;
  --neutral-light: #f9fafb;
  --neutral-mid:   #6b7280;
  --border:        #e5e7eb;
  /* Shadows */
  --shadow-sm:     0 1px 3px rgba(0,0,0,.08);
  --shadow-md:     0 4px 12px rgba(0,0,0,.10);
  --shadow-lg:     0 8px 24px rgba(0,0,0,.12);
  /* Radius */
  --radius:        8px;
  --radius-lg:     12px;
  /* Aliases for portal (--blue / --red) */
  --blue:          #1A4B9B;
  --blue-mid:      #1e47a6;
  --blue-light:    #e8eef8;
  --red:           #DC1F26;
  --red-dark:      #be1a19;

  font-size: 14px;
}

/* ── Base ───────────────────────────────────────────── */
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont,
               'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei',
               system-ui, sans-serif;
  background: #f4f6fb;
  color: var(--neutral);
  min-height: 100vh;
  line-height: 1.5;
}

/* ── Animations ─────────────────────────────────────── */
@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes spin    { to   { transform: rotate(360deg); } }
@keyframes shimmer {
  0%   { background-position: -600px 0; }
  100% { background-position:  600px 0; }
}

/* ── Buttons ────────────────────────────────────────── */
/* Base: optional modifier that adds flex + gap */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  font-family: inherit;
  cursor: pointer;
}
.btn:active { transform: scale(.98); }

/* Primary — self-contained, works with or without .btn */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 18px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s, transform .1s;
  white-space: nowrap;
}
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-primary:active:not(:disabled) { transform: scale(.99); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }

/* Ghost — self-contained */
.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 18px;
  background: transparent;
  color: var(--neutral-mid);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
  white-space: nowrap;
}
.btn-ghost:hover { background: var(--neutral-light); color: var(--neutral); }

/* Danger — for destructive actions */
.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 12px;
  background: transparent;
  color: var(--danger);
  border: 1px solid #fca5a5;
  border-radius: var(--radius);
  font-size: 12.5px;
  font-family: inherit;
  cursor: pointer;
  transition: background .12s, border-color .12s;
  white-space: nowrap;
}
.btn-danger:hover { background: var(--danger-light); border-color: #f87171; }

/* Full width */
.btn-block { width: 100%; }
/* Small size — use after other btn variants to override padding */
.btn-sm { padding: 5px 12px; font-size: 12.5px; }

/* Required field marker */
.req { color: var(--accent); }

/* ── Panel / card ───────────────────────────────────── */
.panel {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  overflow: hidden;
}

.panel-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.panel-title { font-size: 14px; font-weight: 600; color: #111827; }

.panel-count {
  font-size: 12px;
  color: var(--neutral-mid);
  background: var(--neutral-light);
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 6px;
}

/* ── Filter bar ─────────────────────────────────────── */
.filter-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.search-wrap { position: relative; flex: 1; min-width: 160px; }

.search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: #9ca3af; font-size: 14px; pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 8px 10px 8px 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13.5px;
  font-family: inherit;
  color: var(--neutral);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.search-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,75,155,.12); }

.filter-select {
  padding: 8px 28px 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
  color: var(--neutral);
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b7280' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 8px center;
  appearance: none;
  cursor: pointer;
  outline: none;
  transition: border-color .15s;
}
.filter-select:focus { border-color: var(--primary); }

/* ── Table ──────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

thead th {
  background: #f9fafb;
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  color: var(--neutral-mid);
  text-transform: uppercase;
  letter-spacing: .4px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  user-select: none;
}
thead th:hover { color: var(--neutral); }
thead th .sort-icon { margin-left: 4px; opacity: .5; font-size: 11px; }
thead th.sorted .sort-icon { opacity: 1; color: var(--primary); }

tbody tr { border-bottom: 1px solid #f3f4f6; transition: background .1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #f8faff; }

tbody td { padding: 11px 12px; color: var(--neutral); vertical-align: middle; }

/* Action column helper */
.action-cell { white-space: nowrap; }

/* ── Badges ─────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }

.badge-active   { background: var(--success-light); color: var(--success); }
.badge-active::before   { background: var(--success); }
.badge-on-leave { background: var(--warning-light); color: var(--warning); }
.badge-on-leave::before { background: var(--warning); }
.badge-inactive { background: #f3f4f6; color: #6b7280; }
.badge-inactive::before { background: #9ca3af; }
/* Aliases used by portal JS */
.badge-ok  { background: var(--success-light); color: var(--success); }
.badge-ok::before  { background: var(--success); }
.badge-off { background: #f3f4f6; color: #6b7280; }
.badge-off::before { background: #9ca3af; }
.badge-sys { background: #ede9fe; color: #5b21b6; }
.badge-sys::before { display: none; }

.badge-system { background: #ede9fe; color: #5b21b6; }
.badge-system::before { display: none; }
.badge-fulltime { background: var(--primary-light); color: var(--primary); }
.badge-fulltime::before { background: var(--primary); }
.badge-parttime { background: #fdf2f8; color: #9d174d; }
.badge-parttime::before { background: #9d174d; }
.badge-seasonal { background: #fffbeb; color: #92400e; }
.badge-seasonal::before { background: #92400e; }
.badge-dept { background: var(--neutral-light); color: var(--neutral); border: 1px solid var(--border); font-size: 11.5px; }
.badge-dept::before { display: none; }

/* ── Empty state ────────────────────────────────────── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--neutral-mid); }
.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state p { font-size: 15px; font-weight: 500; margin-bottom: 4px; color: var(--neutral); }
.empty-state span { font-size: 13px; }

/* ── Skeleton ───────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
  background-size: 600px 100%;
  animation: shimmer 1.4s infinite linear;
  border-radius: 4px;
  display: inline-block;
}

/* ── Popup modals (portal style) ────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 24px;
}

.modal-card {
  background: #fff;
  border-radius: 18px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.2);
  overflow: hidden;
}
.modal-card-wide { max-width: 560px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid #f3f4f6;
  font-size: 16px;
  font-weight: 700;
  color: #111827;
}

.modal-close {
  background: none;
  border: none;
  font-size: 16px;
  color: #9ca3af;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: background .15s, color .15s;
}
.modal-close:hover { background: #f3f4f6; color: #374151; }

.modal-body { padding: 24px; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid #f3f4f6;
}

/* ── Form fields ────────────────────────────────────── */
.field { margin-bottom: 16px; }

.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 6px;
}

.field input[type="text"],
.field input[type="password"],
.field select {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  color: #111827;
  outline: none;
  background: #fafafa;
  transition: border-color .2s, background .2s;
}
.field input:focus,
.field select:focus { border-color: var(--primary); background: #fff; }

/* Password input wrapper with eye toggle */
.input-wrap { position: relative; }
.input-wrap input { width: 100%; padding-right: 42px; }

.eye-btn {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; color: #9ca3af;
  padding: 4px; border-radius: 4px;
  display: flex; align-items: center;
  transition: color .15s;
}
.eye-btn:hover { color: var(--primary); }
.eye-icon { width: 18px; height: 18px; }

/* Standalone form input (HR style) */
.form-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  color: var(--neutral);
  background: #fff;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  box-sizing: border-box;
}
.form-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,75,155,.12); }
.form-input:disabled { background: #f9fafb; cursor: not-allowed; color: var(--neutral-mid); }

/* 2-col form grid */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 20px; }
@media (max-width: 540px) { .form-grid { grid-template-columns: 1fr; } }

/* ── Alerts ─────────────────────────────────────────── */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 14px;
}
.alert-error   { background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; }
.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }

.error-banner {
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid #fca5a5;
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13.5px;
  margin-bottom: 16px;
}

/* ── Spinner / loading ──────────────────────────────── */
.spinner {
  display: inline-block;
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

.loading-center { display: flex; justify-content: center; align-items: center; padding: 60px; }
