/* ============================================================
   Pulse UI Components
   ============================================================ */

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: 8px 20px;
    border: none;
    border-radius: var(--radius-pill);
    font-family: var(--font-family);
    font-size: 14px;
    font-weight: 700;
    line-height: 1.4;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
    user-select: none;
    outline: none;
}
.btn:focus-visible { box-shadow: 0 0 0 3px var(--accent-soft); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn--primary { background: var(--accent); color: var(--accent-text); }
.btn--primary:hover:not(:disabled) { background: var(--accent-hover); transform: translateY(-1px); }

.btn--outline { background: transparent; color: var(--text-primary); border: 1.5px solid var(--border-primary); }
.btn--outline:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }

.btn--ghost { background: transparent; color: var(--text-secondary); }
.btn--ghost:hover:not(:disabled) { color: var(--text-primary); background: var(--bg-hover); }

.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover:not(:disabled) { opacity: .9; }

.btn--icon { padding: 8px; border-radius: var(--radius-md); }
.btn--sm { padding: 6px 14px; font-size: 13px; }
.btn--lg { padding: 12px 28px; font-size: 15px; }
.btn--full { width: 100%; }

.btn--google { background: var(--bg-secondary); color: var(--text-primary); border: 1.5px solid var(--border-primary); }

.btn i[class^="iconoir-"] { font-size: var(--icon-size-sm); }
.btn--lg i[class^="iconoir-"] { font-size: var(--icon-size); }

/* --- Form Elements --- */
.form-group { margin-bottom: var(--space-md); }
.form-label {
    display: block;
    margin-bottom: var(--space-xs);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}
.form-input {
    width: 100%;
    padding: 10px 16px;
    background: var(--bg-input);
    border: 1.5px solid var(--border-primary);
    border-radius: var(--radius-md);
    font-family: var(--font-family);
    font-size: 14px;
    color: var(--text-primary);
    transition: border-color var(--transition);
    outline: none;
    box-sizing: border-box;
}
.form-input:focus { border-color: var(--accent); }
.form-input::placeholder { color: var(--text-tertiary); }
.form-input--xl { font-size: 28px; padding: 16px 20px; letter-spacing: 6px; font-weight: 800; text-align: center; border-radius: var(--radius-lg); }
.form-input--lg { font-size: 16px; padding: 14px 18px; }
.form-input--sm { padding: 6px 12px; font-size: 13px; }
.form-input--center { text-align: center; }

textarea.form-input { resize: vertical; min-height: 44px; }

/* --- Custom Select --- */
.pulse-select {
    position: relative;
    width: 100%;
}
.pulse-select__trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 10px 16px;
    background: var(--bg-input);
    border: 1.5px solid var(--border-primary);
    border-radius: var(--radius-md);
    font-family: var(--font-family);
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition);
    outline: none;
    box-sizing: border-box;
    gap: var(--space-sm);
}
.pulse-select__trigger:hover { border-color: var(--text-tertiary); }
.pulse-select__trigger:focus,
.pulse-select--open .pulse-select__trigger { border-color: var(--accent); }
.pulse-select__trigger-text { flex: 1; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pulse-select__arrow {
    font-size: 16px;
    color: var(--text-tertiary);
    transition: transform var(--transition);
    flex-shrink: 0;
}
.pulse-select--open .pulse-select__arrow { transform: rotate(180deg); }

.pulse-select__dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--bg-elevated);
    border: 1.5px solid var(--border-primary);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: var(--z-dropdown);
    max-height: 240px;
    overflow-y: auto;
    padding: var(--space-xs);
    opacity: 0;
    transform: translateY(-8px);
    pointer-events: none;
    transition: all var(--transition);
}
.pulse-select--open .pulse-select__dropdown {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}
.pulse-select__option {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    transition: background var(--transition-fast);
}
.pulse-select__option:hover { background: var(--bg-hover); }
.pulse-select__option--selected { background: var(--accent-soft); color: var(--accent); }
.pulse-select__option i { font-size: var(--icon-size-sm); color: var(--text-tertiary); }
.pulse-select__option--selected i { color: var(--accent); }

.pulse-select--sm .pulse-select__trigger { padding: 6px 12px; font-size: 13px; }
.pulse-select--sm .pulse-select__option { padding: 6px 10px; font-size: 12px; }

/* Hidden native select for form data */
.pulse-select select { position: absolute; opacity: 0; pointer-events: none; width: 0; height: 0; }

