/* ============================================================
   Draw System — main stylesheet
   نفس الهوية البصرية الاحترافية لأنظمة الشركة (أرجواني #4A1259/#6B1F7A)
   ملف مستقل بالكامل عن مشروع UGHI — لا مشاركة كود فعلية، فقط نفس
   لغة التصميم لضمان اتساق تجربة الإدارة عبر أنظمة الشركة.
   يدعم RTL و LTR بالكامل عبر خصائص CSS المنطقية (logical properties)
   لأن صفحات هذا المشروع تُستخدم بالعربية والإنجليزية معاً.
   ============================================================ */

:root {
    --brand-900: #340C40;
    --brand-800: #4A1259;   /* العناوين الرئيسية */
    --brand-700: #6B1F7A;   /* العناوين الفرعية والأزرار */
    --brand-600: #7B2D8B;
    --brand-100: #F3E8F7;   /* صفوف الجداول الفاتحة */
    --brand-50:  #FAF5FC;
    --ink:       #2B2233;
    --muted:     #837A8C;
    --line:      #E5DCEB;
    --warn-bg:   #FFF3CD;
    --warn-text: #C0392B;
    --orange:    #E67E22;
    --blue:      #1A5276;
    --ok:        #1E7B4F;
    --bg:        #F6F3F8;
    --card:      #FFFFFF;
    --gold:      #C9A24B;   /* لمسة خاصة بطابع الجوائز/التذاكر */
    --gold-dark: #B58E3A;
    --radius:    10px;
    --shadow:    0 1px 3px rgba(52, 12, 64, 0.08), 0 4px 16px rgba(52, 12, 64, 0.06);
    --touch:     48px; /* الحد الأدنى لارتفاع أي عنصر قابل للنقر على الجوال */
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
    font-family: 'Segoe UI', Tahoma, Arial, sans-serif;
    background: var(--bg);
    color: var(--ink);
    min-height: 100vh;
    line-height: 1.65;
}

h1, h2, h3 { color: var(--brand-800); }

/* ------------------------------------------------------------
   صفحة تسجيل الدخول — تصميم مقسوم (لوحة جانبية + نموذج)
   ------------------------------------------------------------ */
.login-wrap {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 5fr 4fr;
}

.login-side {
    background: linear-gradient(160deg, var(--brand-900) 0%, var(--brand-700) 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 64px;
    position: relative;
    overflow: hidden;
}

.login-side::after {
    content: '';
    position: absolute;
    inset-inline-start: -120px;
    bottom: -120px;
    width: 420px;
    height: 420px;
    border: 2px solid rgba(255, 255, 255, 0.07);
    border-radius: 50%;
    box-shadow: 0 0 0 60px rgba(255,255,255,0.03), 0 0 0 130px rgba(255,255,255,0.02);
}

.login-side h1 {
    font-size: 1.9rem;
    font-weight: 700;
    margin-bottom: 14px;
    line-height: 1.4;
    color: #fff;
}

.login-side p {
    color: rgba(255, 255, 255, 0.75);
    max-width: 42ch;
    font-size: 0.98rem;
}

.login-side .phases {
    margin-top: 42px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    position: relative;
    z-index: 1;
}

.login-side .phases span {
    font-size: 0.78rem;
    padding: 5px 13px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 999px;
    color: rgba(255, 255, 255, 0.85);
}

.login-form-col {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
    background: var(--card);
}

.login-card { width: 100%; max-width: 380px; }

.login-card h2 {
    color: var(--brand-800);
    font-size: 1.35rem;
    margin-bottom: 6px;
}

.login-card .hint {
    color: var(--muted);
    font-size: 0.9rem;
    margin-bottom: 28px;
}

@media (max-width: 860px) {
    .login-wrap { grid-template-columns: 1fr; }
    .login-side { padding: 40px 28px; min-height: 200px; }
    .login-side .phases { display: none; }
}

/* ------------------------------------------------------------
   النماذج — حقول بحجم مريح للمس (48px+) على الجوال
   ------------------------------------------------------------ */
.field { margin-bottom: 18px; }

.field label {
    display: block;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--brand-800);
    margin-bottom: 7px;
}

