/**
 * Password Toggle Styles
 *
 * Styles for the show/hide password toggle button that appears
 * next to password and PIN code input fields.
 */

/* Wrapper for password field + toggle button */
.password-toggle-wrapper {
    position: relative;
    display: inline-block;
    width: 100%;
}

/* Password input with toggle button */
.password-toggle-input {
    padding-right: 3rem !important; /* Make room for the toggle button */
}

/* Toggle button */
.password-toggle-btn {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    color: #6c757d;
    transition: color 0.15s ease-in-out;
    z-index: 10;
    height: auto;
    line-height: 1;
}

.password-toggle-btn:hover {
    color: #495057;
}

.password-toggle-btn:focus {
    outline: 2px solid #0d6efd;
    outline-offset: 2px;
    border-radius: 0.25rem;
}

.password-toggle-btn:active {
    color: #212529;
}

/* Icon - Eye symbol using CSS */
.password-toggle-icon {
    display: inline-block;
    width: 1.25rem;
    height: 1.25rem;
    position: relative;
}

/* Eye icon - hidden state (eye with slash) */
.password-toggle-icon::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 1.25rem;
    height: 0.75rem;
    border: 2px solid currentColor;
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
}

.password-toggle-icon::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 0.5rem;
    height: 0.5rem;
    background: currentColor;
    border-radius: 50%;
}

/* Slash line when password is hidden */
.password-toggle-icon {
    background: linear-gradient(
        to top right,
        transparent 0%,
        transparent calc(50% - 1px),
        currentColor calc(50% - 1px),
        currentColor calc(50% + 1px),
        transparent calc(50% + 1px),
        transparent 100%
    );
}

/* Remove slash when password is visible */
.password-toggle-btn.password-visible .password-toggle-icon {
    background: none;
}

/* Alternative: Use Font Awesome or Bootstrap Icons if available */
/* Uncomment and adjust if you prefer to use icon fonts */
/*
.password-toggle-icon::before {
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
    content: "\f070"; /* fa-eye-slash
}

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

/* Specific adjustments for form groups */
.form-group .password-toggle-wrapper {
    display: block;
}

/* Bootstrap input group compatibility */
.input-group .password-toggle-wrapper {
    flex: 1 1 auto;
    width: 1%;
    min-width: 0;
}

/* Adjustments for inline forms */
.form-inline .password-toggle-wrapper {
    display: inline-block;
    width: auto;
}

/* Responsive adjustments */
@media (max-width: 576px) {
    .password-toggle-btn {
        padding: 0.5rem;
    }

    .password-toggle-icon {
        width: 1.125rem;
        height: 1.125rem;
    }
}

/* Special styling for payment code fields */
.payment-code-field .password-toggle-wrapper {
    max-width: 100%;
}

.payment-code-field .password-toggle-input {
    text-align: center;
    letter-spacing: 0.25rem;
    font-size: 1.5rem;
    font-weight: bold;
}

/* Dark mode support (if applicable) */
@media (prefers-color-scheme: dark) {
    .password-toggle-btn {
        color: #adb5bd;
    }

    .password-toggle-btn:hover {
        color: #dee2e6;
    }

    .password-toggle-btn:active {
        color: #f8f9fa;
    }
}

/* Accessibility: High contrast mode */
@media (prefers-contrast: high) {
    .password-toggle-btn {
        border: 1px solid currentColor;
        border-radius: 0.25rem;
    }
}

/* Print: Hide toggle button when printing */
@media print {
    .password-toggle-btn {
        display: none;
    }

    .password-toggle-input {
        padding-right: 0.75rem !important;
    }
}

/* =============================================
   Payment Code Toggle Specific Styles
   ============================================= */

/* Code visual container */
#code-visual {
    min-height: 3rem;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 1rem auto;
    gap: 0.5rem;
}

/* Code dots (hidden state) */
.code-dot {
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
    background-color: #dee2e6;
    display: inline-block;
    margin: 0 0.25rem;
}

.code-dot.filled {
    background-color: #495057;
}

/* Code digits (visible state) */
.code-digit {
    font-size: 2rem;
    font-weight: bold;
    color: #212529;
    display: inline-block;
    margin: 0 0.25rem;
    min-width: 1.5rem;
    text-align: center;
}

/* Payment code toggle button */
.payment-code-toggle-btn {
    background: transparent;
    border: 1px solid #6c757d;
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    color: #6c757d;
    transition: all 0.15s ease-in-out;
    margin: 0.5rem auto;
    display: block;
}

.payment-code-toggle-btn:hover {
    color: #495057;
    border-color: #495057;
    background-color: #f8f9fa;
}

.payment-code-toggle-btn:focus {
    outline: 2px solid #0d6efd;
    outline-offset: 2px;
    border-radius: 0.5rem;
}

.payment-code-toggle-btn:active {
    color: #212529;
    border-color: #212529;
}

/* Use the same eye icon styles */
.payment-code-toggle-btn .password-toggle-icon {
    display: inline-block;
    width: 1.25rem;
    height: 1.25rem;
    position: relative;
}

.payment-code-toggle-btn .password-toggle-icon::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 1.25rem;
    height: 0.75rem;
    border: 2px solid currentColor;
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
}

.payment-code-toggle-btn .password-toggle-icon::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 0.5rem;
    height: 0.5rem;
    background: currentColor;
    border-radius: 50%;
}

/* Slash line when code is hidden */
.payment-code-toggle-btn .password-toggle-icon {
    background: linear-gradient(
        to top right,
        transparent 0%,
        transparent calc(50% - 1px),
        currentColor calc(50% - 1px),
        currentColor calc(50% + 1px),
        transparent calc(50% + 1px),
        transparent 100%
    );
}

/* Remove slash when code is visible */
.payment-code-toggle-btn.code-visible .password-toggle-icon {
    background: none;
}

/* Responsive adjustments for payment code toggle */
@media (max-width: 576px) {
    .code-dot {
        width: 1.125rem;
        height: 1.125rem;
        margin: 0 0.375rem;
    }

    .code-digit {
        font-size: 2.5rem;
        margin: 0 0.375rem;
        min-width: 2rem;
    }

    #code-visual {
        min-height: 4rem;
        gap: 0.75rem;
    }

    .payment-code-toggle-btn {
        padding: 0.75rem 1rem;
        font-size: 1.1rem;
    }
}
