/* ========== VARIABLES Y RESET ========== */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding-bottom: 80px;
    color: #333;
}

/* ========== HEADER CON LOGO ========== */

.app-header {
    background: linear-gradient(135deg, #4ade80 0%, #22c55e 100%);
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    box-shadow: 0 4px 12px rgba(74, 222, 128, 0.3);
    position: sticky;
    top: 0;
    z-index: 100;
    height: 80px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.app-header:hover {
    box-shadow: 0 6px 16px rgba(74, 222, 128, 0.4);
}

.header-logo {
    height: 50px;
    width: auto;
    object-fit: contain;
    transition: transform 0.3s ease;
}

.app-header:hover .header-logo {
    transform: scale(1.05);
}

.header-text {
    font-size: 24px;
    font-weight: 700;
    color: white;
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* ========== MAIN CONTENT ========== */

.app-main {
    padding: 20px 15px;
    max-width: 600px;
    margin: 0 auto;
}

/* ========== PANTALLAS ========== */

.pantalla {
    display: none;
}

.pantalla.activa {
    display: block;
}

/* ========== MENSAJE INICIAL ========== */

.message {
    background: white;
    border-radius: 20px;
    padding: 30px 20px;
    text-align: center;
    margin-bottom: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.message p {
    color: #64748b;
    font-size: 16px;
    line-height: 1.6;
}

/* ========== VIDEO Y CANVAS ========== */

#video {
    width: 100%;
    max-width: 100%;
    border-radius: 20px;
    display: none;
    margin-bottom: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

#video.active {
    display: block;
}

#canvas {
    display: none;
}

/* ========== CONTROLES DE CÁMARA ========== */

.controls {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.controls button {
    width: 100%;
    padding: 16px 24px;
    border: none;
    border-radius: 20px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

#startBtn {
    background: linear-gradient(135deg, #4ade80 0%, #22c55e 100%);
    color: white;
}

#startBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(74, 222, 128, 0.4);
}

#startBtn:active {
    transform: translateY(0);
}

#switchBtn {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
}

#switchBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
}

#captureBtn {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    font-size: 18px;
}

#captureBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(245, 158, 11, 0.4);
}

/* ========== PANTALLA DE ANÁLISIS ========== */

