/* ══════════════════════════════════════════
   إعدادات عامة
   ══════════════════════════════════════════ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Tajawal', sans-serif;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
    color: #fff;
}

/* ══════════════════════════════════════════
   خلفية الفيديو
   ══════════════════════════════════════════ */
.video-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
}

#bg-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.video-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 25, 0.65);
}

/* ══════════════════════════════════════════
   الحاوية الرئيسية (بتكبر بعد الدخول)
   ══════════════════════════════════════════ */
.app-container {
    text-align: center;
    width: 100%;
    max-width: 420px;        /* حجم اللوجين */
    padding: 20px;
    z-index: 1;
    transition: max-width 0.6s ease;
}

.app-container.expanded {
    max-width: 900px;        /* حجم الـ Workspace */
}

/* ══════════════════════════════════════════
   الهيدر واللوجو
   ══════════════════════════════════════════ */
.main-header {
    margin-bottom: 25px;
    text-align: center;
}

.logo-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-bottom: 10px;
}

.logo-img {
    width: 55px;
    height: auto;
    filter: drop-shadow(0 0 10px rgba(0, 210, 255, 0.4));
    transition: width 0.6s ease;
}

.app-container.expanded .logo-img {
    width: 100px;
}

.main-header h1 {
    font-size: 2.4rem;
    font-weight: 600;
    letter-spacing: 2px;
    text-transform: uppercase;
    transition: font-size 0.6s ease;
}

.app-container.expanded .main-header h1 {
    font-size: 3rem;
}

/* العنوان الفرعي (مخفي وقت اللوجين) */
.subtitle {
    font-size: 0.95rem;
    letter-spacing: 4px;
    color: #b0b0d0;
    text-transform: uppercase;
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    transition: opacity 0.5s ease 0.3s, max-height 0.5s ease 0.3s;
}

.app-container.expanded .subtitle {
    opacity: 1;
    max-height: 40px;
}

/* ══════════════════════════════════════════
   الكارت الزجاجي (Glassmorphism)
   ══════════════════════════════════════════ */
.glass-card {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 45px 30px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
    transition: padding 0.6s ease;
}

.app-container.expanded .glass-card {
    padding: 50px 40px;
}

/* ══════════════════════════════════════════
   Fade Animation للأقسام
   ══════════════════════════════════════════ */
#login-section,
#workspace-section {
    transition: opacity 0.4s ease, transform 0.4s ease;
}

#login-section {
    opacity: 1;
    transform: translateY(0);
}

#login-section.fade-out {
    opacity: 0;
    transform: translateY(-10px);
}

/* ترتيب الـ workspace: ترحيب فوق / grid في النص / logout تحت */
#workspace-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    opacity: 0;
    transform: translateY(10px);
}

#workspace-section.fade-in {
    opacity: 1;
    transform: translateY(0);
}

/* لما يكون مخفي، نرجّعه none عشان ميظهرش */
#workspace-section.hidden {
    display: none;
}

.hidden {
    display: none;
}

/* ══════════════════════════════════════════
   فورم اللوجين
   ══════════════════════════════════════════ */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.input-group {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 15px;
    color: #b0b0d0;
    font-size: 1rem;
    transition: color 0.3s ease;
}

.input-group input {
    width: 100%;
    padding: 12px 15px 12px 45px;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: #fff;
    font-size: 0.95rem;
    outline: none;
    transition: all 0.3s ease;
}

.input-group input:focus {
    border-color: #00d2ff;
    background: rgba(255, 255, 255, 0.12);
    box-shadow: 0 0 10px rgba(0, 210, 255, 0.2);
}

.input-group input:focus + .input-icon {
    color: #00d2ff;
}

.form-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: #b0b0d0;
}

/* ══════════════════════════════════════════
   Remember me (محسّن)
   ══════════════════════════════════════════ */
.remember-me {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.remember-me input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.07);
    cursor: pointer;
    position: relative;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.remember-me input[type="checkbox"]:hover {
    border-color: #00d2ff;
}

