/**
 * Reactive UI Polish - Enhanced UX with loading states, empty states, and accessibility
 * Provides refined visual feedback, better error states, and improved accessibility
 */

/* ================================================================
   LOADING STATES & SKELETONS
   ================================================================ */

.loading-skeleton {
    background: linear-gradient(
        90deg,
        rgba(148, 163, 184, 0.1) 25%,
        rgba(148, 163, 184, 0.2) 50%,
        rgba(148, 163, 184, 0.1) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 2s infinite;
    border-radius: 8px;
}


.post-skeleton {
    padding: 1.5rem;
    margin-bottom: 1rem;
    border-radius: 12px;
    background: var(--card-bg, rgba(30, 41, 59, 0.5)); /* theme token: was a dark-only gradient */
    border: 1px solid rgba(148, 163, 184, 0.1);
}

.skeleton-header {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    flex-shrink: 0;
}

.skeleton-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.skeleton-line {
    height: 10px;
    border-radius: 4px;
}

.skeleton-line.short {
    width: 60%;
}

.skeleton-content {
    height: 60px;
    border-radius: 8px;
    margin-bottom: 1rem;
}

/* ================================================================
   EMPTY STATES
   ================================================================ */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    text-align: center;
    color: #9ca3af;
    min-height: 400px;
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #cbd5e1;
    margin-bottom: 0.5rem;
    letter-spacing: 0.01em;
}

.empty-state-message {
    font-size: 0.95rem;
    color: #9ca3af;
    margin-bottom: 1.5rem;
    max-width: 400px;
    line-height: 1.6;
}

.empty-state-action {
    background: linear-gradient(135deg, #c084fc 0%, #a855f7 100%);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1); transition-property: var(--transition-safe);
    letter-spacing: 0.02em;
}

.empty-state-action:hover {
    box-shadow: 0 8px 20px rgba(192, 132, 252, 0.3);
    transform: translateY(-2px);
}

/* ================================================================
   ERROR STATES
   ================================================================ */

.error-state {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border-radius: 8px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
    margin-bottom: 1rem;
}

.error-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.error-message {
    flex: 1;
    font-size: 0.9rem;
    line-height: 1.5;
}

.error-action {
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1); transition-property: var(--transition-safe);
    white-space: nowrap;
    flex-shrink: 0;
}

.error-action:hover {
    background: rgba(239, 68, 68, 0.3);
    border-color: rgba(239, 68, 68, 0.5);
}

/* ================================================================
   BUTTON ENHANCEMENTS
   ================================================================ */

button {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

button:focus-visible {
    outline: 2px solid #c084fc;
    outline-offset: 2px;
}

button:active {
    transform: scale(0.98);
}

.btn-primary {
    background: linear-gradient(135deg, #c084fc 0%, #a855f7 100%);
    color: white;
    border: none;
    font-weight: 600;
    letter-spacing: 0.02em;
    transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1); transition-property: var(--transition-safe);
    position: relative;
    overflow: hidden;
}

.btn-primary::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    opacity: 0;
    animation: shimmer-button 0.5s ease-in-out;
    pointer-events: none;
}

.btn-primary:hover {
    box-shadow: 0 8px 20px rgba(192, 132, 252, 0.3);
    transform: translateY(-2px);
}

.btn-primary:active {
    transform: scale(0.98) translateY(2px);
}

@keyframes shimmer-button {
    0% { opacity: 0; transform: translateX(-100%); }
    50% { opacity: 1; }
    100% { opacity: 0; transform: translateX(100%); }
}

.btn-secondary {
    background: transparent;
    border: 1px solid rgba(148, 163, 184, 0.2);
    color: #cbd5e1;
    transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1); transition-property: var(--transition-safe);
}

.btn-secondary:hover {
    border-color: #c084fc;
    color: #e2e8f0;
    background: rgba(192, 132, 252, 0.1);
}

/* ================================================================
   FORM ELEMENT POLISH
   ================================================================ */