.analysis-header {
    background: white;
    border-radius: 20px;
    padding: 20px;
    text-align: center;
    margin-bottom: 20px;
    font-size: 22px;
    font-weight: 700;
    color: #1a1a1a;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.image-container {
    background: white;
    border-radius: 20px;
    padding: 15px;
    margin-bottom: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.image-container img {
    width: 100%;
    border-radius: 12px;
    display: block;
}

/* ========== LOADING ========== */

.loading {
    background: white;
    border-radius: 20px;
    padding: 40px 20px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f4f6;
    border-top: 4px solid #4ade80;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading p {
    color: #64748b;
    font-size: 16px;
}

/* ========== RESULTADO ========== */

.resultado-card {
    background: white;
    border-radius: 20px;
    padding: 25px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.resultado-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.resultado-header h2 {
    font-size: 24px;
    color: #1a1a1a;
    font-weight: 700;
}

.badge-confianza {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
}

.resultado-estado {
    background: #f1f5f9;
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 15px;
    font-size: 15px;
}

.resultado-estado strong {
    color: #1a1a1a;
    font-weight: 700;
}

.estado-baja {
    background: #d1fae5;
    border-left: 4px solid #22c55e;
}

.estado-normal {
    background: #fef3c7;
    border-left: 4px solid #f59e0b;
}

.estado-muy-avanzada {
    background: #fee2e2;
    border-left: 4px solid #ef4444;
}

.resultado-dias {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f0f9ff;
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 15px;
    border-left: 4px solid #3b82f6;
}

.dias-icon {
    font-size: 24px;
}

.resultado-dias span {
    font-size: 15px;
    color: #1e293b;
}

.resultado-dias strong {
    color: #1e40af;
    font-weight: 700;
}

.resultado-razon {
    background: #f8fafc;
    padding: 15px;
    border-radius: 12px;
    border-left: 4px solid #64748b;
}

.resultado-razon strong {
    color: #1a1a1a;
    font-weight: 700;
    display: block;
    margin-bottom: 8px;
}

.resultado-razon p {
    color: #475569;
    line-height: 1.6;
    font-size: 14px;
}

/* ========== ERROR ========== */

.error-message {
    background: white;
    border-radius: 20px;
    padding: 40px 20px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.error-message p {
    color: #ef4444;
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 10px;
}

.error-detail {
    color: #64748b !important;
    font-size: 14px !important;
    font-weight: 400 !important;
}

/* ========== GUÍA ========== */

.guia-card {
    background: white;
    border-radius: 20px;
    padding: 25px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.guia-header {
    text-align: center;
    margin-bottom: 20px;
    border-bottom: 2px solid #4ade80;
    padding-bottom: 15px;
}

.guia-header h3 {
    font-size: 20px;
    color: #22c55e;
    margin-bottom: 5px;
}

.guia-header h4 {
    font-size: 16px;
    color: #64748b;
    font-weight: 500;
}

.guia-contenido {
    color: #1a1a1a;
    line-height: 1.8;
    font-size: 14px;
}

.guia-contenido p {
    margin-bottom: 12px;
    white-space: pre-line;
}

.guia-botones {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
}

/* ========== BOTONES ========== */

.button-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.btn-primary,
.btn-success,
.btn-secondary {
    width: 100%;
    padding: 16px 24px;
    border: none;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-primary {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
}

.btn-success {
    background: linear-gradient(135deg, #4ade80 0%, #22c55e 100%);
    color: white;
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(74, 222, 128, 0.4);
}

.btn-secondary {
    background: linear-gradient(135deg, #94a3b8 0%, #64748b 100%);
    color: white;
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(148, 163, 184, 0.4);
}

.btn-primary:active,
.btn-success:active,
.btn-secondary:active {
    transform: translateY(0);
}

/* ========== FOOTER TABS ========== */

.tabs-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-around;
    padding: 12px 0;
    z-index: 1000;
}

.tab-spacer {
    flex: 1;
}

.tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    text-decoration: none;
    color: #94a3b8;
    transition: all 0.3s ease;
    padding: 8px;
    border-radius: 12px;
    position: relative;
}

.tab:hover {
    background: #f8fafc;
}

.tab.active {
    color: #4ade80;
}

.tab-icon {
    font-size: 24px;
    position: relative;
}

.tab-label {
    font-size: 12px;
    font-weight: 600;
}

/* Badge de alertas en tab */
.tab-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.3);
}

/* ========== RESPONSIVE ========== */

@media (max-width: 480px) {
    .app-header {
        padding: 12px 15px;
        height: 70px;
    }
    
    .header-logo {
        height: 40px;
    }
    
    .header-text {
        font-size: 20px;
    }

    .app-main {
        padding: 15px 12px;
    }

    .analysis-header {
        font-size: 20px;
        padding: 18px;
    }

    .resultado-header h2 {
        font-size: 20px;
    }

    .controls button {
        padding: 14px 20px;
        font-size: 14px;
    }

    .tab-icon {
        font-size: 22px;
    }

    .tab-label {
        font-size: 11px;
    }
}

@media (max-width: 360px) {
    .header-text {
        font-size: 18px;
    }
    
    .header-logo {
        height: 35px;
    }

    .resultado-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .badge-confianza {
        align-self: flex-start;
    }
}

/* ========== BOTÓN DE PERFIL EN HEADER ========== */

.header-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
}

.btn-perfil {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-perfil:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
    border-color: rgba(255, 255, 255, 0.5);
}

.btn-perfil:active {
    transform: scale(0.95);
}

/* Responsive botón perfil */
@media (max-width: 480px) {
    .btn-perfil {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
}/* ========== BOTÓN DE PERFIL EN HEADER ========== */

.header-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
}

.btn-perfil {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-perfil:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
    border-color: rgba(255, 255, 255, 0.5);
}

.btn-perfil:active {
    transform: scale(0.95);
}

/* Responsive botón perfil */
@media (max-width: 480px) {
    .btn-perfil {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
}