.remember-me input[type="checkbox"]:checked {
    background: linear-gradient(135deg, #00d2ff, #7928ca);
    border-color: transparent;
}

.remember-me input[type="checkbox"]:checked::after {
    content: "";
    position: absolute;
    left: 5px;
    top: 1px;
    width: 5px;
    height: 10px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* ══════════════════════════════════════════
   زرار الدخول
   ══════════════════════════════════════════ */
.submit-btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #00d2ff, #7928ca);
    border: none;
    border-radius: 8px;
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.3s ease;
    margin-top: 10px;
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 210, 255, 0.4);
}

.submit-btn:active {
    transform: translateY(0);
}

/* رسالة الخطأ */
#login-error {
    color: #ff5b7f;
    font-size: 0.85rem;
    text-align: center;
    margin-top: 5px;
}

/* ══════════════════════════════════════════
   رسالة الترحيب (ثابتة فوق)
   ══════════════════════════════════════════ */
.welcome-msg {
    font-size: 1.3rem;
    font-weight: 500;
    margin-bottom: 25px;
    color: #fff;
    flex-shrink: 0;
}

.welcome-msg span {
    color: #00d2ff;
    font-weight: 600;
}

/* ══════════════════════════════════════════
   شبكة الـ Workspace (scroll داخلي)
   ══════════════════════════════════════════ */
.grid-container {
    display: grid;
    grid-template-columns: repeat(3, minmax(150px, 1fr));
    gap: 40px;

    max-height: 45vh;
    overflow-y: auto;
    padding: 10px;
    margin-right: -5px;
    width: 100%;

    /* ثابت دايماً بنفس الاتجاه عشان مكان الأيقونات ميتغيرش لما اللغة تتغيّر */
    direction: rtl;
}

/* اسكرول موحّد من tokens.css */

.grid-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: transform 0.3s ease, filter 0.3s ease;
}

.icon-box {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.9rem;
    color: #e0e0ff;
    margin-bottom: 12px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.14);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    transition: color 0.3s ease, transform 0.3s ease, background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.grid-item span,
.grid-item a {
    text-decoration: none;
    color: #e0e0e0;
    font-size: 1rem;
    font-weight: 400;
    letter-spacing: 0.5px;
    transition: color 0.3s ease;
}

.grid-item:hover {
    transform: translateY(-5px);
}

.grid-item:hover .icon-box {
    color: #00d2ff;
    transform: scale(1.08);
    background: rgba(0, 210, 255, 0.14);
    border-color: rgba(0, 210, 255, 0.5);
    box-shadow: 0 0 18px rgba(0, 210, 255, 0.45);
}

.grid-item:hover span,
.grid-item:hover a {
    color: #fff;
    font-weight: 600;
}

