/**
 * Base Theme Styles - Shared across all 40+ themes
 * Uses CSS variables defined in individual theme files
 *
 * Purpose: Eliminate ~6,000 lines of duplicate code
 * DO NOT modify theme-specific colors here - use CSS variables
 *
 * Individual themes define:
 * - --bg-primary, --bg-secondary, --bg-tertiary, --bg-card
 * - --accent-primary, --accent-secondary, --accent-tertiary
 * - --accent-primary-rgb (for rgba() usage)
 * - --text-primary, --text-secondary, --text-color
 * - --border-color, --shadow-primary
 * - Body backgrounds and theme-specific animations
 *
 * This file provides:
 * - Button styles (with theme colors)
 * - Card styles and hover effects
 * - Form input styles
 * - Link styles
 * - Scrollbar styles
 * - Common UI component patterns
 */

/* ============================================
   BUTTONS
   ============================================ */

.btn, button, .cta-btn, input[type="submit"] {
    background: linear-gradient(135deg,
        var(--accent-primary) 0%,
        var(--accent-secondary) 100%
    );
    border: 2px solid var(--accent-primary);
    box-shadow: 0 2px 8px rgba(var(--accent-primary-rgb, 0, 0, 0), 0.2);
    transition: all 0.3s ease;
    color: var(--text-button, #ffffff) !important;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    padding: 12px 24px;
    min-height: 48px;
    min-width: 48px;
    border-radius: 8px;
    font-weight: 500;
}

.btn:hover, button:hover, .cta-btn:hover, input[type="submit"]:hover {
    box-shadow: 0 4px 12px rgba(var(--accent-primary-rgb, 0, 0, 0), 0.25);
    transform: translateY(-2px);
}

.btn:active, button:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--bg-secondary);
    border-color: var(--border-color);
    color: var(--text-primary) !important;
}

/* ============================================
   CARDS
   ============================================ */

.card, .post-card, .profile-card,
.achievement-card, .win-card, .group-card, .event-card,
.suggestion-item, .stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-primary);
    border-radius: 12px;
    padding: 20px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

/* ============================================
   CARD HOVER EFFECTS (Shine/Glow Animation)
   Most duplicated code - ~2,000 lines saved!
   ============================================ */

/* Card Hover Shine Effect */
.card::before, .post-card::before, .profile-card::before,
.achievement-card::before, .win-card::before, .group-card::before,
.event-card::before, .stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(var(--accent-primary-rgb, 255, 255, 255), 0.1),
        transparent
    );
    transition: left 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1;
}

.card:hover::before, .post-card:hover::before,
.profile-card:hover::before, .achievement-card:hover::before,
.win-card:hover::before, .group-card:hover::before,
.event-card:hover::before, .stat-card:hover::before {
    left: 100%;
}

.card:hover, .post-card:hover, .profile-card:hover,
.achievement-card:hover, .win-card:hover, .group-card:hover,
.event-card:hover, .stat-card:hover {
    box-shadow:
        0 12px 40px rgba(0, 0, 0, 0.2),
        0 0 20px rgba(var(--accent-primary-rgb, 255, 255, 255), 0.3);
    transform: translateY(-6px);
}

/* Ensure card content stays above shine effect */
.card > *, .post-card > *, .profile-card > *,
.achievement-card > *, .win-card > * {
    position: relative;
    z-index: 2;
}

/* ============================================
   FORM INPUTS
   ============================================ */

input, textarea, select {
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    color: var(--text-primary);
    padding: 12px;
    border-radius: 8px;
    transition: all 0.3s;
    font-family: inherit;
    font-size: 14px;
    width: 100%;
}

/* Password field with toggle button */
.password-field-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.password-field-wrapper input {
    padding-right: 50px;
}

.password-toggle {
    position: absolute;
    right: 8px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px 12px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    opacity: 0.6;
}

.password-toggle:hover {
    opacity: 1;
    background: rgba(var(--accent-primary-rgb, 156, 39, 176), 0.1);
    border-radius: 6px;
}

.password-toggle-icon {
    font-size: 20px;
    user-select: none;
}

input:focus, textarea:focus, select:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(var(--accent-primary-rgb, 0, 0, 0), 0.1);
    outline: none;
    background: var(--bg-card);
}

input::placeholder, textarea::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

/* Input types */
input[type="checkbox"], input[type="radio"] {
    width: auto;
    min-width: 24px;
    min-height: 24px;
    cursor: pointer;
}

/* ============================================
   LINKS
   ============================================ */

a {
    color: var(--accent-primary);
    transition: all 0.3s;
    text-decoration: none;
}

a:hover {
    color: var(--accent-secondary);
    text-decoration: underline;
}

/* ============================================
   SCROLLBARS
   ============================================ */

::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg,
        var(--accent-primary),
        var(--accent-secondary)
    );
    border-radius: 6px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-primary);
}

/* Firefox scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--accent-primary) var(--bg-secondary);
}

/* ============================================
   HEADINGS
   ============================================ */

