/* ============================================
   Nush.ai HR — Shared Components
   ============================================ */

/* ===== BUTTONS ===== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: 10px 20px;
    font-size: var(--text-sm);
    font-weight: var(--font-weight-semibold);
    line-height: 1;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    user-select: none;
}

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

.btn--primary {
    background: var(--brand-gradient);
    color: #fff;
    border-color: transparent;
    box-shadow: var(--shadow-sm);
}

.btn--primary:hover {
    opacity: 0.9;
    box-shadow: var(--shadow-glow-purple);
    transform: translateY(-1px);
}

.btn--primary:active {
    transform: translateY(0);
    opacity: 0.85;
}

.btn--secondary {
    background: transparent;
    color: var(--text-primary);
    border-color: var(--border-default);
}

.btn--secondary:hover {
    background: var(--bg-tertiary);
    border-color: var(--text-tertiary);
}

.btn--danger {
    background: var(--status-terminated);
    color: #fff;
    border-color: transparent;
}

.btn--danger:hover {
    background: #DC2626;
    box-shadow: 0 0 16px rgba(239, 68, 68, 0.3);
    transform: translateY(-1px);
}

.btn--danger:active {
    transform: translateY(0);
}

.btn--ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: transparent;
}

.btn--ghost:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn--sm {
    padding: 6px 12px;
    font-size: var(--text-xs);
}

.btn--lg {
    padding: 14px 28px;
    font-size: var(--text-base);
    border-radius: var(--radius-md);
}

.btn--icon {
    width: 40px;
    height: 40px;
    padding: 0;
}

.btn--icon.btn--sm {
    width: 32px;
    height: 32px;
}

.btn--icon.btn--lg {
    width: 48px;
    height: 48px;
}

/* ===== INPUTS ===== */

.input,
.select,
.textarea {
    width: 100%;
    padding: 10px 14px;
    font-size: var(--text-sm);
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

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

.input:hover,
.select:hover,
.textarea:hover {
    border-color: var(--text-tertiary);
}

.input:focus,
.select:focus,
.textarea:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
    outline: none;
}

.select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236B6780' 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 12px center;
    padding-right: 36px;
    cursor: pointer;
}

.textarea {
    min-height: 100px;
    resize: vertical;
    line-height: var(--line-height-normal);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

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

.form-group .form-hint {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
}

.form-group .form-error {
    font-size: var(--text-xs);
    color: var(--status-denied);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-md);
}

/* ===== CARDS ===== */

.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    transition: all var(--transition-fast);
}

.card:hover {
    border-color: var(--border-default);
}

.card--interactive {
    cursor: pointer;
}

.card--interactive:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-md);
}

.card__title {
    font-size: var(--text-base);
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
}

.card__subtitle {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-top: var(--space-xs);
}

/* ===== BADGES ===== */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    font-size: var(--text-xs);
    font-weight: var(--font-weight-semibold);
    border-radius: var(--radius-full);
    line-height: 1.4;
    white-space: nowrap;
}

.badge--success {
    background: rgba(16, 185, 129, 0.12);
    color: #34D399;
}

.badge--warning {
    background: rgba(245, 158, 11, 0.12);
    color: #FBBF24;
}

.badge--danger {
    background: rgba(239, 68, 68, 0.12);
    color: #F87171;
}

.badge--info {
    background: rgba(6, 182, 212, 0.12);
    color: #22D3EE;
}

.badge--purple {
    background: rgba(139, 92, 246, 0.12);
    color: #A78BFA;
}

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

/* Badge dot variant */
.badge--dot::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: var(--radius-full);
    background: currentColor;
    flex-shrink: 0;
}

/* ===== AVATARS ===== */

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    font-weight: var(--font-weight-semibold);
    color: #fff;
    flex-shrink: 0;
    user-select: none;
    overflow: hidden;
}

.avatar--sm {
    width: 32px;
    height: 32px;
    font-size: var(--text-xs);
}

.avatar--md {
    width: 40px;
    height: 40px;
    font-size: var(--text-sm);
}

.avatar--lg {
    width: 56px;
    height: 56px;
    font-size: var(--text-lg);
}

.avatar--xl {
    width: 80px;
    height: 80px;
    font-size: var(--text-2xl);
}

.avatar--cyan {
    background: var(--brand-cyan);
}

.avatar--purple {
    background: var(--brand-purple);
}

.avatar--magenta {
    background: var(--brand-magenta);
}

