﻿/* ============================================================
   صفحة إدارة المنشآت - Establishments Management Styles (V2)
   ============================================================ */

/* 1. الحاوية الرئيسية للهيدر */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding: 25px;
    background: var(--bg-side);
    border-radius: 20px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.02);
}

.header-text h1 {
    font-size: 1.8rem;
    color: var(--accent);
    margin: 0;
    font-weight: 900;
}

.header-text p {
    color: var(--text-muted);
    margin: 8px 0 0 0;
    font-size: 0.95rem;
}

/* 2. بطاقات الإحصائيات الصغيرة في الهيدر */
.header-stats {
    display: flex;
    gap: 15px;
}

.mini-stat {
    background: var(--bg-app);
    padding: 12px 20px;
    border-radius: 15px;
    border: 1px solid var(--border-color);
    min-width: 140px;
    text-align: center;
}

    .mini-stat .label {
        display: block;
        font-size: 0.75rem;
        color: var(--text-muted);
        font-weight: 600;
        margin-bottom: 4px;
    }

    .mini-stat .value {
        font-size: 1.4rem;
        font-weight: 900;
    }

        .mini-stat .value.success {
            color: var(--accent);
        }

        .mini-stat .value.warning {
            color: #f59e0b;
        }

/* 3. شريط الأدوات (المعدل بالكامل) */
.toolbar-card {
    background: var(--bg-side);
    padding: 18px 25px;
    border-radius: 18px;
    margin-bottom: 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
    gap: 20px;
}

.search-wrapper {
    position: relative;
    flex: 1;
    max-width: 480px;
}

    .search-wrapper i {
        position: absolute;
        right: 15px;
        top: 50%;
        transform: translateY(-50%);
        color: var(--accent);
        font-size: 1.3rem;
    }

    .search-wrapper input {
        width: 100%;
        padding: 12px 45px 12px 15px;
        border-radius: 12px;
        border: 2px solid var(--border-color);
        background: var(--bg-app);
        color: var(--text-main);
        outline: none;
        font-family: 'Cairo', sans-serif;
        transition: var(--transition);
    }

        .search-wrapper input:focus {
            border-color: var(--accent);
            background: var(--bg-side);
            box-shadow: 0 0 0 4px var(--accent-light);
        }

/* مجموعة الفلترة والأزرار */
.filter-group {
    display: flex;
    align-items: center;
    gap: 15px;
}

.custom-select {
    padding: 10px 15px;
    border-radius: 12px;
    border: 2px solid var(--border-color);
    background: var(--bg-side);
    color: var(--text-main);
    font-family: 'Cairo', sans-serif;
    font-weight: 700;
    outline: none;
    cursor: pointer;
    min-width: 160px;
    transition: var(--transition);
}

    .custom-select:focus {
        border-color: var(--accent);
    }

.export-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 22px;
    background: var(--accent-light);
    color: var(--accent);
    border: 2px solid var(--accent);
    border-radius: 12px;
    font-family: 'Cairo', sans-serif;
    font-weight: 800;
    cursor: pointer;
    transition: var(--transition);
}

    .export-btn:hover {
        background: var(--accent);
        color: #ffffff;
        transform: translateY(-2px);
        box-shadow: 0 5px 15px var(--accent-light);
    }

/* 4. تنسيقات الجدول الاحترافي */
.table-container {
    background: var(--bg-side);
    border-radius: 20px;
    border: 1px solid var(--border-color);
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.02);
}

.org-table {
    width: 100%;
    border-collapse: collapse;
    text-align: right;
}

    .org-table th {
        background: var(--bg-app);
        padding: 18px 25px;
        color: var(--text-muted);
        font-size: 0.85rem;
        font-weight: 800;
        border-bottom: 2px solid var(--border-color);
        text-transform: uppercase;
    }

    .org-table td {
        padding: 20px 25px;
        border-bottom: 1px solid var(--border-color);
        vertical-align: middle;
    }

/* 5. بروفايل المنشأة */
.org-profile {
    display: flex;
    align-items: center;
    gap: 15px;
}

    .org-profile .avatar {
        width: 45px;
        height: 45px;
        background: var(--accent);
        color: white;
        border-radius: 12px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-weight: 900;
        font-size: 1.3rem;
        box-shadow: 0 4px 10px var(--accent-light);
    }

    .org-profile .details .name {
        display: block;
        font-weight: 800;
        color: var(--text-main);
        font-size: 1rem;
    }

    .org-profile .details .sub {
        font-size: 0.8rem;
        color: var(--text-muted);
    }

