/* ===== CSS Variables — Light & Dark ===== */
:root {
    --bg:        #f1f5f9;
    --card-bg:   #ffffff;
    --text:      #111827;
    --text-muted:#6b7280;
    --border:    #e5e7eb;
    --primary:   #f97316;
    --input-bg:  #f9fafb;
    --shadow:    0 10px 30px rgba(0,0,0,0.08);
}

[data-theme='dark'] {
    --bg:        #0f172a;
    --card-bg:   #1e293b;
    --text:      #e2e8f0;
    --text-muted:#94a3b8;
    --border:    #334155;
    --primary:   #f97316;
    --input-bg:  #0f172a;
    --shadow:    0 10px 30px rgba(0,0,0,0.4);
}

body {
    background: var(--bg);
    color: var(--text);
    transition: background 0.3s, color 0.3s;
}

/* ===== Profile Card ===== */
.profile-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.profile-details {
    background: rgba(0,0,0,0.04);
    border: 1px solid var(--border);
}

[data-theme='dark'] .profile-details {
    background: rgba(255,255,255,0.03);
}

.detail-item {
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

.detail-item span:first-child { color: var(--text-muted); }

/* ===== Name Input ===== */
.profile-name-input {
    color: var(--text) !important;
    background: transparent !important;
}

.profile-name-input:focus {
    background: var(--input-bg) !important;
    border-color: var(--primary) !important;
}

/* ===== Email ===== */
#user-display-email { color: var(--text-muted); }

/* ===== Avatar Icon ===== */
.profile-avatar i { color: var(--primary); }

/* ===== Dropdown ===== */
#user-dropdown {
    background: var(--card-bg);
    border: 1px solid var(--border);
}

#user-dropdown a,
#user-dropdown button {
    color: var(--text) !important;
}

#user-dropdown a:hover { background: rgba(249,115,22,0.08); }

/* ===== UID text ===== */
#user-uid { color: var(--text-muted); font-size: 12px; }

.profile-container {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 50px 20px;
    min-height: 80vh;
}

.profile-card {
    background: var(--card-bg);
    width: 100%;
    max-width: 450px;
    border-radius: 20px;
    padding: 30px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    border: 1px solid rgba(255,255,255,0.05);
}

.profile-avatar i {
    font-size: 80px;
    color: var(--primary);
    margin-bottom: 15px;
}

.profile-header h2 {
    margin: 10px 0 5px;
    color: var(--text);
}

.profile-header p {
    color: #64748b;
    margin-bottom: 25px;
}

.profile-details {
    background: rgba(0,0,0,0.05);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 25px;
    text-align: right;
}

.detail-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.detail-item:last-child { border-bottom: none; }

.logout-full-btn {
    background: #ef4444;
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 10px;
    cursor: pointer;
    width: 100%;
    font-weight: bold;
    display: flex;
    justify-content: center;
    gap: 10px;
    transition: 0.3s;
}


.logout-full-btn:hover { background: #dc2626; }

/* تنسيق الصورة وتعديلها */
.profile-avatar-container {
    position: relative;
    display: inline-block;
    margin-bottom: 20px;
}

.profile-avatar i {
    font-size: 80px;
    color: var(--primary);
}

.profile-avatar img {
    width: 80px; height: 80px;
    object-fit: cover;
}

.edit-photo-btn {
    position: absolute; bottom: 0; right: 0;
    background: #4caf50; color: white; border: none;
    border-radius: 50%; width: 30px; height: 30px;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

/* تنسيق تعديل الاسم */
/* --- إصلاح حاوية الاسم لضمان ظهورها في سطر مستقل --- */
.edit-name-container {
    display: flex;
    flex-direction: column; /* التأكد من أن العناصر تحت بعضها */
    align-items: center;
    position: relative;
    width: 100%;
    margin: 15px 0; /* إعطاء مساحة فوق وتحت الاسم */
}

.profile-name-input {
    font-size: 22px;
    font-weight: bold;
    color: var(--text);
    background: rgba(0, 0, 0, 0.05); /* خلفية خفيفة لتمييز مكان الإدخال */
    border: 1px dashed transparent;
    text-align: center;
    padding: 8px 15px;
    border-radius: 10px;
    width: 80%;
    max-width: 300px;
    transition: 0.3s;
}

/* عند الضغط للتعديل */
.profile-name-input:focus {
    border: 1px solid var(--primary);
    background: var(--card-bg);
    outline: none;
    box-shadow: 0 0 10px rgba(255, 152, 0, 0.2);
}

/* أيقونة القلم التوضيحية */
.edit-icon-hint {
    margin-top: 5px;
    color: #94a3b8;
    font-size: 12px;
    font-weight: normal;
}

/* تحسين السطر الفاصل بين الاسم والإيميل */
#user-display-email {
    margin-top: 0;
    margin-bottom: 20px;
    opacity: 0.8;
    font-size: 14px;
}
.profile-name-input {
    font-size: 20px; font-weight: bold; color: var(--text);
    background: transparent; border: 1px solid transparent; text-align: center;
    padding: 5px; cursor: pointer; border-radius: 8px;
    text-decoration: none; /* إزالة الخطوط */
}

.profile-name-input:focus {
    border: 1px solid var(--primary); outline: none; background: rgba(0,0,0,0.1);
}

.edit-icon-hint {
    position: absolute; right: calc(50% + 70px); top: 5px;
    color: #94a3b8; font-size: 14px;
}

/* زر الحفظ */
.save-btn {
    background: #4caf50; color: white; border: none;
    padding: 10px 20px; border-radius: 8px; cursor: pointer;
    font-weight: bold; margin-bottom: 20px; animation: fadeIn 0.3s;
}

.save-btn:hover { background: #388e3c; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }



/* إصلاح موضع قائمة البروفيل */
#user-dropdown {
    position: absolute;
    top: 100%;
    right: auto;
    left: 0;        /* يظهر لليسار بدل اليمين */
    min-width: 160px;
    z-index: 9999;
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    padding: 8px 0;
    display: none;
}

#user-dropdown.show {
    display: block;
}

/* الحاوية تكون relative */
.user-menu-wrapper,
.nav-icons,
header {
    position: relative;
}