/* ============================================================================
   KỆ TIMESHEET — REUSABLE UI COMPONENTS
   ============================================================================
   Load order: base.css → components.css → page-specific.css
   Depends on: CSS variables defined in base.css
   ============================================================================ */


/* ============================================================================
   1. BUTTONS
   ============================================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  font-family: var(--font-ui);
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn:disabled,
.btn.is-disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Primary — main action (purple gradient) */
.btn-primary {
  background: linear-gradient(135deg, var(--deep-violet), var(--vibrant-purple));
  color: var(--text-on-brand);
  box-shadow: var(--shadow-md);
}
.btn-primary:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
}
.btn-primary:active {
  transform: translateY(0);
}

/* Secondary — supporting action (outlined) */
.btn-secondary {
  background: var(--bg-card);
  color: var(--accent);
  border-color: var(--border-strong);
}
.btn-secondary:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

/* Ghost — tertiary action (no background) */
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* Danger — destructive action (red) */
.btn-danger {
  background: var(--red-critical);
  color: var(--pure-white);
}
.btn-danger:hover {
  background: #D04848;
  box-shadow: var(--shadow-md);
}

/* Sizes */
.btn-sm {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
}
.btn-lg {
  padding: var(--space-4) var(--space-6);
  font-size: var(--text-lg);
}
.btn-block {
  width: 100%;
}

/* Icon-only button */
.btn-icon {
  padding: var(--space-3);
  aspect-ratio: 1;
}


/* ============================================================================
   2. FORM INPUTS
   ============================================================================ */

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.form-label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-primary);
}

.form-label-required::after {
  content: ' *';
  color: var(--red-critical);
}

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-md);
  font-family: var(--font-ui);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(154, 41, 226, 0.1);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-muted);
}

.form-input:disabled,
.form-textarea:disabled {
  background: var(--bg-hover);
  cursor: not-allowed;
  opacity: 0.7;
}

/* Error state */
.form-input.is-error,
.form-textarea.is-error {
  border-color: var(--red-critical);
}
.form-input.is-error:focus {
  box-shadow: 0 0 0 3px rgba(240, 96, 96, 0.1);
}

/* Helper text below input */
.form-helper {
  font-size: var(--text-xs);
  color: var(--text-muted);
}
.form-helper.is-error {
  color: var(--red-critical);
}

/* Textarea specific */
.form-textarea {
  min-height: 80px;
  resize: vertical;
}


/* ============================================================================
   3. CARDS
   ============================================================================ */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  transition: box-shadow var(--transition-base);
}

.card-elevated {
  box-shadow: var(--shadow-md);
}

.card-interactive {
  cursor: pointer;
}
.card-interactive:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border-default);
}

.card-title {
  font-size: var(--text-lg);
  font-weight: var(--weight-medium);
  color: var(--text-primary);
}

.card-footer {
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-default);
}


/* ============================================================================
   4. CHIPS (selectable tags — roles, business types, shifts)
   ============================================================================ */

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-pill);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  cursor: pointer;
  user-select: none;
  transition: all var(--transition-fast);
}

.chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.chip.is-selected {
  background: var(--accent);
  color: var(--text-on-brand);
  border-color: var(--accent);
}

.chip-add {
  background: transparent;
  border-style: dashed;
  color: var(--text-muted);
}
.chip-add:hover {
  border-style: solid;
  border-color: var(--accent);
  color: var(--accent);
}

/* Dismissable chip with × button */
.chip-dismiss {
  margin-left: var(--space-1);
  cursor: pointer;
  opacity: 0.6;
  font-size: var(--text-lg);
  line-height: 1;
}
.chip-dismiss:hover {
  opacity: 1;
}


/* ============================================================================
   5. BADGES (status pills — non-interactive)
   ============================================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-3);
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  line-height: 1.5;
}

.badge-success {
  background: rgba(61, 214, 140, 0.15);
  color: var(--green-ok);
}

.badge-warning {
  background: rgba(240, 164, 41, 0.15);
  color: var(--amber-warning);
}

.badge-danger {
  background: rgba(240, 96, 96, 0.15);
  color: var(--red-critical);
}

.badge-info {
  background: rgba(74, 144, 226, 0.15);
  color: var(--info-blue);
}

.badge-neutral {
  background: var(--bg-hover);
  color: var(--text-secondary);
}

.badge-accent {
  background: var(--accent-soft);
  color: var(--accent);
}


/* ============================================================================
   6. AVATARS
   ============================================================================ */

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-pill);
  background: var(--vibrant-purple);
  color: var(--text-on-brand);
  font-weight: var(--weight-medium);
  font-size: var(--text-base);
  flex-shrink: 0;
  text-transform: uppercase;
}

.avatar-sm { width: 28px; height: 28px; font-size: var(--text-xs); }
.avatar-lg { width: 56px; height: 56px; font-size: var(--text-lg); }
.avatar-xl { width: 80px; height: 80px; font-size: var(--text-xl); }

/* Color variants for visual variety in employee lists */
.avatar-violet    { background: var(--deep-violet); }
.avatar-purple    { background: var(--vibrant-purple); }
.avatar-lavender  { background: var(--soft-lavender); color: var(--deep-violet); }
.avatar-green     { background: var(--green-ok); }
.avatar-amber     { background: var(--amber-warning); }
.avatar-red       { background: var(--red-critical); }
.avatar-blue      { background: var(--info-blue); }


