/* Variables de colores minimalistas */
:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-600: #4b5563;
    --gray-900: #111827;
    --border-radius: 8px;
}

/* Reset y base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
    line-height: 1.6;
}

/* Navbar minimalista */
.navbar {
    background: white !important;
    border-bottom: 1px solid var(--gray-200);
    padding: 1rem 0;
}

.navbar-brand {
    font-weight: 600;
    font-size: 1.25rem;
    color: var(--gray-900) !important;
}

.badge {
    background: var(--gray-100) !important;
    color: var(--gray-600) !important;
    font-weight: 500;
    border-radius: 6px;
    padding: 0.35rem 0.75rem;
    font-size: 0.875rem;
}

/* Container principal */
.container {
    max-width: 800px;
}

/* Cards minimalistas */
.main-card {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    transition: border-color 0.2s ease;
}

.main-card:hover {
    border-color: var(--gray-300);
}

.card-body {
    padding: 2.5rem;
}

.status-card {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    display: none;
}

/* Modal de resultados */
.results-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    animation: fadeIn 0.3s ease;
}

.results-modal.active {
    display: block;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
}

.modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: var(--border-radius);
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translate(-50%, -45%);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: var(--gray-100);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--gray-600);
    transition: all 0.2s ease;
    z-index: 10;
}

.modal-close:hover {
    background: var(--gray-900);
    color: white;
}

.modal-body {
    padding: 1.5rem;
}

/* Imagen en el modal */
.modal-image-container {
    width: 100%;
    margin-bottom: 1rem;
    border-radius: var(--border-radius);
    overflow: hidden;
    background: var(--gray-50);
}

.modal-image {
    width: 100%;
    height: auto;
    max-height: 200px;
    object-fit: contain;
    display: block;
}

/* Resultado principal compacto */
.modal-main-result {
    text-align: center;
    padding: 0.75rem;
    background: var(--gray-50);
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
}

.modal-main-result h4 {
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
    font-weight: 600;
}

/* Grid 2x2 de información */
.modal-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.modal-info-grid .info-card {
    padding: 0.75rem;
    text-align: center;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
}

.modal-info-grid .info-card h5 {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray-600);
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.modal-info-grid .info-card .h2 {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
}

