.auth-panel {
  margin: 20px auto 30px;
  padding: 18px 22px;
  background: linear-gradient(120deg, #ffffff 0%, #ffffff 60%, #f7f2ee 100%);
  border: 1px solid #efe3db;
  border-left: 4px solid #c0392b;
  border-radius: 6px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.08);
}

.auth-panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 600;
  color: #2c2c2c;
}

.auth-panel-subtitle {
  margin: 6px 0 0;
  color: #6b6b6b;
}

.auth-panel-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  align-items: center;
  margin-top: 5px;
}

.auth-panel .auth-btn {
  min-width: 120px;
  border-radius: 4px;
}

.auth-guest-btn {
  color: #555;
  text-decoration: underline;
}

.auth-panel-hidden {
  display: none;
}

.auth-modal .modal-content {
  border-radius: 6px;
  overflow: hidden;
}

.auth-modal-header {
  background: #f7f2ee;
  border-bottom: 1px solid #eee;
}

.auth-tabs {
  margin-bottom: 15px;
}

.auth-tab-content .form-group label {
  font-weight: 600;
}

.auth-submit {
  margin-top: 10px;
}

.auth-errors {
  margin: 10px 0;
}

.auth-social {
  margin: 10px 0 12px;
}

.auth-social-btn {
  text-align: left;
  border: 1px solid #e5e5e5;
  color: #333;
  background: #fff;
}

.auth-social-btn:hover,
.auth-social-btn:focus {
  text-decoration: none;
  background: #fff;
}

.auth-social-btn i {
  margin-right: 8px;
  width: 18px;
  text-align: center;
}

.auth-social-btn.auth-google:hover {
  border-color: #d34836;
  color: #d34836;
}

.auth-social-btn.auth-facebook:hover {
  border-color: #3b5998;
  color: #3b5998;
}

.auth-divider {
  position: relative;
  text-align: center;
  margin: 10px 0 15px;
}

.auth-divider:before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: #eee;
}

.auth-divider span {
  position: relative;
  background: #fff;
  padding: 0 10px;
  color: #777;
  font-size: 12px;
}

.auth-help {
  margin-top: 10px;
  color: #777;
  font-size: 12px;
}

.auth-forgot {
  margin: -5px 0 10px;
  text-align: right;
}

.auth-forgot a {
  color: #777;
  font-size: 12px;
}

.auth-loading {
  display: block;
  margin: 12px auto 0;
  width: 36px;
}

.auth-guest-inline {
  display: block;
  margin: 8px auto 0;
  color: #555;
}

.auth-trigger-item {
  margin-left: 6px;
}

.auth-trigger {
  background: none;
  border: none;
  color: #fff;
  padding: 0;
  cursor: pointer;
}

.auth-trigger:hover,
.auth-trigger:focus {
  color: #f1f1f1;
}

.auth-user-menu .auth-user-toggle {
  color: #f8fafc;
  padding: 0;
}

.auth-user-menu .auth-user-toggle:hover,
.auth-user-menu .auth-user-toggle:focus {
  color: #f1f1f1;
  text-decoration: none;
}

.auth-user-name {
  margin: 0 6px;
  font-size: 12px;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: inline-block;
  vertical-align: middle;
}

.auth-user-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.7);
  vertical-align: middle;
}

@media (max-width: 767px) {
  .auth-panel {
    text-align: center;
  }

  .auth-panel-actions {
    justify-content: center;
  }
}

/* 1. الكونتينر الأساسي (مخفي افتراضياً) */
.modern-user-dropdown {
    display: none; /* التغيير المهم: مخفي لحد ما نطلبه */
    padding: 0 !important;
    margin-top: 10px !important;
    border: 1px solid rgba(15, 23, 42, 0.08) !important;
    border-radius: 14px !important;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.16) !important;
    min-width: 260px !important;
    background-color: #ffffff !important;
    overflow: hidden !important;
    
    /* التثبيت الصحيح */
    position: absolute;
    right: 0 !important;
    left: auto !important;
    z-index: 99999;
}