/* 6. معلومات التوثيق والاتصال */
.docs-info, .contact-info {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 0.85rem;
}

    .docs-info span i, .contact-info span i {
        font-size: 1.1rem;
        color: var(--accent);
        margin-left: 5px;
    }

/* 7. حالات الاشتراك (Pills) */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 30px;
    font-size: 0.8rem;
    font-weight: 800;
}

    .status-pill.active {
        background: #e6fcf5;
        color: #00c853;
    }

    .status-pill.pending {
        background: #fff4e5;
        color: #ff9800;
    }

/* 8. أزرار التحكم */
.action-group {
    display: flex;
    gap: 10px;
}

.btn-action {
    border: none;
    padding: 10px 18px;
    border-radius: 10px;
    font-weight: 800;
    font-family: 'Cairo';
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
}

    .btn-action.activate {
        background: var(--accent);
        color: white;
    }

        .btn-action.activate:hover {
            filter: brightness(1.1);
            transform: translateY(-2px);
        }

    .btn-action.deactivate {
        background: #fee2e2;
        color: #ef4444;
    }

.btn-icon {
    background: var(--bg-app);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 10px;
    border-radius: 10px;
    cursor: pointer;
    transition: var(--transition);
}

    .btn-icon:hover {
        background: var(--border-color);
        color: var(--text-main);
    }
/* --- المودال المدمج (Compact) --- */
/* --- المودال المتوافق مع الدارك مود والهوية الخليجية --- */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5); /* تعتيم الخلفية */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    backdrop-filter: blur(4px);
}

.modal-card {
    background: var(--bg-side); /* خلفية الكارد تتبع المود */
    width: 95%;
    max-width: 550px; /* مدمج واحترافي */
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
    border: 1px solid var(--border-color); /* الحدود تتبع المود */
    position: relative;
    margin-bottom: 50px;
    z-index: 2001;
    overflow: hidden;
    animation: modalShow 0.3s ease-out;
}

/* Header */
.modal-header-compact {
    padding: 16px 20px;
    background: var(--bg-app); /* أفتح قليلاً من خلفية الكارد في الدارك */
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-info h3 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--accent); /* الأخضر السعودي */
    font-weight: 800;
}

.header-info span {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Body & Grid Fix */
.modal-body-compact {
    padding: 20px;
}

.input-grid-mini {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important; /* عمودين إجباري */
    gap: 15px;
}

.input-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

    .input-field.full {
        grid-column: span 2 !important;
    }

    .input-field label {
        font-size: 0.8rem;
        font-weight: 700;
        color: var(--text-muted);
    }

    .input-field input, .input-field select {
        padding: 10px 12px;
        border-radius: 10px;
        border: 1px solid var(--border-color);
        font-size: 0.85rem;
        background: var(--bg-app); /* يقلب داكن في الدارك مود */
        color: var(--text-main); /* النص يقلب أبيض في الدارك */
        transition: 0.2s;
        font-family: 'Cairo', sans-serif;
    }

        .input-field input:focus {
            border-color: var(--accent);
            background: var(--bg-side);
            outline: none;
        }

/* Preview Bar (الميكس الخليجي) */
.mini-preview-bar {
    margin-top: 15px;
    padding: 12px;
    background: var(--accent-light); /* خلفية شفافة من الأخضر */
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    border-right: 4px solid var(--kw-blue, #006837); /* خط أزرق كويتي */
}

.preview-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-main);
}

    .preview-item b {
        color: var(--accent);
    }

