/**
 * PIN Pad Modal Styles
 * Secure PIN entry modal with numeric keypad
 * Version: 1.0
 */

/* Modal Overlay */
.pin-pad-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    opacity: 0;
    transition: opacity 0.3s ease;
    user-select: none;
    -webkit-user-select: none;
}

.pin-pad-modal-overlay.show {
    opacity: 1;
}

/* Modal Container */
.pin-pad-modal {
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 400px;
    width: 90%;
    max-height: 90vh;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

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

/* Shake animation on error */
.pin-pad-modal.shake {
    animation: shake 0.5s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-10px); }
    20%, 40%, 60%, 80% { transform: translateX(10px); }
}

/* Header */
.pin-pad-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    text-align: center;
}

.pin-pad-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* Body */
.pin-pad-body {
    padding: 24px;
}

/* Info Section */
.pin-info {
    text-align: center;
    margin-bottom: 24px;
}

.widget-label {
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
    margin: 0 0 8px 0;
}

.action-label {
    font-size: 14px;
    color: #6b7280;
    margin: 0;
}

.action-label strong {
    color: #667eea;
    font-weight: 600;
}

/* PIN Display */
.pin-display {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
    padding: 16px;
    background: #f3f4f6;
    border-radius: 12px;
    min-height: 48px;
}

.pin-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #d1d5db;
    transition: all 0.2s ease;
}

.pin-dot.filled {
    background: #667eea;
    transform: scale(1.2);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

/* Keypad */
.pin-keypad {
    margin-bottom: 16px;
}

.keypad-row {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.keypad-row:last-child {
    margin-bottom: 0;
}

.keypad-btn {
    flex: 1;
    height: 56px;
    font-size: 24px;
    font-weight: 600;
    color: #1f2937;
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    -webkit-user-select: none;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.keypad-btn:hover:not(:disabled) {
    background: #f3f4f6;
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.keypad-btn:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.2);
}

.keypad-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #f9fafb;
}

/* Special buttons */
.keypad-delete {
    background: #fef2f2;
    color: #dc2626;
    border-color: #fecaca;
}

.keypad-delete:hover:not(:disabled) {
    background: #fee2e2;
    border-color: #fca5a5;
}

.keypad-submit {
    background: #ecfdf5;
    color: #10b981;
    border-color: #a7f3d0;
}

.keypad-submit:hover:not(:disabled) {
    background: #d1fae5;
    border-color: #6ee7b7;
}

.keypad-btn svg {
    width: 20px;
    height: 20px;
}

/* Warning/Status */
.pin-warning {
    text-align: center;
    padding: 12px;
    background: #fef3c7;
    color: #92400e;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 16px;
    transition: all 0.3s ease;
}

.pin-warning.info {
    background: #dbeafe;
    color: #1e40af;
}

.pin-warning.error {
    background: #fee2e2;
    color: #991b1b;
}

.pin-warning.success {
    background: #d1fae5;
    color: #065f46;
}

/* Cancel Button */
.pin-cancel-btn {
    width: 100%;
    padding: 12px;
    background: transparent;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    color: #6b7280;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pin-cancel-btn:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
    color: #374151;
}

.pin-cancel-btn:active {
    transform: scale(0.98);
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .pin-pad-modal {
        background: #1f2937;
    }

    .widget-label {
        color: #f3f4f6;
    }

    .action-label {
        color: #9ca3af;
    }

    .action-label strong {
        color: #818cf8;
    }

    .pin-display {
        background: #111827;
    }

    .pin-dot {
        background: #4b5563;
    }

    .pin-dot.filled {
        background: #818cf8;
    }

    .keypad-btn {
        background: #374151;
        border-color: #4b5563;
        color: #f3f4f6;
    }

    .keypad-btn:hover:not(:disabled) {
        background: #4b5563;
        border-color: #818cf8;
    }

    .keypad-btn:disabled {
        background: #1f2937;
        color: #6b7280;
    }

    .keypad-delete {
        background: #450a0a;
        color: #fca5a5;
        border-color: #7f1d1d;
    }

    .keypad-delete:hover:not(:disabled) {
        background: #7f1d1d;
        border-color: #991b1b;
    }

    .keypad-submit {
        background: #064e3b;
        color: #6ee7b7;
        border-color: #065f46;
    }

    .keypad-submit:hover:not(:disabled) {
        background: #065f46;
        border-color: #047857;
    }

    .pin-warning {
        background: #78350f;
        color: #fde68a;
    }

    .pin-warning.info {
        background: #1e3a8a;
        color: #93c5fd;
    }

    .pin-warning.error {
        background: #7f1d1d;
        color: #fecaca;
    }

    .pin-warning.success {
        background: #064e3b;
        color: #a7f3d0;
    }

    .pin-cancel-btn {
        border-color: #4b5563;
        color: #9ca3af;
    }

    .pin-cancel-btn:hover {
        background: #374151;
        border-color: #6b7280;
        color: #d1d5db;
    }
}

/* Responsive Design */
@media (max-width: 480px) {
    .pin-pad-modal {
        width: 95%;
        max-width: none;
    }

    .pin-pad-body {
        padding: 20px;
    }

    .keypad-btn {
        height: 48px;
        font-size: 20px;
    }

    .pin-dot {
        width: 14px;
        height: 14px;
    }

    .pin-display {
        gap: 10px;
        padding: 12px;
    }
}

/* Accessibility */
.keypad-btn:focus-visible {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

.pin-cancel-btn:focus-visible {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* Prevent text selection on buttons */
.keypad-btn::selection,
.pin-cancel-btn::selection {
    background: transparent;
}

/* Loading state */
.keypad-btn:disabled::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    opacity: 0;
}

.keypad-btn:disabled.loading::after {
    opacity: 1;
}

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

/* High contrast mode support */
@media (prefers-contrast: high) {
    .keypad-btn {
        border-width: 3px;
    }

    .pin-dot {
        border: 2px solid currentColor;
    }

    .pin-warning {
        border: 2px solid currentColor;
    }
}
