/**
 * CubaOpina - Estilos del Formulario de Login
 * Mismo diseño que el formulario de registro
 */

/* ==========================================================================
   CONTENEDOR PRINCIPAL
   ========================================================================== */

.co-login-wrapper {
    max-width: 480px;
    margin: 40px auto;
    padding: 20px;
}

/* ==========================================================================
   ALERTAS (Compartidas con registro)
   ========================================================================== */

.co-alert {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 20px;
    border-radius: 8px;
    margin-bottom: 25px;
    animation: slideDown 0.3s ease;
}

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

.co-alert-error {
    background: #fee;
    border: 1px solid #fcc;
    color: #c33;
}

.co-alert-success {
    background: #efe;
    border: 1px solid #cfc;
    color: #3c3;
}

.co-alert-info {
    background: #e3f2fd;
    border: 1px solid #90caf9;
    color: #1976d2;
}

.co-alert-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.co-alert-content {
    flex: 1;
    font-size: 15px;
    line-height: 1.5;
}

/* ==========================================================================
   FORMULARIO DE LOGIN
   ========================================================================== */

.co-login-form {
    background: #fff;
    padding: 50px 40px 40px 40px;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

/* Header del formulario */
.co-form-header {
    text-align: center;
    margin-bottom: 40px;
}

.co-login-logo {
    width: 80px;
    height: 80px;
    margin: 0 auto 20px;
    background: linear-gradient(135deg, #0033a0 0%, #0055cc 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 51, 160, 0.3);
}

.logo-icon {
    font-size: 40px;
    line-height: 1;
}

.co-form-header h2 {
    font-size: 28px;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0 0 10px 0;
}

.co-form-header p {
    font-size: 16px;
    color: #666;
    margin: 0;
}

/* ==========================================================================
   GRUPOS DE FORMULARIO
   ========================================================================== */

.co-form-group {
    margin-bottom: 25px;
}

.co-form-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
}

.co-label-icon {
    font-size: 18px;
}

/* Inputs */
.co-form-control {
    width: 100%;
    padding: 14px 16px;
    font-size: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    transition: all 0.3s ease;
    font-family: inherit;
    box-sizing: border-box;
}

.co-form-control:focus {
    outline: none;
    border-color: #0033a0;
    box-shadow: 0 0 0 3px rgba(0, 51, 160, 0.1);
}

.co-form-control::placeholder {
    color: #999;
}

/* ==========================================================================
   CAMPO DE CONTRASEÑA
   ========================================================================== */

.co-password-wrapper {
    position: relative;
}

.co-password-wrapper .co-form-control {
    padding-right: 50px;
}

.co-toggle-password {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    font-size: 20px;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.co-toggle-password:hover {
    opacity: 1;
}

.co-toggle-password:focus {
    outline: 2px solid #0033a0;
    outline-offset: 2px;
    border-radius: 4px;
}

.eye-icon {
    display: block;
    line-height: 1;
}

/* ==========================================================================
   OPCIONES DEL FORMULARIO
   ========================================================================== */

.co-form-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

/* Checkbox personalizado */
.co-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.co-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #0033a0;
}

.co-checkbox-label {
    font-size: 14px;
    color: #666;
}

.co-forgot-link {
    font-size: 14px;
    color: #0033a0;
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s;
}

.co-forgot-link:hover {
    color: #002580;
    text-decoration: underline;
}

/* ==========================================================================
   BOTÓN DE INICIO DE SESIÓN
   ========================================================================== */

.co-btn {
    width: 100%;
    padding: 16px 24px;
    font-size: 16px;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-family: inherit;
}

.co-btn-primary {
    background: linear-gradient(135deg, #0033a0 0%, #0055cc 100%);
    color: #fff;
    box-shadow: 0 4px 15px rgba(0, 51, 160, 0.3);
}

.co-btn-primary:hover {
    background: linear-gradient(135deg, #002580 0%, #0044aa 100%);
    box-shadow: 0 6px 20px rgba(0, 51, 160, 0.4);
    transform: translateY(-2px);
}

.co-btn-primary:active {
    transform: translateY(0);
}

.co-btn-arrow {
    font-size: 20px;
    transition: transform 0.3s ease;
}

.co-btn:hover .co-btn-arrow {
    transform: translateX(4px);
}

/* ==========================================================================
   DIVISOR
   ========================================================================== */

.co-form-divider {
    text-align: center;
    margin: 30px 0;
    position: relative;
}

.co-form-divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: #e0e0e0;
}

.co-form-divider span {
    position: relative;
    display: inline-block;
    padding: 0 15px;
    background: #fff;
    color: #999;
    font-size: 14px;
}

/* ==========================================================================
   FOOTER DEL FORMULARIO
   ========================================================================== */

.co-form-footer {
    text-align: center;
    margin-top: 25px;
}

.co-form-footer p {
    font-size: 14px;
    color: #666;
    margin: 0;
}

.co-form-footer a {
    color: #0033a0;
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s;
}

.co-form-footer a:hover {
    color: #002580;
    text-decoration: underline;
}

/* ==========================================================================
   LOGIN SOCIAL (Opcional)
   ========================================================================== */

.co-social-login {
    margin-top: 25px;
    padding-top: 25px;
    border-top: 1px solid #e0e0e0;
}

.co-social-title {
    text-align: center;
    font-size: 14px;
    color: #666;
    margin: 0 0 15px 0;
}

/* ==========================================================================
   BOTÓN DE LOGOUT
   ========================================================================== */

.co-logout-btn {
    display: inline-block;
    padding: 10px 20px;
    background: #dc3545;
    color: #fff;
    text-decoration: none;
    border-radius: 6px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.co-logout-btn:hover {
    background: #c82333;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.3);
}

/* ==========================================================================
   WIDGET DE USUARIO
   ========================================================================== */

.co-user-widget {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.co-user-greeting {
    flex: 1;
    font-size: 14px;
    color: #333;
}

.co-user-greeting strong {
    color: #0033a0;
}

.co-logout-link {
    font-size: 13px;
    color: #dc3545;
    text-decoration: none;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 4px;
    transition: all 0.2s;
}

.co-logout-link:hover {
    background: #dc3545;
    color: #fff;
}

.co-login-link {
    display: inline-block;
    padding: 10px 20px;
    background: #0033a0;
    color: #fff;
    text-decoration: none;
    border-radius: 6px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.co-login-link:hover {
    background: #002580;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 51, 160, 0.3);
}

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

.co-btn.loading {
    pointer-events: none;
    opacity: 0.7;
    position: relative;
}

.co-btn.loading::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin: -8px 0 0 -8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

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

@media (max-width: 768px) {
    .co-login-wrapper {
        padding: 15px;
        margin: 20px auto;
    }

    .co-login-form {
        padding: 40px 25px 30px 25px;
    }

    .co-login-logo {
        width: 70px;
        height: 70px;
        margin-bottom: 15px;
    }

    .logo-icon {
        font-size: 35px;
    }

    .co-form-header h2 {
        font-size: 24px;
    }

    .co-form-header p {
        font-size: 14px;
    }

    .co-form-control {
        padding: 12px 14px;
        font-size: 16px; /* Prevenir zoom en iOS */
    }

    .co-btn {
        padding: 14px 20px;
        font-size: 15px;
    }

    .co-form-options {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .co-forgot-link {
        margin-left: 26px; /* Alinear con el checkbox */
    }
}

@media (max-width: 380px) {
    .co-login-form {
        padding: 30px 20px;
    }

    .co-user-widget {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
}

/* ==========================================================================
   ESTADOS DE VALIDACIÓN
   ========================================================================== */

.co-form-control:invalid:not(:placeholder-shown) {
    border-color: #fcc;
}

.co-form-control:valid:not(:placeholder-shown) {
    border-color: #cfc;
}

/* ==========================================================================
   ACCESIBILIDAD
   ========================================================================== */

.co-form-control:focus-visible,
.co-btn:focus-visible,
.co-toggle-password:focus-visible,
.co-checkbox:focus-within {
    outline: 2px solid #0033a0;
    outline-offset: 2px;
}

/* ==========================================================================
   ANIMACIONES
   ========================================================================== */

.co-login-form {
    animation: fadeInUp 0.4s ease;
}

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

/* ==========================================================================
   TEMA OSCURO (Opcional)
   ========================================================================== */

@media (prefers-color-scheme: dark) {
    .co-login-form {
        background: #2c2c2c;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    }

    .co-form-header h2 {
        color: #f0f0f0;
    }

    .co-form-header p,
    .co-form-group label,
    .co-checkbox-label {
        color: #b0b0b0;
    }

    .co-form-control {
        background: #1a1a1a;
        border-color: #444;
        color: #f0f0f0;
    }

    .co-form-control:focus {
        border-color: #4477cc;
        background: #252525;
    }

    .co-form-divider::before {
        background: #444;
    }

    .co-form-divider span {
        background: #2c2c2c;
    }

    .co-form-footer p {
        color: #999;
    }

    .co-user-widget {
        background: #1a1a1a;
        border-color: #444;
    }

    .co-user-greeting {
        color: #b0b0b0;
    }
}

/* ==========================================================================
   PRINT STYLES
   ========================================================================== */

@media print {
    .co-login-form {
        box-shadow: none;
        border: 1px solid #ddd;
    }

    .co-btn,
    .co-form-divider,
    .co-social-login {
        display: none;
    }
}

.co-password-wrapper {
    position: relative;
}

.co-password-wrapper .co-form-control {
    padding-right: 50px;
}

.co-toggle-password {
    position: absolute !important;
    right: 16px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    cursor: pointer !important;
    font-size: 18px !important;
    opacity: 0.5 !important;
    transition: opacity 0.2s !important;
    user-select: none !important;
    color: #666 !important;
    font-family: "Font Awesome 6 Free" !important;
    font-weight: 900 !important;
}

.co-toggle-password::before {
    content: "\f06e"; /* fa-eye */
}

.co-password-wrapper input[type="text"] + .co-toggle-password::before {
    content: "\f070"; /* fa-eye-slash */
}

.co-toggle-password:hover {
    opacity: 0.8 !important;
}

/* Altura uniforme */
.co-form-control {
    height: 48px !important;
    padding: 12px 14px !important;
    font-size: 16px !important;
    box-sizing: border-box !important;
}

.co-password-wrapper .co-form-control {
    padding-right: 50px !important;
}