h1, h2, h3, h4, h5, h6 {
    color: var(--accent-primary);
    font-weight: 600;
    margin-bottom: 16px;
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

/* Mobile back button - hidden on desktop */
.mobile-back-btn {
    display: none;
}

.shadow {
    box-shadow: var(--shadow-primary);
}

.glow {
    box-shadow: 0 0 20px rgba(var(--accent-primary-rgb, 255, 255, 255), 0.5);
}

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

.text-secondary {
    color: var(--text-secondary);
}

.text-accent {
    color: var(--accent-primary);
}

.bg-card {
    background: var(--bg-card);
}

.bg-primary {
    background: var(--bg-primary);
}

.bg-secondary {
    background: var(--bg-secondary);
}

/* ============================================
   ENHANCED BUTTON EFFECTS
   ============================================ */

/* Button Glow on Hover */
.btn::after, button::after, .cta-btn::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%);
    transition: width 0.6s, height 0.6s;
}

.btn:hover::after, button:hover::after, .cta-btn:hover::after {
    width: 300px;
    height: 300px;
    opacity: 0;
}

@media (max-width: 768px) {
    .btn:hover::after, button:hover::after, .cta-btn:hover::after {
        width: 200px;
        height: 200px;
    }
}

/* ============================================
   LOADING STATES
   ============================================ */

.btn-loading, button.btn-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn-loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: btn-spin 0.6s linear infinite;
}

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

/* ============================================
   DROPDOWN / SELECT ENHANCEMENTS
   ============================================ */

select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 40px;
    cursor: pointer;
}

/* ============================================
   BADGES / TAGS
   ============================================ */

.badge, .tag {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    background: var(--accent-primary);
    color: #ffffff;
}

/* ============================================
   TOOLTIPS (Basic)
   ============================================ */

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

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.9);
    color: #fff;
    font-size: 12px;
    white-space: nowrap;
    border-radius: 4px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s, transform 0.3s;
    z-index: var(--z-tooltip, 1070);
}

[data-tooltip]:hover::after {
    opacity: 1;
    transform: translateX(-50%) translateY(-4px);
}

/* ============================================
   ANIMATIONS
   ============================================ */

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

.fade-in-element {
    opacity: 0;
    animation: fadeIn 0.6s ease-out forwards;
}

.fade-in-visible {
    animation: fadeIn 0.6s ease-out forwards;
}

/* ============================================
   RESPONSIVE UTILITIES
   ============================================ */

@media (max-width: 768px) {
    .card, .post-card, .profile-card {
        padding: 20px;
    }

    .btn, button, .cta-btn, input[type="submit"] {
        padding: 14px 20px;
        min-height: 48px;
        min-width: 48px;
        font-size: 16px;
    }

    /* Touch target spacing for adjacent buttons */
    .btn + .btn, button + button, .btn + button, button + .btn {
        margin-left: 8px;
    }

    /* Ensure checkboxes and radios are tappable on mobile */
    input[type="checkbox"], input[type="radio"] {
        min-width: 28px;
        min-height: 28px;
    }

    /* Badge/tag touch targets */
    .badge, .tag {
        font-size: 14px;
        padding: 6px 14px;
        min-height: 32px;
    }

    /* Mobile back button for messages */
    .mobile-back-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
        background: transparent;
        border: none;
        color: var(--accent-primary);
        font-size: 16px;
        font-weight: bold;
        padding: 10px 16px;
        min-height: 44px;
        min-width: 80px;
        cursor: pointer;
        transition: all 0.2s;
        margin-right: 10px;
    }

    .mobile-back-btn:hover {
        background: rgba(var(--accent-primary-rgb, 156, 39, 176), 0.1);
        border-radius: 8px;
    }

    h1 {
        font-size: 24px;
    }

    h2 {
        font-size: 20px;
    }

    h3 {
        font-size: 18px;
    }
}

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

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

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

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
    .btn, button {
        box-shadow: none;
    }

    .card, .post-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #000;
    }
}

/* ============================================
   ENHANCED MICRO-INTERACTIONS
   Added: November 11, 2025
   ============================================ */

/* Smooth fade-in for all cards */
.card, .post-card, .profile-card, .achievement-card,
.win-card, .group-card, .event-card, .stat-card {
    animation: cardFadeIn 0.5s ease-out;
}

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

/* Stagger animation for lists */
.card:nth-child(1) { animation-delay: 0s; }
.card:nth-child(2) { animation-delay: 0.1s; }
.card:nth-child(3) { animation-delay: 0.2s; }
.card:nth-child(4) { animation-delay: 0.3s; }
.card:nth-child(5) { animation-delay: 0.4s; }

/* Enhanced focus ring for accessibility */
button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: 3px solid var(--accent-primary);
    outline-offset: 3px;
    border-radius: 4px;
}