/* Keep user menu closed unless toggle is expanded */
.auth-user-menu .modern-user-dropdown {
    display: none !important;
}

.auth-user-menu .auth-user-toggle[aria-expanded="true"] + .modern-user-dropdown {
    display: block !important;
}

/* 2. قاعدة الإظهار (يظهر فقط لما القائمة تكون مفتوحة) */
.open > .modern-user-dropdown {
    display: block !important;
    animation: fadeIn 0.2s ease-in-out; /* حركة ناعمة للظهور */
}

/* حركة بسيطة للظهور (Optional) */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 3. تنظيف شامل للعناصر */
.modern-user-dropdown li,
.modern-user-dropdown li.menu-item {
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
    border: none !important;
    display: block !important;
}

/* إخفاء العناصر الوهمية وشريط التمرير */
.modern-user-dropdown li::before,
.modern-user-dropdown li::after,
.modern-user-dropdown a::before,
.modern-user-dropdown a::after { content: none !important; display: none !important; }
.modern-user-dropdown::-webkit-scrollbar { display: none !important; }

/* 4. الهيدر البرتقالي */
.modern-user-dropdown li.user-header {
    background: #f8fafc !important;
    padding: 14px 18px !important;
    border-bottom: 1px solid #eef2f7;
}

.modern-user-dropdown .u-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.modern-user-dropdown .u-info img {
    width: 45px !important;
    height: 45px !important;
    border-radius: 50% !important;
    border: 2px solid rgba(15, 23, 42, 0.08) !important;
    background: transparent !important;
    margin: 0 !important;
}

.modern-user-dropdown .u-text {
    display: flex;
    flex-direction: column;
    text-align: left;
    line-height: 1.3;
}

.modern-user-dropdown .u-name { color: #0f172a !important; font-weight: 700; font-size: 15px; }
.modern-user-dropdown .u-sub { color: #6b7280 !important; font-size: 12px; }

/* 5. الروابط */
.modern-user-dropdown li a {
    display: flex !important;
    align-items: center !important;
    width: 100% !important;
    padding: 12px 20px !important;
    color: #111827 !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    text-decoration: none !important;
    background: transparent !important;
    border-bottom: 1px solid #eef2f7 !important;
    transition: all 0.2s ease;
}

.modern-user-dropdown li form {
    margin: 0 !important;
}

.modern-user-dropdown li button {
    display: flex !important;
    align-items: center !important;
    width: 100% !important;
    padding: 12px 20px !important;
    color: #111827 !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    text-decoration: none !important;
    border: 0 !important;
    border-bottom: 1px solid #eef2f7 !important;
    background: transparent !important;
    cursor: pointer !important;
    transition: all 0.2s ease;
    text-align: left !important;
}

.modern-user-dropdown li a i {
    width: 25px !important;
    text-align: center !important;
    margin-right: 10px !important;
    color: #94a3b8 !important;
    background: transparent !important;
}

.modern-user-dropdown li a:hover { background-color: rgba(15, 23, 42, 0.04) !important; color: #0f172a !important; }
.modern-user-dropdown li a:hover i { color: #0f172a !important; }
.modern-user-dropdown li button:hover { background-color: rgba(15, 23, 42, 0.04) !important; color: #0f172a !important; }
.modern-user-dropdown li button:hover i { color: #0f172a !important; }

.modern-user-dropdown .text-danger { color: #dc2626 !important; }
.modern-user-dropdown .text-danger:hover { background-color: #fef2f2 !important; }

.modern-user-dropdown .divider { height: 1px !important; margin: 0 !important; background-color: #eef2f7 !important; }

/* السهم الصغير */
.modern-user-dropdown:before {
    content: '';
    position: absolute;
    top: -6px; right: 15px;
    width: 12px; height: 12px;
    background: #ffffff;
    transform: rotate(45deg);
    z-index: 100000;
    pointer-events: none;
}

@media (max-width: 767px) {
    .modern-user-dropdown { min-width: 280px !important; right: -10px !important; }
}