.avatar--green {
    background: var(--status-active);
}

.avatar--amber {
    background: var(--status-on-leave);
}

.avatar--red {
    background: var(--status-terminated);
}

.avatar--gradient {
    background: var(--brand-gradient);
}

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

.avatar-group {
    display: flex;
    align-items: center;
}

.avatar-group .avatar {
    border: 2px solid var(--bg-secondary);
    margin-left: -8px;
}

.avatar-group .avatar:first-child {
    margin-left: 0;
}

/* ===== SEARCH BAR ===== */

.search-bar {
    position: relative;
    width: 100%;
}

.search-bar__icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    pointer-events: none;
    width: 18px;
    height: 18px;
}

.search-bar .input {
    padding-left: 38px;
}

/* ===== DROPDOWN ===== */

.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown__menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 200px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 50;
    padding: var(--space-xs);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all var(--transition-fast);
}

.dropdown__menu.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown__menu--right {
    left: auto;
    right: 0;
}

.dropdown__item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.dropdown__item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.dropdown__item--danger {
    color: var(--status-terminated);
}

.dropdown__item--danger:hover {
    background: rgba(239, 68, 68, 0.1);
}

.dropdown__divider {
    height: 1px;
    background: var(--border-subtle);
    margin: var(--space-xs) 0;
}

/* ===== TABLE ===== */

.table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
}

.table {
    width: 100%;
    text-align: left;
}

.table th {
    padding: var(--space-sm) var(--space-md);
    font-size: var(--text-xs);
    font-weight: var(--font-weight-semibold);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-subtle);
    white-space: nowrap;
}

.table td {
    padding: var(--space-sm) var(--space-md);
    font-size: var(--text-sm);
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: middle;
}

.table tbody tr {
    transition: background var(--transition-fast);
}

.table tbody tr:hover {
    background: var(--bg-tertiary);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table--striped tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

.table__cell-flex {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

/* ===== EMPTY STATE ===== */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-2xl) var(--space-lg);
    text-align: center;
}

.empty-state__icon {
    width: 64px;
    height: 64px;
    color: var(--text-tertiary);
    margin-bottom: var(--space-md);
    opacity: 0.5;
}

.empty-state__title {
    font-size: var(--text-lg);
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
}

.empty-state__description {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    max-width: 360px;
    margin-bottom: var(--space-lg);
}

/* ===== TOASTS ===== */

.toast-container {
    position: fixed;
    bottom: var(--space-lg);
    right: var(--space-lg);
    display: flex;
    flex-direction: column-reverse;
    gap: var(--space-sm);
    z-index: 200;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    font-size: var(--text-sm);
    color: var(--text-primary);
    pointer-events: auto;
    animation: toast-in var(--transition-base) ease forwards;
    min-width: 300px;
    max-width: 420px;
}

.toast--success {
    border-left: 3px solid var(--status-active);
}

.toast--error {
    border-left: 3px solid var(--status-terminated);
}

.toast--warning {
    border-left: 3px solid var(--status-on-leave);
}

.toast--info {
    border-left: 3px solid var(--brand-cyan);
}

.toast__icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
}

.toast__message {
    flex: 1;
}

.toast__close {
    flex-shrink: 0;
    padding: var(--space-xs);
    color: var(--text-tertiary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.toast__close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.toast.removing {
    animation: toast-out var(--transition-fast) ease forwards;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateX(40px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toast-out {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(40px);
    }
}

/* ===== MODAL ===== */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 150;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-fast);
    padding: var(--space-lg);
}

.modal-overlay.open {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 560px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    transform: scale(0.95) translateY(10px);
    transition: transform var(--transition-base);
}

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

.modal--lg {
    max-width: 720px;
}

.modal--xl {
    max-width: 960px;
}

.modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
}

.modal__title {
    font-size: var(--text-lg);
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
}

.modal__close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-tertiary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.modal__close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.modal__body {
    padding: var(--space-lg);
    overflow-y: auto;
    flex: 1;
}

.modal__footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--border-subtle);
    flex-shrink: 0;
}

/* ===== TABS ===== */

.tabs {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    border-bottom: 1px solid var(--border-subtle);
    overflow-x: auto;
}

.tabs__item {
    padding: var(--space-sm) var(--space-md);
    font-size: var(--text-sm);
    font-weight: var(--font-weight-medium);
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    margin-bottom: -1px;
}

