/* =====================================================
   نظام إدارة شركة الدلتا ناشيونال - CSS الرئيسي
   RTL Design - Arabic Interface
   ===================================================== */

/* Import Arabic Font */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;600;700;900&display=swap');

/* =====================================================
   Variables & Reset
   ===================================================== */
:root {
    --primary: #0D47A1;
    --primary-light: #1976D2;
    --primary-dark: #0a3880;
    --secondary: #1565C0;
    --accent: #FF6F00;
    --accent-light: #FFA000;
    --success: #2e7d32;
    --danger: #c62828;
    --warning: #f57f17;
    --info: #01579b;
    --sidebar-width: 260px;
    --sidebar-bg: linear-gradient(180deg, #0D47A1 0%, #1565C0 50%, #0a3880 100%);
    --topbar-height: 60px;
    --body-bg: #f0f4f8;
    --card-bg: #ffffff;
    --border-color: #e2e8f0;
    --text-primary: #1a202c;
    --text-secondary: #4a5568;
    --text-muted: #718096;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --transition: all 0.25s ease;
}

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

html { scroll-behavior: smooth; }

body.delta-body {
    font-family: 'Cairo', sans-serif;
    background-color: var(--body-bg);
    color: var(--text-primary);
    direction: rtl;
    text-align: right;
    min-height: 100vh;
    overflow-x: hidden;
}

/* =====================================================
   Sidebar
   ===================================================== */
.sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    z-index: 1050;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    box-shadow: -4px 0 20px rgba(0,0,0,0.15);
    overflow: hidden;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.15);
    position: relative;
}

.brand-logo {
    width: 44px;
    height: 44px;
    background: rgba(255,255,255,0.2);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: #fff;
    flex-shrink: 0;
}

.brand-text {
    flex: 1;
    min-width: 0;
}

.brand-name {
    display: block;
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.brand-sub {
    display: block;
    font-size: 11px;
    color: rgba(255,255,255,0.7);
    margin-top: 2px;
}

.sidebar-close-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    padding: 4px;
    display: none;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0;
}

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

.nav-section-title {
    font-size: 10px;
    font-weight: 700;
    color: rgba(255,255,255,0.5);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 16px 20px 6px;
    list-style: none;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: rgba(255,255,255,0.8);
    font-size: 14px;
    font-weight: 500;
    border-radius: 0;
    transition: var(--transition);
    position: relative;
    border-right: 3px solid transparent;
    text-decoration: none;
}

.sidebar-nav .nav-link:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
    border-right-color: rgba(255,255,255,0.5);
    padding-right: 24px;
}

.sidebar-nav .nav-link.active {
    background: rgba(255,255,255,0.15);
    color: #fff;
    font-weight: 700;
    border-right-color: white;
}

.sidebar-nav .nav-link i {
    font-size: 17px;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1040;
}

/* =====================================================
   Main Wrapper & Topbar
   ===================================================== */
.main-wrapper {
    margin-right: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-right 0.3s ease;
}

.topbar {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    height: var(--topbar-height);
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: var(--shadow-md);
    padding: 0 !important;
}

.topbar-title {
    color: rgba(255,255,255,0.9);
    font-weight: 600;
    font-size: 15px;
}

.topbar-icon {
    position: relative;
    padding: 8px;
    border-radius: 8px;
    text-decoration: none;
    transition: var(--transition);
}

.topbar-icon:hover {
    background: rgba(255,255,255,0.15);
}

.content-wrapper {
    flex: 1;
    padding: 24px;
}

/* =====================================================
   Cards
   ===================================================== */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 16px 20px;
    border-radius: var(--border-radius) var(--border-radius) 0 0 !important;
    font-weight: 700;
    font-size: 15px;
    color: var(--primary);
}

.card-body { padding: 20px; }

/* =====================================================
   Stats Cards (Dashboard)
   ===================================================== */
.stat-card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: var(--transition);
    text-decoration: none;
    color: inherit;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    color: inherit;
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    color: #fff;
    flex-shrink: 0;
}

