/* =====================================
   واتساب اصول - Osoool Brand Identity
   ===================================== */


:root {

    /* ===== خلفيات أصول الرسمية ===== */
    --bg-primary:   #0d0d0d;
    --bg-secondary: #141414;
    --bg-card:      #1a1a1a;
    --bg-hover:     #222222;

    /* ===== اللون الأساسي: برتقالي أصول ===== */
    --accent-orange:      #ff5e00;
    --accent-orange-dark: #cc4a00;
    --accent-orange-glow: rgba(255, 94, 0, 0.25);

    /* ===== للتوافق مع الكود الموجود ===== */
    --accent-copper:      #ff5e00;
    --accent-copper-dark: #cc4a00;
    --accent-gold:        #ff7a2a;
    --accent-gold-light:  #ff9550;
    --accent-green:       #2db84b;   /* أخضر واتساب - محفوظ */
    --accent-green-dark:  #1a8c35;
    --accent-blue:        #ff5e00;
    --accent-purple:      #e05500;

    /* ===== نصوص ===== */
    --text-primary:   #ffffff;
    --text-secondary: #a0a0a0;
    --text-muted:     #555555;

    /* ===== حدود ===== */
    --border:       rgba(255, 94, 0, 0.15);
    --border-hover: rgba(255, 94, 0, 0.4);

    --sidebar-width: 260px;
    --radius:    12px;
    --radius-sm:  8px;
    --shadow:    0 8px 32px rgba(0,0,0,0.8);
    --shadow-sm: 0 2px 12px rgba(0,0,0,0.6);
    --glow-copper: 0 0 20px rgba(255,94,0,0.3);
    --glow-gold:   0 0 30px rgba(255,94,0,0.15);
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html, body {
    font-family: 'Cairo', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100%;
    direction: rtl;
    font-size: 14px;
    /* نسيج دقيق في الخلفية */
    background-image:
        radial-gradient(ellipse at 80% 10%, rgba(255,94,0,0.05) 0%, transparent 50%),
        radial-gradient(ellipse at 10% 90%, rgba(255,94,0,0.03) 0%, transparent 40%);
}

.page { height: 100vh; width: 100%; }
.page.hidden { display: none; }
.hidden { display: none !important; }

/* ========== LOGIN ========== */
.login-bg {
    position: fixed; inset: 0;
    background:
        radial-gradient(ellipse at 65% 15%, rgba(255,94,0,0.18) 0%, transparent 45%),
        radial-gradient(ellipse at 20% 80%, rgba(255,94,0,0.08) 0%, transparent 40%),
        linear-gradient(160deg, #111111 0%, #0a0a0a 100%);
    overflow: hidden;
}
.login-circles { position: absolute; inset: 0; }
.circle {
    position: absolute; border-radius: 50%;
    background: radial-gradient(circle, rgba(255,94,0,0.1), transparent);
    filter: blur(1px);
}
.c1 { width: 600px; height: 600px; top: -150px; right: -150px; animation: pulse 7s ease-in-out infinite; }
.c2 { width: 350px; height: 350px; bottom: -80px; left: -80px; background: radial-gradient(circle, rgba(255,94,0,0.07), transparent); animation: pulse 9s ease-in-out infinite reverse; }
.c3 { width: 250px; height: 250px; top: 45%; right: 25%; background: radial-gradient(circle, rgba(255,94,0,0.05), transparent); animation: pulse 5s ease-in-out infinite; }
@keyframes pulse { 0%,100%{transform:scale(1);opacity:0.7} 50%{transform:scale(1.15);opacity:1} }

.login-card {
    position: relative; z-index: 1;
    width: 420px; max-width: 94vw;
    margin: 0 auto; padding-top: 80px;
    animation: fadeInUp 0.6s ease;
}
@keyframes fadeInUp { from{opacity:0;transform:translateY(30px)} to{opacity:1;transform:translateY(0)} }

.login-logo { text-align: center; margin-bottom: 40px; }
.logo-icon {
    width: 80px; height: 80px; border-radius: 24px;
    background: linear-gradient(135deg, var(--accent-copper), var(--accent-copper-dark));
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 16px; color: white;
    box-shadow: 0 8px 32px rgba(200,132,58,0.4);
}
.logo-icon svg { width: 40px; height: 40px; }
.login-logo h1 { font-size: 28px; font-weight: 800; color: var(--text-primary); }
.login-logo p { color: var(--text-secondary); margin-top: 6px; }

.login-card form {
    background: #1a1a1a;
    border: 1px solid rgba(255,94,0,0.2);
    border-radius: var(--radius);
    padding: 32px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.6);
}
.login-footer { text-align: center; color: var(--text-muted); margin-top: 20px; font-size: 12px; }

/* ========== APP LAYOUT ========== */
#page-app { display: flex; height: 100vh; overflow: hidden; }

/* SIDEBAR */
.sidebar {
    width: var(--sidebar-width); min-width: var(--sidebar-width);
    background: linear-gradient(180deg, #181818 0%, #111111 100%);
    border-left: 1px solid var(--border);
    display: flex; flex-direction: column;
    transition: var(--transition);
    z-index: 100;
    box-shadow: 4px 0 24px rgba(0,0,0,0.6);
}
.sidebar-header {
    padding: 24px 16px 16px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(135deg, rgba(255,94,0,0.1) 0%, rgba(255,94,0,0.04) 50%, transparent 100%);
    position: relative;
    overflow: hidden;
}
/* خط برتقالي متوهج في الأعلى */
.sidebar-header::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent-orange), transparent);
}
.sidebar-logo {
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    color: var(--accent-copper); font-size: 15px; font-weight: 700;
    margin-bottom: 2px;
    text-align: center;
}
.sidebar-logo img {
    width: 70px; height: 70px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255,94,0,0.4);
    box-shadow: 0 0 20px rgba(255,94,0,0.4), 0 0 40px rgba(255,94,0,0.15);
    transition: var(--transition);
}
.sidebar-logo img:hover {
    box-shadow: 0 0 30px rgba(255,94,0,0.65), 0 0 60px rgba(255,94,0,0.25);
    transform: scale(1.05);
}
.wa-status-bar {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 16px;
    background: rgba(0,0,0,0.2);
    font-size: 11px; color: var(--text-secondary);
}
.wa-indicator {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--text-muted);
    transition: var(--transition);
    flex-shrink: 0;
}
.wa-indicator.connected { background: var(--accent-green); box-shadow: 0 0 8px var(--accent-green); }
.wa-indicator.connecting { background: var(--accent-gold); animation: blink 1s infinite; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.3} }
.wa-connect-btn {
    margin-right: auto; background: none; border: 1px solid var(--border);
    color: var(--accent-copper); padding: 2px 8px; border-radius: 4px;
    font-family: 'Cairo', sans-serif; font-size: 11px; cursor: pointer;
}
.wa-connect-btn:hover { background: rgba(200,132,58,0.1); }