.tabs__item:hover {
    color: var(--text-primary);
}

.tabs__item.active {
    color: var(--brand-purple);
    border-bottom-color: var(--brand-purple);
}

/* ===== PROGRESS BAR ===== */

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-bar__fill {
    height: 100%;
    border-radius: var(--radius-full);
    background: var(--brand-gradient);
    transition: width var(--transition-slow);
    position: relative;
}

.progress-bar__fill::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
    animation: progress-shimmer 2s infinite;
}

.progress-bar--sm {
    height: 4px;
}

.progress-bar--lg {
    height: 12px;
}

@keyframes progress-shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* ===== STAT CARD ===== */

.stat-card {
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    padding: var(--space-lg);
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.stat-card:hover {
    border-color: var(--border-default);
    box-shadow: var(--shadow-sm);
}

.stat-card__icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-card__icon--purple {
    background: rgba(139, 92, 246, 0.12);
    color: var(--brand-purple);
}

.stat-card__icon--cyan {
    background: rgba(6, 182, 212, 0.12);
    color: var(--brand-cyan);
}

.stat-card__icon--magenta {
    background: rgba(217, 70, 239, 0.12);
    color: var(--brand-magenta);
}

.stat-card__icon--green {
    background: rgba(16, 185, 129, 0.12);
    color: var(--status-active);
}

.stat-card__icon--amber {
    background: rgba(245, 158, 11, 0.12);
    color: var(--status-on-leave);
}

.stat-card__content {
    flex: 1;
    min-width: 0;
}

.stat-card__value {
    font-size: var(--text-2xl);
    font-weight: var(--font-weight-bold);
    color: var(--text-primary);
    line-height: var(--line-height-tight);
}

.stat-card__label {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-top: var(--space-xs);
}

.stat-card__trend {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-size: var(--text-xs);
    font-weight: var(--font-weight-semibold);
    margin-top: var(--space-xs);
}

.stat-card__trend--up {
    color: var(--status-active);
}

.stat-card__trend--down {
    color: var(--status-terminated);
}

/* ===== APP SWITCHER ===== */

.app-switcher {
    position: relative;
}

.app-switcher__trigger {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition-fast);
    color: var(--text-secondary);
    font-size: var(--text-sm);
    font-weight: var(--font-weight-medium);
}

.app-switcher__trigger:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.app-switcher__trigger-icon {
    width: 24px;
    height: 24px;
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.app-switcher__dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    width: 240px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 120;
    padding: var(--space-xs);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all var(--transition-fast);
}

.app-switcher__dropdown.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.app-switcher__item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    color: var(--text-secondary);
    font-size: var(--text-sm);
}

.app-switcher__item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.app-switcher__item.active {
    background: rgba(139, 92, 246, 0.1);
    color: var(--brand-purple);
}

.app-switcher__item-icon {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-xs);
    font-weight: var(--font-weight-bold);
    color: #fff;
    flex-shrink: 0;
}

/* ===== TOOLTIP ===== */

[data-tooltip] {
    position: relative;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    padding: 4px 10px;
    font-size: var(--text-xs);
    font-weight: var(--font-weight-medium);
    color: var(--text-primary);
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-fast);
    z-index: 60;
    pointer-events: none;
}

[data-tooltip]:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* ===== SKELETON LOADER ===== */

.skeleton {
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    position: relative;
    overflow: hidden;
}

.skeleton::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.04), transparent);
    animation: skeleton-shimmer 1.5s infinite;
}

@keyframes skeleton-shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* ===== CHECKBOX / TOGGLE ===== */

.checkbox {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    cursor: pointer;
    font-size: var(--text-sm);
    color: var(--text-primary);
}

.checkbox__input {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-default);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.checkbox__input.checked {
    background: var(--brand-purple);
    border-color: var(--brand-purple);
}

.toggle {
    position: relative;
    width: 44px;
    height: 24px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.toggle.active {
    background: var(--brand-purple);
    border-color: var(--brand-purple);
}

.toggle__knob {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: var(--radius-full);
    background: #fff;
    transition: transform var(--transition-fast);
    box-shadow: var(--shadow-sm);
}

.toggle.active .toggle__knob {
    transform: translateX(20px);
}

/* ===== DIVIDER ===== */

.divider {
    height: 1px;
    background: var(--border-subtle);
    margin: var(--space-lg) 0;
}

.divider--sm {
    margin: var(--space-sm) 0;
}
