/**
 * AUTOCORE360 Admin Panel - Miscellaneous Components
 * WhatsApp editor, BBCode editor, progress bars, avatars, micro-interactions
 */

/* ============ EMPTY STATES ============ */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 3rem 2rem;
    min-height: 200px;
}

.empty-state__icon {
    width: var(--icon-xl, 3.5rem);
    height: var(--icon-xl, 3.5rem);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(var(--text-muted-rgb, 148, 163, 184), 0.1);
    color: var(--text-muted);
    font-size: 1.5rem;
    margin-bottom: 1.25rem;
    opacity: 0.6;
}

.empty-state__title {
    font-size: var(--text-lg, 1.125rem);
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.empty-state__text {
    font-size: var(--text-sm, 0.875rem);
    color: var(--text-muted);
    max-width: 300px;
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.empty-state__action {
    margin-top: 0.5rem;
}

/* Empty state variants */
.empty-state--compact {
    padding: 2rem 1.5rem;
    min-height: 150px;
}

.empty-state--compact .empty-state__icon {
    width: var(--icon-lg, 3rem);
    height: var(--icon-lg, 3rem);
    font-size: 1.25rem;
    margin-bottom: 1rem;
}

.empty-state--compact .empty-state__title {
    font-size: var(--text-base, 1rem);
}

.empty-state--compact .empty-state__text {
    font-size: var(--text-xs, 0.75rem);
    margin-bottom: 1rem;
}

/* Inline empty state (for tables/lists) */
.empty-state--inline {
    flex-direction: row;
    gap: 1rem;
    text-align: left;
    padding: 1.5rem;
    min-height: auto;
}

.empty-state--inline .empty-state__icon {
    margin-bottom: 0;
}

.empty-state--inline .empty-state__content {
    flex: 1;
}

.empty-state--inline .empty-state__text {
    margin-bottom: 0;
}

/* ============ WHATSAPP MESSAGE EDITOR ============ */
.wa-message-editor {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    overflow: hidden;
}

.wa-message-content {
    padding: 0.75rem 1rem;
    min-height: 80px;
    font-size: 0.875rem;
    line-height: 1.6;
    color: var(--text);
    outline: none;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.wa-message-content:focus {
    background: var(--background);
}

.wa-placeholder {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.125rem 0.625rem;
    margin: 0 0.125rem;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 0.75rem;
    cursor: grab;
    user-select: none;
    vertical-align: middle;
    line-height: 1.4;
    transition: all var(--transition-speed) ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
    position: relative;
}

.wa-placeholder::before {
    content: "\f023"; /* lock icon */
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
    font-size: 0.625rem;
    opacity: 0.7;
}

.wa-placeholder:hover {
    transform: scale(1.05);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
}

.wa-placeholder:active {
    cursor: grabbing;
    transform: scale(0.98);
}

.wa-placeholder[draggable="true"]:hover {
    cursor: grab;
}

.wa-placeholder[draggable="true"]:active {
    cursor: grabbing;
}

.wa-placeholder[data-placeholder="product"] {
    background: linear-gradient(135deg, #667eea, #764ba2);
}

.wa-placeholder[data-placeholder="tokens"] {
    background: linear-gradient(135deg, #f5af19, #f12711);
}

.wa-placeholder[data-placeholder="hwid"] {
    background: linear-gradient(135deg, #f093fb, #f5576c);
}

.wa-placeholder[data-placeholder="customer_name"] {
    background: linear-gradient(135deg, #11998e, #38ef7d);
}

.wa-placeholder.dragging {
    opacity: 0.5;
    transform: scale(1.1);
}

.wa-placeholder-preview {
    display: inline-flex;
    padding: 0.125rem 0.5rem;
    font-size: 0.6875rem;
    font-weight: 600;
    border-radius: 0.5rem;
    color: white;
    vertical-align: middle;
}

.wa-placeholder-preview:first-of-type {
    background: linear-gradient(135deg, #f5af19, #f12711);
}

.wa-placeholder-preview:last-of-type {
    background: linear-gradient(135deg, #11998e, #38ef7d);
}

/* WhatsApp Chat Preview */
.wa-chat-preview {
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    max-width: 100%;
}

.wa-chat-header {
    background: linear-gradient(135deg, #075E54, #128C7E);
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.wa-chat-avatar {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.875rem;
}

.wa-chat-contact {
    flex: 1;
}

.wa-chat-name {
    color: white;
    font-weight: 600;
    font-size: 0.9375rem;
}

.wa-chat-status {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.75rem;
}

.wa-chat-body {
    background: #ECE5DD;
    padding: 1rem;
    min-height: 120px;
    position: relative;
}

.wa-chat-bg {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23000000' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    opacity: 0.5;
}

.wa-chat-messages {
    position: relative;
    z-index: 1;
}

.wa-message {
    max-width: 85%;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    line-height: 1.4;
    position: relative;
    margin-bottom: 0.5rem;
    box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13);
}

.wa-message-sent {
    background: #DCF8C6;
    margin-left: auto;
    border-bottom-right-radius: 0;
}

.wa-message-sent::after {
    content: '';
    position: absolute;
    right: -8px;
    bottom: 0;
    width: 0;
    height: 0;
    border: 8px solid transparent;
    border-left-color: #DCF8C6;
    border-bottom-color: #DCF8C6;
}

.wa-message-text {
    color: #303030;
    word-wrap: break-word;
}

.wa-message-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.25rem;
    margin-top: 0.25rem;
}

.wa-message-time {
    font-size: 0.6875rem;
    color: rgba(0, 0, 0, 0.45);
}

.wa-message-status {
    color: #53bdeb;
    font-size: 0.75rem;
}

/* Dark mode WhatsApp preview */
[data-theme="dark"] .wa-chat-body {
    background: #0b141a;
}

[data-theme="dark"] .wa-chat-bg {
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.02'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

[data-theme="dark"] .wa-message-sent {
    background: #005c4b;
}

[data-theme="dark"] .wa-message-sent::after {
    border-left-color: #005c4b;
    border-bottom-color: #005c4b;
}

[data-theme="dark"] .wa-message-text {
    color: #e9edef;
}

[data-theme="dark"] .wa-message-time {
    color: rgba(255, 255, 255, 0.6);
}

/* ============ WHATSAPP NUMBERS LIST ============ */
.whatsapp-numbers-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.whatsapp-number-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.whatsapp-number-item .wa-label-input {
    width: 120px;
    flex-shrink: 0;
}

.whatsapp-number-item .wa-number-input {
    flex: 1;
}

.whatsapp-number-item .btn-remove-wa {
    padding: 0.25rem 0.5rem;
    color: var(--danger);
    background: transparent;
    border: none;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.whatsapp-number-item .btn-remove-wa:hover {
    opacity: 1;
}

.whatsapp-number-item:first-child .btn-remove-wa {
    visibility: hidden;
}

/* ============ PROGRESS BAR ============ */
.progress {
    height: 0.5rem;
    background: var(--border);
    border-radius: 1rem;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--primary-gradient);
    border-radius: 1rem;
    transition: width var(--transition-speed) ease;
}

.progress-bar.success {
    background: linear-gradient(135deg, var(--success), var(--success-dark));
}

.progress-bar.danger {
    background: linear-gradient(135deg, var(--danger), var(--danger-dark));
}

.progress-bar.warning {
    background: linear-gradient(135deg, var(--warning), var(--warning-dark));
}

/* ============ AVATARS ============ */
.avatar {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 0.875rem;
}

.avatar.sm {
    width: 2rem;
    height: 2rem;
    font-size: 0.75rem;
}

.avatar.lg {
    width: 3.5rem;
    height: 3.5rem;
    font-size: 1.125rem;
}

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

/* ============ BBCODE EDITOR ============ */
.bbcode-editor {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface);
}

.bbcode-toolbar {
    display: flex;
    gap: 2px;
    padding: 8px;
    background: var(--background);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.bbcode-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    transition: all 0.15s;
}

.bbcode-btn:hover {
    background: var(--surface-hover);
    color: var(--primary);
}

.bbcode-btn.active {
    background: var(--primary);
    color: white;
}

.bbcode-divider {
    width: 1px;
    height: 24px;
    background: var(--border);
    margin: 0 6px;
    align-self: center;
}

.bbcode-content {
    position: relative;
}

.bbcode-textarea {
    border: none !important;
    border-radius: 0 !important;
    min-height: 120px;
    resize: vertical;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 13px;
    line-height: 1.6;
}

.bbcode-textarea:focus {
    box-shadow: none !important;
}

.bbcode-preview {
    padding: 16px;
    min-height: 120px;
    background: var(--surface);
    font-size: 13px;
    line-height: 1.7;
    color: var(--text);
}

.bbcode-preview-content {
    max-height: 300px;
    overflow-y: auto;
}

.bbcode-preview-content p {
    margin-bottom: 10px;
}

.bbcode-preview-content p:last-child {
    margin-bottom: 0;
}

.bbcode-preview-content strong,
.bbcode-preview-content b {
    color: var(--text);
    font-weight: 600;
}

.bbcode-preview-content a {
    color: var(--primary);
}

.bbcode-preview-content code {
    background: var(--background);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Consolas', monospace;
    font-size: 12px;
}

.bbcode-preview-content ul {
    margin: 8px 0;
    padding-left: 20px;
}

.bbcode-preview-content li {
    margin-bottom: 4px;
}

/* ============ COMMAND PALETTE ============ */
.command-palette-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 12vh;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.command-palette-overlay.active {
    opacity: 1;
}

.command-palette {
    width: 90%;
    max-width: 560px;
    background: var(--surface);
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.05);
    overflow: hidden;
    transform: scale(0.95) translateY(-20px);
    transition: transform 0.2s ease;
}

.command-palette-overlay.active .command-palette {
    transform: scale(1) translateY(0);
}

.command-palette__header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: var(--background);
}

.command-palette__header i {
    color: var(--text-muted);
    font-size: 1rem;
}

.command-palette__input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 1rem;
    color: var(--text);
    outline: none;
    font-family: inherit;
}

.command-palette__input::placeholder {
    color: var(--text-muted);
}

.command-palette__results {
    max-height: 400px;
    overflow-y: auto;
    padding: 0.5rem;
}

.command-palette__item {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    color: var(--text);
    text-decoration: none;
    transition: all 0.15s ease;
    cursor: pointer;
}

.command-palette__item i {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(59, 91, 219, 0.1), rgba(92, 124, 250, 0.1));
    color: var(--primary);
    font-size: 0.9rem;
    flex-shrink: 0;
    transition: all 0.15s ease;
}

.command-palette__item span {
    font-size: 0.9375rem;
    font-weight: 500;
}

.command-palette__item:hover,
.command-palette__item.selected {
    background: linear-gradient(135deg, rgba(59, 91, 219, 0.1), rgba(92, 124, 250, 0.08));
}

.command-palette__item.selected i {
    background: linear-gradient(135deg, #3B5BDB, #5c7cfa);
    color: #fff;
    box-shadow: 0 4px 12px rgba(59, 91, 219, 0.3);
}

.command-palette__item.selected span {
    color: var(--primary);
}

.command-palette__footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border);
    background: var(--background);
}

.command-palette__footer span {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.command-palette__footer kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5rem;
    height: 1.375rem;
    padding: 0 0.375rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    border-radius: 4px;
    font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

/* Dark mode enhancements */
[data-theme="dark"] .command-palette {
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .command-palette__item i {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(139, 92, 246, 0.15));
}

[data-theme="dark"] .command-palette__item:hover,
[data-theme="dark"] .command-palette__item.selected {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(139, 92, 246, 0.1));
}

/* ============ KEYBOARD SHORTCUTS MODAL ============ */
.keyboard-shortcuts-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeIn 0.2s ease;
}

.keyboard-shortcuts-modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    width: 90%;
    max-width: 480px;
    max-height: 80vh;
    overflow: hidden;
    animation: scaleIn 0.2s ease;
}

.keyboard-shortcuts-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: var(--background);
}

.keyboard-shortcuts-header h3 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.keyboard-shortcuts-header h3 i {
    color: var(--primary);
    font-size: 1.25rem;
}

.keyboard-shortcuts-content {
    padding: 1.25rem 1.5rem;
    max-height: 60vh;
    overflow-y: auto;
}

.shortcut-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

.shortcut-item:last-child {
    border-bottom: none;
}

.shortcut-item span {
    font-size: 0.875rem;
    color: var(--text);
}

.shortcut-item kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    height: 1.75rem;
    padding: 0 0.5rem;
    background: var(--background);
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    border-radius: var(--radius);
    font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    white-space: nowrap;
}