.form-error { display: block; margin-top: 4px; font-size: 12px; color: var(--danger); min-height: 16px; }

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

.form-link { color: var(--accent); font-size: 13px; text-decoration: none; font-weight: 700; }
.form-link:hover { text-decoration: underline; }

.form-checkbox {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
}
.form-checkbox input { accent-color: var(--accent); }

.form-toggle {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}
.form-toggle input { display: none; }
.form-toggle__switch {
    position: relative;
    width: 40px;
    height: 22px;
    background: var(--border-primary);
    border-radius: var(--radius-pill);
    transition: background var(--transition);
    flex-shrink: 0;
}
.form-toggle__switch::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    transition: transform var(--transition);
}
.form-toggle input:checked + .form-toggle__switch { background: var(--accent); }
.form-toggle input:checked + .form-toggle__switch::after { transform: translateX(18px); }

.form-color {
    width: 44px;
    height: 36px;
    border: 1.5px solid var(--border-primary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: none;
    padding: 2px;
}

.form-range { width: 100%; accent-color: var(--accent); height: 6px; }

/* --- Cards --- */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-secondary);
    border-radius: var(--radius-xl);
    padding: var(--space-lg);
    transition: all var(--transition);
}
.card:hover { border-color: var(--border-primary); box-shadow: var(--shadow-sm); }

.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-secondary);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    text-align: center;
}
.stat-card__value { font-size: 32px; font-weight: 900; color: var(--accent); line-height: 1.2; }
.stat-card__label { font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-top: var(--space-xs); }

/* --- Modal --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    backdrop-filter: blur(4px);
    z-index: var(--z-modal);
    animation: fadeIn var(--transition);
}
.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: calc(var(--z-modal) + 1);
    width: 90%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp var(--transition-slow);
}
.modal__content {
    background: var(--bg-elevated);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-xl);
    overflow: hidden;
}
.modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-lg) var(--space-lg) 0;
}
.modal__title { font-size: 18px; font-weight: 800; color: var(--text-primary); }
.modal__close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}
.modal__body { padding: var(--space-lg); }
.modal__footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-sm);
    padding: 0 var(--space-lg) var(--space-lg);
}

/* --- Toast --- */
.toast-container {
    position: fixed;
    top: var(--space-lg);
    right: var(--space-lg);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}
.toast {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: 12px 20px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    animation: slideInRight var(--transition-slow);
    min-width: 280px;
}
.toast--success { border-left: 3px solid var(--success); }
.toast--error   { border-left: 3px solid var(--danger); }
.toast--warning { border-left: 3px solid var(--warning); }
.toast--info    { border-left: 3px solid var(--info); }

/* --- Dropdown --- */
.dropdown {
    position: absolute;
    right: var(--space-md);
    top: 56px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: var(--z-dropdown);
    min-width: 180px;
    padding: var(--space-xs);
    animation: fadeIn var(--transition-fast);
}
.dropdown__item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    width: 100%;
    padding: 8px 14px;
    background: none;
    border: none;
    text-align: left;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-family: var(--font-family);
}
.dropdown__item i { font-size: var(--icon-size-sm); color: var(--text-tertiary); }
.dropdown__item:hover { background: var(--bg-hover); }
.dropdown__item--danger { color: var(--danger); }
.dropdown__divider { border: none; border-top: 1px solid var(--border-secondary); margin: var(--space-xs) 0; }

/* --- Tabs --- */
.tab-group { display: flex; gap: 2px; background: var(--bg-tertiary); border-radius: var(--radius-pill); padding: 3px; }
.tab-group__tab {
    padding: 6px 16px;
    border: none;
    background: transparent;
    border-radius: var(--radius-pill);
    font-family: var(--font-family);
    font-size: 13px;
    font-weight: 700;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}
.tab-group__tab:hover { color: var(--text-primary); }
.tab-group__tab--active { background: var(--bg-secondary); color: var(--text-primary); box-shadow: var(--shadow-sm); }
.tab-group--sm .tab-group__tab { padding: 5px 12px; font-size: 12px; }

/* --- Avatar --- */
.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 14px;
    color: var(--accent-text);
    flex-shrink: 0;
}
.avatar--sm { width: 32px; height: 32px; font-size: 12px; }
.avatar--lg { width: 48px; height: 48px; font-size: 18px; }

