/* ============================================
   DopaBrain Portal - 2026 Neon Purple UI
   Dark Mode First | Glassmorphism 2.0
   Theme: Dopamine + Brain + Neon
   ============================================ */

/* === CSS Variables === */
:root {
    --primary: #8b5cf6;
    --primary-light: #a78bfa;
    --primary-dark: #7c3aed;
    --accent: #06b6d4;
    --accent-pink: #ec4899;
    --neon-purple: #c084fc;
    --neon-blue: #22d3ee;
    --neon-pink: #f472b6;

    /* Dark Mode (Default) */
    --bg: #030014;
    --bg-secondary: #0a0520;
    --surface: rgba(10, 5, 30, 0.95);
    --surface-glass: rgba(139, 92, 246, 0.06);
    --surface-glass-hover: rgba(139, 92, 246, 0.12);
    --border-glass: rgba(139, 92, 246, 0.12);
    --border-glass-hover: rgba(139, 92, 246, 0.25);

    --text: #f0f0ff;
    --text-secondary: #a5a0d0;
    --text-dim: #5a5580;

    --radius: 16px;
    --radius-sm: 10px;
    --radius-lg: 24px;

    --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 30px rgba(139, 92, 246, 0.15);

    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: all 0.15s ease;
}

/* === Reset & Base === */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* === Background Effects === */
.bg-effects {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.bg-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.35;
    animation: orbFloat 25s ease-in-out infinite;
}

.bg-orb-1 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.4), transparent);
    top: -150px;
    right: -150px;
    animation-delay: 0s;
}

.bg-orb-2 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(6, 182, 212, 0.3), transparent);
    bottom: 10%;
    left: -120px;
    animation-delay: -8s;
}

.bg-orb-3 {
    width: 350px;
    height: 350px;
    background: radial-gradient(circle, rgba(236, 72, 153, 0.25), transparent);
    top: 40%;
    right: -80px;
    animation-delay: -16s;
}

@keyframes orbFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(40px, -40px) scale(1.08); }
    50% { transform: translate(-30px, 30px) scale(0.92); }
    75% { transform: translate(25px, 15px) scale(1.04); }
}

/* === Container === */
.container {
    position: relative;
    z-index: 1;
    max-width: 900px;
    margin: 0 auto;
    padding: 16px 16px 100px;
    min-height: 100vh;
}

/* === Ad Banners === */
.ad-banner {
    background: var(--surface-glass);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    padding: 10px;
    text-align: center;
    margin-bottom: 16px;
}

.ad-banner.ad-bottom {
    position: fixed;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 32px);
    max-width: 900px;
    z-index: 100;
    margin-bottom: 0;
}

.ad-placeholder {
    color: var(--text-dim);
    font-size: 12px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* === Header === */
.portal-header {
    text-align: center;
    padding: 28px 0 20px;
}

.logo-area {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-bottom: 12px;
}

.logo-icon {
    font-size: 44px;
    animation: brainPulse 3s ease-in-out infinite;
    filter: drop-shadow(0 0 12px rgba(139, 92, 246, 0.6));
}

@keyframes brainPulse {
    0%, 100% {
        filter: drop-shadow(0 0 12px rgba(139, 92, 246, 0.6));
        transform: scale(1);
    }
    50% {
        filter: drop-shadow(0 0 24px rgba(6, 182, 212, 0.8)) drop-shadow(0 0 48px rgba(139, 92, 246, 0.4));
        transform: scale(1.08);
    }
}

.logo-text h1 {
    font-size: 34px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--neon-purple), var(--neon-blue), var(--neon-pink));
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
    animation: gradientShift 4s ease infinite;
}

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

.tagline {
    font-size: 12px;
    color: var(--accent);
    font-weight: 600;
    letter-spacing: 3px;
    text-transform: uppercase;
}

.header-desc {
    font-size: 14px;
    color: var(--text-dim);
    max-width: 420px;
    margin: 0 auto;
}

/* === Search === */
.search-area {
    margin-bottom: 16px;
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 16px;
    width: 18px;
    height: 18px;
    color: var(--text-dim);
    pointer-events: none;
    transition: var(--transition-fast);
}

.search-box input {
    width: 100%;
    padding: 14px 44px 14px 46px;
    background: rgba(139, 92, 246, 0.05);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 15px;
    outline: none;
    transition: var(--transition);
}

.search-box input::placeholder {
    color: var(--text-dim);
}

.search-box input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15), 0 0 20px rgba(139, 92, 246, 0.1);
}

.search-box input:focus ~ .search-icon,
.search-box input:focus + .search-icon {
    color: var(--primary-light);
}

.search-clear {
    position: absolute;
    right: 12px;
    width: 28px;
    height: 28px;
    background: rgba(139, 92, 246, 0.15);
    border: none;
    border-radius: 50%;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.search-clear:hover {
    background: rgba(139, 92, 246, 0.3);
    color: var(--text);
}

/* === Category Filter === */
.category-filter {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 4px 0 16px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.category-filter::-webkit-scrollbar {
    display: none;
}

.cat-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: rgba(139, 92, 246, 0.06);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border-glass);
    border-radius: 100px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    min-height: 44px;
}