/* ============ KEYBOARD NAVIGATION ============ */

/* Keyboard shortcut badges */
.kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5rem;
    height: 1.5rem;
    padding: 0 0.375rem;
    background: var(--surface-hover);
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    border-radius: var(--radius-sm);
    font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--text-muted);
    white-space: nowrap;
}

.kbd-sm {
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 0.25rem;
    font-size: 0.625rem;
}

.kbd-lg {
    min-width: 2rem;
    height: 2rem;
    padding: 0 0.5rem;
    font-size: 0.8125rem;
}

/* Keyboard shortcut group */
.kbd-group {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.kbd-group-separator {
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* Keyboard hints tooltip */
.kbd-hint {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    color: var(--text-muted);
}

/* Keyboard shortcuts panel */
.kbd-shortcuts-panel {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    padding: 1rem;
    z-index: 1000;
    min-width: 280px;
    max-width: 360px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all var(--transition-fast) var(--ease-out);
}

.kbd-shortcuts-panel.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.kbd-shortcuts-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.kbd-shortcuts-title {
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--text);
}

.kbd-shortcuts-close {
    width: 1.5rem;
    height: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast) ease;
}

.kbd-shortcuts-close:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.kbd-shortcuts-list {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
}

.kbd-shortcut-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.kbd-shortcut-label {
    font-size: 0.8125rem;
    color: var(--text);
}

