/**
 * HIBP Password Checker - Styles
 * Full Accessibility Support
 */

/* ==========================================
   Screen Reader Only - للقراء الشاشة فقط
   ========================================== */
.screen-reader-text {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.screen-reader-text:focus {
    background-color: #f1f1f1;
    border-radius: 3px;
    box-shadow: 0 0 2px 2px rgba(0, 0, 0, 0.6);
    clip: auto !important;
    color: #21759b;
    display: block;
    font-size: 14px;
    font-weight: bold;
    height: auto;
    left: 5px;
    line-height: normal;
    padding: 15px 23px 14px;
    text-decoration: none;
    top: 5px;
    width: auto;
    z-index: 100000;
}

/* ==========================================
   حاوية النتيجة الأساسية
   ========================================== */
.hibp-result {
    margin-top: 8px;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 13px;
    display: none;
    direction: rtl;
    text-align: right;
}

/* حالة التحميل */
.hibp-result.hibp-checking {
    background-color: #f0f0f1;
    color: #50575e;
    display: block;
}

/* كلمة مرور آمنة */
.hibp-result.hibp-safe {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    display: block;
}

/* كلمة مرور مخترقة */
.hibp-result.hibp-pwned {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    display: block;
}

/* خطأ */
.hibp-result.hibp-error {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
    display: block;
}

/* Spinner للتحميل */
.hibp-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #0073aa;
    border-radius: 50%;
    animation: hibp-spin 1s linear infinite;
    vertical-align: middle;
    margin-left: 5px;
}

@keyframes hibp-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ==========================================
   Shortcode Styles
   ========================================== */
.hibp-shortcode-wrapper {
    max-width: 500px;
    margin: 20px auto;
    padding: 25px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    direction: rtl;
    text-align: right;
}

.hibp-shortcode-title {
    margin: 0 0 10px 0;
    font-size: 1.5em;
    color: #1e3a5f;
}

.hibp-shortcode-description {
    margin: 0 0 20px 0;
    color: #666;
    font-size: 0.95em;
}

/* Input Group */
.hibp-input-group {
    margin-bottom: 15px;
}

.hibp-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.hibp-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.hibp-shortcode-input {
    width: 100%;
    padding: 12px 45px 12px 15px;
    font-size: 16px;
    border: 2px solid #ddd;
    border-radius: 8px;
    transition: border-color 0.3s, box-shadow 0.3s;
    direction: ltr;
    text-align: left;
}

.hibp-shortcode-input:focus {
    border-color: #0073aa;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.2);
    outline: none;
}

.hibp-shortcode-input:focus-visible {
    outline: 3px solid #0073aa;
    outline-offset: 2px;
}

/* Toggle Visibility Button */
.hibp-toggle-visibility {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    font-size: 18px;
    color: #666;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.hibp-toggle-visibility:hover {
    background-color: #f0f0f0;
}

.hibp-toggle-visibility:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

.hibp-toggle-visibility:focus-visible {
    outline: 3px solid #0073aa;
    outline-offset: 2px;
    background-color: #e8f4fc;
}

/* Submit Button */
.hibp-shortcode-button {
    width: 100%;
    padding: 14px 20px;
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, #0073aa, #005a87);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    min-height: 50px;
}

