:root {
    /* ألوان متناسقة مع شعار الطاهرة العنابي/البنفسجي */
    --primary: #5c1a4b;
    --secondary: #8a2a74;
    --bg-gradient: linear-gradient(135deg, #f5e6f3 0%, #e1bee7 100%);
    --card-bg: rgba(255, 255, 255, 0.95);
    --text-dark: #2a1b26;
    --text-light: #665863;
    --star-active: #ffb703;
    --star-inactive: #e9ecef;
}

* {
    font-family: 'Tajawal', sans-serif;
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg-gradient);
    background-attachment: fixed;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px 20px;
    direction: rtl;
    /* لضمان دعم اللغة العربية بشكل صحيح */
    transition: padding-bottom 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

body.keyboard-active {
    /* مساحة إضافية في الأسفل لتجنب تغطية الكيبورد للمحتوى */
    padding-bottom: 250px;
}

.feedback-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    width: 100%;
    max-width: 650px;
    border-radius: 24px;
    padding: 45px 40px;
    box-shadow: 0 25px 45px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.6);

    /* للتحضير لحركة الإخفاء والعودة للخلف */
    opacity: 0;
    transform: translateY(40px) scale(0.98);
    transition: opacity 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275),
        transform 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.feedback-card.show {
    opacity: 1;
    transform: translateY(0) scale(1);
    /* نزيل الأنيميشن لكي يعتمد على الـ transition ذهاباً وإياباً */
}

/* إزالة الـ keyframes القديم لأنه استبدل بـ transition */

.header {
    text-align: center;
    margin-bottom: 35px;
}

.logo {
    width: 85px;
    height: 85px;
    margin-bottom: 15px;
    animation: floating 3s ease-in-out infinite;
}

@keyframes floating {
    0% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-10px);
    }

    100% {
        transform: translateY(0px);
    }
}

.header h1 {
    color: var(--primary);
    font-size: 30px;
    font-weight: 800;
    margin-bottom: 5px;
}

.header p {
    color: var(--secondary);
    font-size: 18px;
    font-weight: 700;
}

.header h2 {
    margin-top: 25px;
    font-size: 20px;
    color: var(--text-dark);
    font-weight: 700;
}

.form-group {
    background: #ffffff;
    padding: 20px 25px;
    border-radius: 16px;
    margin-bottom: 25px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.02);
    border: 1px solid #f1f3f5;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    opacity: 0;
    transform: translateY(20px);
    animation: fadeInUpGroup 0.6s ease-out forwards;
}

.form-group:nth-child(1) {
    animation-delay: 0.2s;
}

.form-group:nth-child(2) {
    animation-delay: 0.4s;
}

.form-group:nth-child(3) {
    animation-delay: 0.6s;
}

.form-group:nth-child(4) {
    animation-delay: 0.8s;
}

.form-group:nth-child(5) {
    animation-delay: 1.0s;
}

@keyframes fadeInUpGroup {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.form-group:hover {
    transform: translateY(-3px) !important;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.06) !important;
}

.form-group label {
    display: block;
    font-size: 19px;
    font-weight: 800;
    color: var(--text-dark);
    margin-bottom: 8px;
}

.form-group .desc {
    font-size: 15px;
    color: var(--text-light);
    margin-bottom: 15px;
}

input[type="text"],
input[type="tel"],
textarea,
select {
    width: 100%;
    padding: 16px;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    font-size: 16px;
    transition: all 0.3s ease;
    background: #f8f9fa;
    color: var(--text-dark);
}

input[type="text"]:focus,
input[type="tel"]:focus,
textarea:focus,
select:focus {
    border-color: var(--secondary);
    background: #ffffff;
    outline: none;
    box-shadow: 0 0 0 4px rgba(138, 42, 116, 0.1);
}

/* ==================================
   الخلية العائمة فوق الكيبورد (Floating Input)
   ================================== */
.floating-input-placeholder {
    /* يُستخدم لحفظ مكان العنصر الأصلي عندما يطير العنصر فوق الكيبورد */
    visibility: hidden;
}

.floating-input-active {
    position: fixed !important;
    bottom: calc(var(--keyboard-top, 300px) + 20px) !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    width: 90% !important;
    max-width: 600px !important;
    z-index: 10001 !important;
    box-shadow: 0 15px 35px rgba(92, 26, 75, 0.3) !important;
    border: 3px solid var(--primary) !important;
    border-radius: 16px !important;
    background: #ffffff !important;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
    padding: 18px !important;
    font-size: 18px !important;
}

/* ==================================
   شاشة البداية (Splash Screen)
   ================================== */
.splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--bg-gradient);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1), transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.splash-screen.hidden {
    opacity: 0;
    transform: translateY(-50px) scale(0.95);
    pointer-events: none;
}

.splash-logo {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    margin-bottom: 30px;
    box-shadow: 0 20px 40px rgba(138, 42, 116, 0.2);
    animation: pulseLogo 2.5s infinite alternate ease-in-out;
}

@keyframes pulseLogo {
    0% {
        transform: scale(1);
        box-shadow: 0 15px 35px rgba(138, 42, 116, 0.2);
    }

    100% {
        transform: scale(1.1);
        box-shadow: 0 30px 60px rgba(138, 42, 116, 0.4);
    }
}

.splash-title {
    font-size: 45px;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 15px;
    animation: splashFadeInUp 1s ease-out;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.splash-subtitle {
    font-size: 20px;
    color: var(--text-light);
    font-weight: 700;
    animation: splashFadeInUp 1.2s ease-out infinite alternate;
}

@keyframes splashFadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==================================
   شبكة اختيار الفرع (Branch Grid) 
   ================================== */
.branch-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 10px;
    margin-top: 15px;
}

.branch-radio {
    display: block;
    position: relative;
    cursor: pointer;
    text-align: center;
}

.branch-radio input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}

.branch-radio span {
    display: block;
    padding: 12px 10px;
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 700;
    color: var(--text-dark);
    transition: all 0.3s ease;
}

.branch-radio:hover span {
    border-color: rgba(138, 42, 116, 0.4);
    background: #fff;
}

.branch-radio input:checked~span {
    background: rgba(138, 42, 116, 0.08);
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: 0 4px 10px rgba(138, 42, 116, 0.15);
}



.btn-primary {
    padding: 15px 30px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    font-size: 18px;
    font-weight: 800;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(138, 42, 116, 0.4);
}

.btn-secondary {
    padding: 15px 30px;
    background: #e9ecef;
    color: var(--text-dark);
    font-size: 18px;
    font-weight: 700;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    background: #dee2e6;
    transform: translateY(-2px);
}

/* ==================================
   التقييم بالإيموجي 3D 
   ================================== */

.emojis {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-top: 20px;
}

.emoji-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    padding: 10px;
    border-radius: 16px;
    background: transparent;
    border: 2px solid transparent;
}

.emoji {
    width: 60px;
    height: 60px;
    object-fit: contain;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.15));
    transition: all 0.3s ease;
}

.emoji-wrapper span {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-light);
    margin-top: 8px;
    transition: color 0.3s ease;
}

/* التفاعل (Hover & Active) */
.emoji-wrapper:hover {
    transform: scale(1.1);
    background: rgba(138, 42, 116, 0.05);
}

.emoji-wrapper.selected {
    transform: scale(1.15);
    background: rgba(138, 42, 116, 0.1);
    border-color: rgba(138, 42, 116, 0.3);
}

.emoji-wrapper.selected .emoji {
    filter: drop-shadow(0 8px 12px rgba(138, 42, 116, 0.4));
}

.emoji-wrapper.selected span {
    color: var(--primary);
}