.kbd-shortcut-keys {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-shrink: 0;
}

/* Keyboard section divider */
.kbd-shortcuts-section {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.kbd-shortcuts-section-title {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

/* Focus visible styles for accessibility */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.btn:focus-visible,
.form-control:focus-visible,
.nav-item:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(var(--primary-rgb, 37, 99, 235), 0.15);
}

/* Skip link for keyboard navigation */
.skip-link {
    position: fixed;
    top: -100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.75rem 1.5rem;
    background: var(--primary);
    color: white;
    font-weight: 500;
    border-radius: var(--radius-md);
    z-index: 10000;
    text-decoration: none;
    transition: top var(--transition-fast) ease;
}

.skip-link:focus {
    top: 1rem;
}

/* Focusable list items */
.focusable-list [role="option"],
.focusable-list [role="menuitem"] {
    cursor: pointer;
    transition: background var(--transition-fast) ease;
}

.focusable-list [role="option"]:focus,
.focusable-list [role="menuitem"]:focus {
    outline: none;
    background: var(--surface-hover);
}

.focusable-list [role="option"][aria-selected="true"],
.focusable-list [role="menuitem"][aria-current="true"] {
    background: rgba(var(--primary-rgb, 37, 99, 235), 0.1);
    color: var(--primary);
}

/* Keyboard navigation indicator */
.keyboard-nav-active *:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* ============ ANIMATIONS & MICRO-INTERACTIONS ============ */

/* Fade animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInLeft {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Scale animations */
@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes scaleOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.95);
    }
}