.modal-info-grid .info-card i {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

/* Métricas compactas */
.modal-metrics {
    background: var(--gray-50);
    padding: 0.75rem;
    border-radius: var(--border-radius);
}

.modal-metrics h6 {
    font-size: 0.7rem;
    margin-bottom: 0.5rem;
}

.modal-metrics .progress {
    height: 6px;
    margin-bottom: 0.5rem;
}

.modal-metrics .progress:last-child {
    margin-bottom: 0;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Títulos */
h2 {
    font-weight: 600;
    color: var(--gray-900);
    font-size: 1.75rem;
    letter-spacing: -0.025em;
}

h3 {
    font-weight: 600;
    color: var(--gray-900);
    font-size: 1.5rem;
    letter-spacing: -0.025em;
}

h5 {
    font-weight: 600;
    color: var(--gray-900);
    font-size: 1.125rem;
}

h6 {
    font-weight: 500;
    color: var(--gray-600);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.text-muted {
    color: var(--gray-600) !important;
}

/* Botones minimalistas */
.btn {
    border-radius: 6px;
    font-weight: 500;
    padding: 0.625rem 1.25rem;
    transition: all 0.2s ease;
    border: none;
    font-size: 0.9375rem;
}

.btn-action {
    border: 1.5px solid var(--gray-300);
    background: white;
    color: var(--gray-900);
}

.btn-action:hover {
    border-color: var(--primary);
    background: var(--gray-50);
    color: var(--primary);
}

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

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

.btn-outline-primary {
    border: 1.5px solid var(--primary);
    color: var(--primary);
    background: transparent;
}

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

.classify-btn {
    display: none;
    background: var(--gray-900);
    color: white;
    padding: 0.875rem 2rem;
    font-weight: 500;
    border-radius: 6px;
    transition: all 0.2s ease;
    margin-right: 0.5rem;
}

.classify-btn:hover {
    background: var(--gray-600);
    transform: translateY(-1px);
}

.realtime-btn {
    display: none;
    background: var(--primary);
    color: white;
    padding: 0.875rem 1.5rem;
    font-weight: 500;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.realtime-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.realtime-btn.active {
    background: var(--danger);
}

.realtime-btn.active:hover {
    background: #dc2626;
}

/* Preview de imagen */
.image-preview-container {
    min-height: 400px;
    max-height: 600px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--gray-50);
    border-radius: var(--border-radius);
    border: 2px dashed var(--gray-300);
    position: relative;
    overflow: hidden;
}

.preview-media {
    display: none;
    max-width: 100%;
    max-height: 600px;
    height: auto;
    width: auto;
    border-radius: var(--border-radius);
    object-fit: contain;
    position: relative;
    z-index: 1;
}

/* Video específico para cámaras web */
#videoFeed {
    max-width: 100%;
    max-height: 600px;
    width: auto;
    height: auto;
    object-fit: contain;
}

/* Overlay de detección en tiempo real */
.realtime-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: none;
    pointer-events: none;
    border-radius: var(--border-radius);
    background: linear-gradient(to bottom, rgba(0,0,0,0.3), rgba(0,0,0,0.05));
    z-index: 100;
}

.realtime-overlay.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

.overlay-content {
    position: absolute;
    top: 1rem;
    left: 1rem;
    right: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Estados de búsqueda y error */
.overlay-status {
    background: rgba(17, 24, 39, 0.95);
    backdrop-filter: blur(15px);
    color: white;
    padding: 1.25rem;
    border-radius: 8px;
    text-align: center;
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.overlay-status.searching {
    background: rgba(37, 99, 235, 0.95);
    border-color: rgba(37, 99, 235, 0.3);
}

.overlay-status.error {
    background: rgba(239, 68, 68, 0.95);
    border-color: rgba(239, 68, 68, 0.3);
}

.overlay-status i {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    display: block;
}

.overlay-status .status-text {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.overlay-status .status-message {
    font-size: 0.875rem;
    opacity: 0.9;
}

/* Información de detección */
.overlay-detection-info {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Badges principales mejorados */
.overlay-main-badges {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.overlay-badge {
    background: rgba(17, 24, 39, 0.95);
    backdrop-filter: blur(15px);
    color: white;
    padding: 0.65rem 1rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border: 2px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}

.overlay-badge .badge-icon {
    font-size: 1.3rem;
}

.overlay-badge .badge-confidence {
    background: rgba(255, 255, 255, 0.2);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    margin-left: 0.25rem;
}

.overlay-badge.success {
    background: rgba(16, 185, 129, 0.95);
    border-color: rgba(16, 185, 129, 0.3);
}

.overlay-badge.warning {
    background: rgba(245, 158, 11, 0.95);
    border-color: rgba(245, 158, 11, 0.3);
}

/* Sección de probabilidades */
.overlay-probabilities {
    background: rgba(17, 24, 39, 0.95);
    backdrop-filter: blur(15px);
    padding: 1rem;
    border-radius: 8px;
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.prob-section {
    margin-bottom: 0.75rem;
}

.prob-section:last-child {
    margin-bottom: 0;
}

.prob-header {
    margin-bottom: 0.5rem;
}

.prob-label {
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.8;
}

.prob-bar-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.prob-bar-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.prob-bar-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: white;
    font-size: 0.85rem;
}

.prob-value {
    font-weight: 600;
    font-size: 0.8rem;
}

.prob-bar {
    height: 8px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    overflow: hidden;
}

.prob-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

/* Colores de barras de progreso */
.prob-bar-fill.species-dorada {
    background: linear-gradient(90deg, #3b82f6, #60a5fa);
}

.prob-bar-fill.species-lubina {
    background: linear-gradient(90deg, #6b7280, #9ca3af);
}

.prob-bar-fill.classification-cultivada {
    background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.prob-bar-fill.classification-salvaje {
    background: linear-gradient(90deg, #10b981, #34d399);
}

/* Confianza de detección */
.overlay-detection-confidence {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding-top: 0.5rem;
    margin-top: 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    color: white;
    font-size: 0.85rem;
    font-weight: 500;
}

.overlay-detection-confidence i {
    color: #10b981;
    font-size: 1rem;
}

/* Resultado principal */
.main-result {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    padding: 2rem;
}

.display-3 {
    font-size: 3.5rem;
}

/* Info cards minimalistas */
.info-card {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    padding: 1.25rem;
    text-align: center;
    transition: all 0.2s ease;
}

.info-card:hover {
    border-color: var(--gray-300);
}

.info-card i {
    color: var(--gray-600);
}

.info-card .text-primary {
    color: var(--primary) !important;
}

.info-card .text-success {
    color: var(--success) !important;
}

.info-card .text-info {
    color: var(--primary) !important;
}

/* Progress bars minimalistas */
.progress {
    height: 8px;
    border-radius: 4px;
    background: var(--gray-200);
    overflow: hidden;
}

.progress-bar {
    border-radius: 4px;
    transition: width 0.5s ease;
}

.bg-warning {
    background: var(--warning) !important;
}

.bg-success {
    background: var(--success) !important;
}

.bg-info {
    background: var(--primary) !important;
}

.bg-secondary {
    background: var(--gray-600) !important;
}

/* Badges de resultados */
.badge.bg-primary {
    background: var(--primary) !important;
    color: white !important;
    padding: 0.5rem 1rem;
    font-size: 1rem;
}

.badge.bg-success {
    background: var(--success) !important;
    color: white !important;
    padding: 0.5rem 1rem;
    font-size: 1rem;
}

.badge.bg-warning {
    background: var(--warning) !important;
    color: white !important;
    padding: 0.5rem 1rem;
    font-size: 1rem;
}

/* Loading */
.spinner-border {
    width: 1.5rem;
    height: 1.5rem;
    border-width: 2px;
}

.spinner-border.text-primary {
    color: var(--primary) !important;
}

/* Error */
.border-danger {
    border-left-color: var(--danger) !important;
}

.text-danger {
    color: var(--danger) !important;
}

/* Footer minimalista */
footer {
    margin-top: 4rem;
    padding: 2rem 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 1rem;
}

.footer-logos {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
}

.footer-logo {
    height: 60px;
    width: auto;
    object-fit: contain;
}

footer .footer-logo-fondos {
    height: 140px !important;
    width: auto;
}

footer .text-muted {
    color: var(--gray-600) !important;
}

/* Mostrar solo escritorio por defecto */
.footer-mobile {
    display: none !important;
}

.footer-desktop {
    display: flex !important;
}

.gloria-logo {
    height: 50px;
    width: auto;
    object-fit: contain;
    margin: 0 2px;
}

.universidad-logo {
    height: 85px;
    width: auto;
    object-fit: contain;
    margin: 0 2px;
}

/* Iconos */
.bi {
    vertical-align: middle;
}

/* Sección de debug */
.bg-light {
    background: var(--gray-50) !important;
    border: 1px solid var(--gray-200);
}

/* Responsivo */
@media (max-width: 768px) {
    /* Navbar responsive - más compacto */
    .navbar {
        padding: 0.5rem 0;
    }

    .navbar-brand {
        font-size: 0.9rem !important;
        text-align: center;
    }

    .navbar .container > div {
        flex-direction: column;
        gap: 0.5rem;
    }

    /* Logos del header más pequeños en móvil */
    .gloria-logo {
        height: 30px !important;
        margin: 0 2px;
    }

    .universidad-logo {
        height: 50px !important;
        margin: 0 2px;
    }

    /* Contenedor principal más compacto */
    .container.py-3 {
        padding-top: 0.5rem !important;
        padding-bottom: 0.5rem !important;
    }

    /* Card más compacto pero con espacio para el visor */
    .card-body {
        padding: 0.75rem !important;
    }

    .card-body.p-5 {
        padding: 0.75rem !important;
    }

    /* Títulos más pequeños */
    h2 {
        font-size: 1.25rem;
        margin-bottom: 0.5rem !important;
    }

    .text-center.mb-4 {
        margin-bottom: 0.5rem !important;
    }

    .text-center.mb-4 p {
        display: none;
    }

    /* Preview de imagen y video grande en móvil */
    .image-preview-container {
        min-height: 70vh;
        max-height: 70vh;
        margin: -0.75rem;
        margin-bottom: 0.5rem;
        border-radius: 0;
    }

    .preview-media {
        max-height: 70vh !important;
        max-width: 100%;
        height: auto;
        width: auto;
        border-radius: 0;
        object-fit: contain;
    }

    /* El video en móvil - mantener aspecto original de la cámara */
    #videoFeed {
        max-width: 100%;
        max-height: 70vh;
        width: auto;
        height: auto;
        object-fit: contain;
    }

    /* Modal responsive */
    .modal-content {
        width: 95%;
        max-height: 95vh;
    }

    .modal-body {
        padding: 1rem !important;
    }

    .modal-close {
        top: 0.5rem;
        right: 0.5rem;
        width: 28px;
        height: 28px;
    }

    .modal-image {
        max-height: 150px !important;
    }

    .modal-main-result {
        padding: 0.5rem !important;
        margin-bottom: 0.75rem !important;
    }

    .modal-main-result h4 {
        font-size: 0.95rem !important;
    }

    .modal-info-grid {
        gap: 0.5rem !important;
        margin-bottom: 0.75rem !important;
    }

    .modal-info-grid .info-card {
        padding: 0.5rem !important;
    }

    .modal-info-grid .info-card h5 {
        font-size: 0.65rem !important;
    }

    .modal-info-grid .info-card .h2 {
        font-size: 1rem !important;
    }

    .modal-info-grid .info-card i {
        font-size: 1.25rem !important;
    }

    .modal-metrics {
        padding: 0.5rem !important;
    }

    /* Resultados más compactos */
    .main-result {
        padding: 1rem !important;
        margin-bottom: 1rem !important;
    }

    .display-3 {
        font-size: 1.75rem !important;
    }

    /* Info cards más pequeñas */
    .info-card {
        padding: 0.75rem !important;
    }

    .info-card h5 {
        font-size: 0.9rem;
        margin-bottom: 0.25rem;
    }

    /* Reducir espaciado entre secciones */
    .mt-4 {
        margin-top: 0.75rem !important;
    }

    .mb-3 {
        margin-bottom: 0.5rem !important;
    }

    .mb-4 {
        margin-bottom: 0.75rem !important;
    }

    /* Footer responsive - compacto vertical */
    footer {
        margin-top: 0.5rem !important;
        padding: 0.5rem 0 !important;
    }

    /* Footer logos responsive - verticales para verse más grandes */
    .footer-logos {
        flex-direction: column;
        gap: 0.5rem;
        padding: 0;
        justify-content: center;
        align-items: center;
    }

    .footer-logo {
        height: 40px !important;
        max-width: 120px;
    }

    footer .footer-logo-fondos {
        height: 75px !important;
        max-width: 200px;
    }

    /* Show mobile footer, hide desktop footer on mobile */
    .footer-desktop {
        display: none !important;
    }

    .footer-mobile {
        display: flex !important;
        flex-direction: column;
    }

    footer .text-muted {
        font-size: 0.6rem !important;
        margin-top: 0.5rem !important;
        padding: 0 !important;
    }

    .btn {
        font-size: 0.875rem;
        padding: 0.5rem 1rem;
    }

    .badge {
        font-size: 0.875rem !important;
        padding: 0.4rem 0.75rem !important;
    }

    .classify-btn, .realtime-btn {
        display: block;
        width: 100%;
        margin-bottom: 0.5rem;
        margin-right: 0;
        padding: 0.75rem 1rem;
        font-size: 1rem;
        font-weight: 600;
    }

    /* Ajustar margen superior de los botones cuando hay video */
    .mt-4 {
        margin-top: 0.5rem !important;
    }

    /* Ocultar botones de acción cuando el video está activo */
    .action-buttons {
        margin-bottom: 0.5rem !important;
    }

    /* Hacer los botones más pequeños en móvil */
    .action-buttons .btn {
        padding: 0.5rem !important;
        font-size: 0.85rem !important;
    }

    .overlay-badge {
        font-size: 0.8rem;
        padding: 0.5rem 0.75rem;
    }

    .overlay-badge .badge-icon {
        font-size: 1.1rem;
    }

    .overlay-badge .badge-confidence {
        font-size: 0.7rem;
    }

    .overlay-status i {
        font-size: 1.5rem;
    }

    .overlay-status .status-text {
        font-size: 1rem;
    }

    .overlay-probabilities {
        padding: 0.75rem;
    }

    .prob-label {
        font-size: 0.7rem;
    }

    .prob-bar-label {
        font-size: 0.75rem;
    }

    .prob-value {
        font-size: 0.75rem;
    }

    .overlay-content {
        top: 0.5rem;
        left: 0.5rem;
        right: 0.5rem;
    }

    .overlay-detection-confidence {
        font-size: 0.75rem;
    }
}

/* Utilidades */
.rounded {
    border-radius: var(--border-radius);
}

.shadow-sm {
    box-shadow: none;
}

.shadow-lg {
    box-shadow: none;
}

/* Hover states suaves */
button:active, .btn:active {
    transform: scale(0.98);
}

/* Input file hidden */
input[type="file"] {
    display: none;
}

label[for="imageUpload"] {
    cursor: pointer;
    margin-bottom: 0;
}

/* Spacing consistente */
.mb-3 {
    margin-bottom: 1rem;
}

.mb-4 {
    margin-bottom: 1.5rem;
}

.mt-4 {
    margin-top: 1.5rem;
}

.p-3 {
    padding: 1rem;
}

.p-4 {
    padding: 1.5rem;
}

/* Check icon verde */
.bi-check-circle-fill.text-success {
    color: var(--success) !important;
}

/* Mejora visual de barras de progreso grandes */
.progress[style*="height: 25px"] {
    height: 10px !important;
    border-radius: 5px;
}

.progress[style*="height: 8px"] {
    height: 6px !important;
}

/* Limpieza de transiciones innecesarias */
* {
    transition: none;
}

button, .btn, a, .card, .info-card, .progress-bar {
    transition: all 0.2s ease;
}
