/**
 * Login Shortcode CSS
 * 
 * Production-optimized styles for the login form shortcode
 * 
 * @package Yatra
 */

/* CSS Custom Properties for better maintainability */
:root {
    --yatra-login-primary: var(--yatra-primary, #3b82f6);
    --yatra-login-primary-hover: var(--yatra-primary-dark, #2563eb);
    --yatra-login-primary-light: color-mix(in srgb, var(--yatra-primary, #3b82f6) 12%, transparent);
    --yatra-login-text: #1f2937;
    --yatra-login-text-muted: #6b7280;
    --yatra-login-border: #d1d5db;
    --yatra-login-border-hover: #9ca3af;
    --yatra-login-background: #ffffff;
    --yatra-login-background-secondary: #f9fafb;
    --yatra-login-error: #dc2626;
    --yatra-login-error-bg: #fef2f2;
    --yatra-login-error-border: #fecaca;
    --yatra-login-success: #10b981;
    --yatra-login-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    --yatra-login-shadow-hover: 0 2px 8px color-mix(in srgb, var(--yatra-primary, #3b82f6) 28%, transparent);
    --yatra-login-border-radius: 12px;
    --yatra-login-border-radius-sm: 8px;
    --yatra-login-border-radius-xs: 6px;
    --yatra-login-transition: all 0.2s ease;
    --yatra-login-transition-fast: all 0.15s ease;
}

/* Main container with hardware acceleration */
.yatra-login-shortcode {
    max-width: 500px;
    margin: 30px auto;
    will-change: transform;
    transform: translateZ(0); /* Hardware acceleration */
}

.yatra-login-container {
    background: var(--yatra-login-background);
    border: 1px solid #e5e7eb;
    border-radius: var(--yatra-login-border-radius);
    overflow: hidden;
    box-shadow: var(--yatra-login-shadow);
    will-change: transform;
    transform: translateZ(0); /* Hardware acceleration */
}

.yatra-login-header {
    padding: 30px 30px 20px;
    text-align: center;
    background: var(--yatra-login-background-secondary);
    border-bottom: 1px solid #e5e7eb;
}

.yatra-login-title {
    margin: 0 0 10px 0;
    color: var(--yatra-login-text);
    font-size: 1.875rem;
    font-weight: 600;
    line-height: 1.2;
}

.yatra-login-subtitle {
    margin: 0;
    color: var(--yatra-login-text-muted);
    font-size: 0.875rem;
    line-height: 1.4;
}

.yatra-login-form-container {
    padding: 30px;
}

.yatra-form-group {
    margin-bottom: 20px;
}

.yatra-form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--yatra-login-text);
    font-size: 0.875rem;
    line-height: 1.4;
}

.yatra-form-input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--yatra-login-border);
    border-radius: var(--yatra-login-border-radius-sm);
    font-size: 1rem;
    font-family: inherit;
    line-height: 1.5;
    transition: var(--yatra-login-transition);
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.yatra-form-input:focus {
    outline: none;
    border-color: var(--yatra-login-primary);
    box-shadow: 0 0 0 3px var(--yatra-login-primary-light);
}

.yatra-password-input-group {
    position: relative;
}

.yatra-password-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: var(--yatra-login-border-radius-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--yatra-login-text-muted);
    transition: var(--yatra-login-transition);
    will-change: color;
}

.yatra-password-toggle:hover {
    color: var(--yatra-login-primary);
}

.yatra-password-toggle:focus {
    outline: 2px solid var(--yatra-login-primary-light);
    outline-offset: 2px;
}

.yatra-eye-icon,
.yatra-eye-off-icon {
    width: 20px;
    height: 20px;
    pointer-events: none; /* Prevent clicking on SVG */
}

.yatra-eye-off-icon {
    display: none;
}

.yatra-form-checkbox {
    margin-bottom: 20px;
}

.yatra-checkbox-wrapper {
    display: flex;
    align-items: center;
}

.yatra-checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 0.875rem;
    color: #374151;
    transition: all 0.2s ease;
    padding: 4px;
    border-radius: 8px;
    margin: -4px;
}

.yatra-checkbox-label:hover {
    color: #1f2937;
    background-color: #f9fafb;
}

.yatra-checkbox-label:active {
    transform: scale(0.98);
}

.yatra-checkbox-label input[type="checkbox"] {
    display: none;
}

.yatra-checkbox-custom {
    width: 20px;
    height: 20px;
    border: 2px solid #d1d5db;
    border-radius: 6px;
    margin-right: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    background: #ffffff;
    position: relative;
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.yatra-checkbox-label:hover .yatra-checkbox-custom {
    border-color: #9ca3af;
}

.yatra-checkbox-label input[type="checkbox"]:checked + .yatra-checkbox-custom {
    background: linear-gradient(135deg, var(--yatra-login-primary) 0%, var(--yatra-login-primary-hover) 100%);
    border-color: var(--yatra-login-primary-hover);
    box-shadow: var(--yatra-login-shadow-hover), 0 0 0 3px var(--yatra-login-primary-light);
}

.yatra-check-icon {
    width: 16px;
    height: 16px;
    color: #ffffff;
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.2s ease;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
}

.yatra-checkbox-label input[type="checkbox"]:checked + .yatra-checkbox-custom .yatra-check-icon {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* Fallback for when SVG doesn't load */
.yatra-checkbox-custom::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    width: 6px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    opacity: 0;
    transition: all 0.2s ease;
}

.yatra-checkbox-label input[type="checkbox"]:checked + .yatra-checkbox-custom::after {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1) rotate(45deg);
}

/* Hide fallback when SVG is present */
.yatra-check-icon:not(:empty) + .yatra-checkbox-custom::after {
    display: none;
}

.yatra-checkbox-text {
    font-weight: 500;
    user-select: none;
    flex: none !important;
}

/* Override listing.css flex rule for login checkbox */
.yatra-login-shortcode .yatra-checkbox-label span:not(.yatra-filter-count) {
    flex: none !important;
}

.yatra-login-shortcode .yatra-checkbox-label .yatra-checkbox-custom {
    flex: none !important;
}

.yatra-login-shortcode .yatra-checkbox-label .yatra-check-icon {
    flex: none !important;
}

.yatra-form-actions {
    margin-bottom: 20px;
}

.yatra-btn-full {
    width: 100%;
    padding: 12px 24px;
}

/* Production-optimized anti-flicker styles */
.yatra-login-form[data-ajax="true"] {
    transition: none;
    contain: layout style paint; /* CSS containment for performance */
}

.yatra-login-form[data-ajax="true"] .yatra-btn-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transition: var(--yatra-login-transition);
    will-change: opacity, transform;
}