@keyframes popIn {
    0% {
        opacity: 0;
        transform: scale(0.8);
    }
    70% {
        transform: scale(1.05);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Bounce animation */
@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

/* Shake animation for errors */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
    20%, 40%, 60%, 80% { transform: translateX(4px); }
}

/* Spin animation */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Pulse animation */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Shimmer effect */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* Attention pulse */
@keyframes attentionPulse {
    0% { box-shadow: 0 0 0 0 rgba(var(--primary-rgb, 37, 99, 235), 0.5); }
    70% { box-shadow: 0 0 0 10px rgba(var(--primary-rgb, 37, 99, 235), 0); }
    100% { box-shadow: 0 0 0 0 rgba(var(--primary-rgb, 37, 99, 235), 0); }
}

/* Animation utility classes */
.animate-fade-in { animation: fadeIn var(--transition-normal) ease forwards; }
.animate-fade-in-up { animation: fadeInUp var(--transition-normal) var(--ease-out) forwards; }
.animate-fade-in-down { animation: fadeInDown var(--transition-normal) var(--ease-out) forwards; }
.animate-fade-in-left { animation: fadeInLeft var(--transition-normal) var(--ease-out) forwards; }
.animate-fade-in-right { animation: fadeInRight var(--transition-normal) var(--ease-out) forwards; }
.animate-scale-in { animation: scaleIn var(--transition-normal) var(--ease-out) forwards; }
.animate-pop-in { animation: popIn var(--transition-normal) var(--ease-out) forwards; }
.animate-bounce { animation: bounce 0.5s ease infinite; }
.animate-shake { animation: shake 0.5s ease; }
.animate-spin { animation: spin 1s linear infinite; }
.animate-pulse { animation: pulse 2s ease infinite; }
.animate-attention { animation: attentionPulse 2s infinite; }

/* Animation delays */
.animate-delay-100 { animation-delay: 100ms; }
.animate-delay-200 { animation-delay: 200ms; }
.animate-delay-300 { animation-delay: 300ms; }
.animate-delay-400 { animation-delay: 400ms; }
.animate-delay-500 { animation-delay: 500ms; }

/* Staggered children animations */
.stagger-children > *:nth-child(1) { animation-delay: 50ms; }
.stagger-children > *:nth-child(2) { animation-delay: 100ms; }
.stagger-children > *:nth-child(3) { animation-delay: 150ms; }
.stagger-children > *:nth-child(4) { animation-delay: 200ms; }
.stagger-children > *:nth-child(5) { animation-delay: 250ms; }
.stagger-children > *:nth-child(6) { animation-delay: 300ms; }
.stagger-children > *:nth-child(7) { animation-delay: 350ms; }
.stagger-children > *:nth-child(8) { animation-delay: 400ms; }

/* Hover micro-interactions */
.hover-lift {
    transition: transform var(--transition-fast) ease, box-shadow var(--transition-fast) ease;
}

.hover-lift:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.hover-scale {
    transition: transform var(--transition-fast) ease;
}

.hover-scale:hover {
    transform: scale(1.02);
}

.hover-glow {
    transition: box-shadow var(--transition-fast) ease;
}

.hover-glow:hover {
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.3);
}