.cat-btn:hover {
    background: rgba(139, 92, 246, 0.12);
    border-color: rgba(139, 92, 246, 0.25);
    color: var(--text);
}

.cat-btn.active {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.25), rgba(6, 182, 212, 0.15));
    border-color: rgba(139, 92, 246, 0.4);
    color: var(--text);
    font-weight: 600;
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.15);
}

.cat-icon {
    font-size: 16px;
}

/* Ripple effect */
.ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(139, 92, 246, 0.2);
    animation: rippleAnim 0.6s ease-out forwards;
    pointer-events: none;
}

@keyframes rippleAnim {
    from { transform: scale(0); opacity: 1; }
    to { transform: scale(2.5); opacity: 0; }
}

/* === Personalized Section === */
.personalized-section {
    margin-bottom: 20px;
}

.personalized-greeting {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 16px;
    padding-left: 2px;
}

.personalized-block {
    margin-bottom: 16px;
}

.personalized-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 10px;
    padding-left: 2px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.personalized-label::before {
    content: '';
    display: inline-block;
    width: 3px;
    height: 14px;
    border-radius: 2px;
    background: linear-gradient(180deg, var(--neon-purple), var(--neon-blue));
}

.personalized-scroll {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 8px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.personalized-scroll::-webkit-scrollbar {
    display: none;
}

.p-card {
    position: relative;
    flex: 0 0 auto;
    width: 130px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 14px 10px;
    background: rgba(139, 92, 246, 0.04);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(139, 92, 246, 0.1);
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text);
    transition: var(--transition);
    scroll-snap-align: start;
    text-align: center;
}

.p-card:hover {
    transform: translateY(-3px);
    border-color: var(--p-color, rgba(139, 92, 246, 0.3));
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3),
                0 0 15px color-mix(in srgb, var(--p-color) 15%, transparent);
}

