/* ============================================================
   VARIABLES CSS CORPORATIVAS
   ============================================================ */
:root {
    --naranja-primary: #F97316;
    --naranja-dark: #EA580C;
    --naranja-light: #FED7AA;
    --gris-perlado: #F9FAFB;
    --gris-medio: #E5E7EB;
    --gris-oscuro: #374151;
    --blanco: #FFFFFF;
    --exito: #10B981;
    --info: #3B82F6;
    --advertencia: #F59E0B;
    --peligro: #EF4444;
}

* {
    box-sizing: border-box;
}

body {
    background: linear-gradient(135deg, var(--gris-perlado) 0%, var(--blanco) 100%);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: var(--gris-oscuro);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ============================================================
   HEADER
   ============================================================ */
header.header-corporativo {
    background: linear-gradient(135deg, var(--naranja-primary) 0%, var(--naranja-dark) 100%);
    color: var(--blanco);
    padding: 1.5rem 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.logo-placeholder {
    width: 180px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
}

header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    margin: 0;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

header p {
    font-size: 0.95rem;
    opacity: 0.95;
    margin: 0;
}

/* ============================================================
   MAIN CONTAINER
   ============================================================ */
main {
    max-width: 1800px;
    margin: 2rem auto;
    padding: 0 1rem;
}

/* ============================================================
   CARDS Y PANELES
   ============================================================ */
.card-custom {
    background: var(--blanco);
    border: none;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.07);
    margin-bottom: 1.5rem;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card-custom:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.12);
}

.card-header-custom {
    background: linear-gradient(135deg, var(--naranja-primary) 0%, var(--naranja-dark) 100%);
    color: var(--blanco);
    font-weight: 600;
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-header-icon {
    font-size: 1.3rem;
}

.card-body {
    padding: 1.5rem;
}

/* ============================================================
   ZONA DE CARGA
   ============================================================ */
.upload-zone {
    border: 3px dashed var(--naranja-primary);
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
    background: linear-gradient(135deg, rgba(249, 115, 22, 0.05) 0%, rgba(249, 115, 22, 0.02) 100%);
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.upload-zone:hover {
    border-color: var(--naranja-dark);
    background: linear-gradient(135deg, rgba(249, 115, 22, 0.1) 0%, rgba(249, 115, 22, 0.05) 100%);
    transform: scale(1.02);
}

.upload-zone.dragging {
    border-color: var(--exito);
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15) 0%, rgba(16, 185, 129, 0.05) 100%);
}

.upload-icon {
    font-size: 4rem;
    color: var(--naranja-primary);
    margin-bottom: 1rem;
}

.upload-text {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--gris-oscuro);
    margin-bottom: 0.5rem;
}

.upload-hint {
    font-size: 0.9rem;
    color: var(--gris-medio);
}

#imageFileInput {
    display: none;
}

/* ============================================================
   PREVIEW DE IMAGEN
   ============================================================ */
.image-preview-container {
    position: relative;
    max-width: 100%;
    margin: 1.5rem auto;
    display: none;
}

.image-preview-container.active {
    display: block;
}

.preview-image {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
    border: 3px solid var(--naranja-primary);
}

.image-info-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(249, 115, 22, 0.95);
    color: var(--blanco);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.85rem;
    backdrop-filter: blur(10px);
}

/* ============================================================
   CONTROLES DE HIPERPARÁMETROS
   ============================================================ */
.control-group {
    background: var(--gris-perlado);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    position: relative;
}

.control-label {
    font-weight: 600;
    color: var(--gris-oscuro);
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.95rem;
}

.control-value {
    background: var(--naranja-primary);
    color: var(--blanco);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.85rem;
}

.form-range::-webkit-slider-thumb {
    background: var(--naranja-primary);
    cursor: pointer;
}

.form-range::-moz-range-thumb {
    background: var(--naranja-primary);
    cursor: pointer;
}

.form-select {
    border: 2px solid var(--gris-medio);
    border-radius: 8px;
    padding: 0.5rem;
    font-weight: 600;
    cursor: pointer;
}

.form-select:focus {
    border-color: var(--naranja-primary);
    box-shadow: 0 0 0 0.25rem rgba(249, 115, 22, 0.25);
}

/* ============================================================
   TOOLTIP EDUCATIVO
   ============================================================ */