/* Click feedback */
.click-shrink:active {
    transform: scale(0.98);
}

.click-feedback {
    position: relative;
    overflow: hidden;
}

.click-feedback::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.3) 0%, transparent 70%);
    opacity: 0;
    transform: scale(0);
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.click-feedback:active::after {
    opacity: 1;
    transform: scale(2);
    transition: none;
}

/* Ripple effect */
.ripple {
    position: relative;
    overflow: hidden;
}

.ripple-effect {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    transform: scale(0);
    animation: ripple 0.6s ease-out forwards;
    pointer-events: none;
}

@keyframes ripple {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* Success checkmark animation */
.checkmark-circle {
    stroke-dasharray: 166;
    stroke-dashoffset: 166;
    animation: checkmark-stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}

.checkmark-check {
    stroke-dasharray: 48;
    stroke-dashoffset: 48;
    animation: checkmark-stroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.4s forwards;
}

@keyframes checkmark-stroke {
    to { stroke-dashoffset: 0; }
}

/* Number counter animation */
.counter-animate {
    display: inline-block;
    transition: transform var(--transition-fast) ease;
}

.counter-animate.counting {
    animation: counterPop 0.3s ease;
}

@keyframes counterPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* Progress bar animation */
.progress-animated .progress-bar {
    animation: progressGrow 1s var(--ease-out) forwards;
}

@keyframes progressGrow {
    from { width: 0; }
}

/* Typing indicator */
.typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typingDot 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) { animation-delay: 0s; }
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingDot {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ============ MICRO-INTERACTIONS (Mandiag Style) ============ */

/* Hover Lift Classes (Mandiag) */
.hover-lift {
    transition: var(--transition);
}

.hover-lift:hover {
    transform: var(--hover-lift);
    box-shadow: var(--shadow-lg);
}

.hover-lift-sm:hover {
    transform: var(--hover-lift-sm);
}

/* Scale on hover (Mandiag) */
.hover-scale {
    transition: var(--transition);
}

.hover-scale:hover {
    transform: scale(1.05);
}

.hover-scale-lg:hover {
    transform: scale(1.1);
}

/* Icon hover animations */
.icon-hover-bounce:hover i,
.icon-hover-bounce:hover .icon {
    animation: iconBounce 0.5s var(--ease-bounce);
}

.icon-hover-spin:hover i,
.icon-hover-spin:hover .icon {
    animation: iconSpin 0.5s ease;
}

.icon-hover-shake:hover i,
.icon-hover-shake:hover .icon {
    animation: iconShake 0.5s ease;
}

.icon-hover-pulse:hover i,
.icon-hover-pulse:hover .icon {
    animation: iconPulse 0.5s ease;
}

@keyframes iconBounce {
    0%, 100% { transform: translateY(0); }
    25% { transform: translateY(-6px); }
    50% { transform: translateY(0); }
    75% { transform: translateY(-3px); }
}

@keyframes iconSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes iconShake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-4px); }
    40% { transform: translateX(4px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

@keyframes iconPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* Ripple effect (Mandiag) */
.ripple {
    position: relative;
    overflow: hidden;
}

.ripple::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
}

.ripple:active::after {
    width: 200px;
    height: 200px;
    opacity: 0;
    transition: width 0.3s ease, height 0.3s ease, opacity 0.3s ease;
}

/* Button press effect */
.press-effect {
    transition: var(--transition);
}

.press-effect:active {
    transform: scale(0.95);
}

/* Glow effect on hover */
.hover-glow {
    transition: var(--transition);
}

.hover-glow:hover {
    box-shadow: 0 0 20px var(--primary-glow);
}

.hover-glow-success:hover {
    box-shadow: 0 0 20px rgba(var(--success-rgb, 34, 197, 94), 0.4);
}

.hover-glow-danger:hover {
    box-shadow: 0 0 20px rgba(var(--danger-rgb, 239, 68, 68), 0.4);
}

/* Pulse animation for notifications/badges */
.pulse-animation {
    animation: pulseGlow 2s infinite;
}

@keyframes pulseGlow {
    0%, 100% {
        box-shadow: 0 0 0 0 var(--primary-glow);
    }
    50% {
        box-shadow: 0 0 0 10px transparent;
    }
}

/* Attention-grabbing pulse */
.attention-pulse {
    animation: attentionPulseAnim 2s infinite;
}

@keyframes attentionPulseAnim {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.8;
    }
}