/* Pulse animation for primary CTAs */
@keyframes ctaPulse {
    0%, 100% {
        box-shadow: 0 4px 15px rgba(var(--accent-primary-rgb, 0, 0, 0), 0.3);
    }
    50% {
        box-shadow: 0 6px 25px rgba(var(--accent-primary-rgb, 0, 0, 0), 0.5),
                    0 0 30px rgba(var(--accent-primary-rgb, 0, 0, 0), 0.2);
    }
}

.btn-primary,
.cta-btn,
input[type="submit"]:not(.btn-secondary) {
    animation: ctaPulse 3s ease-in-out infinite;
}

/* Improved card shadows with depth */
.card:hover,
.post-card:hover {
    box-shadow:
        0 15px 45px rgba(0, 0, 0, 0.25),
        0 0 25px rgba(var(--accent-primary-rgb, 255, 255, 255), 0.25),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Glass morphism effect for elevated elements */
.glass-effect {
    background: rgba(var(--bg-card-rgb, 255, 255, 255), 0.05);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Smooth transitions for theme colors */
* {
    transition: background-color 0.3s ease,
                border-color 0.3s ease,
                color 0.3s ease;
}

/* Skip the transition for specific fast-changing elements */
button:active,
.btn:active,
input:active {
    transition-duration: 0.1s;
}

/* Enhanced typography scale */
h1, h2, h3, h4, h5, h6 {
    line-height: 1.2;
    letter-spacing: -0.02em;
}

h1 {
    font-size: clamp(2rem, 5vw, 3rem);
}

h2 {
    font-size: clamp(1.5rem, 4vw, 2.25rem);
}

h3 {
    font-size: clamp(1.25rem, 3vw, 1.75rem);
}

/* Improved link underline animation */
a:not(.btn):not(.quick-action-btn) {
    position: relative;
    text-decoration: none;
}

a:not(.btn):not(.quick-action-btn)::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: -2px;
    left: 0;
    background: var(--accent-primary);
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

a:not(.btn):not(.quick-action-btn):hover::after {
    width: 100%;
}

/* Skeleton loading states */
.skeleton {
    background: linear-gradient(
        90deg,
        rgba(var(--bg-tertiary-rgb, 42, 42, 42), 0.3) 25%,
        rgba(var(--accent-primary-rgb, 156, 39, 176), 0.15) 50%,
        rgba(var(--bg-tertiary-rgb, 42, 42, 42), 0.3) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 2s infinite linear;
    border-radius: 8px;
}

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

/* Improved form validation states */
input:invalid:not(:placeholder-shown),
textarea:invalid:not(:placeholder-shown) {
    border-color: #e74c3c;
    box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.1);
}

input:valid:not(:placeholder-shown),
textarea:valid:not(:placeholder-shown) {
    border-color: #2ecc71;
    box-shadow: 0 0 0 3px rgba(46, 204, 113, 0.1);
}

/* Success/Error message animations */
.alert,
.message,
.notification {
    animation: slideInRight 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 16px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border: 2px solid;
    position: relative;
}

.alert-error {
    background: rgba(231, 76, 60, 0.1);
    border-color: #e74c3c;
    color: #e74c3c;
}

.alert-success {
    background: rgba(46, 204, 113, 0.1);
    border-color: #2ecc71;
    color: #2ecc71;
}

.alert-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.alert-message {
    flex: 1;
    font-weight: 500;
}

.alert-close {
    background: transparent;
    border: none;
    color: inherit;
    font-size: 24px;
    cursor: pointer;
    padding: 4px 8px;
    min-width: 40px;
    min-height: 40px;
    opacity: 0.7;
    transition: opacity 0.2s;
    flex-shrink: 0;
}

.alert-close:hover {
    opacity: 1;
}

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

/* Enhanced badge styling */
.badge,
.tag {
    box-shadow: 0 2px 8px rgba(var(--accent-primary-rgb, 0, 0, 0), 0.2);
    transition: all 0.3s ease;
}

.badge:hover,
.tag:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(var(--accent-primary-rgb, 0, 0, 0), 0.3);
}

/* Avatar group overlapping effect */
.avatar-group {
    display: flex;
    flex-direction: row-reverse;
    justify-content: flex-end;
    margin-left: 10px;
}

.avatar-group img {
    margin-left: -10px;
    border: 3px solid var(--bg-primary);
    transition: all 0.3s ease;
}

.avatar-group img:hover {
    transform: translateY(-5px) scale(1.1);
    z-index: var(--z-above, 1);
}

/* Improved code blocks (if used in posts/comments) */
code,
pre {
    background: rgba(var(--bg-tertiary-rgb, 42, 42, 42), 0.6);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 2px 6px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
}

pre {
    padding: 16px;
    overflow-x: auto;
}

pre code {
    background: none;
    border: none;
    padding: 0;
}

/* Grid layouts for responsive cards */
.grid-auto-fit {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
}

.grid-auto-fill {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
}

/* Improved empty states */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: 0.3;
}

.empty-state-text {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 10px;
}

.empty-state-subtext {
    font-size: 0.95rem;
    opacity: 0.7;
}