/* Footer */
.modal-footer-compact {
    padding: 15px 20px;
    background: var(--bg-app);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* الزر الأساسي (أخضر سعودي) */
.btn-fill {
    background: var(--accent);
    color: #ffffff !important;
    border: none;
    padding: 10px 25px;
    border-radius: 10px;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 4px 10px var(--accent-light);
}

/* زر الإلغاء */
.btn-text {
    background: var(--bg-side);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 8px 20px;
    border-radius: 10px;
    font-weight: 700;
    cursor: pointer;
    transition: 0.2s;
}

    .btn-text:hover {
        background: var(--border-color);
        color: var(--text-main);
    }

@keyframes modalShow {
    from {
        transform: translateY(15px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

    .btn-fill:hover {
        background: #004494;
        box-shadow: 0 4px 12px rgba(0, 86, 179, 0.25);
    }

.btn-text {
    background: #f1f5f9; /* خلفية رمادية فاتحة جداً */
    border: 1px solid #e2e8f0; /* تحديد بسيط */
    color: #64748b; /* لون نص هادئ */
    padding: 10px 25px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.85rem;
    font-family: 'Cairo', sans-serif;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

    .btn-text:hover {
        background: #e2e8f0; /* يغمق قليلاً عند التمرير */
        color: #1e293b; /* النص يبرز أكثر */
        border-color: #cbd5e1;
    }

    .btn-text:active {
        transform: scale(0.98); /* تأثير ضغطة الزر */
    }
    
    .btn-fill {
    /* درجة الأزرق الكويتي الاحترافي */
    background: #006837;
    color: #ffffff;
    border: none;
    padding: 10px 24px; /* زيادة بسيطة في المساحة لراحة الضغط */
    border-radius: 8px;
    font-weight: 600;
    font-family: 'Cairo', sans-serif;
    cursor: pointer;
    transition: all 0.3s ease; /* لإضافة نعومة عند التفاعل */
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 6px rgba(0, 86, 179, 0.15); /* ظل خفيف بنفس اللون */
}

    .btn-fill:hover {
        /* درجة أغمق قليلاً عند تمرير الماوس */
        background: #004494;
        transform: translateY(-1px); /* حركة بسيطة للأعلى */
        box-shadow: 0 6px 12px rgba(0, 86, 179, 0.2);
    }

    .btn-fill:active {
        transform: translateY(0); /* تأثير الضغط */
        filter: brightness(0.9);
    }

/* تحديث لون الأيقونة والحدود في شريط المعاينة ليتماشى مع الأزرق الجديد */
.icon-circle, .preview-item i {
    color: #006837 !important;
    background: rgba(0, 86, 179, 0.1) !important;
}

.mini-preview-bar {
    border-right: 4px solid #006837 !important; /* تغيير الجهة لليمين لأننا في RTL */
    border-left: none !important;
}

/* Animation */
.animate-pop { animation: modalShow 0.2s ease-out; }
@keyframes modalShow {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* ستايلات بوب التأكيد */
.confirm-icon {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    font-size: 40px;
}

    /* حالة الإيقاف (أحمر) */
    .confirm-icon.to-deactivate {
        background: #fee2e2;
        color: #ef4444;
    }

    /* حالة التفعيل (أخضر سعودي) */
    .confirm-icon.to-activate {
        background: var(--accent-light);
        color: var(--accent);
    }

/* ألوان أزرار التأكيد */
.btn-danger {
    background: #ef4444 !important;
}

    .btn-danger:hover {
        background: #dc2626 !important;
    }

.btn-success {
    background: var(--accent) !important;
}





/* سهم التوسيع */
.expand-btn-arrow {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    transition: transform 0.3s ease;
    padding: 5px;
    display: flex;
    align-items: center;
}

    .expand-btn-arrow.rotated {
        transform: rotate(-90deg); /* يتجه لأسفل في RTL */
        color: var(--accent);
    }

/* استايل صف الفروع */
.branch-row {
    background: rgba(0, 0, 0, 0.015); /* تظليل خفيف جداً لتمييزه */
}

.branch-cell-indent {
    position: relative;
    padding-right: 45px !important; /* إزاحة جهة اليمين */
}

/* خط الربط البصري بين المنشأة وفرعها */
.branch-line-connector {
    position: absolute;
    right: 22px;
    top: -20px;
    bottom: 50%;
    width: 2px;
    border-right: 2px dashed var(--border-color);
}

.branch-avatar-mini {
    width: 32px !important;
    height: 32px !important;
    background: var(--bg-app) !important;
    color: var(--text-muted) !important;
    box-shadow: none !important;
    border: 1px solid var(--border-color);
    font-size: 1rem !important;
}

.branch-name-text {
    font-size: 0.9rem !important;
    color: var(--text-main);
}

.add-branch-btn:hover {
    color: var(--accent) !important;
    border-color: var(--accent) !important;
}

/* Animation لظهور الفروع */
.animate-slide-down {
    animation: slideIn 0.2s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* نقطة الحالة للفروع */
.branch-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    margin-left: 5px;
}

    .branch-status-dot.online {
        background: var(--accent);
    }

    .branch-status-dot.offline {
        background: #ef4444;
    }