/* Skeleton loading */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--surface-hover) 25%,
        var(--surface-active) 50%,
        var(--surface-hover) 75%
    );
    background-size: 200% 100%;
    animation: skeletonShimmer 1.5s infinite;
    border-radius: var(--radius);
}

.skeleton-text {
    height: 1rem;
    margin-bottom: 0.5rem;
    border-radius: var(--radius-xs);
}

.skeleton-text:last-child {
    width: 60%;
}

.skeleton-title {
    height: 1.5rem;
    width: 40%;
    margin-bottom: 1rem;
}

.skeleton-avatar {
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
}

.skeleton-card {
    height: 200px;
    border-radius: var(--radius-lg);
}

.skeleton-button {
    height: 2.5rem;
    width: 100px;
    border-radius: var(--radius);
}

@keyframes skeletonShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Loading spinner */
.spinner {
    width: 1.5rem;
    height: 1.5rem;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spinnerRotate 0.8s linear infinite;
}

.spinner-sm {
    width: 1rem;
    height: 1rem;
    border-width: 1.5px;
}

.spinner-lg {
    width: 2.5rem;
    height: 2.5rem;
    border-width: 3px;
}

.spinner-white {
    border-color: rgba(255, 255, 255, 0.3);
    border-top-color: white;
}

@keyframes spinnerRotate {
    to { transform: rotate(360deg); }
}

/* Loading overlay */
.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(var(--surface-rgb, 255, 255, 255), 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    backdrop-filter: blur(2px);
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.loading-overlay.active {
    opacity: 1;
    visibility: visible;
}

[data-theme="dark"] .loading-overlay {
    background: rgba(30, 30, 46, 0.8);
}

/* Button loading state */
.btn.loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 1.25rem;
    height: 1.25rem;
    margin: -0.625rem 0 0 -0.625rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spinnerRotate 0.8s linear infinite;
}

.btn-secondary.loading::after,
.btn-outline.loading::after {
    border-color: var(--border);
    border-top-color: var(--primary);
}

/* Progress bar animation (Mandiag) */
.progress-animated .progress-bar {
    animation: progressPulse 2s ease-in-out infinite;
}

@keyframes progressPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Success checkmark animation (Mandiag) */
.success-checkmark {
    width: 80px;
    height: 80px;
    margin: 0 auto;
}

