/**
 * GP Business Login Form with MFA - WordPress Compatible CSS
 * Version: 2.2.0
 * 
 * Styled to match GRIPAR login design
 * Compatible with Blocksy theme
 */

/* ===========================
   CSS VARIABLES
   =========================== */
.gp-login-wrapper {
    /* Primary Blue - GRIPAR Style */
    --gp-primary: #5B6ABF;
    --gp-primary-dark: #4A59A8;
    --gp-primary-light: #7B8AD4;
    --gp-accent: #6B7AD7;
    
    /* Background & Card */
    --gp-bg-page: #f9fafb;
    --gp-bg-card: #FFFFFF;
    --gp-bg-input: #FFFFFF;
    
    /* Text Colors */
    --gp-text-primary: #2D3748;
    --gp-text-secondary: #6B7280;
    --gp-text-muted: #9CA3AF;
    
    /* Status Colors */
    --gp-success: #48BB78;
    --gp-error: #EF4444;
    --gp-warning: #F59E0B;
    
    /* Borders & Shadows */
    --gp-border: #E5E7EB;
    --gp-border-focus: #CBD5E1;
    --gp-shadow-card: 0 4px 24px rgba(0, 0, 0, 0.06), 0 1px 4px rgba(0, 0, 0, 0.04);
    
    /* Spacing */
    --gp-spacing-xs: 4px;
    --gp-spacing-sm: 8px;
    --gp-spacing-md: 16px;
    --gp-spacing-lg: 24px;
    --gp-spacing-xl: 32px;
    --gp-spacing-2xl: 40px;
    
    /* Border Radius */
    --gp-radius-sm: 6px;
    --gp-radius-md: 12px;
    --gp-radius-lg: 16px;
    --gp-radius-pill: 9999px;
    
    /* Transitions */
    --gp-transition-fast: 0.15s ease;
    --gp-transition-base: 0.2s ease;
}

/* ===========================
   LOGIN WRAPPER - Centered
   =========================== */
.gp-login-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 480px;
    margin: 40px auto 30px;
    padding: 0 var(--gp-spacing-md);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.5;
    color: var(--gp-text-primary);
    box-sizing: border-box;
}

.gp-login-wrapper *,
.gp-login-wrapper *::before,
.gp-login-wrapper *::after {
    box-sizing: border-box;
}

/* ===========================
   LOGIN CARD
   =========================== */
.gp-login-card {
    width: 100%;
    background: var(--gp-bg-card);
    border-radius: var(--gp-radius-lg);
    padding: var(--gp-spacing-2xl) var(--gp-spacing-xl);
    box-shadow: var(--gp-shadow-card);
    border: 1px solid var(--gp-border);
    position: relative;
}

/* ===========================
   SUCCESS ICON
   =========================== */
.gp-success-icon {
    display: none;
    width: 64px;
    height: 64px;
    margin: 0 auto var(--gp-spacing-lg);
}

.gp-success-icon.show {
    display: block;
}

.gp-success-icon svg {
    width: 100%;
    height: 100%;
}

.gp-success-icon circle {
    fill: var(--gp-success);
    opacity: 0.15;
}

.gp-success-icon path {
    stroke: var(--gp-success);
    stroke-width: 3;
    fill: none;
    stroke-dasharray: 100;
    stroke-dashoffset: 100;
    animation: gp-checkmark 0.5s ease-out forwards;
}

@keyframes gp-checkmark {
    to { stroke-dashoffset: 0; }
}

/* ===========================
   ERROR MESSAGE
   =========================== */
.gp-error-message {
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.25);
    color: var(--gp-error);
    padding: var(--gp-spacing-md);
    border-radius: var(--gp-radius-md);
    font-size: 14px;
    display: none;
    align-items: center;
    gap: var(--gp-spacing-sm);
    margin-bottom: var(--gp-spacing-lg);
    animation: gp-slideDown 0.3s ease;
}

.gp-error-message.show {
    display: flex;
}

@keyframes gp-slideDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.gp-error-icon {
    font-size: 16px;
    flex-shrink: 0;
    line-height: 1;
}

.gp-error-text {
    flex: 1;
    margin: 0;
    padding: 0;
    line-height: 1.4;
}

/* ===========================
   FORM
   =========================== */
.gp-login-form {
    display: flex;
    flex-direction: column;
    gap: var(--gp-spacing-lg);
}

.gp-form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 0;
    padding: 0;
}

