/* ===== RESET & BASE ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --secondary-color: #f3f4f6;
    --accent-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --bg-white: #ffffff;
    --bg-gray: #f9fafb;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1);
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    overflow-x: hidden;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* ===== HEADER ===== */
.header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    margin-bottom: 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
}

.logo {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo-icon {
    font-size: 2rem;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-top: -0.5rem;
    padding-bottom: 1rem;
}

.trials-counter {
    background: linear-gradient(135deg, var(--danger-color), #dc2626);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-lg);
    font-weight: 600;
    font-size: 0.875rem;
    box-shadow: var(--shadow-md);
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.trials-number {
    background: rgba(255, 255, 255, 0.2);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
}

/* ===== SECTIONS ===== */
.main {
    padding-bottom: 4rem;
}

section {
    margin-bottom: 3rem;
}

.section-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    text-align: center;
}

.section-header {
    margin-bottom: 1.5rem;
}

/* ===== UPLOAD SECTION ===== */
.upload-card {
    background: var(--bg-white);
    border-radius: var(--radius-xl);
    padding: 2rem;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.upload-zone {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    padding: 3rem 2rem;
    transition: var(--transition);
    cursor: pointer;
    background: var(--bg-gray);
    user-select: none;
    position: relative;
}

.upload-zone:hover {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.05);
}

.upload-zone.dragover {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.1);
    transform: scale(1.02);
}

.upload-zone.uploading {
    pointer-events: none;
    opacity: 0.6;
}

.upload-zone.uploading::after {
    content: "Procesando...";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--primary-color);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    z-index: 10;
}

.upload-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.6;
}

.upload-text {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.upload-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.preview-container {
    position: relative;
    margin-top: 1.5rem;
    display: inline-block;
}

.preview-image {
    max-width: 300px;
    max-height: 300px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.btn-remove {
    position: absolute;
    top: -0.5rem;
    right: -0.5rem;
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.875rem;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
}

.btn-remove:hover {
    transform: scale(1.1);
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    box-shadow: var(--shadow-sm);
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--secondary-color);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: #e5e7eb;
    transform: translateY(-1px);
}

.btn-outline {
    background: transparent;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

.btn-outline:hover {
    background: var(--primary-color);
    color: white;
}

.btn-outline-light {
    background: transparent;
    color: white;
    border: 2px solid white;
}

.btn-outline-light:hover {
    background: white;
    color: var(--primary-color);
}


.btn-process {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: var(--radius-lg);
    font-size: 1.125rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0 auto 1rem;
}

.btn-process:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-xl);
}

.btn-process:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    transform: none;
    box-shadow: var(--shadow-sm);
}

.btn-icon {
    font-size: 1.25rem;
}

/* ===== CATEGORY TABS ===== */
.category-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    overflow-x: auto;
    padding: 0.25rem;
    background: var(--bg-gray);
    border-radius: var(--radius-lg);
    justify-content: center;
    flex-wrap: wrap;
}

.category-tab {
    padding: 0.75rem 1.5rem;
    border: none;
    background: transparent;
    border-radius: var(--radius-md);
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    font-size: 0.875rem;
}

.category-tab.active {
    background: var(--primary-color);
    color: white;
    box-shadow: var(--shadow-sm);
}

.category-tab:hover:not(.active) {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary-color);
}

/* ===== STYLES GRID CON ICONOS ===== */
.styles-section {
    background: var(--bg-white);
    border-radius: var(--radius-xl);
    padding: 2rem;
    box-shadow: var(--shadow-lg);
}

.styles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}

.style-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border: 2px solid transparent;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: var(--transition);
    background: var(--bg-gray);
    position: relative;
    overflow: hidden;
}

.style-item:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.style-item.selected {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.1);
    box-shadow: var(--shadow-md);
}

.style-preview-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    border: 3px solid rgba(255, 255, 255, 0.3);
    flex-shrink: 0;
    transition: var(--transition);
    position: relative;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.style-preview-icon svg {
    width: 32px;
    height: 32px;
    fill: white;
}

.style-item.selected .style-preview-icon {
    border-color: white;
    transform: scale(1.1);
    box-shadow: 0 0 0 2px var(--primary-color);
}

.style-info {
    flex: 1;
}

.style-name {
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--text-primary);
}

.style-description {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* ===== COLORS SECTION ===== */
.colors-section {
    background: var(--bg-white);
    border-radius: var(--radius-xl);
    padding: 2rem;
    box-shadow: var(--shadow-lg);
}

.colors-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
}

.color-item {
    text-align: center;
    padding: 1rem;
    border: 2px solid transparent;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: var(--transition);
    background: var(--bg-gray);
}

.color-item:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.color-item.selected {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.1);
    box-shadow: var(--shadow-md);
}

.color-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin: 0 auto 0.75rem;
    border: 3px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.color-item.selected .color-circle {
    border-color: var(--primary-color);
    transform: scale(1.1);
}

