/* ========================================
   INDEX.CSS - Estilos específicos para index.php
   Versión 3.0 - Mejorado con las recomendaciones
   ======================================== */

/* Variables CSS actualizadas */
:root {
    --primary: #5D4037;
    --secondary: #8D6E63;
    --accent: #FFF8E1;
    --gold: #FFD700;
    --silver: #C0C0C0;
    --bronze: #CD7F32;
    --success: #4CAF50;
    --warning: #FF9800;
    --error: #f44336;
    --shadow: 0 4px 15px rgba(0,0,0,0.1);
    --border-radius: 12px;
    --transition: all 0.3s ease;
}

/* Header responsivo mejorado */
.header-container {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem 15px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    position: relative;
    overflow: hidden;
}

.header-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('coffee-pattern.png') repeat;
    opacity: 0.1;
    z-index: 0;
}

.header-content {
    position: relative;
    z-index: 1;
    text-align: center;
    max-width: 1200px;
    width: 100%;
}

.header-content h1 {
    font-family: 'Playfair Display', serif;
    font-size: 2.5rem;
    margin: 1rem 0 0.5rem;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    margin-bottom: 1rem;
    font-weight: 300;
}

.logo {
    width: 80px;
    height: auto;
    margin-bottom: 1rem;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.3));
    transition: transform 0.3s ease;
}

.logo:hover {
    transform: scale(1.05) rotate(2deg);
}

.auth-buttons {
    position: absolute;
    top: 1rem;
    right: 1rem;
}

.auth-btn {
    background: rgba(255,255,255,0.2);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 25px;
    text-decoration: none;
    transition: var(--transition);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.3);
}