.gp-form-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--gp-text-secondary);
    margin: 0;
    padding: 0;
    display: block;
    text-align: center;
}

.gp-form-label .gp-required {
    color: var(--gp-error);
    margin-left: 2px;
}

/* ===========================
   INPUT FIELDS - Pill Shape
   =========================== */
.gp-form-input-wrapper {
    position: relative;
    margin: 0;
    padding: 0;
}

.gp-form-input {
    width: 100%;
    height: 48px;
    padding: 0 20px;
    background: var(--gp-bg-input);
    border: 1.5px solid var(--gp-border);
    border-radius: var(--gp-radius-pill);
    color: var(--gp-text-primary);
    font-size: 15px;
    font-family: inherit;
    transition: border-color var(--gp-transition-base), box-shadow var(--gp-transition-base);
    outline: none;
    margin: 0;
    line-height: 48px;
    
    
    appearance: none;
}

.gp-form-input::placeholder {
    color: var(--gp-text-muted);
}

.gp-form-input:hover {
    border-color: var(--gp-border-focus);
}

.gp-form-input:focus {
    border-color: var(--gp-primary);
    box-shadow: 0 0 0 3px rgba(91, 106, 191, 0.12);
}

.gp-form-input:disabled {
    background: #F9FAFB;
    cursor: not-allowed;
    opacity: 0.6;
}

.gp-form-input.error {
    border-color: var(--gp-error);
    animation: gp-shake 0.4s ease;
}

/* Password field - extra right padding for toggle */
input[type="password"].gp-form-input,
.gp-form-input-wrapper:has(.gp-password-toggle) .gp-form-input {
    padding-right: 50px;
}

@keyframes gp-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
}

/* ===========================
   PASSWORD TOGGLE
   =========================== */
.gp-password-toggle {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--gp-text-muted);
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    transition: color var(--gp-transition-base);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

.gp-password-toggle:hover {
    color: var(--gp-text-secondary);
    background: rgba(0, 0, 0, 0.04);
}

.gp-password-toggle:focus {
    outline: 2px solid var(--gp-primary);
    outline-offset: 2px;
}

.gp-password-toggle svg {
    width: 20px;
    height: 20px;
    display: block;
}

/* ===========================
   FORM OPTIONS (Remember Me)
   =========================== */
.gp-form-options {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    margin: 0;
    gap: var(--gp-spacing-sm);
}

.gp-checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: var(--gp-spacing-sm);
    margin: 0;
    padding: 0;
}

.gp-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--gp-primary);
    margin: 0;
}

.gp-checkbox:focus {
    outline: 2px solid var(--gp-primary);
    outline-offset: 2px;
}

.gp-checkbox-label {
    font-size: 14px;
    color: var(--gp-text-secondary);
    cursor: pointer;
    user-select: none;
    margin: 0;
    padding: 0;
    display: inline;
    font-weight: 400;
}

/* Hide inline forgot link - moved outside the card */
.gp-form-options .gp-forgot-link {
    display: none;
}

/* ===========================
   SUBMIT BUTTON - Pill Blue
   =========================== */
.gp-submit-btn {
    margin-top: var(--gp-spacing-sm);
    height: 48px;
    padding: 0 24px;
    background: var(--gp-primary);
    color: #FFFFFF;
    border: none;
    border-radius: var(--gp-radius-pill);
    font-size: 16px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background var(--gp-transition-base), transform var(--gp-transition-fast), box-shadow var(--gp-transition-base);
    box-shadow: 0 2px 8px rgba(91, 106, 191, 0.25);
    width: 100%;
    display: block;
    text-align: center;
    line-height: 48px;
    
    
    appearance: none;
}

.gp-submit-btn:hover:not(:disabled) {
    background: var(--gp-primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(91, 106, 191, 0.35);
}

.gp-submit-btn:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 1px 4px rgba(91, 106, 191, 0.2);
}

.gp-submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.gp-submit-btn:focus {
    outline: 2px solid var(--gp-primary);
    outline-offset: 2px;
}

/* Button Loading State */
.gp-btn-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--gp-spacing-sm);
    height: 100%;
}

.gp-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: gp-spin 0.6s linear infinite;
    display: none;
    flex-shrink: 0;
}

.gp-submit-btn.loading .gp-spinner {
    display: block;
}

.gp-submit-btn.loading .gp-btn-text {
    opacity: 0.7;
}

@keyframes gp-spin {
    to { transform: rotate(360deg); }
}

/* ===========================
   FOOTER LINKS (Below Card)
   =========================== */