/* ============================================================================
   7. PROGRESS BAR (multi-step wizards)
   ============================================================================ */

.progress {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
}

.progress-step {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 1;
}

.progress-circle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-pill);
  background: var(--bg-card);
  border: 2px solid var(--border-default);
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  flex-shrink: 0;
  transition: all var(--transition-base);
}

.progress-step.is-active .progress-circle {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--text-on-brand);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.progress-step.is-completed .progress-circle {
  background: var(--green-ok);
  border-color: var(--green-ok);
  color: var(--pure-white);
}

.progress-label {
  font-size: var(--text-sm);
  color: var(--text-muted);
  font-weight: var(--weight-medium);
  white-space: nowrap;
}
.progress-step.is-active .progress-label,
.progress-step.is-completed .progress-label {
  color: var(--text-primary);
}

.progress-line {
  flex: 1;
  height: 2px;
  background: var(--border-default);
  transition: background var(--transition-base);
}
.progress-line.is-completed {
  background: var(--green-ok);
}


/* ============================================================================
   8. MODAL / DIALOG
   ============================================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(14, 11, 26, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-base);
}

.modal-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(20px);
  transition: transform var(--transition-base);
}

.modal-overlay.is-open .modal {
  transform: translateY(0);
}

.modal-header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border-default);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: var(--text-xl);
  font-weight: var(--weight-medium);
  color: var(--text-primary);
}

.modal-body {
  padding: var(--space-6);
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-default);
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
  background: var(--bg-page);
}


/* ============================================================================
   9. TOGGLE SWITCH (theme toggle, settings)
   ============================================================================ */

.toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
  user-select: none;
}

.toggle-track {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--border-input);
  border-radius: var(--radius-pill);
  transition: background var(--transition-fast);
}

.toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: var(--pure-white);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-fast);
}

.toggle-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle-input:checked ~ .toggle-track {
  background: var(--accent);
}
.toggle-input:checked ~ .toggle-track .toggle-thumb {
  transform: translateX(20px);
}

.toggle-label {
  font-size: var(--text-sm);
  color: var(--text-primary);
}


/* ============================================================================
   10. ALERTS / BANNERS
   ============================================================================ */

.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-md);
  border-left: 4px solid;
  font-size: var(--text-sm);
}

.alert-icon {
  font-size: var(--text-xl);
  line-height: 1;
  flex-shrink: 0;
}

.alert-content {
  flex: 1;
}

.alert-title {
  font-weight: var(--weight-medium);
  margin-bottom: var(--space-1);
}

.alert-success {
  background: rgba(61, 214, 140, 0.1);
  border-left-color: var(--green-ok);
  color: var(--text-primary);
}

.alert-warning {
  background: rgba(240, 164, 41, 0.1);
  border-left-color: var(--amber-warning);
  color: var(--text-primary);
}

.alert-danger {
  background: rgba(240, 96, 96, 0.1);
  border-left-color: var(--red-critical);
  color: var(--text-primary);
}

.alert-info {
  background: rgba(74, 144, 226, 0.1);
  border-left-color: var(--info-blue);
  color: var(--text-primary);
}


/* ============================================================================
   11. LOGO COMPONENT
   ============================================================================
   Uses real SVG assets from public/assets/icons/logo/
   Files received from designer on May 18, 2026
   ============================================================================ */

.logo {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
  color: var(--text-primary);
  line-height: 1;
}

.logo:hover {
  text-decoration: none;
  opacity: 0.85;
}

/* The mark (K + moon symbol) */
.logo-mark {
  display: block;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
}

.logo-mark img,
.logo-mark svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* Wordmark text "Kệ Timesheet" */
.logo-text {
  font-family: var(--font-brand);
  font-size: var(--text-xl);
  font-weight: var(--weight-medium);
  color: var(--text-primary);
  white-space: nowrap;
}

.logo-text-accent {
  color: var(--accent);
}

/* Size variants */
.logo-sm .logo-mark {
  width: 24px;
  height: 24px;
}
.logo-sm .logo-text {
  font-size: var(--text-base);
}

.logo-lg .logo-mark {
  width: 56px;
  height: 56px;
}
.logo-lg .logo-text {
  font-size: var(--text-2xl);
}

.logo-xl .logo-mark {
  width: 80px;
  height: 80px;
}
.logo-xl .logo-text {
  font-size: var(--text-3xl);
}

/* Mark-only variant (no text) */
.logo-mark-only .logo-text {
  display: none;
}

/* Vertical stack (mark on top, text below) */
.logo-stacked {
  flex-direction: column;
  gap: var(--space-2);
  text-align: center;
}


/* ============================================================================
   12. CONTAINER & LAYOUT HELPERS
   ============================================================================ */

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-5);
}

.container-sm {
  max-width: 560px;
}

.container-md {
  max-width: 800px;
}

.divider {
  height: 1px;
  background: var(--border-default);
  margin: var(--space-6) 0;
  border: none;
}

.section {
  padding: var(--space-8) 0;
}

@media (min-width: 768px) {
  .section {
    padding: var(--space-12) 0;
  }
}
