/* ============================================================
   SCIE PR-CRM — Custom Styles
   RTL Arabic + Bootstrap 3.3.7
   ============================================================ */

/* ---- الخطوط والأساسيات ---- */
body {
    font-family: 'Segoe UI', Tahoma, Arial, sans-serif;
    direction: rtl;
    text-align: right;
    background: #f4f6f9;
    font-size: 13px;
    color: #333;
}

a { color: #2980b9; }
a:hover { color: #1a5276; }

/* ---- السايدبار ---- */
#sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 215px;
    background: linear-gradient(180deg, #1a252f 0%, #2c3e50 100%);
    z-index: 1000;
    overflow-y: auto;
    box-shadow: -2px 0 8px rgba(0,0,0,0.3);
}

#sidebar::-webkit-scrollbar { width: 4px; }
#sidebar::-webkit-scrollbar-track { background: transparent; }
#sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 2px; }

/* شعار التطبيق */
.sidebar-brand {
    padding: 16px 14px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    margin-bottom: 6px;
}
.sidebar-brand .brand-title {
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.3;
    display: block;
}
.sidebar-brand .brand-sub {
    color: rgba(255,255,255,0.5);
    font-size: 10px;
    display: block;
    margin-top: 2px;
}

/* قسم السايدبار */
.sidebar-section {
    padding: 8px 14px 4px;
    font-size: 9px;
    font-weight: 700;
    color: rgba(255,255,255,0.3);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 4px;
}

/* روابط السايدبار */
#sidebar ul {
    list-style: none;
    padding: 0;
    margin: 0;
}
#sidebar ul li a {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 16px;
    color: rgba(255,255,255,0.72);
    text-decoration: none;
    font-size: 12.5px;
    transition: all 0.15s;
    border-right: 3px solid transparent;
}
#sidebar ul li a:hover {
    background: rgba(255,255,255,0.07);
    color: #fff;
    border-right-color: rgba(255,255,255,0.3);
}
#sidebar ul li.active > a {
    background: rgba(52, 152, 219, 0.25);
    color: #fff;
    border-right-color: #3498db;
    font-weight: 600;
}
#sidebar ul li a .glyphicon {
    font-size: 13px;
    width: 16px;
    text-align: center;
    opacity: 0.85;
}

/* عداد في السايدبار */
.sidebar-badge {
    margin-right: auto;
    margin-left: 0;
    background: #e74c3c;
    color: #fff;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 10px;
    font-weight: 700;
}

/* معلومات المستخدم في أسفل السايدبار */
.sidebar-user {
    position: absolute;
    bottom: 0;
    right: 0;
    left: 0;
    padding: 10px 14px;
    background: rgba(0,0,0,0.2);
    border-top: 1px solid rgba(255,255,255,0.07);
    display: flex;
    align-items: center;
    gap: 8px;
}
.sidebar-user .user-avatar {
    width: 30px;
    height: 30px;
    background: #3498db;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
}
.sidebar-user .user-name {
    color: rgba(255,255,255,0.85);
    font-size: 11.5px;
    font-weight: 600;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---- المحتوى الرئيسي ---- */
#main-content {
    margin-right: 215px;
    min-height: 100vh;
}

/* الشريط العلوي */
#topbar {
    background: #fff;
    border-bottom: 1px solid #e8ecf0;
    padding: 0 20px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 900;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
#topbar .page-title {
    font-size: 15px;
    font-weight: 700;
    color: #2c3e50;
    margin: 0;
}
#topbar .topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* منطقة المحتوى */
#content-area {
    padding: 20px;
}

/* ---- الـ Flash Messages ---- */
.flash-wrap {
    margin-bottom: 14px;
}
.flash-wrap .alert {
    border-radius: 6px;
    border: none;
    padding: 10px 14px;
    font-size: 13px;
}

/* ---- بطاقات KPI ---- */
.kpi-card {
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 14px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    transition: transform 0.15s, box-shadow 0.15s;
}
.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}
.kpi-card .panel-body {
    padding: 14px 16px !important;
}
.kpi-body {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.kpi-value {
    font-size: 30px;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 2px;
}
.kpi-label {
    font-size: 11px;
    opacity: 0.85;
    margin-bottom: 4px;
}
.kpi-sub {
    font-size: 10px;
    opacity: 0.72;
}
.kpi-icon {
    font-size: 40px;
    opacity: 0.18;
}

/* ---- الـ Panels ---- */
.panel {
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    margin-bottom: 16px;
}
.panel-heading {
    border-radius: 8px 8px 0 0 !important;
    padding: 10px 14px;
}
.panel-title {
    font-size: 13px;
    font-weight: 700;
}
.panel-body { padding: 14px; }

/* ---- الجداول ---- */
.table { margin-bottom: 0; }
.table th {
    background: #f8f9fa;
    font-size: 11px;
    font-weight: 700;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    border-bottom: 2px solid #e8ecf0 !important;
    padding: 8px 10px !important;
}
.table td {
    padding: 9px 10px !important;
    vertical-align: middle !important;
    font-size: 12.5px;
}
.table-hover tbody tr:hover {
    background: #f0f7ff;
}

/* ---- Labels وBadges ---- */
.label { font-size: 10.5px; font-weight: 600; padding: 2px 7px; border-radius: 10px; }
.badge { font-size: 10px; }

/* ---- الأزرار ---- */
.btn { border-radius: 5px; font-size: 12.5px; }
.btn-sm { font-size: 11.5px; padding: 4px 10px; }
.btn-xs { font-size: 10.5px; padding: 2px 7px; }

/* ---- Timeline للتفاعلات ---- */
.timeline {
    position: relative;
    padding: 0;
    list-style: none;
}
.timeline::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    right: 20px;
    width: 2px;
    background: #e8ecf0;
}
.timeline-item {
    position: relative;
    padding-right: 50px;
    padding-bottom: 16px;
}
.timeline-icon {
    position: absolute;
    right: 8px;
    top: 2px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 11px;
    z-index: 1;
}
.timeline-content {
    background: #fff;
    border: 1px solid #e8ecf0;
    border-radius: 7px;
    padding: 10px 12px;
}
.timeline-meta {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
}