.sidebar-user {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.user-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-copper), var(--accent-copper-dark));
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 14px; color: white; flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 600; display: block; }
.user-role { font-size: 11px; color: var(--text-secondary); }

.sidebar-nav {
    flex: 1; padding: 12px 8px;
    display: flex; flex-direction: column; gap: 2px;
    overflow-y: auto;
}
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; border-radius: var(--radius-sm);
    color: var(--text-secondary); text-decoration: none;
    font-size: 13px; font-weight: 500;
    transition: var(--transition); position: relative;
}
.nav-item svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; flex-shrink: 0; }
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active { background: rgba(200,132,58,0.12); color: var(--accent-copper); }
.nav-badge {
    margin-right: auto; background: var(--accent-copper);
    color: white; border-radius: 50%; width: 18px; height: 18px;
    display: flex; align-items: center; justify-content: center;
    font-size: 10px; font-weight: 700;
}
.sidebar-footer {
    padding: 12px 16px; border-top: 1px solid var(--border);
}

/* MAIN CONTENT */
.main-content {
    flex: 1; display: flex; flex-direction: column;
    overflow: hidden;
    position: relative;
    z-index: 1;
    background:
        radial-gradient(ellipse at 90% 5%, rgba(255,94,0,0.04) 0%, transparent 35%),
        var(--bg-primary);
}
.top-header {
    display: flex; align-items: center; gap: 16px;
    padding: 14px 24px; border-bottom: 1px solid var(--border);
    background: linear-gradient(90deg, var(--bg-secondary), var(--bg-primary) 70%);
    flex-shrink: 0;
    box-shadow: 0 2px 12px rgba(0,0,0,0.5);
    position: relative;
    z-index: 10;
}
.top-header h2 { font-size: 18px; font-weight: 700; }
.menu-toggle {
    display: none; background: none; border: none; color: var(--text-secondary); cursor: pointer; padding: 6px;
}
.menu-toggle svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; }