.submit-btn {
    width: 100%;
    padding: 15px 30px;
    background: linear-gradient(135deg, #198754 0%, #20c997 100%);
    color: white;
    font-size: 20px;
    font-weight: 800;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.3s ease;
}

.submit-btn:hover {
    transform: translateY(-3px) !important;
    box-shadow: 0 12px 25px rgba(25, 135, 84, 0.4) !important;
    filter: brightness(1.1);
}

.submit-btn:active {
    transform: translateY(0);
}

.submit-btn:disabled {
    background: #adb5bd;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.success-message {
    margin-top: 25px;
    padding: 20px;
    background: #d1e7dd;
    color: #0f5132;
    border-radius: 14px;
    text-align: center;
    font-size: 18px;
    font-weight: 700;
    animation: slideUp 0.5s ease;
}

.error-message {
    margin-top: 25px;
    padding: 20px;
    background: #f8d7da;
    color: #842029;
    border-radius: 14px;
    text-align: center;
    font-size: 18px;
    font-weight: 700;
    animation: slideUp 0.5s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==================================
   التجاوب مع الشاشات (Responsive Design)
   ================================== */

@media (max-width: 991px) {

    /* Tablets */
    .container {
        padding: 10px;
    }

    .feedback-card {
        padding: 40px 30px;
        margin: 20px auto;
    }

    .header h1 {
        font-size: 32px;
    }

    .header h2 {
        font-size: 18px;
    }

    .emojis {
        gap: 15px;
        padding: 15px;
    }

    .emoji {
        width: 60px;
        height: 60px;
    }

    .btn-primary,
    .btn-secondary,
    .submit-btn {
        padding: 14px 25px;
        font-size: 16px;
    }
}

@media (max-width: 600px) {

    /* Mobile Phones */
    .container {
        padding: 5px;
    }

    .feedback-card {
        padding: 25px 15px;
        margin: 10px auto;
        border-radius: 20px;
    }

    .header .logo {
        width: 70px;
        height: 70px;
        margin-bottom: 15px;
    }

    .header h1 {
        font-size: 26px;
    }

    .header p {
        font-size: 16px;
    }

    .header h2 {
        font-size: 15px;
        margin: 15px auto 25px auto;
        padding: 10px 15px;
    }

    .form-group label {
        font-size: 17px;
    }

    .desc {
        font-size: 14px;
    }

    .emojis {
        gap: 8px;
        flex-wrap: wrap;
        /* للسماح بالنزول لسطر جديد إذا ضاقت الشاشة */
        justify-content: center;
        padding: 10px;
    }

    .emoji-wrapper {
        flex: 1 1 30%;
        /* كل وجه يأخذ ثلث المساحة تقريباً */
        min-width: 80px;
        padding: 10px 5px;
    }

    .emoji {
        width: 50px;
        height: 50px;
    }

    .emoji-wrapper span {
        font-size: 12px;
    }


}

/* شاشات الجوالات الصغيرة جداً */
@media (max-width: 380px) {
    .emoji-wrapper {
        flex: 1 1 45%;
        /* كل وجهين في سطر */
    }

    .header h1 {
        font-size: 22px;
    }
}

/* ==================================
   لوحة المفاتيح الافتراضية الذكية (Virtual Tech Keyboard)
   ================================== */
.virtual-keyboard {
    position: fixed;
    bottom: -100%;
    left: 0;
    width: 100%;
    background: #222;
    /* Dark theme to match PC keyboard */
    backdrop-filter: blur(15px);
    border-top: 3px solid #111;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
    padding: 8px 8px 15px 8px;
    z-index: 10000;
    transition: bottom 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border-radius: 12px 12px 0 0;
}

.virtual-keyboard.active {
    bottom: 0;
}

.vk-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 10px 8px;
    border-bottom: 1px solid #333;
    margin-bottom: 8px;
}

.vk-title {
    color: #aaa;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.vk-close-btn {
    background: transparent;
    border: none;
    color: #888;
    width: 30px;
    height: 30px;
    border-radius: 4px;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: center;
    align-items: center;
}

.vk-close-btn:hover {
    background: #444;
    color: #fff;
}

.vk-keys-pc {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-width: 900px;
    margin: 0 auto;
    direction: ltr;
    /* فرض الاتجاه من اليسار لليمين ليطابق اتجاه المصفوفة والكيبورد الحقيقي */
}

.vk-row {
    display: flex;
    justify-content: center;
    gap: 6px;
    width: 100%;
}

.vk-key {
    background: #444;
    /* Darker key bg like physical key */
    border: 1px solid #222;
    border-radius: 6px;
    color: #eee;
    font-size: 18px;
    font-weight: 500;
    min-height: 48px;
    padding: 0 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.1s ease;
    user-select: none;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 2px 2px rgba(0, 0, 0, 0.5);
    flex: 1;
    /* Allow keys to stretch evenly */
    position: relative;
    overflow: hidden;
}

.vk-key:active {
    transform: translateY(2px);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.6);
    background: #333;
    color: #fff;
    border-color: #111;
}

.vk-key.action-key {
    background: #3a3a3a;
    font-size: 16px;
    color: #ccc;
}

.vk-key.modifier-key {
    flex: 1.5;
    /* Modifier keys slightly wider */
    font-size: 14px;
    background: #353535;
    justify-content: flex-start;
    padding-left: 12px;
}

.vk-key.delete-key {
    color: #aaa;
    justify-content: flex-end;
    padding-right: 12px;
}

.vk-key.wide-key {
    flex: 2;
    /* Enter, Shift, Backspace */
}

.vk-key.space-key {
    flex: 10;
    /* Very wide spacebar */
    background: #444;
}

.vk-key.arrow-key {
    background: #353535;
    color: #ccc;
    font-size: 16px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 2px 2px rgba(0, 0, 0, 0.5);
    flex: 1.2;
}

.vk-key.enter-key {
    background: #333;
    color: #ccc;
    justify-content: flex-start;
    padding-left: 12px;
}

.vk-key.enter-key:active {
    background: #222;
}

@media (min-width: 768px) {
    .virtual-keyboard {
        max-width: 1000px;
        left: 50%;
        transform: translateX(-50%);
        border-radius: 12px 12px 0 0;
        border-left: 3px solid #111;
        border-right: 3px solid #111;
    }
}