/* ---- Pipeline Kanban ---- */
.pipeline-board {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 8px;
}
.pipeline-column {
    min-width: 200px;
    flex: 0 0 200px;
    background: #f4f6f9;
    border-radius: 8px;
    padding: 8px;
}
.pipeline-column-header {
    font-size: 11.5px;
    font-weight: 700;
    padding: 6px 8px;
    border-radius: 5px;
    color: #fff;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.pipeline-card {
    background: #fff;
    border-radius: 6px;
    padding: 9px 10px;
    margin-bottom: 7px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    font-size: 12px;
    cursor: pointer;
    transition: box-shadow 0.15s;
    border-right: 3px solid transparent;
    text-decoration: none;
    display: block;
    color: #333;
}
.pipeline-card:hover {
    box-shadow: 0 3px 8px rgba(0,0,0,0.12);
    text-decoration: none;
    color: #333;
}
.pipeline-card .company-name {
    font-weight: 600;
    font-size: 12.5px;
    margin-bottom: 3px;
}
.pipeline-card .service-tag {
    font-size: 10px;
    color: #888;
    margin-bottom: 4px;
}
.pipeline-card .card-footer-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 5px;
}

/* ---- الفورم ---- */
.form-control {
    border-radius: 5px;
    font-size: 12.5px;
    border-color: #d8dce2;
    height: 34px;
}
.form-control:focus {
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52,152,219,0.15);
}
textarea.form-control { height: auto; min-height: 80px; }
.form-group label {
    font-size: 12px;
    font-weight: 600;
    color: #555;
    margin-bottom: 4px;
}
.form-group {
    margin-bottom: 14px;
}
.field-required label::after {
    content: ' *';
    color: #e74c3c;
}

/* إصلاح RTL في Bootstrap 3 */
.rtl-form .row {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    flex-wrap: wrap;
}
.rtl-form .row > [class*="col-"] {
    float: none;
}

/* ---- شريط البحث ---- */
.search-bar {
    background: #fff;
    border: 1px solid #e8ecf0;
    border-radius: 8px;
    padding: 14px;
    margin-bottom: 16px;
}

/* ---- الطباعة ---- */
@media print {
    #sidebar, #topbar, .no-print { display: none !important; }
    #main-content { margin-right: 0 !important; }
    #content-area { padding: 0 !important; }
    .panel { box-shadow: none !important; border: 1px solid #ddd !important; }
}

/* ---- الـ Animation ---- */
@keyframes spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}
.spin { animation: spin 1s linear infinite; }

/* ---- المودالات ---- */
.modal-content { border-radius: 8px; }
.modal-header {
    background: #2c3e50;
    color: #fff;
    border-radius: 8px 8px 0 0;
    padding: 12px 16px;
}
.modal-header .close { color: #fff; opacity: 0.8; margin-top: -2px; }
.modal-header .close:hover { opacity: 1; }
.modal-title { font-size: 14px; font-weight: 700; }
.modal-body { padding: 16px; }
.modal-footer { padding: 10px 16px; background: #f8f9fa; border-radius: 0 0 8px 8px; }

/* ---- مؤشر الاهتمام ---- */
.priority-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-left: 4px;
}
.priority-dot.high   { background: #e74c3c; }
.priority-dot.medium { background: #f39c12; }
.priority-dot.low    { background: #95a5a6; }

/* ---- شريط التقدم المصغر ---- */
.mini-progress {
    background: #eee;
    border-radius: 3px;
    height: 5px;
    margin-top: 3px;
    overflow: hidden;
}
.mini-progress-bar {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s;
}

/* ---- صفحة الـ View ---- */
.view-header {
    background: #fff;
    border-radius: 8px;
    padding: 16px 18px;
    margin-bottom: 16px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}
.view-title {
    font-size: 18px;
    font-weight: 700;
    color: #2c3e50;
    margin: 0 0 4px;
}
.view-meta {
    font-size: 11.5px;
    color: #888;
}

/* ---- Empty State ---- */
.empty-state {
    text-align: center;
    padding: 30px 20px;
    color: #aaa;
}
.empty-state .glyphicon {
    font-size: 36px;
    margin-bottom: 10px;
    display: block;
    opacity: 0.35;
}
.empty-state p {
    font-size: 13px;
    margin: 0;
}

/* ---- تذييل الصفحة ---- */
#page-footer {
    text-align: center;
    padding: 12px;
    font-size: 11px;
    color: #bbb;
    border-top: 1px solid #e8ecf0;
    margin-top: 20px;
    background: #fff;
}

/* ---- إصلاح المودالات مع السايدبار RTL ---- */
.modal {
    text-align: right !important;
    direction: rtl !important;
}
.modal-dialog {
    margin: 30px auto !important;
    position: relative !important;
    z-index: 1060 !important;
}
.modal-backdrop {
    z-index: 1055 !important;
}
.modal.fade.in {
    display: block !important;
    opacity: 1 !important;
}
.modal-open .modal {
    overflow-x: hidden !important;
    overflow-y: auto !important;
    display: block !important;
}

/* ---- إصلاح backdrop يغطي المودال ---- */
.modal-backdrop {
    z-index: 1050 !important;
}
.modal {
    z-index: 1055 !important;
}
.modal-dialog {
    z-index: 1060 !important;
}