.hibp-shortcode-button:hover:not(:disabled) {
    background: linear-gradient(135deg, #005a87, #004466);
    transform: translateY(-1px);
}

.hibp-shortcode-button:focus {
    outline: 3px solid #0073aa;
    outline-offset: 3px;
}

.hibp-shortcode-button:focus-visible {
    outline: 3px solid #0073aa;
    outline-offset: 3px;
    box-shadow: 0 0 0 6px rgba(0, 115, 170, 0.3);
}

.hibp-shortcode-button:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.hibp-button-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.hibp-spinner-small {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid #fff;
    border-radius: 50%;
    animation: hibp-spin 1s linear infinite;
}

/* ==========================================
   Results Area - Shortcode
   ========================================== */
.hibp-shortcode-result {
    margin-top: 20px;
    padding: 20px;
    border-radius: 10px;
    display: none;
    animation: hibp-fadeIn 0.3s ease-out;
}

.hibp-shortcode-result:focus {
    outline: 3px solid #0073aa;
    outline-offset: 2px;
}

@keyframes hibp-fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.hibp-result-checking {
    background: #f8f9fa;
    border: 2px solid #dee2e6;
    display: block;
}

.hibp-result-checking .hibp-result-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.hibp-spinner-large {
    width: 24px;
    height: 24px;
    border: 3px solid #dee2e6;
    border-top: 3px solid #0073aa;
    border-radius: 50%;
    animation: hibp-spin 1s linear infinite;
}

.hibp-result-safe {
    background: linear-gradient(135deg, #d4edda, #c3e6cb);
    border: 2px solid #28a745;
    display: block;
}

.hibp-result-pwned {
    background: linear-gradient(135deg, #f8d7da, #f5c6cb);
    border: 2px solid #dc3545;
    display: block;
}

.hibp-result-error {
    background: linear-gradient(135deg, #fff3cd, #ffeeba);
    border: 2px solid #ffc107;
    display: block;
}

.hibp-result-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.hibp-result-icon {
    font-size: 28px;
}

.hibp-result-title {
    font-size: 1.3em;
    font-weight: bold;
}

.hibp-result-safe .hibp-result-title {
    color: #155724;
}

.hibp-result-pwned .hibp-result-title {
    color: #721c24;
}

.hibp-result-error .hibp-result-title {
    color: #856404;
}

.hibp-result-detail {
    margin: 10px 0;
    line-height: 1.6;
    color: #333;
}

/* Breach Count Display */
.hibp-breach-count {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 15px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 8px;
}

.hibp-count-number {
    font-size: 1.8em;
    font-weight: bold;
    color: #dc3545;
}

.hibp-count-label {
    color: #666;
    font-size: 0.9em;
}

/* Safe Tips */
.hibp-safe-tips {
    margin-top: 15px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 8px;
}

.hibp-safe-tips p {
    margin: 0 0 10px 0;
}

.hibp-safe-tips ul {
    margin: 0;
    padding-right: 20px;
}

.hibp-safe-tips li {
    margin-bottom: 5px;
    line-height: 1.5;
}

/* ==========================================
   Privacy Info Section
   ========================================== */
.hibp-privacy-info {
    margin-top: 20px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
}

.hibp-privacy-info summary {
    padding: 12px 15px;
    background: #f8f9fa;
    cursor: pointer;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background-color 0.2s;
}

.hibp-privacy-info summary:hover {
    background: #e9ecef;
}

.hibp-privacy-info summary:focus {
    outline: 3px solid #0073aa;
    outline-offset: -3px;
}

.hibp-privacy-info summary:focus-visible {
    outline: 3px solid #0073aa;
    outline-offset: -3px;
    background: #e8f4fc;
}

.hibp-info-icon {
    font-size: 1.1em;
}

.hibp-info-content {
    padding: 15px;
    background: #fff;
}

.hibp-info-content p {
    margin: 0 0 10px 0;
}

.hibp-info-content ol {
    margin: 0;
    padding-right: 25px;
}

.hibp-info-content li {
    margin-bottom: 8px;
    line-height: 1.5;
}

/* ==========================================
   High Contrast Mode Support
   ========================================== */
@media (prefers-contrast: high) {
    .hibp-shortcode-wrapper {
        border: 2px solid #000;
    }
    
    .hibp-shortcode-input {
        border: 2px solid #000;
    }
    
    .hibp-shortcode-button {
        background: #000;
        color: #fff;
        border: 2px solid #000;
    }
    
    .hibp-result-safe {
        border: 3px solid #000;
        background: #d4edda;
    }
    
    .hibp-result-pwned {
        border: 3px solid #000;
        background: #f8d7da;
    }
    
    .hibp-shortcode-input:focus,
    .hibp-shortcode-button:focus,
    .hibp-toggle-visibility:focus {
        outline: 3px solid #000;
        outline-offset: 2px;
    }
}

/* ==========================================
   Reduced Motion Support
   ========================================== */
@media (prefers-reduced-motion: reduce) {
    .hibp-spinner,
    .hibp-spinner-small,
    .hibp-spinner-large {
        animation: none;
    }
    
    .hibp-shortcode-result {
        animation: none;
    }
    
    .hibp-shortcode-button:hover:not(:disabled) {
        transform: none;
    }
}

/* ==========================================
   تنسيقات صفحة الإعدادات
   ========================================== */
.hibp-settings-wrap {
    max-width: 800px;
}

.hibp-settings-wrap .form-table th {
    width: 250px;
}

/* ==========================================
   تنسيقات لصفحة تسجيل الدخول
   ========================================== */
.login .hibp-result {
    margin: 10px 0;
}

/* ==========================================
   تنسيقات WooCommerce
   ========================================== */
.woocommerce-form .hibp-result {
    margin-top: 5px;
    margin-bottom: 10px;
}

/* ==========================================
   تنسيقات للموبايل
   ========================================== */
@media screen and (max-width: 782px) {
    .hibp-result {
        font-size: 14px;
        padding: 10px;
    }
    
    .hibp-settings-wrap .form-table th {
        width: 100%;
    }
    
    .hibp-shortcode-wrapper {
        margin: 15px;
        padding: 20px;
    }
    
    .hibp-shortcode-input {
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .hibp-result-icon {
        font-size: 24px;
    }
    
    .hibp-result-title {
        font-size: 1.1em;
    }
    
    .hibp-count-number {
        font-size: 1.5em;
    }
}

/* ==========================================
   تنسيقات RTL للعربية
   ========================================== */
html[dir="rtl"] .hibp-result,
body.rtl .hibp-result {
    direction: rtl;
    text-align: right;
}

html[dir="rtl"] .hibp-spinner,
body.rtl .hibp-spinner {
    margin-left: 0;
    margin-right: 5px;
}

/* ==========================================
   تنسيقات لصفحة البروفايل في لوحة التحكم
   ========================================== */
#profile-page .hibp-result,
#your-profile .hibp-result {
    margin-top: 5px;
    max-width: 25em;
}

/* ==========================================
   تنسيقات لصفحة إنشاء مستخدم جديد
   ========================================== */
#createuser .hibp-result {
    margin-top: 5px;
}

/* ==========================================
   Focus Visible Polyfill Support
   ========================================== */
.js-focus-visible :focus:not(.focus-visible) {
    outline: none;
}

.js-focus-visible .focus-visible {
    outline: 3px solid #0073aa;
    outline-offset: 2px;
}