.gp-login-footer {
    margin-top: var(--gp-spacing-lg);
    text-align: center;
    width: 100%;
}

.gp-footer-links {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0;
    flex-wrap: wrap;
    margin: 0;
    padding: 0;
    list-style: none;
}

.gp-footer-link {
    color: var(--gp-primary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: color var(--gp-transition-base);
    display: inline;
    margin: 0;
    padding: 0;
}

.gp-footer-link:hover {
    color: var(--gp-primary-dark);
    text-decoration: underline;
}

.gp-footer-separator {
    color: var(--gp-text-muted);
    margin: 0 12px;
    font-size: 14px;
    user-select: none;
}

/* ===========================
   MFA BOX
   =========================== */
.gp-mfa-box {
    display: none;
    animation: gp-fadeIn 0.3s ease;
}

@keyframes gp-fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.gp-mfa-header {
    text-align: center;
    margin-bottom: var(--gp-spacing-xl);
}

.gp-mfa-header h3 {
    font-size: 22px;
    font-weight: 600;
    color: var(--gp-text-primary);
    margin: 0 0 var(--gp-spacing-sm) 0;
    padding: 0;
    line-height: 1.3;
}

.gp-mfa-header p {
    color: var(--gp-text-secondary);
    font-size: 14px;
    margin: 0;
    padding: 0;
    line-height: 1.5;
}

/* ===========================
   MFA QR CODE
   =========================== */
.gp-mfa-qr {
    margin-bottom: var(--gp-spacing-lg);
}

.gp-mfa-qr-container {
    text-align: center;
    background: #fff;
    padding: var(--gp-spacing-lg);
    border: 1px solid var(--gp-border);
    border-radius: var(--gp-radius-md);
}

.gp-mfa-qr-title {
    margin: 0 0 var(--gp-spacing-md) 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--gp-text-primary);
    padding: 0;
}

.gp-mfa-qr-image {
    border: 1px solid var(--gp-border);
    padding: var(--gp-spacing-sm);
    border-radius: var(--gp-radius-sm);
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
}

.gp-mfa-instruction {
    text-align: center;
    color: var(--gp-text-secondary);
    font-size: 14px;
    margin: 0;
    padding: 0;
}

/* ===========================
   MFA DEV CODE
   =========================== */
.gp-mfa-dev {
    display: none;
    margin: var(--gp-spacing-lg) 0;
    padding: var(--gp-spacing-lg);
    background: #fff9e6;
    border: 2px dashed #ff6b35;
    border-radius: var(--gp-radius-md);
    text-align: center;
}

.gp-dev-code-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--gp-spacing-sm);
}

.gp-dev-label {
    color: #ff6b35;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0;
    padding: 0;
}

.gp-dev-code {
    font-size: 28px;
    font-weight: 700;
    background: #ffffcc;
    padding: var(--gp-spacing-sm) var(--gp-spacing-lg);
    border-radius: var(--gp-radius-sm);
    font-family: 'Courier New', monospace;
    letter-spacing: 4px;
    color: var(--gp-text-primary);
    margin: 0;
    display: inline-block;
}

/* ===========================
   MFA INPUT
   =========================== */
.gp-mfa-input {
    text-align: center;
    font-size: 22px;
    letter-spacing: 8px;
    font-weight: 600;
    font-family: 'Courier New', monospace;
}

/* ===========================
   MFA MESSAGE
   =========================== */
.gp-mfa-message {
    margin-top: var(--gp-spacing-md);
    text-align: center;
    font-size: 14px;
    font-weight: 500;
    min-height: 20px;
}

/* ===========================
   MFA BACK LINK
   =========================== */
.gp-mfa-back {
    margin-top: var(--gp-spacing-xl);
    text-align: center;
}