input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: 2px solid #c084fc;
    outline-offset: 2px;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    color: #e2e8f0;
    margin-bottom: 0.5rem;
    letter-spacing: 0.01em;
}

.form-input,
.form-textarea,
.form-select {
    width: 100%;
    padding: 0.75rem 1rem;
    background: rgba(15, 9, 21, 0.5);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 8px;
    color: #e2e8f0;
    font-family: inherit;
    font-size: 0.95rem;
    transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1); transition-property: var(--transition-safe);
    letter-spacing: 0.01em;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    border-color: #c084fc;
    box-shadow: 0 0 0 3px rgba(192, 132, 252, 0.1);
    background: rgba(15, 9, 21, 0.7);
}

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

.form-hint {
    display: block;
    font-size: 0.8rem;
    color: #9ca3af;
    margin-top: 0.5rem;
    letter-spacing: 0.01em;
}

/* ================================================================
   BADGE & COUNTER POLISH
   ================================================================ */

.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: linear-gradient(135deg, rgba(192, 132, 252, 0.2) 0%, rgba(168, 85, 247, 0.2) 100%);
    border: 1px solid rgba(192, 132, 252, 0.3);
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #c084fc;
    letter-spacing: 0.02em;
}

.badge-unread {
    background: linear-gradient(135deg, #c084fc 0%, #a855f7 100%);
    color: white;
    border-color: transparent;
}

.notification-badge {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding-inline: 0.35em;
    border-radius: 999px;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
    animation: pulse-badge 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse-badge {
    0%, 100% {
        box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3), 0 0 0 0 rgba(239, 68, 68, 0.4);
    }
    50% {
        box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3), 0 0 0 8px rgba(239, 68, 68, 0);
    }
}

/* ================================================================
   INTERACTIVE ELEMENT FEEDBACK
   ================================================================ */

.ripple-effect {
    position: relative;
    overflow: hidden;
}

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

.ripple-effect:active::after {
    animation: ripple 0.6s ease-out;
}


/* ================================================================
   HOVER STATES
   ================================================================ */

.card-hover {
    transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1); transition-property: var(--transition-safe);
    cursor: pointer;
}

.card-hover:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3);
}

/* ================================================================
   ACCESSIBILITY ENHANCEMENTS
   ================================================================ */

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: #c084fc;
    color: white;
    padding: 0.5rem 1rem;
    text-decoration: none;
    z-index: 100;
    font-weight: 600;
}

.skip-link:focus {
    top: 0;
}

/* Focus visible for keyboard navigation */
*:focus-visible {
    outline: 2px solid #c084fc;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: more) {
    .post-card.reactive-post,
    .notification-item.reactive-notification {
        border-width: 2px;
    }

    button {
        border-width: 2px;
    }
}

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

/* ================================================================
   HOVER STATE IMPROVEMENTS
   ================================================================ */

.interactive-element {
    transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1); transition-property: var(--transition-safe);
}

.interactive-element:hover {
    color: #c084fc;
}

.clickable {
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}

/* ================================================================
   TOAST/NOTIFICATION POLISH
   ================================================================ */

.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.95) 0%, rgba(30, 41, 59, 0.9) 100%);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 8px;
    padding: 1rem 1.5rem;
    color: #e2e8f0;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    animation: slideInUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 1000;
    font-size: 0.9rem;
    letter-spacing: 0.01em;
}

.toast.success {
    border-left: 4px solid #10b981;
}

.toast.error {
    border-left: 4px solid #ef4444;
}

.toast.info {
    border-left: 4px solid #3b82f6;
}

.toast.warning {
    border-left: 4px solid #f59e0b;
}

/* ================================================================
   TRANSITION SMOOTHING
   ================================================================ */

/* Smooth transitions for all interactive elements */
a,
button,
input,
textarea,
select {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* A universal `* { color: inherit; background-color: inherit; }` stood
   here: every element repainted its parent's background opaquely (stripes
   over unread rows, attachment names and card text) and lost its own text
   colour (links, placeholders). Elements keep their own colours. */