.p-card-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    background: linear-gradient(135deg, var(--p-color, #8b5cf6)22, var(--p-color, #8b5cf6)08);
}

.p-card-name {
    font-size: 12px;
    font-weight: 600;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Time-based indicator dot */
.p-card[data-time-boost]::after {
    content: '';
    position: absolute;
    top: 8px;
    right: 8px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--neon-blue);
    box-shadow: 0 0 8px var(--neon-blue);
}

@media (min-width: 600px) {
    .p-card { width: 140px; }
    .personalized-greeting { font-size: 20px; }
}

/* === App Grid === */
.app-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

/* === App Card === */
.app-card {
    position: relative;
    display: flex;
    flex-direction: column;
    background: rgba(139, 92, 246, 0.04);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(139, 92, 246, 0.1);
    border-radius: var(--radius);
    overflow: hidden;
    text-decoration: none;
    color: var(--text);
    transition: var(--transition);
    cursor: pointer;
    min-height: 160px;
}

.app-card:hover {
    transform: translateY(-4px);
    border-color: var(--card-color, rgba(139, 92, 246, 0.3));
    box-shadow:
        0 8px 30px rgba(0, 0, 0, 0.3),
        0 0 25px color-mix(in srgb, var(--card-color) 20%, transparent),
        inset 0 0 30px rgba(139, 92, 246, 0.03);
}

.app-card:active {
    transform: translateY(-2px) scale(0.98);
}

/* Card glow effect on hover */
.card-glow {
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at center, var(--card-color, #8b5cf6) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
}

.app-card:hover .card-glow {
    opacity: 0.06;
}

.card-content {
    position: relative;
    z-index: 1;
    flex: 1;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.card-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    border: 1px solid rgba(139, 92, 246, 0.1);
    flex-shrink: 0;
}

.card-badges {
    display: flex;
    gap: 4px;
}

.badge {
    padding: 3px 8px;
    border-radius: 100px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-new {
    background: linear-gradient(135deg, #06b6d4, #22d3ee);
    color: #fff;
    box-shadow: 0 0 8px rgba(6, 182, 212, 0.3);
}

.badge-popular {
    background: linear-gradient(135deg, #ec4899, #f472b6);
    color: #fff;
    box-shadow: 0 0 8px rgba(236, 72, 153, 0.3);
}

.card-info {
    flex: 1;
}

.card-title {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 3px;
    line-height: 1.3;
}

.card-desc {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-arrow {
    display: flex;
    justify-content: flex-end;
}

.card-arrow svg {
    width: 18px;
    height: 18px;
    color: var(--text-dim);
    transition: var(--transition);
}

.app-card:hover .card-arrow svg {
    color: var(--card-color, var(--primary));
    transform: translateX(3px);
}

.card-color-bar {
    height: 3px;
    width: 100%;
    opacity: 0.5;
    transition: opacity 0.3s ease;
}

.app-card:hover .card-color-bar {
    opacity: 1;
    box-shadow: 0 0 10px color-mix(in srgb, var(--card-color, #8b5cf6) 40%, transparent);
}

/* === Card Animation === */
.app-card.fade-in {
    animation: cardFadeIn 0.5s ease forwards;
    opacity: 0;
}

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

/* === Empty State === */
.empty-state {
    text-align: center;
    padding: 48px 16px;
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.empty-state p {
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.reset-btn {
    padding: 10px 24px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border: none;
    border-radius: 100px;
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    min-height: 44px;
}

.reset-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 20px rgba(139, 92, 246, 0.35);
}

/* === Stats Section === */
.stats-section {
    display: flex;
    justify-content: center;
    gap: 32px;
    padding: 24px 0;
    margin-bottom: 16px;
    opacity: 0;
    transform: translateY(20px);
    transition: var(--transition);
}

.stats-section.visible {
    opacity: 1;
    transform: translateY(0);
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.stat-number {
    font-size: 28px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--neon-purple), var(--neon-blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-label {
    font-size: 12px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 500;
}

/* === Footer === */
.portal-footer {
    text-align: center;
    padding: 16px 0 24px;
    border-top: 1px solid var(--border-glass);
    opacity: 0;
    transform: translateY(20px);
    transition: var(--transition);
}

.portal-footer.visible {
    opacity: 1;
    transform: translateY(0);
}

.portal-footer p {
    font-size: 12px;
    color: var(--text-dim);
    margin-bottom: 8px;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 16px;
}

.footer-links a {
    font-size: 12px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition-fast);
}

.footer-links a:hover {
    color: var(--neon-purple);
}

/* === Blog Section === */
.blog-section {
    margin-bottom: 24px;
}

.blog-header {
    text-align: center;
    margin-bottom: 16px;
}

.blog-title {
    font-size: 22px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--neon-purple), var(--neon-blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.3px;
    margin-bottom: 4px;
}

.blog-subtitle {
    font-size: 13px;
    color: var(--text-dim);
}

.blog-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.blog-card {
    display: block;
    background: rgba(139, 92, 246, 0.04);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(139, 92, 246, 0.1);
    border-radius: var(--radius);
    padding: 16px;
    text-decoration: none;
    color: var(--text);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.blog-card:hover {
    transform: translateY(-2px);
    border-color: rgba(139, 92, 246, 0.25);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3), 0 0 15px rgba(139, 92, 246, 0.1);
}

.blog-card-tag {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 100px;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.3px;
    margin-bottom: 8px;
}

.blog-card-title {
    font-size: 16px;
    font-weight: 700;
    line-height: 1.4;
    margin-bottom: 6px;
}

.blog-card-desc {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 8px;
}

.blog-card-meta {
    font-size: 11px;
    color: var(--text-dim);
    font-weight: 500;
}

@media (min-width: 600px) {
    .blog-grid {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 12px;
    }
}

/* === Utility Classes === */
.hidden {
    display: none !important;
}

/* === Responsive === */

/* Tablet */
@media (min-width: 600px) {
    .container {
        padding: 24px 24px 100px;
    }

    .app-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
    }

    .logo-text h1 {
        font-size: 38px;
    }

    .portal-header {
        padding: 36px 0 24px;
    }
}

/* Desktop */
@media (min-width: 900px) {
    .app-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .search-box input {
        font-size: 16px;
        padding: 16px 44px 16px 48px;
    }
}

/* Small mobile */
@media (max-width: 380px) {
    .app-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .app-card {
        min-height: auto;
    }

    .card-content {
        flex-direction: row;
        align-items: center;
        gap: 12px;
    }

    .card-header {
        flex-shrink: 0;
    }

    .card-arrow {
        flex-shrink: 0;
    }

    .card-badges {
        position: absolute;
        top: 8px;
        right: 8px;
    }

    .logo-text h1 {
        font-size: 28px;
    }
}

/* === Accessibility === */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

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

a:focus:not(:focus-visible),
button:focus:not(:focus-visible) {
    outline: none;
}

/* High contrast mode */
@media (forced-colors: active) {
    .app-card {
        border: 2px solid ButtonText;
    }
    .badge {
        border: 1px solid ButtonText;
    }
}

/* === Language Selector === */
.language-selector {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

.lang-btn {
    background: rgba(139, 92, 246, 0.3);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(139, 92, 246, 0.4);
    color: #fff;
    font-size: 20px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lang-btn:hover {
    background: rgba(139, 92, 246, 0.5);
    transform: scale(1.05);
}

.lang-btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.lang-menu {
    position: absolute;
    top: 52px;
    right: 0;
    background: rgba(3, 0, 20, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 12px;
    padding: 8px;
    min-width: 150px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.lang-menu.hidden {
    display: none;
}

.lang-option {
    width: 100%;
    padding: 10px 14px;
    background: transparent;
    border: none;
    text-align: left;
    cursor: pointer;
    border-radius: 8px;
    font-size: 14px;
    color: var(--text-secondary);
    transition: background 0.2s;
}

.lang-option:hover {
    background: rgba(139, 92, 246, 0.2);
    color: var(--text);
}

.lang-option:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
}

.lang-option.active {
    background: rgba(139, 92, 246, 0.3);
    font-weight: 600;
    color: var(--text);
}