.gp-back-link {
    color: var(--gp-text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: color var(--gp-transition-base);
    display: inline-block;
    margin: 0;
    padding: 0;
}

.gp-back-link:hover {
    color: var(--gp-primary);
    text-decoration: underline;
}

/* ===========================
   NOTICE (Already Logged In)
   =========================== */
.gp-login-notice {
    background: rgba(72, 187, 120, 0.1);
    border: 1px solid rgba(72, 187, 120, 0.3);
    color: #2F855A;
    padding: var(--gp-spacing-lg);
    border-radius: var(--gp-radius-md);
    text-align: center;
    font-size: 15px;
    margin: 0;
}

.gp-login-notice a {
    color: var(--gp-primary);
    font-weight: 600;
    text-decoration: none;
}

.gp-login-notice a:hover {
    text-decoration: underline;
}

/* ===========================
   RESPONSIVE
   =========================== */
@media (max-width: 768px) {
    .gp-login-wrapper {
        padding: 0 var(--gp-spacing-md);
        margin: 24px auto 20px;
    }

    .gp-login-card {
        padding: var(--gp-spacing-xl) var(--gp-spacing-lg);
    }

    .gp-mfa-header h3 {
        font-size: 20px;
    }

    .gp-dev-code {
        font-size: 22px;
        letter-spacing: 2px;
    }
}

@media (max-width: 480px) {
    .gp-login-card {
        padding: var(--gp-spacing-lg) var(--gp-spacing-md);
        border-radius: var(--gp-radius-md);
    }

    .gp-form-input {
        height: 44px;
        padding: 0 16px;
        font-size: 14px;
        line-height: 44px;
    }

    .gp-submit-btn {
        height: 44px;
        font-size: 15px;
        line-height: 44px;
    }

    .gp-mfa-input {
        font-size: 18px;
        letter-spacing: 6px;
    }

    .gp-dev-code {
        font-size: 18px;
        padding: var(--gp-spacing-sm) var(--gp-spacing-md);
    }
}

/* ===========================
   ACCESSIBILITY
   =========================== */
@media (prefers-reduced-motion: reduce) {
    .gp-login-wrapper *,
    .gp-login-wrapper *::before,
    .gp-login-wrapper *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

.gp-login-wrapper *:focus-visible {
    outline: 2px solid var(--gp-primary);
    outline-offset: 2px;
}

/* ===========================
   BLOCKSY / THEME COMPAT
   =========================== */

/* Ensure our wrapper isn't squished by theme flex/grid */
.gp-login-wrapper {
    flex-shrink: 0;
}

/* Override Blocksy default input styles inside our form */
.gp-login-wrapper .gp-form-input,
.gp-login-wrapper input[type="email"],
.gp-login-wrapper input[type="password"],
.gp-login-wrapper input[type="text"] {
    width: 100% !important;
    height: 48px !important;
    padding: 0 20px !important;
    border: 1.5px solid var(--gp-border) !important;
    border-radius: var(--gp-radius-pill) !important;
    font-size: 15px !important;
    background: var(--gp-bg-input) !important;
    color: var(--gp-text-primary) !important;
    box-shadow: none !important;
    
    line-height: 48px !important;
    margin: 0 !important;
}

.gp-login-wrapper .gp-form-input:focus,
.gp-login-wrapper input[type="email"]:focus,
.gp-login-wrapper input[type="password"]:focus,
.gp-login-wrapper input[type="text"]:focus {
    border-color: var(--gp-primary) !important;
    box-shadow: 0 0 0 3px rgba(91, 106, 191, 0.12) !important;
    outline: none !important;
}

/* Password field right padding override */
.gp-login-wrapper .gp-form-input-wrapper:has(.gp-password-toggle) input {
    padding-right: 50px !important;
}

/* Override Blocksy button styles */
.gp-login-wrapper .gp-submit-btn,
.gp-login-wrapper button[type="submit"] {
    background: var(--gp-primary) !important;
    color: #FFFFFF !important;
    border: none !important;
    border-radius: var(--gp-radius-pill) !important;
    height: 48px !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    width: 100% !important;
    cursor: pointer !important;
    box-shadow: 0 2px 8px rgba(91, 106, 191, 0.25) !important;
    
    line-height: 48px !important;
    padding: 0 24px !important;
}

.gp-login-wrapper .gp-submit-btn:hover:not(:disabled),
.gp-login-wrapper button[type="submit"]:hover:not(:disabled) {
    background: var(--gp-primary-dark) !important;
    box-shadow: 0 4px 12px rgba(91, 106, 191, 0.35) !important;
}

/* Override Blocksy label styles */
.gp-login-wrapper .gp-form-label {
    font-size: 14px !important;
    font-weight: 500 !important;
    color: var(--gp-text-secondary) !important;
    text-align: center !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Override Blocksy link styles */
.gp-login-wrapper a.gp-footer-link,
.gp-login-wrapper a.gp-back-link {
    color: var(--gp-primary) !important;
    text-decoration: none !important;
}

.gp-login-wrapper a.gp-footer-link:hover,
.gp-login-wrapper a.gp-back-link:hover {
    color: var(--gp-primary-dark) !important;
    text-decoration: underline !important;
}