.content-section {
    flex: 1; overflow-y: auto; padding: 24px;
    display: none;
    position: relative;
    z-index: 5;
}
.content-section.active { display: block; }

/* STAT CARDS */
.stats-grid {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: linear-gradient(135deg, var(--bg-card) 0%, rgba(30,21,16,0.8) 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px;
    display: flex; align-items: center; gap: 16px;
    transition: var(--transition);
    position: relative; overflow: hidden;
}
/* خط علوي متوهج عند الـ hover */
.stat-card::before {
    content: '';
    position: absolute; top: 0; left: 0; right: 0; height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent-orange), transparent);
    opacity: 0; transition: opacity 0.3s;
}
.stat-card:hover::before { opacity: 1; }
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow), var(--glow-copper); border-color: var(--border-hover); }
.stat-icon {
    width: 48px; height: 48px; border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.stat-icon svg { width: 24px; height: 24px; stroke: white; fill: none; stroke-width: 2; }
.stat-card.green  .stat-icon { background: linear-gradient(135deg, #2db84b, #1a8c35); }
.stat-card.blue   .stat-icon { background: linear-gradient(135deg, #c8843a, #8a5520); }
.stat-card.purple .stat-icon { background: linear-gradient(135deg, #d4a635, #a07820); }
.stat-card.orange .stat-icon { background: linear-gradient(135deg, #e8c060, #c8843a); }
.stat-value { font-size: 28px; font-weight: 800; display: block; }
.stat-label { color: var(--text-secondary); font-size: 12px; }

/* DASHBOARD GRID */
.dashboard-grid { display: grid; grid-template-columns: 1fr 320px; gap: 16px; }
.card {
    background: linear-gradient(160deg, var(--bg-card) 0%, rgba(14,10,8,0.9) 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius); overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.card-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.card-header h3, .card-title { font-size: 15px; font-weight: 700; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-title { margin: 0; }
.recent-list { padding: 8px 0; }
.recent-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 20px; border-bottom: 1px solid var(--border);
    transition: var(--transition);
}
.recent-item:hover { background: var(--bg-hover); }
.recent-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-copper), var(--accent-copper-dark));
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 700; color: white; flex-shrink: 0;
}
.recent-name { font-size: 13px; font-weight: 600; }
.recent-preview { font-size: 12px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-time { font-size: 11px; color: var(--text-muted); margin-right: auto; white-space: nowrap; }

.wa-connection-card {
    padding: 24px; text-align: center;
    display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.wa-big-icon { color: var(--accent-green); }
.wa-big-icon svg { width: 60px; height: 60px; }

/* CHAT LAYOUT */
.chat-layout { display: grid; grid-template-columns: 300px 1fr; gap: 0; height: calc(100vh - 57px); margin: -24px; }
.chat-list-panel {
    border-left: 1px solid var(--border);
    display: flex; flex-direction: column;
    background: var(--bg-secondary);
}
.chat-search { padding: 12px; border-bottom: 1px solid var(--border); }
.chat-search input {
    width: 100%; background: var(--bg-hover); border: 1px solid var(--border);
    color: var(--text-primary); border-radius: var(--radius-sm); padding: 8px 12px;
    font-family: 'Cairo', sans-serif; font-size: 13px;
}
.chat-list { flex: 1; overflow-y: auto; }
.chat-item {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px; border-bottom: 1px solid var(--border);
    cursor: pointer; transition: var(--transition);
}
.chat-item:hover, .chat-item.active { background: var(--bg-hover); }
.chat-item-avatar {
    width: 42px; height: 42px; border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-copper), var(--accent-copper-dark));
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 15px; color: white; flex-shrink: 0;
}
.chat-item-info { flex: 1; overflow: hidden; }
.chat-item-name { font-size: 13px; font-weight: 600; }
.chat-item-preview { font-size: 12px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item-time { font-size: 11px; color: var(--text-muted); white-space: nowrap; }

/* CHAT MAIN */
.chat-main {
    display: flex; flex-direction: column;
    background: var(--bg-primary);
}
.chat-welcome {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 12px; color: var(--text-secondary); text-align: center;
}
.chat-welcome-icon { font-size: 60px; }
.chat-header-active {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 20px; border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}
.chat-header-name { font-weight: 700; }
.chat-header-phone { font-size: 12px; color: var(--text-secondary); }
.chat-messages { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 8px; }
.msg-bubble {
    max-width: 60%; padding: 10px 14px;
    border-radius: 12px; font-size: 13px; line-height: 1.5;
    animation: msgIn 0.2s ease;
}
@keyframes msgIn { from{opacity:0;transform:scale(0.95)} to{opacity:1;transform:scale(1)} }
.msg-bubble.outgoing {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--accent-copper-dark), #5a3510);
    border-bottom-left-radius: 4px;
}
.msg-bubble.incoming {
    align-self: flex-start;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-bottom-right-radius: 4px;
}
.msg-time { font-size: 10px; opacity: 0.6; margin-top: 4px; text-align: left; }
.chat-input-area {
    padding: 12px 20px; border-top: 1px solid var(--border);
    background: var(--bg-secondary); display: flex; gap: 10px; align-items: flex-end;
}
.chat-input-area textarea {
    flex: 1; background: var(--bg-hover); border: 1px solid var(--border);
    color: var(--text-primary); border-radius: var(--radius-sm);
    padding: 10px 14px; font-family: 'Cairo', sans-serif; font-size: 13px;
    resize: none; max-height: 120px; min-height: 42px;
}
.chat-input-area textarea:focus { outline: none; border-color: var(--accent-copper); }

/* CONTACTS */
.section-toolbar {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 20px; gap: 16px; flex-wrap: wrap;
}
.toolbar-right { display: flex; gap: 10px; align-items: center; flex: 1; }
.toolbar-actions { display: flex; gap: 10px; }
.search-input {
    background: var(--bg-card); border: 1px solid var(--border);
    color: var(--text-primary); border-radius: var(--radius-sm);
    padding: 8px 14px; font-family: 'Cairo', sans-serif; font-size: 13px; width: 220px;
}
select {
    background: var(--bg-card); border: 1px solid var(--border);
    color: var(--text-primary); border-radius: var(--radius-sm);
    padding: 8px 12px; font-family: 'Cairo', sans-serif; font-size: 13px;
}

.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
    background: var(--bg-secondary); color: var(--text-secondary);
    padding: 12px 16px; text-align: right; font-size: 12px;
    font-weight: 600; border-bottom: 1px solid var(--border);
}
.data-table td {
    padding: 12px 16px; border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.data-table tr:hover td { background: var(--bg-hover); }
.data-table tr:last-child td { border-bottom: none; }

/* BULK MESSAGING */
.bulk-layout { display: grid; grid-template-columns: 420px 1fr; gap: 20px; }
.bulk-form-card { padding: 24px; }
.bulk-form-card h3 { font-size: 16px; font-weight: 700; margin-bottom: 20px; }
.char-counter { text-align: left; font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.recipients-tabs { display: flex; gap: 0; margin-bottom: 12px; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--border); }
.tab-btn {
    flex: 1; padding: 8px; background: transparent; border: none;
    color: var(--text-secondary); font-family: 'Cairo', sans-serif; font-size: 13px;
    cursor: pointer; transition: var(--transition);
}
.tab-btn.active { background: var(--accent-copper); color: white; }
.delay-settings { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.bulk-hint {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 14px; background: rgba(245,158,11,0.1);
    border: 1px solid rgba(245,158,11,0.2); border-radius: var(--radius-sm);
    color: var(--accent-orange); font-size: 12px; margin-bottom: 16px;
}
.bulk-hint svg { stroke: currentColor; fill: none; stroke-width: 2; flex-shrink: 0; }
.campaign-item {
    padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.campaign-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.campaign-name { font-weight: 600; font-size: 14px; }
.campaign-progress { background: var(--bg-hover); border-radius: 4px; height: 6px; overflow: hidden; }
.campaign-bar { height: 100%; background: linear-gradient(90deg, var(--accent-copper), var(--accent-gold)); border-radius: 4px; transition: width 0.5s; }
.campaign-stats { display: flex; gap: 16px; margin-top: 6px; font-size: 12px; color: var(--text-secondary); }

/* TEMPLATES */
.templates-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.template-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px;
    transition: var(--transition);
}
.template-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--accent-copper); }
.template-name { font-weight: 700; margin-bottom: 10px; }
.template-content { color: var(--text-secondary); font-size: 13px; line-height: 1.6; white-space: pre-wrap; }
.template-actions { display: flex; gap: 8px; margin-top: 12px; }

/* USERS TABLE */
.status-badge {
    padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600;
}
.status-badge.active { background: rgba(45,184,75,0.15); color: var(--accent-green); }
.status-badge.inactive { background: rgba(239,68,68,0.15); color: #EF4444; }
.role-badge {
    padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600;
}
.role-badge.admin    { background: rgba(200,132,58,0.15); color: var(--accent-copper); }
.role-badge.employee { background: rgba(212,166,53,0.15); color: var(--accent-gold); }

/* SETTINGS */
.settings-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.settings-layout .card { padding: 24px; }
.wa-setup-card { padding: 20px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.wa-instructions { text-align: right; background: var(--bg-hover); border-radius: var(--radius-sm); padding: 16px; width: 100%; }
.wa-instructions p { color: var(--text-secondary); margin-bottom: 8px; }
.wa-instructions ol { padding-right: 20px; color: var(--text-secondary); font-size: 13px; line-height: 1.8; }

/* FORMS */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; color: var(--text-secondary); font-size: 12px; font-weight: 600; margin-bottom: 6px; }
.form-group input, .form-group textarea, .form-group select {
    width: 100%; background: var(--bg-hover); border: 1px solid var(--border);
    color: var(--text-primary); border-radius: var(--radius-sm);
    padding: 10px 14px; font-family: 'Cairo', sans-serif; font-size: 13px;
    transition: var(--transition);
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
    outline: none; border-color: var(--accent-copper);
    box-shadow: 0 0 0 3px rgba(200,132,58,0.12);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* BUTTONS */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 9px 18px; border-radius: var(--radius-sm);
    font-family: 'Cairo', sans-serif; font-size: 13px; font-weight: 600;
    cursor: pointer; border: none; transition: var(--transition); text-decoration: none;
}
.btn svg { stroke: currentColor; fill: none; stroke-width: 2; }
.btn-primary { background: linear-gradient(135deg, var(--accent-copper), var(--accent-copper-dark)); color: white; }
.btn-primary:hover { filter: brightness(1.12); transform: translateY(-1px); box-shadow: 0 4px 16px rgba(200,132,58,0.4); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text-primary); }
.btn-outline:hover { border-color: var(--accent-copper); color: var(--accent-copper); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-danger { background: rgba(239,68,68,0.1); color: #EF4444; border: 1px solid rgba(239,68,68,0.2); }
.btn-danger:hover { background: rgba(239,68,68,0.2); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; padding: 12px; }
.btn-whatsapp { background: linear-gradient(135deg, #25D366, #128C7E); color: white; }
.mt-1 { margin-top: 8px; }

/* MODALS */
.modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; }
.modal-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.7); backdrop-filter: blur(4px); }
.modal-content {
    position: relative; background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); width: 520px; max-width: 94vw; max-height: 90vh;
    display: flex; flex-direction: column; box-shadow: var(--shadow);
    animation: modalIn 0.25s cubic-bezier(0.4,0,0.2,1);
}
.modal-sm { width: 400px; }
@keyframes modalIn { from{opacity:0;transform:scale(0.9)} to{opacity:1;transform:scale(1)} }
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 24px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--text-muted); font-size: 20px; cursor: pointer; width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; border-radius: 50%; }
.modal-close:hover { background: var(--bg-hover); color: var(--text-primary); }
.modal-body { padding: 24px; overflow-y: auto; flex: 1; }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; padding: 16px 24px; border-top: 1px solid var(--border); }

/* QR Code */
.qr-container { padding: 24px; text-align: center; }
.qr-loading { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 40px; color: var(--text-secondary); }
#qr-code-img img { border: 4px solid white; border-radius: var(--radius-sm); max-width: 220px; }
.qr-instructions { background: var(--bg-hover); border-radius: var(--radius-sm); padding: 16px; margin-top: 16px; text-align: right; }
.qr-instructions p { color: var(--text-secondary); font-size: 13px; margin-bottom: 6px; }

/* FILE DROP */
.file-drop-zone {
    border: 2px dashed var(--border); border-radius: var(--radius-sm);
    padding: 32px; text-align: center; cursor: pointer; transition: var(--transition);
    color: var(--text-secondary);
}
.file-drop-zone:hover { border-color: var(--accent-copper); color: var(--accent-copper); }
.file-drop-zone svg { stroke: currentColor; fill: none; stroke-width: 2; margin-bottom: 8px; }
.import-instructions { background: var(--bg-hover); border-radius: var(--radius-sm); padding: 12px 16px; margin-bottom: 16px; font-size: 13px; }
.import-instructions code { background: rgba(255,255,255,0.06); padding: 2px 8px; border-radius: 4px; font-family: monospace; display: block; margin-top: 6px; color: var(--accent-copper); }
.help-text { font-size: 12px; color: var(--text-secondary); }

/* Spinner */
.spinner {
    width: 32px; height: 32px; border: 3px solid var(--border);
    border-top-color: var(--accent-copper); border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to{transform:rotate(360deg)} }

/* TOAST */
#toast-container { position: fixed; bottom: 20px; left: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
    padding: 12px 20px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600;
    box-shadow: var(--shadow); animation: toastIn 0.3s ease; min-width: 220px;
}
@keyframes toastIn { from{opacity:0;transform:translateX(-20px)} to{opacity:1;transform:translateX(0)} }
.toast.success { background: rgba(45,184,75,0.15);  border: 1px solid rgba(45,184,75,0.3);  color: var(--accent-green); }
.toast.error   { background: rgba(239,68,68,0.15);  border: 1px solid rgba(239,68,68,0.3);  color: #EF4444; }
.toast.info    { background: rgba(200,132,58,0.15);  border: 1px solid rgba(200,132,58,0.3);  color: var(--accent-copper); }

/* MISC */
.error-msg { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.2); color: #EF4444; padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 12px; }
.empty-state { color: var(--text-muted); font-size: 13px; text-align: center; padding: 24px; }

/* SCROLLBAR */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* RESPONSIVE */
@media (max-width: 1024px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .dashboard-grid { grid-template-columns: 1fr; }
    .bulk-layout { grid-template-columns: 1fr; }
    .settings-layout { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
    .sidebar { position: fixed; right: -260px; height: 100%; transition: right 0.3s; }
    .sidebar.open { right: 0; }
    .menu-toggle { display: flex; }
    .top-header { padding: 12px 16px; }
    .content-section { padding: 16px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .chat-layout { grid-template-columns: 1fr; }
}

/* =========================================
   HERO SECTION - لوحة التحكم
   ========================================= */
.hero-section {
    position: relative;
    width: calc(100% + 48px);
    height: 420px;
    overflow: hidden;
    margin: -24px -24px 24px;
    background: linear-gradient(160deg, #111 0%, #0a0a0a 100%);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 8%;
    box-sizing: border-box;
}

/* كانفاس الجسيمات الشامل */
#global-particles-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    opacity: 0.6;
}

/* دوائر التوهج المتحركة */
.hero-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    animation: orbFloat 8s ease-in-out infinite;
}
.hero-orb-1 {
    width: 400px; height: 400px;
    background: radial-gradient(circle, rgba(255,94,0,0.2), transparent 70%);
    top: -100px; left: 50%;
    animation-delay: 0s;
}
.hero-orb-2 {
    width: 300px; height: 300px;
    background: radial-gradient(circle, rgba(255,94,0,0.12), transparent 70%);
    bottom: -80px; left: 20%;
    animation-delay: 3s;
}
.hero-orb-3 {
    width: 200px; height: 200px;
    background: radial-gradient(circle, rgba(255,130,0,0.1), transparent 70%);
    top: 30%; right: 30%;
    animation-delay: 5s;
}
@keyframes orbFloat {
    0%,100% { transform: translateY(0) scale(1); }
    50%      { transform: translateY(-30px) scale(1.1); }
}

/* اللوجو الرسمي في الهيرو */
.hero-robot-wrap {
    position: relative;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.hero-logo {
    width: 250px;
    height: 250px;
    object-fit: contain;
    border-radius: 50%;
    /* إضافة توهج محيطي لدمجه مع الخلفية المظلمة */
    box-shadow: 0 0 40px rgba(255,94,0,0.4), inset 0 0 20px rgba(255,130,0,0.2);
    border: 3px solid rgba(255,94,0,0.3);
    animation: floatingLogo 5s ease-in-out infinite;
    position: relative;
    z-index: 2;
}
@keyframes floatingLogo {
    0%,100% { transform: translateY(0); box-shadow: 0 0 40px rgba(255,94,0,0.4), inset 0 0 20px rgba(255,130,0,0.2); }
    50%      { transform: translateY(-15px); box-shadow: 0 0 60px rgba(255,94,0,0.7), inset 0 0 30px rgba(255,130,0,0.4); }
}
.hero-robot-glow {
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    width: 200px; height: 30px;
    background: radial-gradient(ellipse, rgba(255,94,0,0.6), transparent 70%);
    filter: blur(15px);
    animation: shadowPulse 5s ease-in-out infinite;
    z-index: 1;
}
@keyframes shadowPulse {
    0%,100% { opacity: 0.5; transform: translateX(-50%) scale(1); }
    50%      { opacity: 0.8; transform: translateX(-50%) scale(1.1); }
}

/* المحتوى النصي */
.hero-content {
    position: relative;
    z-index: 5;
    max-width: 550px;
    text-align: right;
}
.hero-badge {
    display: inline-block;
    background: rgba(255,94,0,0.15);
    border: 1px solid rgba(255,94,0,0.4);
    color: #ff5e00;
    padding: 5px 18px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1px;
    margin-bottom: 16px;
}
.hero-title {
    font-size: 38px;
    font-weight: 800;
    line-height: 1.25;
    color: #fff;
    margin-bottom: 12px;
}
.hero-highlight {
    color: #ff5e00;
    position: relative;
}
.hero-subtitle {
    color: #a0a0a0;
    font-size: 14px;
    line-height: 1.7;
    margin-bottom: 28px;
}
.hero-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}
.hero-btn-primary {
    background: linear-gradient(135deg, #ff5e00, #cc4a00);
    color: #fff;
    padding: 11px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
    border: none;
    box-shadow: 0 4px 20px rgba(255,94,0,0.35);
    transition: all 0.2s;
}
.hero-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 28px rgba(255,94,0,0.5);
    filter: brightness(1.1);
}
.hero-btn-outline {
    background: transparent;
    color: #fff;
    padding: 11px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    border: 1px solid rgba(255,255,255,0.2);
    transition: all 0.2s;
}
.hero-btn-outline:hover {
    border-color: #ff5e00;
    color: #ff5e00;
}

/* ======= تكبير شعار السايدبار ======= */
.sidebar-logo img {
    width: 100px !important;
    height: 100px !important;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255,94,0,0.4);
    box-shadow: 0 0 24px rgba(255,94,0,0.45), 0 0 50px rgba(255,94,0,0.18);
    transition: var(--transition);
}
.sidebar-logo img:hover {
    box-shadow: 0 0 35px rgba(255,94,0,0.7), 0 0 70px rgba(255,94,0,0.28);
    transform: scale(1.06);
}
.sidebar-logo span {
    font-size: 14px;
    font-weight: 800;
    color: #fff;
    letter-spacing: 0.5px;
}

/* =============================================
   WHATSAPP CLONE CHAT UI (OSOÓL THEME)
   ============================================= */
#section-chat {
    padding: 0 !important;
    height: 100vh;
    display: flex;
    overflow: hidden;
    background: #0d0d0d;
}

.chat-layout {
    display: flex;
    width: 100%;
    height: 100%;
}

.chat-list-panel {
    width: 380px;
    background: #111;
    border-left: 1px solid #222; /* RTL: left border because it's on the right */
    display: flex;
    flex-direction: column;
}

.chat-search {
    padding: 12px;
    background: #111;
    border-bottom: 1px solid #222;
}

.chat-search input {
    background: #2a2a2a;
    border: none;
    border-radius: 8px;
    padding: 10px 15px;
    color: #fff;
    width: 100%;
    font-size: 14px;
}

.chat-list {
    flex: 1;
    overflow-y: auto;
}

.chat-list::-webkit-scrollbar { width: 6px; background: transparent; }
.chat-list::-webkit-scrollbar-thumb { background: #333; }

.chat-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid #1a1a1a;
}

.chat-item:hover, .chat-item.active {
    background: #2a2a2a;
}

.chat-item-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #FF5E00;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 20px;
    color: white;
    margin-left: 15px; /* RTL margin */
    flex-shrink: 0;
}

.chat-item-info {
    flex: 1;
    overflow: hidden;
}

.chat-item-name {
    font-weight: 600;
    color: #fff;
    font-size: 16px;
    margin-bottom: 4px;
}

.chat-item-preview {
    color: #8892b0;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item-time {
    color: #8892b0;
    font-size: 12px;
    white-space: nowrap;
}

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #0d0d0d;
    position: relative;
}

