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

:root {
    --bg: #050506;
    --surface: #111827;
    --surface-light: #1f2937;
    --surface-hover: #1f2937;
    --accent: #00A7E1;
    --accent-glow: rgba(0, 167, 225, 0.25);
    --text: #E0E0E0;
    --text-dim: #A0A0A0;
    --radius: 20px;
    --radius-sm: 14px;
}

html,
body {
    height: 100%;
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-tap-highlight-color: transparent;
    overflow-x: hidden;
}

/* ─── Layout ─── */
.app-container {
    max-width: 600px; /* Mobile default */
    margin: 0 auto;
    padding: 2rem 1.2rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: max-width 0.4s ease;
}

/* Responsive Container Expansion */
@media (min-width: 768px) {
    .app-container { max-width: 900px; padding: 3rem 2rem; }
}
@media (min-width: 1200px) {
    .app-container { max-width: 1200px; }
}

/* ─── Header ─── */
header {
    margin-bottom: 2.5rem;
    animation: slideDown 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.header-content {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 0.5rem;
}

.header-icon {
    font-size: 2.2rem;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

header h1 {
    font-size: 2.2rem;
    font-weight: 800;
    background: linear-gradient(135deg, #E0E0E0, var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.03em;
}

.subtitle {
    color: var(--text-dim);
    font-size: 1.05rem;
    font-weight: 400;
    line-height: 1.4;
}

@media (min-width: 768px) {
    header { margin-bottom: 3.5rem; }
    header h1 { font-size: 3rem; }
    .subtitle { font-size: 1.2rem; }
}

/* ─── Grid ─── */
.apps-grid {
    display: grid;
    grid-template-columns: 1fr; /* Mobile: 1 column */
    gap: 1.2rem;
}

@media (min-width: 768px) {
    .apps-grid {
        grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
        gap: 1.5rem;
    }
}

/* ─── Search Bar ─── */
.search-container {
    position: relative;
    margin-bottom: 1.5rem;
    animation: fadeIn 0.6s ease-out backwards;
    animation-delay: 0.1s;
}

.search-icon {
    position: absolute;
    left: 1.2rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-dim);
    pointer-events: none;
}

.search-input {
    width: 100%;
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    padding: 1rem 1rem 1rem 3rem;
    color: var(--text);
    font-size: 1rem;
    font-family: inherit;
    outline: none;
    transition: all 0.2s;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

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

.search-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

/* ─── Category Filters ─── */
.filter-toggle {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 1rem 1.2rem;
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    color: var(--text);
    cursor: pointer;
    margin-bottom: 1rem;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.2s;
    animation: fadeIn 0.6s ease-out 0.1s backwards;
}

.filter-toggle .toggle-icon { margin-right: 0.8rem; font-size: 1.1rem; }
.filter-toggle .toggle-text { flex: 1; text-align: left; }
.filter-toggle .toggle-arrow { 
    font-size: 0.8rem; 
    transition: transform 0.3s ease;
    opacity: 0.5;
}

.filter-toggle:active { transform: scale(0.98); }

.filter-toggle.active .toggle-arrow { transform: rotate(180deg); }

.category-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
    margin-bottom: 2rem;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Mobile Collapsible State */
@media (max-width: 767px) {
    .category-filters.collapsed {
        max-height: 0;
        margin-bottom: 0;
        opacity: 0;
        pointer-events: none;
        transform: translateY(-10px);
    }
    .category-filters:not(.collapsed) {
        max-height: 500px;
        margin-bottom: 2rem;
        opacity: 1;
        transform: translateY(0);
    }
}

/* On Desktop: Always show, no toggle */
@media (min-width: 768px) {
    .filter-toggle { display: none !important; }
    .category-filters.collapsed { 
        max-height: none; 
        opacity: 1; 
        margin-bottom: 2rem;
        pointer-events: auto;
        transform: none;
    }
}

.filter-pill {
    background: transparent;
    border: 1px solid var(--border, rgba(255, 255, 255, 0.1));
    color: var(--text-dim);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-pill:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
}

.filter-pill.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    box-shadow: 0 4px 12px var(--accent-glow);
}

/* ─── App Card ─── */
.app-card {
    display: flex;
    align-items: center;
    gap: 1.2rem;
    background: var(--surface);
    padding: 1.2rem;
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text);
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    overflow: hidden;
    animation: fadeIn 0.6s ease-out backwards;
    min-height: 100px; /* Asegurar consistencia en grid */
}

/* Stagger animations */
.app-card:nth-child(1) {
    animation-delay: 0.1s;
}

.app-card:nth-child(2) {
    animation-delay: 0.2s;
}

.app-card:nth-child(3) {
    animation-delay: 0.3s;
}

.app-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.03));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.app-card:hover:not(.disabled) {
    transform: translateY(-6px);
    background: var(--surface-hover);
    border-color: var(--accent);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5), 0 0 15px var(--accent-glow);
}