/* ══ أيقونتا الأدمن (مؤشرات + نشاط) أعلى شمال الكارت + popover ══ */
#workspace-section { position: relative; }
.ws-corner { display: flex; gap: 8px; align-items: center; }
.ws-corner.hidden { display: none; }
.ws-cbtn {
    width: 38px; height: 38px; border-radius: 12px; cursor: pointer;
    background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.16);
    color: #cfe6ff; font-size: .95rem; transition: all .2s;
    display: inline-flex; align-items: center; justify-content: center;
}
.ws-cbtn:hover { background: rgba(0,210,255,.16); border-color: rgba(0,210,255,.5); color: #fff; transform: translateY(-2px); }
.ws-cbtn.active { background: linear-gradient(135deg,#00d2ff,#7928ca); color: #fff; border-color: transparent; }
/* العرض جوّه الكارت (بيحلّ محلّ شبكة الأيقونات) */
.ws-pop {
    width: 100%; margin-top: 4px; direction: rtl;
    max-height: 60vh; overflow-y: auto; padding: 2px;
    animation: popIn .18s ease both;
}
.ws-pop[hidden] { display: none; }
@keyframes popIn { from { opacity:0; transform: translateY(-8px); } to { opacity:1; transform:none; } }
.pop-title { font-size: .85rem; font-weight: 800; color: #00d2ff; margin-bottom: 10px; }
.pop-empty { color: rgba(224,224,255,.5); text-align: center; padding: 10px; }
/* بطاقات المؤشرات جوّه الـpopover */
.hs-kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; direction: rtl; }
.hs-kpi { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px;
    background: rgba(255,255,255,.055); border: 1px solid rgba(255,255,255,.10); text-align: right; }
.hs-kpi .hs-ic { font-size: 1.3rem; line-height: 1; }
.hs-kpi .hs-val { font-size: 1.1rem; font-weight: 800; color: #fff; font-variant-numeric: tabular-nums; }
.hs-kpi .hs-lbl { font-size: .68rem; color: rgba(224,224,255,.6); font-weight: 600; }
.hs-kpi.ok .hs-val { color: #34d399; }
.hs-kpi.accent .hs-val { color: #ffce54; }
/* آخر النشاط جوّه الـpopover */
.hs-recent-ul { list-style: none; margin: 0; padding: 0; }
.hs-recent-ul li { display: flex; align-items: center; gap: 10px; padding: 6px 0; font-size: .76rem; border-top: 1px solid rgba(255,255,255,.06); }
.hs-recent-ul li:first-child { border-top: none; }
.hr-op { font-weight: 800; font-size: .66rem; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.hr-insert { background: rgba(52,211,153,.18); color: #34d399; }
.hr-update { background: rgba(41,128,185,.20); color: #5dade2; }
.hr-delete { background: rgba(239,68,68,.18); color: #f87171; }
.hr-edit   { background: rgba(242,200,17,.18); color: #f2c811; }
.hr-tbl { font-weight: 700; color: #e0e0ff; }
.hr-meta { color: rgba(224,224,255,.5); font-size: .7rem; margin-inline-start: auto; white-space: nowrap; }

/* ══════════════════════════════════════════
   زرار تسجيل الخروج (ثابت تحت)
   ══════════════════════════════════════════ */
.logout-btn {
    margin-top: 25px;
    padding: 10px 25px;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 91, 127, 0.4);
    border-radius: 8px;
    color: #ff8fa3;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.logout-btn:hover {
    background: rgba(255, 91, 127, 0.15);
    color: #ff5b7f;
    border-color: #ff5b7f;
    transform: translateY(-2px);
}

/* الإشعارات (التوست) موحّدة في pz-toast */

/* الأيقونات غير الجاهزة */
.grid-item.coming-soon {
    cursor: default;
}

/* ══════════════════════════════════════════
   أنيميشن دخول الأيقونات (stagger)
   ══════════════════════════════════════════ */
@keyframes itemFadeIn {
    from {
        opacity: 0;
        transform: translateY(15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#workspace-section.fade-in .grid-item {
    opacity: 0;
    animation: itemFadeIn 0.4s ease forwards;
}

#workspace-section.fade-in .grid-item:nth-child(1) { animation-delay: 0.05s; }
#workspace-section.fade-in .grid-item:nth-child(2) { animation-delay: 0.10s; }
#workspace-section.fade-in .grid-item:nth-child(3) { animation-delay: 0.15s; }
#workspace-section.fade-in .grid-item:nth-child(4) { animation-delay: 0.20s; }
#workspace-section.fade-in .grid-item:nth-child(5) { animation-delay: 0.25s; }
#workspace-section.fade-in .grid-item:nth-child(6) { animation-delay: 0.30s; }
#workspace-section.fade-in .grid-item:nth-child(7) { animation-delay: 0.35s; }
#workspace-section.fade-in .grid-item:nth-child(8) { animation-delay: 0.40s; }
#workspace-section.fade-in .grid-item:nth-child(9) { animation-delay: 0.45s; }

/* ══════════════════════════════════════════
   متجاوب مع الموبايل
   ══════════════════════════════════════════ */
@media (max-width: 600px) {
    .app-container.expanded .logo-img {
        width: 50px;
    }
    .app-container.expanded .main-header h1 {
        font-size: 2.2rem;
    }
    .grid-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 25px;
    }
    .app-container.expanded .glass-card {
        padding: 30px 20px;
    }
}