.chat-header-active {
    background: #111;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid #222;
    z-index: 10;
    height: 65px;
}

.chat-header-name {
    font-weight: 600;
    color: #fff;
    font-size: 16px;
}

.chat-header-phone {
    color: #8892b0;
    font-size: 13px;
    margin-top: 2px;
}

.chat-messages {
    flex: 1;
    padding: 20px 5%;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px; /* WhatsApp has tight gaps between bubbles */
    background-color: #0b141a; /* WA dark bg */
    background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI0MDAiIGhlaWdodD0iNDAwIiB2aWV3Qm94PSIwIDAgNDAwIDQwMCI+PGcgZmlsbD0id2hpdGUiIGZpbGwtb3BhY2l0eT0iMC4wNSI+PHBhdGggZD0iTTI1LjUgODVjLTEuNyAwLTMuMi0uNS00LjUtMS41QzE5LjIgODIgMTguNSA4MCAxOC41IDc4YzAtMS43LjUtMy4yIDEuNS00LjVDMjEuMyA3MS45IDIzIDcxLjIgMjUuNSA3MS4yYzEuNyAwIDMuMi41IDQuNSAxLjUgMS42IDEuNiAyLjIgMy40IDIuMiA1LjIgMCAxLjctLjUgMy4yLTEuNSA0LjUtMS40IDEuNi0zLjIgMi41LTUuMiAyLjV6bTcyIDIwaDI1djE1aC0yNXYtMTV6bTUwIDEwaDE1djMwaC0xNXYtMzB6bTUtODBMODIgMTk4bDIwLTEwTDE3MiAxNXptMTEwIDE4Yy01IDAtOSAzLTExIDhoLTI3YzEtNSAyLTExIDItMTdINTRWMjJzMi0zIDgtNWg0NmMwIDIgMSAyIDItMWwxMSAzMjYtejQwLTQyVjMyMnoiLz48L2c+PC9zdmc+');
    background-repeat: repeat;
}

