/* ========================================
   الأنماط الأساسية لنظام النبض الطبي
   ======================================== */

/* متغيرات الألوان الموحدة */
:root {
    --primary-color: #0d9488;
    --primary-dark: #0f766e;
    --primary-light: #ccfbf1;
    --secondary-color: #3b82f6;
    --secondary-light: #dbeafe;
    --accent-color: #f59e0b;
    --accent-light: #fef3c7;
    --danger-color: #ef4444;
    --success-color: #10b981;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    --bg-body: #f8fafc;
    --bg-white: #ffffff;
    --border-color: #e2e8f0;
    --card-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    --card-shadow-hover: 0 8px 30px rgba(0, 0, 0, 0.12);
    --radius: 12px;
    --transition: all 0.3s ease;
    --sidebar-width: 260px;
    --sidebar-collapsed: 70px;
}

/* ===== إعادة تعيين الأنماط ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', 'Tahoma', 'Cairo', sans-serif;
    background: var(--bg-body);
    color: var(--text-main);
    direction: rtl;
    line-height: 1.6;
}

a {
    text-decoration: none;
    color: inherit;
}

/* ===== الهيكل العام ===== */
.wrapper {
    display: flex;
    min-height: 100vh;
}

/* ===== الشريط الجانبي ===== */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #0f766e 0%, #0d9488 100%);
    color: white;
    padding: 20px 0;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    box-shadow: 2px 0 15px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    transition: width 0.3s ease;
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}
.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
}

.sidebar-brand {
    padding: 20px 25px;
    font-size: 1.5rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 20px;
}

.sidebar-brand i {
    font-size: 2rem;
}

.sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-menu li {
    padding: 0;
    margin: 2px 10px;
    border-radius: 10px;
    transition: var(--transition);
}

.sidebar-menu li a {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    border-radius: 10px;
    transition: var(--transition);
    font-weight: 500;
}

.sidebar-menu li a i {
    margin-left: 12px;
    width: 20px;
    text-align: center;
    font-size: 1.1rem;
}

.sidebar-menu li.active {
    background: rgba(255, 255, 255, 0.15);
}

.sidebar-menu li.active a {
    color: white;
}

.sidebar-menu li:hover:not(.active) {
    background: rgba(255, 255, 255, 0.08);
}

.sidebar-menu li:hover a {
    color: white;
}

/* ===== المحتوى الرئيسي ===== */
.main-content {
    flex: 1;
    margin-right: var(--sidebar-width);
    padding: 20px 30px;
    min-height: 100vh;
    transition: margin-right 0.3s ease;
}

/* ===== الهيدر العلوي ===== */
.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-white);
    padding: 15px 25px;
    border-radius: var(--radius);
    box-shadow: var(--card-shadow);
    margin-bottom: 25px;
}

.top-header .header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.top-header .header-left .toggle-sidebar {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 5px 10px;
    border-radius: 8px;
    transition: var(--transition);
}

.top-header .header-left .toggle-sidebar:hover {
    background: var(--bg-body);
    color: var(--primary-color);
}

.top-header .header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.header-search {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    padding: 5px 12px;
    border-radius: 8px;
    transition: var(--transition);
}

.user-profile:hover {
    background: var(--bg-body);
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.1rem;
}

/* ===== عنوان الصفحة ===== */
.page-title {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 3px solid var(--primary-color);
}

/* ===== بطاقات الإحصائيات ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--bg-white);
    padding: 20px 24px;
    border-radius: var(--radius);
    box-shadow: var(--card-shadow);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-right: 4px solid var(--primary-color);
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--card-shadow-hover);
}

.stat-card.blue-card {
    border-right-color: var(--secondary-color);
}

.stat-card.amber-card {
    border-right-color: var(--accent-color);
}

.stat-card.green-card {
    border-right-color: var(--success-color);
}

.stat-card.purple-card {
    border-right-color: #8b5cf6;
}

.stat-card.red-card {
    border-right-color: var(--danger-color);
}

.stat-info h3 {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0 0 4px 0;
    font-weight: 500;
}

.stat-info p {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    margin: 0;
}

.stat-icon {
    font-size: 2rem;
    color: var(--text-muted);
    opacity: 0.3;
}

/* ===== تنسيق الصفوف ===== */
.dashboard-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

/* ===== الجداول ===== */
.table-responsive {
    background: var(--bg-white);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--card-shadow);
    overflow-x: auto;
}

.custom-table {
    width: 100%;
    border-collapse: collapse;
}

.custom-table thead {
    background: #f1f5f9;
}

.custom-table thead th {
    padding: 12px 16px;
    text-align: right;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.custom-table tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
    vertical-align: middle;
}

.custom-table tbody tr:hover {
    background: #f8fafc;
}

.custom-table tbody tr:last-child td {
    border-bottom: none;
}

