/*
 * Universal Share Modal Component
 * YouTube-style sharing modal with modern design
 * Used across: Product Detail, Gift Finder, Wishlist, Occasion pages
 * 
 * Design System: Matches React SocialShare component 1:1
 * - Fixed overlay with backdrop blur
 * - Centered modal with rounded corners and shadow
 * - 4-column platform grid
 * - Copy link functionality with feedback
 * - Smooth animations and hover effects
 */

/* Modal Container & Overlay */
.share-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    pointer-events: none;
}

.share-modal--open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.share-modal__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    cursor: pointer;
}

.share-modal__container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    background: white;
    border-radius: 1rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    max-width: 28rem;
    width: calc(100% - 2rem);
    max-height: 80vh;
    overflow: hidden;
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

.share-modal--open .share-modal__container {
    transform: translate(-50%, -50%) scale(1);
}

/* Header Section */
.share-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-light, #f1f5f9);
}

.share-modal__title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary, #1e293b);
    margin: 0;
}

.share-modal__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    background: none;
    border: none;
    border-radius: 50%;
    color: var(--text-secondary, #64748b);
    cursor: pointer;
    transition: all 0.2s ease;
}

.share-modal__close:hover {
    background: var(--background-hover, #f1f5f9);
    color: var(--text-primary, #1e293b);
}

/* URL Section */
.share-modal__url-section {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-light, #f1f5f9);
}

.share-modal__url-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--background-secondary, #f8fafc);
    border-radius: 0.5rem;
    padding: 0.75rem;
}

.share-modal__url-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-secondary, #64748b);
    font-size: 0.875rem;
    font-family: ui-monospace, 'SF Mono', 'Monaco', 'Inconsolata', monospace;
}

.share-modal__copy-btn {
    background: var(--primary, #f97316);
    color: white;
    border: none;
    border-radius: 0.375rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
    min-width: 4rem;
}

.share-modal__copy-btn:hover {
    background: var(--primary-hover, #ea580c);
}

.share-modal__copy-btn--copied {
    background: var(--success, #22c55e);
}

.share-modal__copy-btn--copied:hover {
    background: var(--success-hover, #16a34a);
}

.share-modal__copy-btn .copy-text,
.share-modal__copy-btn .copied-text {
    transition: all 0.3s ease;
}

.share-modal__copy-btn .copied-text {
    opacity: 0;
    transform: translateY(100%);
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%) translateY(100%);
}

.share-modal__copy-btn--copied .copy-text {
    opacity: 0;
    transform: translateY(-100%);
}

.share-modal__copy-btn--copied .copied-text {
    opacity: 1;
    transform: translate(-50%, -50%);
}

/* Platforms Section */
.share-modal__platforms {
    padding: 1.5rem;
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    /* Required for flex child to be scrollable */
}

.share-modal__grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
}

.share-modal__platform {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: none;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    color: inherit;
}

.share-modal__platform:hover {
    background: var(--background-hover, #f1f5f9);
}

.share-modal__platform-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    transition: transform 0.2s ease;
}

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

.share-modal__platform-name {
    font-size: 0.75rem;
    color: var(--text-secondary, #64748b);
    text-align: center;
    line-height: 1.2;
}

/* Platform-specific colors (matching React implementation) */
.share-modal__platform--facebook .share-modal__platform-icon {
    background: #1877f2;
    color: white;
}

.share-modal__platform--twitter .share-modal__platform-icon {
    background: #000000;
    color: white;
}

.share-modal__platform--pinterest .share-modal__platform-icon {
    background: #e60023;
    color: white;
}

.share-modal__platform--whatsapp .share-modal__platform-icon {
    background: #25d366;
    color: white;
}

.share-modal__platform--email .share-modal__platform-icon {
    background: #6b7280;
    color: white;
}

.share-modal__platform--reddit .share-modal__platform-icon {
    background: #ff4500;
    color: white;
}

.share-modal__platform--vk .share-modal__platform-icon {
    background: #4c75a3;
    color: white;
}

.share-modal__platform--ok .share-modal__platform-icon {
    background: #ee8208;
    color: white;
}

.share-modal__platform--blogger .share-modal__platform-icon {
    background: #ff5722;
    color: white;
}

.share-modal__platform--tumblr .share-modal__platform-icon {
    background: #001935;
    color: white;
}

.share-modal__platform--kakaotalk .share-modal__platform-icon {
    background: #fee500;
    color: #000000;
}

.share-modal__platform--native .share-modal__platform-icon {
    background: #6b7280;
    color: white;
}

/* Copy Link Section */
.share-modal__copy-section {
    padding-top: 1rem;
    border-top: 1px solid var(--border-light, #f1f5f9);
}

.share-modal__copy-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.75rem;
    background: none;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    color: inherit;
}

.share-modal__copy-link:hover {
    background: var(--background-hover, #f1f5f9);
}

.share-modal__copy-link .share-modal__platform-icon {
    background: var(--text-secondary, #64748b);
    color: white;
}

.share-modal__copy-link .share-modal__platform-name {
    font-size: 0.875rem;
    color: var(--text-primary, #1e293b);
}

/* Loading State */
.share-modal--loading .share-modal__url-input {
    background-image: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.1), transparent);
    background-size: 200px 100%;
    background-repeat: no-repeat;
    animation: shimmer 1.5s infinite;
}

.share-modal__platform--loading {
    opacity: 0.5;
    pointer-events: none;
}

.share-modal__spinner {
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Animations */
@keyframes shimmer {
    0% {
        background-position: -200px 0;
    }

    100% {
        background-position: 200px 0;
    }
}

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

/* Responsive Design */
@media (max-width: 640px) {
    .share-modal__container {
        max-width: calc(100% - 1rem);
        margin: 0.5rem;
    }

    .share-modal__grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .share-modal__header,
    .share-modal__url-section,
    .share-modal__platforms {
        padding: 1rem;
    }

    .share-modal__platform-icon {
        width: 2.5rem;
        height: 2.5rem;
    }
}

/* Accessibility */
.share-modal__platform:focus-visible,
.share-modal__copy-btn:focus-visible,
.share-modal__close:focus-visible,
.share-modal__copy-link:focus-visible {
    outline: 2px solid var(--primary, #f97316);
    outline-offset: 2px;
}

/* Dark mode support (if enabled) */
@media (prefers-color-scheme: dark) {
    .share-modal__container {
        background: var(--background-dark, #1e293b);
        color: var(--text-dark, #f1f5f9);
    }

    .share-modal__title {
        color: var(--text-dark, #f1f5f9);
    }

    .share-modal__url-container {
        background: var(--background-dark-secondary, #334155);
    }

    .share-modal__url-input {
        color: var(--text-dark-secondary, #cbd5e1);
    }
}