.auth-btn:hover {
    background: rgba(255,255,255,0.3);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

/* Responsive del header */
@media (max-width: 768px) {
    .header-container {
        flex-direction: column;
        text-align: center;
        padding: 1rem;
    }
    
    .header-content h1 {
        font-size: 2rem;
    }
    
    .auth-buttons {
        position: static;
        margin-bottom: 1rem;
    }
    
    .subtitle {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .header-content h1 {
        font-size: 1.5rem;
    }
    
    .logo {
        width: 60px;
    }
}

/* Estilos del contenedor principal */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

/* Section header mejorado */
.section-header {
    text-align: center;
    margin-bottom: 3rem;
    background: white;
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

.section-title {
    font-family: 'Playfair Display', serif;
    font-size: 2.2rem;
    color: var(--primary);
    margin-bottom: 1rem;
    position: relative;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    border-radius: 2px;
}

.section-description {
    font-size: 1.1rem;
    color: #666;
    line-height: 1.7;
    max-width: 800px;
    margin: 0 auto 1.5rem;
}

.section-stats {
    display: flex;
    gap: 2rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

.section-stats span {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #666;
    font-size: 0.95rem;
    font-weight: 500;
}

.section-stats i {
    color: var(--primary);
    font-size: 1.1rem;
}

/* Ranking container mejorado */
.ranking-container {
    margin-bottom: 3rem;
}

.ranking-header {
    text-align: center;
    margin-bottom: 2rem;
    background: linear-gradient(135deg, var(--accent), #FFF);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    border-left: 4px solid var(--primary);
}

.ranking-header h3 {
    font-family: 'Playfair Display', serif;
    font-size: 1.8rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.ranking-header p {
    color: #666;
    font-style: italic;
}

/* Estilos mejorados para ranking items */
.ranking-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
}

.ranking-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.6s ease;
}

.ranking-item:hover::before {
    left: 100%;
}

.ranking-item:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 20px 40px rgba(0,0,0,0.15);
    border-color: var(--primary);
}

.ranking-item:focus {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

/* Rank number styling mejorado */
.rank {
    flex-shrink: 0;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.1rem;
    color: white;
    background: linear-gradient(135deg, #666, #888);
    position: relative;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

/* Colores del podio mejorados (más distintivos) */
.rank-gold {
    background: linear-gradient(135deg, #FFD700, #FFA500) !important;
    color: #8B4513 !important;
    box-shadow: 0 0 25px rgba(255, 215, 0, 0.6) !important;
    border: 2px solid #FFD700;
    animation: pulse-gold 2s infinite;
}

.rank-silver {
    background: linear-gradient(135deg, #E5E5E5, #C0C0C0) !important;
    color: #333 !important;
    box-shadow: 0 0 20px rgba(192, 192, 192, 0.6) !important;
    border: 2px solid #C0C0C0;
}

.rank-bronze {
    background: linear-gradient(135deg, #D2691E, #CD7F32) !important;
    color: #fff !important;
    box-shadow: 0 0 20px rgba(205, 127, 50, 0.6) !important;
    border: 2px solid #CD7F32;
}

@keyframes pulse-gold {
    0%, 100% { 
        box-shadow: 0 0 25px rgba(255, 215, 0, 0.6);
        transform: scale(1);
    }
    50% { 
        box-shadow: 0 0 35px rgba(255, 215, 0, 0.8);
        transform: scale(1.05);
    }
}

/* Estilos para imagen de marca mejorados */
.brand-image {
    flex-shrink: 0;
    width: 70px;
    height: 70px;
    border-radius: 10px;
    overflow: hidden;
    background: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #e9ecef;
    transition: var(--transition);
    position: relative;
}

.marca-logo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.ranking-item:hover .marca-logo {
    transform: scale(1.1);
}

.ranking-item:hover .brand-image {
    border-color: var(--primary);
    box-shadow: 0 0 15px rgba(93, 64, 55, 0.3);
}

/* Placeholder para marcas sin imagen - usando iniciales */
.brand-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    font-size: 1.3rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

/* Rank específicos para brand images */
.rank-gold .brand-image {
    border-color: #FFD700;
    background: linear-gradient(135deg, #FFF8DC, #F5F5DC);
}

.rank-gold .brand-placeholder {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: #8B4513;
}

.rank-silver .brand-image {
    border-color: #C0C0C0;
    background: linear-gradient(135deg, #F8F8FF, #F0F0F0);
}

.rank-silver .brand-placeholder {
    background: linear-gradient(135deg, #C0C0C0, #A0A0A0);
    color: #333;
}

.rank-bronze .brand-image {
    border-color: #CD7F32;
    background: linear-gradient(135deg, #FDF5E6, #F5DEB3);
}

.rank-bronze .brand-placeholder {
    background: linear-gradient(135deg, #CD7F32, #B87333);
    color: white;
}

/* Coffee info section */
.coffee-info {
    flex: 1;
    min-width: 0;
}

.coffee-name {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 0.5rem;
    line-height: 1.2;
}

.coffee-quality {
    font-size: 0.85rem;
    color: #666;
    font-style: italic;
    font-weight: 400;
    display: block;
    margin-top: 4px;
}

.origin {
    color: #888;
    font-size: 0.9rem;
    margin-bottom: 0.8rem;
}

.evaluation-stats {
    display: flex;
    gap: 15px;
    margin-bottom: 0.8rem;
    flex-wrap: wrap;
}

.evaluation-stats span {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8rem;
    color: #666;
}

.best-attributes {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.attribute-badge {
    background: #e8f4fd;
    color: #1976d2;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 500;
    border: 1px solid rgba(25, 118, 210, 0.2);
}

/* Score display mejorado */
.score {
    flex-shrink: 0;
    text-align: center;
    padding: 0.8rem;
    border-radius: 8px;
    min-width: 80px;
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    transition: var(--transition);
}

.score-number {
    font-size: 1.8rem;
    font-weight: bold;
    color: var(--primary);
    line-height: 1;
}

.score-total {
    font-size: 0.9rem;
    opacity: 0.7;
    color: #666;
}

/* Score classes mejoradas */
.score-excellent {
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white !important;
    border-color: #4CAF50;
    box-shadow: 0 0 15px rgba(76, 175, 80, 0.5);
    animation: pulse-excellent 2s infinite;
}

.score-excellent .score-number,
.score-excellent .score-total {
    color: white !important;
}

.score-high {
    background: linear-gradient(135deg, #2196F3, #1976D2);
    color: white !important;
    border-color: #2196F3;
}

.score-high .score-number,
.score-high .score-total {
    color: white !important;
}

.score-medium {
    background: linear-gradient(135deg, #FF9800, #F57C00);
    color: white !important;
    border-color: #FF9800;
}

.score-medium .score-number,
.score-medium .score-total {
    color: white !important;
}

.score-low {
    background: linear-gradient(135deg, #f44336, #d32f2f);
    color: white !important;
    border-color: #f44336;
}

.score-low .score-number,
.score-low .score-total {
    color: white !important;
}

@keyframes pulse-excellent {
    0%, 100% { 
        box-shadow: 0 0 15px rgba(76, 175, 80, 0.5);
        transform: scale(1);
    }
    50% { 
        box-shadow: 0 0 25px rgba(76, 175, 80, 0.8);
        transform: scale(1.05);
    }
}

/* Analyze button mejorado */
.analyze-btn {
    flex-shrink: 0;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border: none;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 4px 15px rgba(93, 64, 55, 0.3);
}

.analyze-btn:hover {
    background: linear-gradient(135deg, var(--secondary), var(--primary));
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(93, 64, 55, 0.4);
}

.analyze-btn:active {
    transform: translateY(0);
}

/* No data state mejorado */
.no-data-enhanced {
    text-align: center;
    padding: 4rem 2rem;
    background: white;
    border-radius: 20px;
    box-shadow: var(--shadow);
    margin: 2rem 0;
    border: 2px dashed #ddd;
}

.no-data-enhanced i {
    font-size: 4rem;
    color: #ddd;
    margin-bottom: 1.5rem;
}

.no-data-enhanced h3 {
    color: var(--primary);
    margin-bottom: 1rem;
    font-size: 1.8rem;
    font-family: 'Playfair Display', serif;
}

.no-data-enhanced p {
    color: #666;
    margin-bottom: 2rem;
    line-height: 1.6;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

/* Action buttons */
.action-buttons {
    text-align: center;
    margin: 3rem 0;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 2rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    transition: var(--transition);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(93, 64, 55, 0.3);
}

.btn:hover {
    background: linear-gradient(135deg, var(--secondary), var(--primary));
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(93, 64, 55, 0.4);
    color: white;
}

.btn-secondary {
    background: linear-gradient(135deg, #6c757d, #5a6268);
}

.btn-secondary:hover {
    background: linear-gradient(135deg, #5a6268, #6c757d);
}

/* Footer mejorado */
footer {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    margin-top: 4rem;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    max-width: 1200px;
    margin: 0 auto;
    padding: 3rem 2rem 2rem;
}

.footer-section h4 {
    color: #FFF8E1;
    margin-bottom: 1rem;
    font-size: 1.2rem;
    font-family: 'Playfair Display', serif;
}

.footer-section p {
    line-height: 1.6;
    opacity: 0.9;
}

.footer-section ul {
    list-style: none;
    padding: 0;
}

.footer-section ul li {
    margin-bottom: 0.5rem;
}

.footer-section ul li a {
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    transition: var(--transition);
}

.footer-section ul li a:hover {
    color: #FFF8E1;
    text-decoration: underline;
}

.social-links {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.social-links a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    color: white;
    transition: var(--transition);
    backdrop-filter: blur(10px);
}

.social-links a:hover {
    background: #FFF8E1;
    color: var(--primary);
    transform: translateY(-2px);
}

.footer-stats {
    display: flex;
    gap: 2rem;
    justify-content: center;
}

.footer-stat {
    text-align: center;
}

.footer-stat .stat-number {
    display: block;
    font-size: 1.8rem;
    font-weight: bold;
    color: #FFF8E1;
}

.footer-stat .stat-label {
    font-size: 0.9rem;
    opacity: 0.8;
}

.footer-bottom {
    border-top: 1px solid rgba(255,255,255,0.2);
    padding: 1.5rem 2rem;
    text-align: center;
    background: rgba(0,0,0,0.2);
    opacity: 0.8;
}

/* Error container */
.error-container {
    text-align: center;
    padding: 3rem 2rem;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    margin: 2rem 0;
    border-left: 4px solid var(--error);
}

.error-message {
    max-width: 600px;
    margin: 0 auto;
}

.error-message i {
    font-size: 3rem;
    color: var(--error);
    margin-bottom: 1rem;
}

.error-message h3 {
    color: var(--error);
    margin-bottom: 1rem;
}

.debug-info {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 1rem;
    margin: 1.5rem 0;
    font-size: 0.9rem;
    color: #495057;
    text-align: left;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

/* Loading states */
.loading-skeleton {
    background: #f0f0f0;
    background-image: linear-gradient(90deg, #f0f0f0, #e0e0e0, #f0f0f0);
    background-size: 200px 100%;
    background-repeat: no-repeat;
    animation: loading 1.5s infinite;
    border-radius: 8px;
    height: 80px;
    margin-bottom: 10px;
}

@keyframes loading {
    0% { background-position: -200px 0; }
    100% { background-position: calc(200px + 100%) 0; }
}

/* Estado de carga para imágenes */
.marca-logo[src=""] {
    background: linear-gradient(90deg, #f0f0f0, #e0e0e0, #f0f0f0);
    background-size: 200px 100%;
    animation: loading 1.5s infinite;
}

/* Optimización para imágenes lazy loading */
.marca-logo[loading="lazy"] {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.marca-logo[loading="lazy"].loaded {
    opacity: 1;
}

/* Responsive design mejorado */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }
    
    .section-header {
        padding: 1.5rem;
        margin-bottom: 2rem;
    }
    
    .section-title {
        font-size: 1.8rem;
    }
    
    .section-stats {
        flex-direction: column;
        align-items: center;
        gap: 1rem;
    }
    
    .ranking-item {
        gap: 0.75rem;
        padding: 1rem;
        flex-wrap: wrap;
    }
    
    .brand-image {
        width: 60px;
        height: 60px;
    }
    
    .coffee-name {
        font-size: 1.1rem;
    }
    
    .evaluation-stats {
        flex-direction: column;
        gap: 8px;
    }
    
    .best-attributes {
        justify-content: flex-start;
    }
    
    .analyze-btn {
        width: 100%;
        justify-content: center;
        margin-top: 1rem;
        flex-basis: 100%;
    }
    
    .footer-stats {
        flex-direction: column;
        gap: 1rem;
    }
    
    .footer-content {
        grid-template-columns: 1fr;
        padding: 2rem 1rem;
    }
}

@media (max-width: 480px) {
    .section-title {
        font-size: 1.5rem;
    }
    
    .ranking-item {
        padding: 0.75rem;
        gap: 0.5rem;
    }
    
    .brand-image {
        width: 50px;
        height: 50px;
    }
    
    .brand-placeholder {
        font-size: 1rem;
    }
    
    .coffee-name {
        font-size: 1rem;
    }
    
    .score {
        min-width: 70px;
        padding: 0.6rem;
    }
    
    .score-number {
        font-size: 1.5rem;
    }
    
    .analyze-btn {
        padding: 0.8rem 1rem;
        font-size: 0.9rem;
    }
    
    .rank {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
}

/* Animaciones adicionales */
@keyframes slideInRight {
    from { 
        transform: translateX(100%); 
        opacity: 0; 
    }
    to { 
        transform: translateX(0); 
        opacity: 1; 
    }
}

@keyframes slideOutRight {
    from { 
        transform: translateX(0); 
        opacity: 1; 
    }
    to { 
        transform: translateX(100%); 
        opacity: 0; 
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Elementos decorativos de café */
.coffee-beans {
    position: fixed;
    font-size: 2rem;
    color: rgba(93, 64, 55, 0.1);
    z-index: -1;
    animation: float 6s ease-in-out infinite;
    pointer-events: none;
}

@keyframes float {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    50% { transform: translateY(-20px) rotate(180deg); }
}

/* Utilidades */
.text-center { text-align: center; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }

/* Focus y accesibilidad mejorada */
*:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

button:focus, 
a:focus {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

/* Mejoras en contraste para accesibilidad */
.coffee-quality {
    color: #555;
}

.evaluation-stats span {
    color: #555;
}

/* Animación de entrada para elementos */
.fade-in {
    animation: fadeInUp 0.6s ease forwards;
    opacity: 0;
}

.fade-in:nth-child(1) { animation-delay: 0.1s; }
.fade-in:nth-child(2) { animation-delay: 0.2s; }
.fade-in:nth-child(3) { animation-delay: 0.3s; }
.fade-in:nth-child(4) { animation-delay: 0.4s; }
.fade-in:nth-child(5) { animation-delay: 0.5s; }

/* Estados de hover mejorados */
.ranking-item:hover .coffee-name {
    color: var(--secondary);
}

.ranking-item:hover .score {
    transform: scale(1.05);
}

/* Mejoras en el diseño del formulario (para páginas futuras) */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--primary);
}

.form-control {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 1rem;
    transition: var(--transition);
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(93, 64, 55, 0.1);
}

/* Print styles */
@media print {
    .auth-buttons,
    .analyze-btn,
    .action-buttons,
    footer {
        display: none;
    }
    
    .ranking-item {
        break-inside: avoid;
        margin-bottom: 1rem;
        box-shadow: none;
        border: 1px solid #ddd;
    }
    
    .header-container {
        background: white;
        color: black;
    }
    
    .coffee-beans {
        display: none;
    }
}

/* Dark mode support (preparado para futuro) */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #1a1a1a;
        --text-color: #ffffff;
        --card-bg: #2d2d2d;
    }
    
    /* Se puede expandir en el futuro */
}

/* Reduced motion para accesibilidad */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .coffee-beans {
        animation: none;
    }
}