.success-checkmark .checkmark-circle {
    stroke-dasharray: 166;
    stroke-dashoffset: 166;
    stroke-width: 2;
    stroke-miterlimit: 10;
    stroke: var(--success);
    fill: none;
    animation: checkmarkStroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}

.success-checkmark .checkmark-check {
    transform-origin: 50% 50%;
    stroke-dasharray: 48;
    stroke-dashoffset: 48;
    stroke: var(--success);
    animation: checkmarkStroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.8s forwards;
}

@keyframes checkmarkStroke {
    100% { stroke-dashoffset: 0; }
}

/* Number counter animation (Mandiag) */
.counter-animate {
    display: inline-block;
    animation: counterBounce 0.5s var(--ease-bounce);
}

@keyframes counterBounce {
    0% { transform: scale(1.3); opacity: 0; }
    50% { transform: scale(0.9); }
    100% { transform: scale(1); opacity: 1; }
}

/* Fade in on scroll (use with JS) */
.fade-in-view {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.fade-in-view.in-view {
    opacity: 1;
    transform: translateY(0);
}

/* Staggered children animation (Mandiag) */
.stagger-children > * {
    opacity: 0;
    transform: translateY(10px);
    animation: staggerFadeIn 0.4s ease forwards;
}

.stagger-children > *:nth-child(1) { animation-delay: 0.05s; }
.stagger-children > *:nth-child(2) { animation-delay: 0.1s; }
.stagger-children > *:nth-child(3) { animation-delay: 0.15s; }
.stagger-children > *:nth-child(4) { animation-delay: 0.2s; }
.stagger-children > *:nth-child(5) { animation-delay: 0.25s; }
.stagger-children > *:nth-child(6) { animation-delay: 0.3s; }
.stagger-children > *:nth-child(7) { animation-delay: 0.35s; }
.stagger-children > *:nth-child(8) { animation-delay: 0.4s; }

@keyframes staggerFadeIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Hover slide effect */
.hover-slide-right {
    transition: var(--transition);
}

.hover-slide-right:hover {
    transform: translateX(4px);
}

.hover-slide-up {
    transition: var(--transition);
}

.hover-slide-up:hover {
    transform: translateY(-4px);
}

/* Text gradient animation */
.text-gradient-animate {
    background: linear-gradient(
        90deg,
        var(--primary),
        var(--accent),
        var(--primary)
    );
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: textGradientFlow 3s linear infinite;
}

@keyframes textGradientFlow {
    to { background-position: 200% center; }
}

/* Border gradient animation */
.border-gradient-animate {
    position: relative;
    background: var(--surface);
    border-radius: var(--radius-lg);
}

.border-gradient-animate::before {
    content: '';
    position: absolute;
    inset: -2px;
    background: linear-gradient(
        90deg,
        var(--primary),
        var(--accent),
        var(--success),
        var(--primary)
    );
    background-size: 300% 300%;
    border-radius: inherit;
    z-index: -1;
    animation: borderGradientFlow 4s linear infinite;
}

@keyframes borderGradientFlow {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Floating animation */
.float-animation {
    animation: floatUpDown 3s ease-in-out infinite;
}

@keyframes floatUpDown {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* Notification dot pulse */
.notification-dot {
    width: 8px;
    height: 8px;
    background: var(--danger);
    border-radius: 50%;
    position: relative;
}

.notification-dot::before {
    content: '';
    position: absolute;
    inset: -4px;
    border: 2px solid var(--danger);
    border-radius: 50%;
    animation: notificationPing 1.5s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes notificationPing {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    75%, 100% {
        transform: scale(2);
        opacity: 0;
    }
}

/* Card flip effect */
.card-flip {
    perspective: 1000px;
}

.card-flip-inner {
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.card-flip:hover .card-flip-inner {
    transform: rotateY(180deg);
}

.card-flip-front,
.card-flip-back {
    backface-visibility: hidden;
}

.card-flip-back {
    transform: rotateY(180deg);
    position: absolute;
    inset: 0;
}

/* Interactive focus ring */
.focus-ring:focus {
    outline: none;
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.focus-ring:focus:not(:focus-visible) {
    box-shadow: none;
}

.focus-ring:focus-visible {
    box-shadow: 0 0 0 3px var(--primary-glow);
}

/* Reduce motion preference */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
