/**
 * JexHRAI 公司切換器樣式（Company Context Switcher）
 * ========================================================
 * Talent Hub v1.7：多公司人才流動的 UI 樣式
 * 採用 Material Design 3 設計語言
 * ========================================================
 */

/* ======== 容器 ======== */
.jexhrai-company-switcher {
    position: relative;
    display: inline-flex;
    align-items: center;
}

/* ======== 觸發按鈕 ======== */
.jexhrai-company-trigger {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--md-sys-color-surface-container);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-shape-corner-medium);
    cursor: pointer;
    transition: all 0.2s var(--md-sys-motion-easing-standard);
    min-width: 160px;
    max-width: 280px;
}

.jexhrai-company-trigger:hover {
    background: var(--md-sys-color-surface-container-high);
    border-color: var(--md-sys-color-outline);
}

.jexhrai-company-trigger:focus {
    outline: 2px solid var(--md-sys-color-primary);
    outline-offset: 2px;
}

/* 載入狀態 */
.jexhrai-company-switcher.is-loading .jexhrai-company-trigger {
    opacity: 0.7;
    pointer-events: none;
}

/* ======== 圖示 ======== */
.jexhrai-company-trigger-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: var(--md-sys-color-primary-container);
    border-radius: var(--md-sys-shape-corner-small);
    color: var(--md-sys-color-on-primary-container);
}

.jexhrai-company-trigger-icon .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

/* ======== 內容區 ======== */
.jexhrai-company-trigger-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    overflow: hidden;
    text-align: left;
}

.jexhrai-company-trigger-label {
    font-size: 0.65rem;
    color: var(--md-sys-color-on-surface-variant);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    line-height: 1;
}

.jexhrai-company-trigger-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--md-sys-color-on-surface);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    line-height: 1.3;
}

/* ======== 箭頭 ======== */
.jexhrai-company-trigger-arrow {
    display: flex;
    align-items: center;
    color: var(--md-sys-color-on-surface-variant);
    transition: transform 0.2s ease;
}

.jexhrai-company-trigger-arrow .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
}

.jexhrai-company-switcher.is-open .jexhrai-company-trigger-arrow {
    transform: rotate(180deg);
}

/* ======== 下拉選單 ======== */
.jexhrai-company-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    min-width: 280px;
    max-width: 360px;
    background: var(--md-sys-color-surface);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-shape-corner-large);
    box-shadow: var(--md-sys-elevation-3);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px) scale(0.95);
    transition: all 0.2s var(--md-sys-motion-easing-emphasized);
    z-index: 9999;
    overflow: hidden;
}

.jexhrai-company-switcher.is-open .jexhrai-company-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* ======== 下拉選單標題 ======== */
.jexhrai-company-dropdown-header {
    padding: 0.75rem 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--md-sys-color-on-surface-variant);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    background: var(--md-sys-color-surface-container-low);
}

/* ======== 選單列表 ======== */
.jexhrai-company-dropdown-list {
    max-height: 320px;
    overflow-y: auto;
    padding: 0.5rem 0;
}

/* ======== 選項 ======== */
.jexhrai-company-dropdown-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: background 0.15s ease;
}

.jexhrai-company-dropdown-item:hover {
    background: var(--md-sys-color-surface-container-high);
}

.jexhrai-company-dropdown-item.is-active {
    background: var(--md-sys-color-primary-container);
}

.jexhrai-company-dropdown-item.is-active:hover {
    background: color-mix(in srgb, var(--md-sys-color-primary-container), var(--md-sys-color-primary) 10%);
}

/* ======== 選項主內容 ======== */
.jexhrai-company-item-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    overflow: hidden;
}

.jexhrai-company-item-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--md-sys-color-on-surface);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.jexhrai-company-item-job {
    font-size: 0.75rem;
    color: var(--md-sys-color-on-surface-variant);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ======== 選項元資料區 ======== */
.jexhrai-company-item-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* ======== 角色徽章 ======== */
.jexhrai-company-item-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.5rem;
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-radius: var(--md-sys-shape-corner-full);
    background: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
}

.jexhrai-company-item-badge.role-owner {
    background: var(--md-sys-color-tertiary-container);
    color: var(--md-sys-color-on-tertiary-container);
}

.jexhrai-company-item-badge.role-admin {
    background: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
}

.jexhrai-company-item-badge.role-hr {
    background: var(--md-sys-color-info-container);
    color: var(--md-sys-color-on-info-container);
}

.jexhrai-company-item-badge.role-manager {
    background: var(--md-sys-color-success-container);
    color: var(--md-sys-color-on-success-container);
}

/* ======== 狀態徽章 ======== */
.jexhrai-company-item-status {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.375rem;
    font-size: 0.625rem;
    border-radius: var(--md-sys-shape-corner-small);
}

.jexhrai-company-item-status.status-active {
    background: var(--md-sys-color-success-container);
    color: var(--md-sys-color-on-success-container);
}

.jexhrai-company-item-status.status-probation {
    background: var(--md-sys-color-warning-container);
    color: var(--md-sys-color-on-warning-container);
}

.jexhrai-company-item-status.status-leave {
    background: var(--md-sys-color-warning-container);
    color: var(--md-sys-color-on-warning-container);
}

.jexhrai-company-item-status.status-resigned {
    background: var(--md-sys-color-error-container);
    color: var(--md-sys-color-on-error-container);
}

/* ======== 勾選圖示 ======== */
.jexhrai-company-item-check {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: var(--md-sys-color-primary);
    border-radius: 50%;
    color: var(--md-sys-color-on-primary);
}

.jexhrai-company-item-check .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
}

/* ======== 空狀態 ======== */
.jexhrai-company-dropdown-empty,
.jexhrai-company-dropdown-error {
    padding: 1.5rem 1rem;
    text-align: center;
    color: var(--md-sys-color-on-surface-variant);
    font-size: 0.875rem;
}

.jexhrai-company-dropdown-error {
    color: var(--md-sys-color-error);
}

.jexhrai-company-dropdown-error .dashicons {
    margin-right: 0.25rem;
}

/* ======== 簡易 Toast ======== */
.jexhrai-simple-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(16px);
    padding: 0.75rem 1.5rem;
    background: var(--md-sys-color-inverse-surface);
    color: var(--md-sys-color-inverse-on-surface);
    font-size: 0.875rem;
    border-radius: var(--md-sys-shape-corner-small);
    box-shadow: var(--md-sys-elevation-3);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 99999;
}

.jexhrai-simple-toast.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.jexhrai-simple-toast.is-error {
    background: var(--md-sys-color-error-container);
    color: var(--md-sys-color-on-error-container);
}

/* ======== 響應式 ======== */
@media (max-width: 600px) {
    .jexhrai-company-trigger {
        min-width: 120px;
        max-width: 180px;
        padding: 0.375rem 0.5rem;
    }

    .jexhrai-company-trigger-label {
        display: none;
    }

    .jexhrai-company-trigger-icon {
        width: 24px;
        height: 24px;
    }

    .jexhrai-company-dropdown {
        min-width: 240px;
        max-width: calc(100vw - 32px);
        left: auto;
        right: 0;
    }
}