.chat-messages::-webkit-scrollbar { width: 6px; background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); }

.msg-bubble {
    max-width: 65%;
    padding: 6px 10px 8px 10px;
    border-radius: 8px;
    position: relative;
    font-size: 14.5px;
    line-height: 19px;
    word-wrap: break-word;
    box-shadow: 0 1px .5px rgba(0,0,0,0.13);
    display: inline-block;
    clear: both;
    margin-bottom: 2px;
}

.msg-bubble::before {
    content: "";
    position: absolute;
    top: 0;
    width: 0;
    height: 0;
    border-style: solid;
}

.msg-bubble.incoming {
    align-self: flex-start;
    background: #202c33; /* WA Dark Incoming */
    color: #e9edef;
    border-top-right-radius: 0;
    margin-right: -8px; 
}

.msg-bubble.incoming::before {
    right: -8px;
    border-width: 0 8px 8px 0;
    border-color: transparent #202c33 transparent transparent;
}

.msg-bubble.outgoing {
    align-self: flex-end;
    background: #005c4b; /* WA Dark Outgoing */
    color: #e9edef;
    border-top-left-radius: 0;
    margin-left: -8px;
}
/* For Osool Brand Feel: let's use the WA Dark outgiong color but subtle orange for ticks */
.msg-bubble.outgoing .msg-time svg {
    color: #53bdeb; /* WA Blue Tick */
}