/* ===== الشارات ===== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-success {
    background: #dcfce7;
    color: #166534;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

.badge-info {
    background: #dbeafe;
    color: #1e40af;
}

.badge-primary {
    background: var(--primary-light);
    color: var(--primary-dark);
}

.badge-gray {
    background: #f1f5f9;
    color: var(--text-muted);
}

/* ===== الأزرار ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 24px;
    border-radius: 8px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.95rem;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(13, 148, 136, 0.3);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background: #2563eb;
    transform: translateY(-2px);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--border-color);
    color: var(--text-main);
}

.btn-outline:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-block {
    display: block;
    width: 100%;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.85rem;
}

.btn-lg {
    padding: 14px 32px;
    font-size: 1.1rem;
}

/* ===== نماذج الإدخال ===== */
.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-main);
    font-size: 0.95rem;
}

.form-group label .required {
    color: var(--danger-color);
    margin-right: 4px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: var(--transition);
    background: var(--bg-white);
    color: var(--text-main);
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(13, 148, 136, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-group .help-text {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ===== تنبيهات ===== */
.alert {
    padding: 15px 20px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.alert i {
    font-size: 1.5rem;
}

.alert-success {
    background: #dcfce7;
    border: 1px solid #86efac;
    color: #166534;
}

.alert-info {
    background: #dbeafe;
    border: 1px solid #93c5fd;
    color: #1e40af;
}

.alert-warning {
    background: #fef3c7;
    border: 1px solid #fcd34d;
    color: #92400e;
}

.alert-danger {
    background: #fee2e2;
    border: 1px solid #fca5a5;
    color: #991b1b;
}

/* ===== كود المندوب ===== */
.code-display {
    display: inline-block;
    background: #f1f5f9;
    padding: 4px 14px;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    font-weight: 700;
    color: var(--primary-dark);
    font-size: 1rem;
    direction: ltr;
    letter-spacing: 1px;
}

/* ===== الفوتر ===== */
.main-footer {
    margin-top: 30px;
    padding: 20px 0;
    text-align: center;
    color: var(--text-muted);
    border-top: 1px solid var(--border-color);
}

.main-footer p {
    margin: 0;
}

/* ===== الأدوات المساعدة ===== */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.text-left {
    text-align: left;
}

.text-muted {
    color: var(--text-muted);
}

.text-primary {
    color: var(--primary-color);
}

.text-success {
    color: var(--success-color);
}

.text-danger {
    color: var(--danger-color);
}

.mt-10 {
    margin-top: 10px;
}

.mt-20 {
    margin-top: 20px;
}

.mb-10 {
    margin-bottom: 10px;
}

.mb-20 {
    margin-bottom: 20px;
}

.p-20 {
    padding: 20px;
}

.p-30 {
    padding: 30px;
}

.flex {
    display: flex;
}

.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.flex-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.flex-column {
    flex-direction: column;
}

.gap-10 {
    gap: 10px;
}

.gap-20 {
    gap: 20px;
}

.w-100 {
    width: 100%;
}

.rounded {
    border-radius: var(--radius);
}

.shadow {
    box-shadow: var(--card-shadow);
}

/* ===== إخفاء العناصر ===== */
.d-none {
    display: none !important;
}

.d-block {
    display: block !important;
}

/* ===== حالة الشاشة الصغيرة ===== */
@media (max-width: 992px) {
    .sidebar {
        width: var(--sidebar-collapsed);
    }

    .sidebar-brand span,
    .sidebar-menu li a span {
        display: none;
    }

    .sidebar-menu li a {
        justify-content: center;
        padding: 14px;
    }

    .sidebar-menu li a i {
        margin: 0;
        font-size: 1.3rem;
    }

    .main-content {
        margin-right: var(--sidebar-collapsed);
        padding: 15px;
    }

    .dashboard-row {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .stat-card {
        padding: 14px 16px;
    }

    .stat-info h3 {
        font-size: 0.75rem;
    }

    .stat-info p {
        font-size: 1.1rem;
    }

    .stat-icon {
        font-size: 1.5rem;
    }

    .top-header {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
        padding: 12px 16px;
    }

    .top-header .header-right {
        justify-content: space-between;
    }

    .page-title {
        font-size: 1.3rem;
    }

    .table-responsive {
        padding: 12px;
    }

    .custom-table th,
    .custom-table td {
        padding: 8px 10px;
        font-size: 0.85rem;
    }

    .main-content {
        padding: 10px;
        margin-right: 0;
    }

    .sidebar {
        width: 0;
        overflow: hidden;
        padding: 0;
    }

    .sidebar.open {
        width: 280px;
        padding: 20px 0;
        overflow-y: auto;
    }

    .sidebar.open .sidebar-brand span,
    .sidebar.open .sidebar-menu li a span {
        display: inline;
    }

    .sidebar.open .sidebar-menu li a {
        justify-content: flex-start;
        padding: 12px 20px;
    }

    .sidebar.open .sidebar-menu li a i {
        margin-left: 12px;
        font-size: 1.1rem;
    }
}

/* ===== تأثيرات حركية ===== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.5s ease;
}

@keyframes pulse {
    0%,
    100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.pulse {
    animation: pulse 2s infinite;
}