.help-icon {
    display: inline-block;
    width: 18px;
    height: 18px;
    background: var(--info);
    color: var(--blanco);
    border-radius: 50%;
    text-align: center;
    line-height: 18px;
    font-size: 0.7rem;
    cursor: help;
    margin-left: 0.5rem;
}

/* ============================================================
   PIPELINE VISUAL
   ============================================================ */
.cnn-pipeline {
    background: var(--gris-perlado);
    padding: 2rem;
    border-radius: 12px;
    overflow-x: auto;
    position: relative;
}

.pipeline-stage {
    display: inline-block;
    vertical-align: top;
    margin: 0 1rem;
    text-align: center;
    position: relative;
    opacity: 0;
    transform: translateY(20px);
}

.pipeline-stage.active {
    animation: fadeInUp 0.6s ease forwards;
}

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.stage-header {
    background: var(--naranja-primary);
    color: var(--blanco);
    padding: 0.5rem 1rem;
    border-radius: 8px 8px 0 0;
    font-weight: 700;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stage-content {
    background: var(--blanco);
    border: 2px solid var(--naranja-primary);
    border-top: none;
    border-radius: 0 0 8px 8px;
    padding: 1rem;
    min-width: 180px;
    min-height: 200px;
}

.stage-canvas {
    border: 1px solid var(--gris-medio);
    border-radius: 4px;
    max-width: 100%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.stage-description {
    margin-top: 0.75rem;
    font-size: 0.85rem;
    color: var(--gris-oscuro);
    line-height: 1.4;
}

.stage-arrow {
    display: inline-block;
    font-size: 2rem;
    color: var(--naranja-primary);
    margin: 0 0.5rem;
    vertical-align: middle;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* ============================================================
   EXPLICACIONES CONTEXTUALES
   ============================================================ */
.stage-explanation {
    background: linear-gradient(135deg, rgba(249, 115, 22, 0.05) 0%, rgba(16, 185, 129, 0.05) 100%);
    border-left: 4px solid var(--naranja-primary);
    padding: 1rem;
    border-radius: 8px;
    margin-top: 1rem;
    display: none;
    animation: fadeIn 0.5s ease;
}

.stage-explanation.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.explanation-title {
    font-weight: 700;
    color: var(--naranja-primary);
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.analogy-box {
    background: var(--blanco);
    border: 1px solid var(--naranja-light);
    padding: 0.75rem;
    border-radius: 6px;
    margin-top: 0.75rem;
    font-style: italic;
    color: var(--gris-oscuro);
    font-size: 0.9rem;
}

/* ============================================================
   GRID DE FILTROS
   ============================================================ */
.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 0.75rem;
}

.filter-item {
    border: 2px solid var(--gris-medio);
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
    position: relative;
}

.filter-item:hover {
    border-color: var(--naranja-primary);
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.3);
}

.filter-canvas {
    width: 100%;
    height: auto;
    display: block;
}

.filter-label {
    background: rgba(0, 0, 0, 0.7);
    color: var(--blanco);
    padding: 0.25rem;
    font-size: 0.75rem;
    text-align: center;
    font-weight: 600;
}

/* ============================================================
   CONTAINER SOFTMAX
   ============================================================ */
.softmax-container {
    max-height: 400px;
    overflow-y: auto;
}

.probability-bar-container {
    margin-bottom: 1rem;
}

.probability-label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
}

.class-name {
    font-weight: 600;
    color: var(--gris-oscuro);
}

.probability-value {
    background: var(--naranja-primary);
    color: var(--blanco);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-weight: 700;
    font-size: 0.85rem;
}

.probability-bar {
    background: var(--gris-perlado);
    border-radius: 20px;
    overflow: hidden;
    height: 24px;
}

.probability-fill {
    background: linear-gradient(90deg, var(--naranja-primary) 0%, var(--naranja-dark) 100%);
    height: 100%;
    transition: width 0.8s ease;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 0.5rem;
    color: var(--blanco);
    font-weight: 700;
    font-size: 0.75rem;
}

.probability-fill.top-prediction {
    background: linear-gradient(90deg, var(--exito) 0%, #059669 100%);
}

/* ============================================================
   MÉTRICAS
   ============================================================ */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

.metric-card {
    background: linear-gradient(135deg, rgba(249, 115, 22, 0.1) 0%, rgba(16, 185, 129, 0.1) 100%);
    border: 2px solid var(--gris-medio);
    border-radius: 12px;
    padding: 1rem;
    text-align: center;
    transition: all 0.3s ease;
}

.metric-card:hover {
    border-color: var(--naranja-primary);
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(249, 115, 22, 0.15);
}

.metric-label {
    font-weight: 600;
    color: var(--gris-oscuro);
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.metric-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--naranja-primary);
    margin-bottom: 0.25rem;
}

.metric-subvalue {
    font-size: 0.75rem;
    color: var(--gris-medio);
    font-weight: 600;
}

/* ============================================================
   CONCEPTOS
   ============================================================ */
.concept-box {
    background: transparent;
}

.concept-title {
    font-weight: 700;
    color: var(--naranja-primary);
    margin-bottom: 1rem;
    font-size: 1rem;
}

.concept-item {
    background: linear-gradient(135deg, rgba(249, 115, 22, 0.05) 0%, rgba(59, 130, 246, 0.05) 100%);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    border-left: 4px solid var(--naranja-primary);
}

.concept-item:last-child {
    margin-bottom: 0;
}

.concept-name {
    font-weight: 700;
    color: var(--naranja-primary);
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.concept-description {
    color: var(--gris-oscuro);
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
    line-height: 1.5;
}

.concept-analogy {
    background: var(--blanco);
    border: 1px solid var(--info);
    padding: 0.75rem;
    border-radius: 6px;
    font-style: italic;
    font-size: 0.85rem;
    color: var(--gris-oscuro);
}

/* ============================================================
   BOTONES
   ============================================================ */
.btn-naranja {
    background: linear-gradient(135deg, var(--naranja-primary) 0%, var(--naranja-dark) 100%);
    color: var(--blanco);
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.3s ease;
    cursor: pointer;
}

.btn-naranja:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(249, 115, 22, 0.4);
    color: var(--blanco);
}

.btn-naranja:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-reset {
    background: var(--gris-medio);
    color: var(--gris-oscuro);
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.3s ease;
    cursor: pointer;
}

.btn-reset:hover {
    background: var(--gris-oscuro);
    color: var(--blanco);
    transform: translateY(-2px);
}

/* ============================================================
   BADGES
   ============================================================ */
.info-badge {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.85rem;
    margin: 0.25rem;
}

.badge-conv {
    background: rgba(59, 130, 246, 0.15);
    color: var(--info);
    border: 1px solid var(--info);
}

.badge-pool {
    background: rgba(139, 92, 246, 0.15);
    color: #8B5CF6;
    border: 1px solid #8B5CF6;
}

.badge-dense {
    background: rgba(16, 185, 129, 0.15);
    color: var(--exito);
    border: 1px solid var(--exito);
}

.badge-softmax {
    background: rgba(249, 115, 22, 0.15);
    color: var(--naranja-primary);
    border: 1px solid var(--naranja-primary);
}

/* ============================================================
   PROCESSING OVERLAY
   ============================================================ */
.processing-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.processing-overlay.active {
    display: flex;
}

.processing-content {
    text-align: center;
    color: var(--blanco);
}

.spinner {
    width: 80px;
    height: 80px;
    margin: 0 auto 1.5rem;
    border: 6px solid rgba(249, 115, 22, 0.2);
    border-top: 6px solid var(--naranja-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.processing-text {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.processing-subtext {
    font-size: 0.95rem;
    opacity: 0.8;
}

/* ============================================================
   IMÁGENES DE EJEMPLO
   ============================================================ */
.example-images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
}

.example-image-item {
    cursor: pointer;
    border: 2px solid var(--gris-medio);
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
    position: relative;
}

.example-image-item:hover {
    border-color: var(--naranja-primary);
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.3);
}

.example-image-item img {
    width: 100%;
    height: 100px;
    object-fit: cover;
    display: block;
}

.example-image-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    color: var(--blanco);
    padding: 0.25rem;
    font-size: 0.75rem;
    text-align: center;
    font-weight: 600;
}

/* ============================================================
   FOOTER
   ============================================================ */
footer {
    text-align: center;
    padding: 2rem 1rem;
    margin-top: 3rem;
    color: var(--naranja-primary);
    font-size: 0.9rem;
}

footer p {
    margin-bottom: 0;
}

/* ============================================================
   RESPONSIVIDAD
   ============================================================ */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.3rem;
    }
    
    .pipeline-stage {
        margin: 0.5rem;
    }
    
    .stage-arrow {
        transform: rotate(90deg);
    }
    
    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