.field input,
.field select {
    width: 100%;
    min-height: var(--touch);
    padding: 11px 14px;
    border: 1.5px solid var(--line);
    border-radius: var(--radius);
    font: inherit;
    font-size: 1rem;
    background: #fff;
    color: var(--ink);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus, .field select:focus {
    outline: none;
    border-color: var(--brand-700);
    box-shadow: 0 0 0 3px rgba(107, 31, 122, 0.12);
}

.field input::placeholder { color: #B9B0C2; }

/* ------------------------------------------------------------
   الأزرار
   ------------------------------------------------------------ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: var(--touch);
    padding: 12px 18px;
    background: var(--brand-700);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font: inherit;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, transform 0.12s;
}
.btn:active { transform: scale(0.98); }
.btn:hover  { background: var(--brand-800); }
.btn:focus-visible { outline: 3px solid rgba(107, 31, 122, 0.35); outline-offset: 2px; }

.btn-ghost {
    background: transparent;
    color: var(--brand-700);
    border: 1.5px solid var(--line);
    width: auto;
}
.btn-ghost:hover { background: var(--brand-50); }

.btn-gold { background: var(--gold); color: var(--brand-900); }
.btn-gold:hover { background: var(--gold-dark); }

.btn-sm {
    display: inline-flex;
    align-items: center;
    width: auto;
    min-height: 40px;
    padding: 6px 16px;
    font-size: 0.85rem;
    border-radius: 7px;
}

.btn-add        { background: var(--brand-700); color: #fff; }
.btn-add:hover  { background: var(--brand-800); }
.btn-activate       { background: #E7F6EE; color: var(--ok); border: 1.5px solid #A7D9BC; }
.btn-activate:hover { background: #CCEFDA; }
.btn-archive        { background: #EFEFEF; color: #666; border: 1.5px solid #DDD; }
.btn-archive:hover  { background: #E2E2E2; }
.btn-reset          { background: #FBEAEA; color: var(--warn-text); border: 1.5px solid #F0BBBB; }
.btn-reset:hover    { background: #F5D0D0; }

.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }
.btn-row .btn { width: auto; }

/* ------------------------------------------------------------
   التنبيهات
   ------------------------------------------------------------ */
.alert, .msg {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-size: 0.92rem;
    font-weight: 600;
}
.alert-error, .msg.error {
    background: var(--warn-bg);
    color: var(--warn-text);
    border-inline-start: 4px solid var(--orange);
}
.alert-success, .msg.success {
    background: #E7F6EE;
    color: var(--ok);
    border-inline-start: 4px solid var(--ok);
}
.msg.warning {
    background: var(--warn-bg);
    color: #7D3C00;
    border-inline-start: 4px solid var(--orange);
}

/* ------------------------------------------------------------
   الهيكل الداخلي بعد الدخول — شريط علوي + حاوية الصفحة
   ------------------------------------------------------------ */
.topbar {
    background: var(--card);
    border-bottom: 1px solid var(--line);
    padding: 0 28px;
    min-height: 62px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar .brand { color: var(--brand-800); font-weight: 700; font-size: 1.02rem; }

.topbar .nav-links { display: flex; gap: 4px; flex-wrap: wrap; }
.topbar .nav-links a {
    display: inline-block;
    padding: 10px 14px;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--muted);
    text-decoration: none;
    border-bottom: 3px solid transparent;
}
.topbar .nav-links a:hover  { color: var(--brand-700); }
.topbar .nav-links a.current { color: var(--brand-700); border-bottom-color: var(--brand-700); }

.topbar .user-area {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 0.88rem;
    color: var(--muted);
}
.topbar .user-area a { color: var(--brand-700); text-decoration: none; font-weight: 600; }
.topbar .user-area a:hover { text-decoration: underline; }

@media (max-width: 700px) {
    .topbar { padding: 10px 16px; }
    .topbar .brand { font-size: 0.9rem; width: 100%; }
}

.page { max-width: 1200px; margin: 28px auto; padding: 0 20px; }
.page-narrow { max-width: 460px; }

.page-title {
    color: var(--brand-800);
    font-size: 1.4rem;
    font-weight: 700;
    padding-bottom: 12px;
    border-bottom: 3px solid var(--brand-700);
    margin-bottom: 24px;
    display: inline-block;
}

.page-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 14px;
    flex-wrap: wrap;
}
.page-actions .page-title { margin-bottom: 0; }

/* ------------------------------------------------------------
   البطاقات
   ------------------------------------------------------------ */
.card-panel {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px 26px;
    margin-bottom: 22px;
}

.section-title {
    color: var(--brand-800);
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
}

/* بطاقات الإحصاءات */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}
.stat-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px 22px;
    border-top: 4px solid var(--brand-700);
}
.stat-card.gold { border-top-color: var(--gold); }
.stat-card .num { font-size: 2rem; font-weight: 700; color: var(--blue); line-height: 1.2; }
.stat-card .label { color: var(--muted); font-size: 0.85rem; margin-top: 4px; }