.yatra-login-form[data-ajax="true"] .yatra-btn-primary {
    transition: var(--yatra-login-transition);
    will-change: transform, opacity;
}

.yatra-login-form[data-ajax="true"] .yatra-btn-primary:disabled {
    transform: scale(0.98);
}

/* Optimized error styles */
.yatra-form-error {
    color: var(--yatra-login-error);
    background-color: var(--yatra-login-error-bg);
    border: 1px solid var(--yatra-login-error-border);
    border-radius: var(--yatra-login-border-radius-sm);
    padding: 12px 16px;
    margin-bottom: 20px;
    font-weight: 500;
    font-size: 0.875rem;
    line-height: 1.4;
    will-change: opacity;
}

/* Performance optimizations */
.yatra-login-shortcode * {
    box-sizing: border-box;
}

/* Reduce paint operations */
.yatra-login-container,
.yatra-login-form-container {
    contain: layout style paint;
}

/* Optimize animations */
@media (prefers-reduced-motion: reduce) {
    .yatra-login-shortcode * {
        transition: none !important;
        animation: none !important;
    }
}

.yatra-forgot-password {
    text-align: center;
    margin-bottom: 20px;
}

.yatra-link {
    color: var(--yatra-primary, #3b82f6);
    text-decoration: none;
    font-size: 0.875rem;
    transition: color 0.3s ease;
}

.yatra-link:hover {
    color: var(--yatra-primary-dark, #2563eb);
}

.yatra-link-bold {
    font-weight: 600;
}

.yatra-register-prompt {
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid #f3f4f6;
}

.yatra-register-prompt p {
    margin: 0;
    color: #6b7280;
    font-size: 0.875rem;
}

.yatra-login-footer {
    padding: 20px 30px;
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
}

.yatra-login-security {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: center;
}

.yatra-security-icon-svg {
    width: 20px;
    height: 20px;
    color: #10b981;
}

.yatra-security-text {
    margin: 0;
    color: #6b7280;
    font-size: 0.75rem;
}

.yatra-login-logged-in {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 40px 30px;
    text-align: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.yatra-logged-in-icon-svg {
    width: 60px;
    height: 60px;
    color: #10b981;
    margin-bottom: 20px;
}

.yatra-logged-in-content h3 {
    margin: 0 0 10px 0;
    color: #1f2937;
}

.yatra-logged-in-content p {
    margin: 0 0 20px 0;
    color: #6b7280;
}

.yatra-logged-in-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* Responsive Design */
@media (max-width: 480px) {
    .yatra-login-shortcode {
        margin: 20px;
    }
    
    .yatra-login-header,
    .yatra-login-form-container,
    .yatra-login-footer {
        padding: 20px;
    }
    
    .yatra-logged-in-actions {
        flex-direction: column;
    }
}