/* Actually user wants WA clone exactly. WA dark mode uses green #005c4b for outgoing and grey #202c33 for incoming. */

.msg-bubble.outgoing::before {
    left: -8px; /* RTL Note: left side for outgoing because RTL is reversed. */
    border-width: 0 0 8px 8px;
    border-color: transparent transparent transparent #005c4b;
}

.msg-time {
    font-size: 11px;
    color: rgba(255,255,255,0.6);
    float: left; /* RTL: float left to put it at the end of the text on the left side */
    margin-top: 4px;
    margin-left: 0;
    margin-right: 15px;
    position: relative;
    top: 2px;
}

.chat-input-area {
    background: #202c33;
    padding: 10px 20px;
    display: flex;
    align-items: flex-end;
    gap: 15px;
    z-index: 10;
}

.chat-input-area textarea {
    flex: 1;
    background: #2a3942;
    border: none;
    border-radius: 8px;
    padding: 12px 20px;
    color: #e9edef;
    resize: none;
    outline: none;
    font-size: 15px;
    line-height: 20px;
    max-height: 100px;
    min-height: 20px;
    font-family: inherit;
}

.chat-input-area textarea::placeholder {
    color: #8892b0;
}

.chat-input-area .btn-primary {
    border-radius: 50%;
    width: 44px;
    height: 44px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #00a884; /* WA Green Send button */
    border: none;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.chat-input-area .btn-primary:hover {
    transform: scale(1.05);
    background: #00c298;
}

.chat-input-area .btn-primary svg {
    margin-right: -2px; /* center optical */
}