.app-card:hover:not(.disabled)::before {
    opacity: 1;
}

.app-card:active:not(.disabled) {
    transform: translateY(-1px) scale(0.99);
}

.card-icon {
    width: 60px;
    height: 60px;
    flex-shrink: 0;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    box-shadow: inset 0 2px 10px rgba(255, 255, 255, 0.05), 0 8px 20px rgba(0, 0, 0, 0.5);
}

.card-icon.bg-primary {
    background: linear-gradient(135deg, #00A7E1, #007bb5);
}

.card-icon.bg-gray {
    background: linear-gradient(135deg, #374151, #1f2937);
    filter: grayscale(100%);
}

.card-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    z-index: 1;
}

.card-info h2 {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.app-badge {
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
    border-radius: 6px;
    background-color: rgba(255, 255, 255, 0.08);
    /* Subtle background */
    border: 1px solid currentColor;
    font-weight: 600;
    white-space: nowrap;
    letter-spacing: normal;
}

.card-info p {
    font-size: 0.85rem;
    color: var(--text-dim);
    line-height: 1.4;
}

.card-arrow {
    color: rgba(255, 255, 255, 0.2);
    transition: transform 0.3s ease, color 0.3s ease;
    display: flex;
    align-items: center;
}

.app-card:hover:not(.disabled) .card-arrow {
    transform: translateX(4px);
    color: var(--accent);
}

.app-card.disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ─── Animations ─── */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(15px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ─── Footer ─── */
.app-footer {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-top: auto;
    padding-top: 2rem;
    line-height: 1.5;
}

.app-footer a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

/* Stagger: 4th card */
.app-card:nth-child(4) {
    animation-delay: 0.4s;
}

/* ─── CTA Banner ─── */
.cta-banner {
    display: block;
    text-align: center;
    padding: 1.2rem;
    margin-top: 1.5rem;
    background: linear-gradient(135deg, rgba(0, 167, 225, 0.08), rgba(0, 123, 181, 0.06));
    border: 1px solid rgba(0, 167, 225, 0.15);
    border-radius: 14px;
    animation: fadeIn 0.6s ease-out 0.5s backwards;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.cta-banner:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 167, 225, 0.15);
}

.cta-banner p {
    font-size: 0.9rem;
    color: var(--text-dim);
    margin-bottom: 0.5rem;
}

.cta-banner span {
    color: var(--accent);
    font-weight: 700;
    font-size: 0.95rem;
}

/* Donation variant */
.cta-donate {
    background: linear-gradient(135deg, rgba(255, 196, 57, 0.08), rgba(0, 167, 225, 0.06));
    border-color: rgba(255, 196, 57, 0.15);
}

.cta-donate:hover {
    box-shadow: 0 6px 20px rgba(255, 196, 57, 0.15);
}

.cta-donate span {
    color: #ffc439;
}

@media (min-width: 768px) {
    .cta-banner {
        display: flex;
        justify-content: space-between;
        align-items: center;
        text-align: left;
        padding: 1.5rem 2rem;
    }
    .cta-banner p { margin-bottom: 0; font-size: 1.1rem; }
    .cta-banner span { font-size: 1.1rem; }
}