/* ============================================
   COMPONENTS CSS - SHARED UI COMPONENTS
   Reusable component patterns and utilities
   Works across all breakpoints
   ============================================ */

/* -------------------- Scroll Animations (Applied via JS) -------------------- */

/* NOTE: Animation states handled by animations.css (loaded on all devices)
   This file only provides emergency fallback for accessibility */

/* Emergency fallback: Show content after 2s even if JS hasn't loaded */
[data-animate]:not(.revealed):not(.animation-complete) {
    animation: emergencyFallback 0.6s ease 2s forwards;
}

@keyframes emergencyFallback {
    to {
        opacity: 1 !important;
        transform: translateY(0) translateX(0) scale(1) !important;
    }
}

/* -------------------- Loading States -------------------- */

.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.6;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    margin: -12px 0 0 -12px;
    border: 3px solid rgba(74, 144, 226, 0.3);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* -------------------- Skeleton Loaders -------------------- */

.skeleton {
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.05) 25%,
        rgba(255, 255, 255, 0.1) 50%,
        rgba(255, 255, 255, 0.05) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--border-radius-sm);
}

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

.skeleton-text {
    height: 1em;
    margin-bottom: 0.5em;
}

.skeleton-title {
    height: 2em;
    width: 60%;
    margin-bottom: 1em;
}

.skeleton-card {
    height: 200px;
    width: 100%;
}

/* -------------------- Toast Notifications -------------------- */

.toast {
    position: fixed;
    bottom: var(--spacing-lg);
    right: var(--spacing-lg);
    background: rgba(10, 22, 40, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--border-radius-md);
    padding: var(--spacing-md) var(--spacing-lg);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    z-index: 1000;
    min-width: 280px;
    max-width: 400px;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: all;
}

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

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

.toast.info {
    border-left: 4px solid var(--color-primary);
}

.toast-content {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

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

.toast-message {
    color: var(--color-text-primary);
    font-size: var(--font-size-base);
    line-height: 1.5;
}

.toast-close {
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: var(--spacing-xs);
    margin-left: auto;
    transition: color 0.2s ease;
}

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

/* -------------------- Badges & Tags -------------------- */

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 9999px;
    line-height: 1;
}

.badge-primary {
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    color: var(--color-text-primary);
}

.badge-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--color-text-secondary);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.badge-success {
    background: rgba(74, 222, 128, 0.2);
    color: #4ade80;
    border: 1px solid rgba(74, 222, 128, 0.3);
}

.badge-error {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* -------------------- Image Placeholders -------------------- */

.image-placeholder {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(74, 144, 226, 0.08), rgba(107, 93, 209, 0.08));
    border-radius: var(--border-radius-md);
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
    position: relative;
    overflow: hidden;
}

.image-placeholder::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100px;
    height: 100px;
    background: linear-gradient(135deg, transparent 50%, rgba(74, 144, 226, 0.1) 50%);
    pointer-events: none;
}

/* -------------------- Card Variations -------------------- */

.card {
    background: rgba(10, 22, 40, 0.6);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--border-radius-md);
    padding: var(--spacing-lg);
    transition: all 0.3s ease;
}

.card:hover {
    border-color: rgba(74, 144, 226, 0.3);
    box-shadow: 0 8px 24px rgba(74, 144, 226, 0.15);
}

.card-header {
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-md);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.card-title {
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: var(--color-text-primary);
    margin: 0;
}

.card-body {
    color: var(--color-text-secondary);
    font-size: var(--font-size-base);
    line-height: 1.7;
}

.card-footer {
    margin-top: var(--spacing-md);
    padding-top: var(--spacing-md);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* -------------------- Dividers -------------------- */

.divider {
    height: 1px;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.2),
        transparent
    );
    margin: var(--spacing-xl) 0;
}

.divider-vertical {
    width: 1px;
    height: 100%;
    background: linear-gradient(
        180deg,
        transparent,
        rgba(255, 255, 255, 0.2),
        transparent
    );
    margin: 0 var(--spacing-md);
}

/* -------------------- Progress Indicators -------------------- */

.progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 9999px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
    border-radius: 9999px;
    transition: width 0.3s ease;
    position: relative;
    overflow: hidden;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    animation: shimmer 2s infinite;
}

/* -------------------- Tooltips (CSS-only) -------------------- */

[data-tooltip] {
    position: relative;
    cursor: help;
}

[data-tooltip]::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) scale(0.9);
    padding: var(--spacing-xs) var(--spacing-sm);
    background: rgba(10, 22, 40, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--border-radius-sm);
    color: var(--color-text-primary);
    font-size: 0.75rem;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: all 0.2s ease;
    z-index: 1000;
}

[data-tooltip]:hover::before {
    opacity: 1;
    transform: translateX(-50%) scale(1);
}

/* -------------------- Click-to-Call / Click-to-WhatsApp -------------------- */

.click-to-call,
.click-to-whatsapp {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-sm) var(--spacing-md);
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--border-radius-md);
    color: var(--color-text-primary);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
    min-height: 44px; /* Touch-friendly */
}

.click-to-call:hover,
.click-to-whatsapp:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--color-primary);
}

.click-to-call::before {
    content: '📞';
    font-size: 1.2em;
}

.click-to-whatsapp::before {
    content: '💬';
    font-size: 1.2em;
}

/* -------------------- Responsive Embeds -------------------- */

.embed-responsive {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    height: 0;
    overflow: hidden;
}

.embed-responsive iframe,
.embed-responsive video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    border-radius: var(--border-radius-md);
}

/* -------------------- Aspect Ratio Utilities -------------------- */

.aspect-square {
    aspect-ratio: 1 / 1;
}

.aspect-video {
    aspect-ratio: 16 / 9;
}

.aspect-portrait {
    aspect-ratio: 3 / 4;
}

/* -------------------- Truncate Text -------------------- */

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* -------------------- Mobile-Only / Desktop-Only Utilities -------------------- */

.mobile-only {
    display: block;
}

.desktop-only {
    display: none;
}

@media (min-width: 1024px) {
    .mobile-only {
        display: none;
    }

    .desktop-only {
        display: block;
    }
}