/* --- Search Box --- */
.search-box { position: relative; width: 100%; max-width: 400px; }
.search-box__icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    font-size: var(--icon-size-sm);
}
.search-box__input {
    width: 100%;
    padding: 8px 12px 8px 38px;
    background: var(--bg-tertiary);
    border: 1.5px solid transparent;
    border-radius: var(--radius-pill);
    font-family: var(--font-family);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    outline: none;
    transition: all var(--transition);
    box-sizing: border-box;
}
.search-box__input:focus { border-color: var(--accent); background: var(--bg-input); }

/* --- Skeleton loader --- */
.skeleton-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: var(--space-md); }
.skeleton-card {
    height: 160px;
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    animation: pulse 1.5s infinite;
}

/* --- Spinner --- */
.pulse-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulseScale 1.2s infinite;
}

/* --- Empty State --- */
.empty-state { text-align: center; padding: var(--space-3xl) var(--space-lg); }
.empty-state__icon { font-size: 48px; margin-bottom: var(--space-md); color: var(--text-tertiary); }
.empty-state__title { font-size: 20px; font-weight: 800; color: var(--text-primary); margin-bottom: var(--space-sm); }
.empty-state__text { font-size: 14px; color: var(--text-secondary); margin-bottom: var(--space-lg); }

/* --- Pulse dot --- */
.pulse-dot { width: 10px; height: 10px; background: var(--accent); border-radius: 50%; animation: pulseScale 1.5s infinite; }
.pulse-dot--lg { width: 16px; height: 16px; }

/* --- Slide type grid --- */
.slide-type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: var(--space-sm); }
.slide-type-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-md);
    background: var(--bg-tertiary);
    border: 2px solid transparent;
    border-radius: var(--radius-lg);
    cursor: pointer;
    font-family: var(--font-family);
    font-size: 12px;
    font-weight: 700;
    color: var(--text-primary);
    transition: all var(--transition);
}
.slide-type-btn:hover { border-color: var(--border-primary); }
.slide-type-btn--active { border-color: var(--accent); background: var(--accent-soft); }
.slide-type-btn__icon { font-size: 26px; color: var(--accent); }

/* --- Auth divider --- */
.auth-divider {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin: var(--space-lg) 0;
    color: var(--text-tertiary);
    font-size: 13px;
    font-weight: 600;
}
.auth-divider::before,
.auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--border-primary); }

/* --- Presentation Card --- */
.pres-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-secondary);
    border-radius: var(--radius-xl);
    padding: var(--space-lg);
    transition: all var(--transition);
    cursor: pointer;
    position: relative;
}
.pres-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.pres-card__header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: var(--space-md); }
.pres-card__title { font-size: 16px; font-weight: 800; color: var(--text-primary); margin: 0; }
.pres-card__status {
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
}
.pres-card__status--draft { background: var(--bg-tertiary); color: var(--text-secondary); }
.pres-card__status--active { background: var(--accent-soft); color: var(--accent); }
.pres-card__status--archived { background: var(--danger-soft); color: var(--danger); }
.pres-card__meta { display: flex; gap: var(--space-lg); font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: var(--space-md); }
.pres-card__actions { display: flex; gap: 4px; }
.pres-card__actions .btn--icon {
    width: 34px;
    height: 34px;
    padding: 0;
    font-size: 16px;
    border-radius: var(--radius-md);
}

/* --- Onboarding option --- */
.onboarding-option {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    width: 100%;
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-tertiary);
    border: 2px solid transparent;
    border-radius: var(--radius-lg);
    cursor: pointer;
    font-family: var(--font-family);
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    transition: all var(--transition);
    text-align: left;
}
.onboarding-option:hover { border-color: var(--border-primary); }
.onboarding-option--selected { border-color: var(--accent); background: var(--accent-soft); }
.onboarding-option__icon { font-size: 24px; color: var(--accent); width: 32px; text-align: center; }

/* --- Option editor --- */
.option-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-sm);
    padding: var(--space-sm);
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}
.option-item__color { width: 8px; height: 32px; border-radius: 4px; flex-shrink: 0; }
.option-item__input {
    flex: 1;
    padding: 8px 12px;
    background: transparent;
    border: none;
    font-family: var(--font-family);
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    outline: none;
}
.option-item__correct { display: flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; color: var(--text-secondary); cursor: pointer; }
.option-item__correct input { accent-color: var(--accent); }
.option-item__delete {
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 4px;
    font-size: 18px;
    line-height: 1;
}
.option-item__delete:hover { color: var(--danger); }

