/* ===========================
   CSS Reset & Base Styles
   =========================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Brand Colors */
    --color-primary: #1B5E20;
    --color-primary-light: #43A047;
    --color-bg-light: #F5F7F8;
    --color-text: #1F2937;
    --color-text-light: #6B7280;
    --color-white: #FFFFFF;
    --color-border: #E5E7EB;
    --color-shadow: rgba(0, 0, 0, 0.1);
    --color-shadow-hover: rgba(0, 0, 0, 0.15);
    
    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    
    /* Spacing */
    --spacing-xs: 0.5rem;
    --spacing-sm: 0.75rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;
    
    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 200ms ease;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    color: var(--color-text);
    background: linear-gradient(
        135deg, 
        #1e3a8a 0%,      /* Azul oscuro */
        #1e40af 20%,     /* Azul profundo */
        #1f2937 35%,     /* Gris oscuro */
        #7f1d1d 50%,     /* Rojo oscuro */
        #991b1b 65%,     /* Rojo profundo */
        #14532d 80%,     /* Verde oscuro */
        #1e3a8a 100%     /* Azul oscuro */
    );
    background-size: 400% 400%;
    background-attachment: fixed;
    animation: gradientShift 20s ease infinite;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
    position: relative;
}

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

/* ===========================
   Container
   =========================== */

.container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 var(--spacing-md);
}

@media (min-width: 768px) {
    .container {
        padding: 0 var(--spacing-xl);
    }
}

/* ===========================
   Main Content
   =========================== */

.main {
    padding: var(--spacing-md);
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
}

.main .container {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0 var(--spacing-md);
    max-width: 100%;
    overflow: visible;
    align-items: center;
}

/* ===========================
   Page Title
   =========================== */

.page-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-white);
    text-align: center;
    margin-bottom: var(--spacing-lg);
    margin-top: var(--spacing-md);
    letter-spacing: -0.02em;
    flex-shrink: 0;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

@media (min-width: 481px) {
    .page-title {
        font-size: 1.5rem;
    }
}

@media (min-width: 769px) {
    .page-title {
        font-size: 1.75rem;
        margin-bottom: var(--spacing-lg);
    }
}

@media (min-width: 1201px) {
    .page-title {
        font-size: 2rem;
    }
}

/* ===========================
   Apps Grid
   =========================== */

.apps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: var(--spacing-lg);
    align-content: start;
    justify-content: center;
    width: 100%;
    max-width: 1200px;
    padding-bottom: var(--spacing-xl);
}

/* Ajuste para pantallas muy pequeñas */
@media (max-width: 480px) {
    .apps-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-md);
        padding-bottom: var(--spacing-2xl);
    }
    
    .main {
        padding: var(--spacing-sm);
    }
    
    .main .container {
        padding: 0 var(--spacing-sm);
    }
}