/* ------------------------------------------------------------
   عنصر "التذكرة" — لصفحات العميل (نتيجة السحب)
   ------------------------------------------------------------ */
.ticket {
    position: relative;
    background: var(--card);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(52, 12, 64, 0.22);
    padding: 40px 28px;
    text-align: center;
    overflow: hidden;
}
.ticket::before, .ticket::after {
    content: "";
    position: absolute;
    width: 24px; height: 24px;
    background: var(--bg);
    border-radius: 50%;
    top: 50%;
    transform: translateY(-50%);
}
.ticket::before { inset-inline-start: -12px; }
.ticket::after  { inset-inline-end: -12px; }
.ticket-divider { border-top: 2px dashed var(--line); margin: 18px 0; }

/* ------------------------------------------------------------
   صندوق إظهار الكود/QR (مبني على أسلوب pass-box لعرض كلمات المرور)
   ------------------------------------------------------------ */
.pass-box {
    background: var(--brand-50);
    border: 1.5px solid var(--brand-100);
    border-radius: var(--radius);
    padding: 22px 18px;
    text-align: center;
    margin-bottom: 16px;
}
.pass-box .pass-label { font-size: 0.83rem; color: var(--muted); margin-bottom: 6px; }
.pass-box .pass-val {
    font-family: 'Courier New', monospace;
    font-size: 1.7rem;
    font-weight: 700;
    color: var(--brand-800);
    letter-spacing: 3px;
    display: block;
    margin: 4px 0 8px;
}
.pass-box .pass-note { font-size: 0.8rem; color: var(--orange); font-weight: 600; }

/* ------------------------------------------------------------
   الجداول — رأس أرجواني وصفوف متبادلة، تمرير أفقي على الجوال
   ------------------------------------------------------------ */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); }

table.data {
    width: 100%;
    min-width: 560px;
    border-collapse: collapse;
    background: var(--card);
    box-shadow: var(--shadow);
    border-radius: var(--radius);
    overflow: hidden;
    font-size: 0.9rem;
}
table.data th {
    background: var(--brand-700);
    color: #fff;
    font-weight: 700;
    padding: 11px 12px;
    text-align: start;
    border: 1px solid var(--brand-600);
    white-space: nowrap;
}
table.data td {
    padding: 9px 12px;
    border: 1px solid #E9E2EE;
    white-space: nowrap;
}
table.data tbody tr:nth-child(even) { background: var(--brand-100); }
table.data tr.no-results td { text-align: center; color: var(--muted); padding: 26px !important; font-style: italic; white-space: normal; }

/* ------------------------------------------------------------
   الشارات (Badges)
   ------------------------------------------------------------ */
.badge {
    display: inline-block;
    padding: 3px 12px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}
.badge.active   { background: #E7F6EE; color: var(--ok); }
.badge.archived { background: #EFEFEF; color: #888; }
.badge-qudia    { background: var(--brand-100); color: var(--brand-800); }
.badge-ono      { background: #EAF2FB; color: var(--blue); }
.badge-used     { background: #EFEFEF; color: #888; }
.badge-expired  { background: var(--warn-bg); color: var(--orange); }

/* ------------------------------------------------------------
   المودال (لتأكيدات مستقبلية)
   ------------------------------------------------------------ */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(36, 8, 46, 0.42);
    z-index: 200;
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.modal-overlay[hidden] { display: none; }
.modal-box {
    background: var(--card);
    border-radius: 14px;
    box-shadow: 0 10px 48px rgba(36,8,46,0.22);
    width: 100%; max-width: 460px; max-height: 92vh; overflow-y: auto;
}
.modal-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 24px 4px; border-bottom: 1px solid var(--line);
}
.modal-head h3 { color: var(--brand-800); font-size: 1.05rem; }
.modal-body { padding: 20px 24px 24px; }

/* ------------------------------------------------------------
   خلفية متدرجة (لصفحة اختيار اللغة وشاشات مركزية أخرى)
   ------------------------------------------------------------ */
.bg-brand-gradient { background: linear-gradient(160deg, var(--brand-900) 0%, var(--brand-700) 100%); }
.center-screen {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    padding: var(--space-4, 16px);
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}

@media (max-width: 700px) {
    .page-actions { flex-direction: column; align-items: flex-start; }
}