/* --- Q&A --- */
.qa-list { display: flex; flex-direction: column; gap: var(--space-sm); margin-top: var(--space-md); }
.qa-item { display: flex; gap: var(--space-md); padding: var(--space-md); background: var(--bg-tertiary); border-radius: var(--radius-md); }
.qa-item__vote { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.qa-item__vote-btn { background: none; border: none; cursor: pointer; font-size: 18px; color: var(--text-tertiary); padding: 2px; }
.qa-item__vote-btn:hover { color: var(--accent); }
.qa-item__count { font-size: 13px; font-weight: 800; color: var(--accent); }
.qa-item__text { flex: 1; font-size: 14px; color: var(--text-primary); }
.qa-item__author { font-size: 12px; color: var(--text-tertiary); margin-top: 4px; }

/* --- Participant option btn --- */
.participant-opt {
    width: 100%;
    padding: 14px 20px;
    background: var(--bg-tertiary);
    border: 2px solid transparent;
    border-radius: var(--radius-lg);
    cursor: pointer;
    font-family: var(--font-family);
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    transition: all var(--transition);
    text-align: left;
    display: flex;
    align-items: center;
    gap: var(--space-md);
}
.participant-opt:hover { border-color: var(--border-primary); }
.participant-opt--selected { border-color: var(--accent); background: var(--accent-soft); }
.participant-opt__marker {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border-primary);
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}
.participant-opt--selected .participant-opt__marker { border-color: var(--accent); background: var(--accent); }

/* --- Reaction / Check-in --- */
.reaction-grid, .checkin-grid { display: flex; flex-wrap: wrap; gap: var(--space-md); justify-content: center; }
.reaction-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-xs);
    font-size: 14px;
    font-weight: 700;
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-tertiary);
    border: 2px solid transparent;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition);
    color: var(--text-primary);
    font-family: var(--font-family);
}
.reaction-btn i { font-size: 28px; color: var(--accent); }
.reaction-btn:hover, .reaction-btn--selected { border-color: var(--accent); transform: scale(1.05); }

.checkin-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-lg);
    background: var(--bg-tertiary);
    border: 2px solid transparent;
    border-radius: var(--radius-lg);
    cursor: pointer;
    font-family: var(--font-family);
    color: var(--text-primary);
    transition: all var(--transition);
}
.checkin-btn i { font-size: 32px; color: var(--accent); }
.checkin-btn span { font-size: 13px; font-weight: 700; }
.checkin-btn:hover, .checkin-btn--selected { border-color: var(--accent); }

/* --- Rankings --- */
.ranking-list { display: flex; flex-direction: column; gap: var(--space-sm); }
.ranking-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: 10px var(--space-md);
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    cursor: grab;
    transition: all var(--transition);
}
.ranking-item:active { cursor: grabbing; }
.ranking-item__handle { color: var(--text-tertiary); }
.ranking-item__text { flex: 1; font-size: 14px; font-weight: 600; color: var(--text-primary); }
.ranking-item__pos { font-size: 13px; font-weight: 800; color: var(--accent); min-width: 24px; text-align: center; }

/* --- Settings --- */
.settings-section { margin-bottom: var(--space-md); }
.settings-divider { border: none; border-top: 1px solid var(--border-secondary); margin: var(--space-lg) 0; }

/* --- Tooltip --- */
[data-tooltip] { position: relative; }
[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) scale(.9);
    padding: 5px 10px;
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity var(--transition-fast), transform var(--transition-fast);
    z-index: var(--z-dropdown);
    box-shadow: var(--shadow-md);
}
[data-tooltip]::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 3px);
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--border-primary);
    pointer-events: none;
    opacity: 0;
    transition: opacity var(--transition-fast);
    z-index: var(--z-dropdown);
}
[data-tooltip]:hover::after {
    opacity: 1;
    transform: translateX(-50%) scale(1);
}
[data-tooltip]:hover::before { opacity: 1; }

/* --- Animations --- */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translate(-50%, -46%); } to { opacity: 1; transform: translate(-50%, -50%); } }
@keyframes slideInRight { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .5; } }
@keyframes pulseScale { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.15); opacity: .7; } }
@keyframes barGrow { from { width: 0; } }