/* Tablets pequeñas */
@media (min-width: 481px) and (max-width: 768px) {
    .apps-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Tablets y desktop pequeño */
@media (min-width: 769px) and (max-width: 1200px) {
    .apps-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Desktop grande */
@media (min-width: 1201px) {
    .apps-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

/* ===========================
   App Card
   =========================== */

.app-card {
    background: linear-gradient(145deg, #ffffff, #f0f0f0);
    border: 2px solid rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    padding: var(--spacing-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: center;
    aspect-ratio: 1 / 1;
    min-height: 0;
    position: relative;
    overflow: hidden;
}

/* Colores individuales para cada tarjeta */
.app-card:nth-child(1) {
    background: linear-gradient(145deg, #e8f5e9, #c8e6c9);
    border-color: #81c784;
}

.app-card:nth-child(2) {
    background: linear-gradient(145deg, #e3f2fd, #bbdefb);
    border-color: #64b5f6;
}

.app-card:nth-child(3) {
    background: linear-gradient(145deg, #fff3e0, #ffe0b2);
    border-color: #ffb74d;
}

.app-card:nth-child(4) {
    background: linear-gradient(145deg, #fce4ec, #f8bbd0);
    border-color: #f06292;
}

.app-card:nth-child(5) {
    background: linear-gradient(145deg, #f3e5f5, #e1bee7);
    border-color: #ba68c8;
}

.app-card:nth-child(6) {
    background: linear-gradient(145deg, #e0f2f1, #b2dfdb);
    border-color: #4db6ac;
}

.app-card:nth-child(7) {
    background: linear-gradient(145deg, #fff9c4, #fff59d);
    border-color: #fdd835;
}

.app-card:nth-child(8) {
    background: linear-gradient(145deg, #ede7f6, #d1c4e9);
    border-color: #9575cd;
}

.app-card:nth-child(9) {
    background: linear-gradient(145deg, #ffebee, #ffcdd2);
    border-color: #e57373;
}

.app-card:nth-child(10) {
    background: linear-gradient(145deg, #e1f5fe, #b3e5fc);
    border-color: #4fc3f7;
}

.app-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.3) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.app-card:hover::before {
    opacity: 1;
}

.app-card:hover {
    transform: translateY(-8px) scale(1.05);
    box-shadow: 
        0 16px 48px rgba(30, 60, 114, 0.4),
        0 0 0 4px rgba(255, 255, 255, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 1);
    filter: brightness(1.1);
}

.app-card.hidden {
    display: none;
}

.app-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-sm);
    text-decoration: none;
    width: 100%;
    transition: transform var(--transition-base);
    cursor: pointer;
    pointer-events: auto;
    position: relative;
    z-index: 1;
}

.app-link:hover .app-icon {
    transform: scale(1.1);
}

.app-icon {
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(27, 94, 32, 0.1), rgba(67, 160, 71, 0.1));
    border-radius: 50%;
    padding: var(--spacing-sm);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.app-link:hover .app-icon {
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
    transform: rotate(10deg);
}

.app-link:hover .app-icon img {
    filter: brightness(0) invert(1);
}

.app-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: filter var(--transition-base);
}

.app-name {
    font-size: 0.7rem;
    font-weight: 600;
    color: #1F2937;
    line-height: 1.1;
    transition: all 0.3s ease;
    max-width: 90%;
    letter-spacing: -0.01em;
}

.app-link:hover .app-name {
    color: var(--color-primary);
    font-weight: 700;
}

/* Ajustes responsive para iconos y texto */
@media (min-width: 481px) {
    .app-icon {
        width: 55px;
        height: 55px;
    }
    
    .app-name {
        font-size: 0.75rem;
    }
}

@media (min-width: 769px) {
    .app-card {
        padding: var(--spacing-lg);
        gap: var(--spacing-sm);
    }
    
    .app-icon {
        width: 60px;
        height: 60px;
    }
    
    .app-name {
        font-size: 0.8rem;
    }
}

@media (min-width: 1201px) {
    .app-icon {
        width: 70px;
        height: 70px;
    }
    
    .app-name {
        font-size: 0.85rem;
    }
}

/* ===========================
   Buttons
   =========================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-sm) var(--spacing-lg);
    font-size: 0.875rem;
    font-weight: 500;
    font-family: var(--font-family);
    text-decoration: none;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background-color var(--transition-base), transform var(--transition-fast);
    outline: none;
}

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

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background-color: var(--color-primary);
    color: var(--color-white);
}

.btn-primary:hover {
    background-color: var(--color-primary-light);
}

.btn-info {
    background-color: transparent;
    color: var(--color-primary);
    border: none;
    font-size: 0.65rem;
    font-weight: 500;
    font-family: var(--font-family);
    cursor: pointer;
    padding: 0;
    text-decoration: none;
    transition: all 0.3s ease;
    position: relative;
    opacity: 0.8;
    z-index: 2;
}

.btn-info::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 1px;
    background-color: var(--color-primary);
    transition: width 0.3s ease;
}

.btn-info:hover {
    color: var(--color-primary);
    opacity: 1;
}

.btn-info:hover::after {
    width: 100%;
}

.btn-info:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

@media (min-width: 769px) {
    .btn-info {
        font-size: 0.7rem;
    }
}

/* ===========================
   No Results
   =========================== */

.no-results {
    text-align: center;
    padding: var(--spacing-2xl);
    color: var(--color-text-light);
    font-size: 1rem;
}

/* ===========================
   Modal
   =========================== */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-md);
}

.modal.active {
    display: flex;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background-color: var(--color-white);
    border-radius: var(--radius-lg);
    padding: var(--spacing-2xl);
    max-width: 500px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease;
}

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

.modal-close {
    position: absolute;
    top: var(--spacing-md);
    right: var(--spacing-md);
    background: none;
    border: none;
    font-size: 2rem;
    line-height: 1;
    color: var(--color-text-light);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: background-color var(--transition-base), color var(--transition-base);
}

.modal-close:hover {
    background-color: var(--color-bg-light);
    color: var(--color-text);
}

.modal-close:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--color-primary);
    margin-bottom: var(--spacing-md);
    padding-right: var(--spacing-xl);
}

.modal-description {
    font-size: 1rem;
    color: var(--color-text);
    line-height: 1.6;
    margin-bottom: var(--spacing-xl);
}

.modal-actions {
    display: flex;
    gap: var(--spacing-md);
    justify-content: flex-end;
}

.modal-actions .btn {
    flex: 1;
}

@media (min-width: 640px) {
    .modal-actions .btn {
        flex: 0 1 auto;
    }
}

/* ===========================
   Footer
   =========================== */

.footer {
    background-color: transparent;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    padding: var(--spacing-sm) 0;
    margin-top: auto;
}

.footer .container {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.footer-text {
    font-size: 0.75rem;
    color: var(--color-white);
}

@media (min-width: 768px) {
    .footer-text {
        font-size: 0.8rem;
    }
}

/* ===========================
   Accessibility
   =========================== */

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

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