.color-name {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.color-description {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

/* ===== ACTION SECTION ===== */
.action-section {
    text-align: center;
    margin: 3rem 0;
}

/* ===== RESULTS SECTION ===== */
.results-section {
    background: var(--bg-white);
    border-radius: var(--radius-xl);
    padding: 2rem;
    box-shadow: var(--shadow-lg);
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.result-item {
    background: var(--bg-gray);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    text-align: center;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.result-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.result-image {
    width: 100%;
    max-width: 200px;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.result-image:hover {
    transform: scale(1.05);
}

.result-info {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

/* ===== EXHAUSTED MESSAGE ===== */
.exhausted-message {
    background: linear-gradient(135deg, var(--danger-color), #dc2626);
    color: white;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
}

.exhausted-content {
    padding: 3rem 2rem;
    text-align: center;
}

.exhausted-content h3 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

/* ===== LOADING OVERLAY ===== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.loading-content {
    background: var(--bg-white);
    border-radius: var(--radius-xl);
    padding: 3rem;
    text-align: center;
    box-shadow: var(--shadow-xl);
    max-width: 400px;
    margin: 1rem;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1.5rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===== MODALS ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--bg-white);
    border-radius: var(--radius-xl);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 2rem;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 2rem;
    flex-wrap: wrap;
}

#video {
    width: 100%;
    max-width: 400px;
    border-radius: var(--radius-lg);
    margin-bottom: 1.5rem;
}

.comparison-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

.comparison-item {
    text-align: center;
}

.comparison-item h4 {
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

.comparison-img {
    width: 100%;
    max-width: 200px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.result-info {
    background: var(--bg-gray);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    margin-bottom: 2rem;
}

.result-info p {
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.result-info strong {
    color: var(--text-primary);
}

/* ===== TOAST NOTIFICATIONS ===== */
.toast {
    position: fixed;
    top: 2rem;
    right: 2rem;
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    z-index: 1100;
    animation: slideIn 0.3s ease-out;
    min-width: 300px;
}

.toast-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
}

.toast-icon {
    font-size: 1.25rem;
}

.toast-message {
    font-weight: 500;
    flex: 1;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
    .container {
        padding: 0 1rem;
    }
    
    .header-content {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .logo {
        font-size: 1.5rem;
    }
    
    .upload-card {
        padding: 1.5rem;
    }
    
    .upload-zone {
        padding: 2rem 1rem;
    }
    
    .upload-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    /* ===== BLOQUE MODIFICADO ===== */
    .category-tabs {
        flex-wrap: wrap; /* Permite que los botones bajen a la siguiente línea */
        justify-content: center; /* Centra las líneas de botones */
        /* Ya no se necesita overflow-x ni flex-nowrap */
    }
    
    .styles-grid {
        grid-template-columns: 1fr;
    }
    
    .style-item {
        padding: 0.75rem;
    }
    
    .style-preview-icon {
        width: 50px;
        height: 50px;
    }
    
    .style-preview-icon svg {
        width: 28px;
        height: 28px;
    }
    
    .colors-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.75rem;
    }
    
    .comparison-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .modal-content {
        margin: 1rem;
        max-height: calc(100vh - 2rem);
    }
    
    .modal-header,
    .modal-body {
        padding: 1rem 1.5rem;
    }
    
    .btn-process {
        padding: 0.875rem 1.5rem;
        font-size: 1rem;
    }
    
    .toast {
        top: 1rem;
        right: 1rem;
        left: 1rem;
        min-width: auto;
    }
    
    .trials-counter {
        font-size: 0.75rem;
        padding: 0.375rem 0.75rem;
    }
}

@media (max-width: 480px) {
    .section-title {
        font-size: 1.25rem;
    }
    
    .upload-icon {
        font-size: 2rem;
    }
    
    .style-item {
        flex-direction: column;
        text-align: center;
        gap: 0.75rem;
        padding: 1rem;
    }
    
    .style-preview-icon {
        width: 50px;
        height: 50px;
        margin: 0;
    }

    .style-preview-icon svg {
        width: 28px;
        height: 28px;
    }
    
    .colors-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .loading-content {
        padding: 2rem;
    }
    
    .modal-actions {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
        justify-content: center;
    }
}

/* ===== ANIMACIONES MEJORADAS ===== */
.style-item,
.color-item,
.result-item {
    opacity: 0;
    animation: fadeInUp 0.3s ease-out forwards;
}

.style-item:nth-child(1) { animation-delay: 0.1s; }
.style-item:nth-child(2) { animation-delay: 0.2s; }
.style-item:nth-child(3) { animation-delay: 0.3s; }
.style-item:nth-child(4) { animation-delay: 0.4s; }
.style-item:nth-child(5) { animation-delay: 0.5s; }
.style-item:nth-child(6) { animation-delay: 0.6s; }

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Estados de focus para accesibilidad */
.btn:focus,
.category-tab:focus,
.style-item:focus,
.color-item:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Mejora para touch devices */
@media (hover: none) {
    .style-item:hover,
    .color-item:hover,
    .btn:hover {
        transform: none;
    }
}