.stat-icon.blue   { background: linear-gradient(135deg, #0D47A1, #1976D2); }
.stat-icon.green  { background: linear-gradient(135deg, #2e7d32, #43a047); }
.stat-icon.orange { background: linear-gradient(135deg, #e65100, #FF6F00); }
.stat-icon.purple { background: linear-gradient(135deg, #4a148c, #7b1fa2); }
.stat-icon.teal   { background: linear-gradient(135deg, #004d40, #00796b); }
.stat-icon.red    { background: linear-gradient(135deg, #b71c1c, #e53935); }

.stat-info h3 {
    font-size: 26px;
    font-weight: 900;
    color: var(--primary);
    line-height: 1;
    margin-bottom: 4px;
}

.stat-info p {
    font-size: 13px;
    color: var(--text-muted);
    margin: 0;
    font-weight: 500;
}

/* =====================================================
   Tables
   ===================================================== */
.table-delta {
    font-size: 14px;
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
}

.table-delta thead tr th {
    background: var(--primary);
    color: white;
    font-weight: 700;
    padding: 12px 14px;
    border: none;
    font-size: 13px;
    white-space: nowrap;
}

.table-delta thead tr th:first-child { border-radius: 0 8px 0 0; }
.table-delta thead tr th:last-child  { border-radius: 8px 0 0 0; }

.table-delta tbody tr td {
    padding: 11px 14px;
    border-bottom: 1px solid #edf2f7;
    vertical-align: middle;
    color: var(--text-primary);
}

.table-delta tbody tr:hover { background: #f7f9fc; }
.table-delta tbody tr:last-child td { border-bottom: none; }

.table-responsive { border-radius: var(--border-radius); overflow: hidden; }

/* =====================================================
   Forms
   ===================================================== */
.form-control, .form-select, .form-floating textarea {
    border: 1.5px solid #d1d9e0;
    border-radius: var(--border-radius-sm);
    font-family: 'Cairo', sans-serif;
    font-size: 14px;
    transition: var(--transition);
    direction: rtl;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.12);
}

.form-label {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

/* =====================================================
   Buttons
   ===================================================== */
.btn {
    font-family: 'Cairo', sans-serif;
    font-weight: 600;
    border-radius: var(--border-radius-sm);
    transition: var(--transition);
    font-size: 14px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border: none;
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(13, 71, 161, 0.35);
}

.btn-outline-primary {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-outline-primary:hover {
    background: var(--primary);
    border-color: var(--primary);
}

/* =====================================================
   Badges
   ===================================================== */
.badge {
    font-family: 'Cairo', sans-serif;
    font-weight: 600;
    font-size: 11px;
    padding: 5px 10px;
    border-radius: 6px;
}

/* =====================================================
   Alerts
   ===================================================== */
.alert {
    border: none;
    border-radius: var(--border-radius-sm);
    font-size: 14px;
    font-weight: 500;
    border-right: 4px solid;
}

.alert-success { border-right-color: var(--success); }
.alert-danger   { border-right-color: var(--danger); }
.alert-warning  { border-right-color: var(--warning); }
.alert-info     { border-right-color: var(--info); }

/* =====================================================
   Page Header
   ===================================================== */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-title {
    font-size: 22px;
    font-weight: 800;
    color: var(--primary);
    margin: 0;
}

.page-title small {
    font-size: 13px;
    font-weight: 400;
    color: var(--text-muted);
    display: block;
    margin-top: 2px;
}

/* =====================================================
   Login Page
   ===================================================== */
.login-page {
    min-height: 100vh;
    height: 100vh;
    width: 100vw;
    margin: 0;
    padding: 20px;
    background: linear-gradient(135deg, #0D47A1 0%, #1565C0 40%, #1976D2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: auto;
    z-index: 9999;
}

.login-page::before {
    content: '';
    position: absolute;
    top: -30%;
    left: -20%;
    width: 500px;
    height: 500px;
    background: rgba(255,255,255,0.05);
    border-radius: 50%;
}

.login-page::after {
    content: '';
    position: absolute;
    bottom: -20%;
    right: -10%;
    width: 400px;
    height: 400px;
    background: rgba(255,255,255,0.05);
    border-radius: 50%;
}

.login-box {
    background: white;
    border-radius: 20px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    position: relative;
    z-index: 1;
    animation: slideUp 0.5s ease;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(30px); }
    to   { opacity: 1; transform: translateY(0); }
}

.login-logo {
    width: 70px;
    height: 70px;
    background: linear-gradient(135deg, #0D47A1, #1976D2);
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    color: white;
    margin: 0 auto 20px;
}

.login-title {
    font-size: 18px;
    font-weight: 800;
    color: var(--primary);
    text-align: center;
    line-height: 1.4;
    margin-bottom: 4px;
}

.login-sub {
    font-size: 13px;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 28px;
}

/* =====================================================
   Chat
   ===================================================== */
.chat-container {
    display: flex;
    height: calc(100vh - var(--topbar-height) - 48px);
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.chat-sidebar {
    width: 280px;
    border-left: 1px solid var(--border-color);
    flex-shrink: 0;
    overflow-y: auto;
    background: #f8fafc;
}

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.chat-header-bar {
    background: var(--primary);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 65px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f0f4f8;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-message {
    max-width: 70%;
    word-break: break-word;
}

.chat-message.sent {
    align-self: flex-end;
}

.chat-message.received {
    align-self: flex-start;
}

.msg-bubble {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    position: relative;
}

.sent .msg-bubble {
    background: var(--primary);
    color: white;
    border-radius: 14px 14px 4px 14px;
}

.received .msg-bubble {
    background: white;
    color: var(--text-primary);
    border-radius: 14px 14px 14px 4px;
    box-shadow: var(--shadow-sm);
}

.msg-time {
    font-size: 11px;
    opacity: 0.7;
    margin-top: 4px;
    display: block;
    text-align: left;
}

.sent .msg-time { color: rgba(255,255,255,0.7); text-align: right; }
.received .msg-time { color: var(--text-muted); }

.chat-input-area {
    padding: 16px;
    background: white;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.chat-user-item {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
}

.chat-user-item:hover, .chat-user-item.active {
    background: #e3f2fd;
    color: inherit;
}

.avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 16px;
    flex-shrink: 0;
}

/* =====================================================
   Avatar SM
   ===================================================== */
.avatar-sm {
    font-size: 22px;
    color: white;
}

/* =====================================================
   Inventory Alert
   ===================================================== */
.low-stock-warning {
    background: #fff3e0;
    border-right: 4px solid var(--warning);
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 13px;
    color: #bf360c;
    margin-bottom: 8px;
}

/* =====================================================
   Print Styles
   ===================================================== */
@media print {
    .sidebar, .topbar, .no-print { display: none !important; }
    .main-wrapper { margin: 0 !important; }
    body { background: white; }
}

/* =====================================================
   Responsive
   ===================================================== */
/* =====================================================
   Responsive
   ===================================================== */
@media (max-width: 992px) {

    /* اخفاء القائمة افتراضيا في الموبايل */
    .sidebar {
        transform: translateX(100%);
        position: fixed;
        right: 0;
        top: 0;
        height: 100%;
        z-index: 1050;
        transition: transform .3s ease;
    }

    /* عند الضغط على زر القائمة */
    .sidebar.open {
        transform: translateX(0);
    }

    /* زر اغلاق القائمة */
    .sidebar-close-btn {
        display: block;
    }

    /* المحتوى يأخذ الشاشة كاملة */
    .main-wrapper {
        margin-right: 0;
    }

    /* الخلفية السوداء */
    .sidebar-overlay.show {
        display: block;
    }

    .content-wrapper {
        padding: 16px;
    }

    .chat-sidebar {
        width: 220px;
    }
}

@media (max-width: 576px) {

    .chat-sidebar {
        display: none;
    }

    .chat-container {
        flex-direction: column;
    }

    .stat-card {
        flex-direction: column;
        text-align: center;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
}
@media (max-width: 576px) {
    .chat-sidebar { display: none; }
    .chat-container { flex-direction: column; }
    .stat-card { flex-direction: column; text-align: center; }
    .page-header { flex-direction: column; align-items: flex-start; }
}

/* =====================================================
   Animations
   ===================================================== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.fade-in { animation: fadeIn 0.4s ease; }

/* =====================================================
   Utilities
   ===================================================== */
.text-primary { color: var(--primary) !important; }
.border-primary { border-color: var(--primary) !important; }
.bg-primary-soft { background: rgba(13, 71, 161, 0.08); }
.rounded-3 { border-radius: var(--border-radius) !important; }
.fw-black { font-weight: 900; }