/* =========================================
   سامانه داروخانه نصرت - فایل استایل جامع و مرکزی
   نسخه: پرمیوم و بهینه‌سازی شده (v9.0)
========================================= */

/* --- تعریف متغیرهای رنگی تم جدید (قرمز مدرن) --- */
:root { 
    --app-bg: #f8fafc; /* پس‌زمینه بسیار روشن و مات */
    --card-bg: #ffffff; 
    --text-main: #1e293b; /* خاکستری خیلی تیره برای متن اصلی */
    --text-muted: #64748b; /* خاکستری متوسط برای متن‌های فرعی */
    
    /* رنگ سازمانی جدید (قرمز) */
    --primary: #e53e3e; 
    --primary-hover: #c53030;
    --primary-shadow: rgba(229, 62, 62, 0.2);
    
    --input-bg: #f1f5f9; /* خاکستری روشن برای پس‌زمینه اینپوت */
    --border-soft: #e2e8f0; 
    
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;
    --info-bg: #eff6ff;
    --info-text: #1e40af;

    /* سایه استاندارد نرم */
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.04);
    --shadow-md: 0 10px 25px -5px rgba(0,0,0,0.05), 0 8px 10px -6px rgba(0,0,0,0.03);
    --shadow-lg: 0 20px 40px -10px rgba(0,0,0,0.07);
    
    /* انیمیشن استاندارد */
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* =========================================
   تایپوگرافی و فونت اختصاصی سایت
========================================= */
@font-face {
    font-family: 'MyCustomFont';
    /* مسیر زیر به مرورگر می‌گوید از پوشه css یک قدم به عقب ب (اگر پسوند فایل شما woff است، ttf را به woff تغییر دهید) 
    */
    src: url('../fonts/myfont.woff2') format('truetype');
    font-weight: normal;
    font-style: normal;
}

html, body {
    width: 100%; max-width: 100vw; overflow-x: hidden;
    margin: 0; padding: 0;
    background-color: var(--app-bg); color: var(--text-main);
    font-size: 16px;
    scroll-behavior: smooth;
}

* { 
    box-sizing: border-box; 
    /* نام فونت شما در اینجا اعمال می‌شود */
    font-family: 'MyCustomFont', system-ui, -apple-system, Tahoma, sans-serif !important; 
    -webkit-tap-highlight-color: transparent; 
    outline: none;
}
/* --- کانتینرها و کارت‌ها --- */
.container { 
    width: 100%; max-width: 600px; 
    margin: 0 auto; padding: 20px 15px 100px 15px; /* پدینگ پایین برای منوی موبایل */
}

.app-card {
    background-color: var(--card-bg);
    border-radius: 24px; /* گوشه‌های گردتر و نرم‌تر */
    padding: 25px;
    box-shadow: var(--shadow-md);
    margin-bottom: 20px;
    width: 100%;
    border: 1px solid rgba(226, 232, 240, 0.5); /* حاشیه بسیار محو */
    transition: var(--transition);
}
.app-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }

.section-title { font-size: 1.1rem; font-weight: 800; margin-bottom: 25px; display: flex; align-items: center; gap: 10px; color: var(--text-main); }
.section-title span { background-color: #fee2e2; color: var(--primary); width: 35px; height: 35px; display: flex; align-items: center; justify-content: center; border-radius: 10px; font-size: 1.1rem; }

/* --- فرم‌ها و ورودی‌ها (اصلاح شده و راست‌چین) --- */
.form-row { display: flex; gap: 20px; flex-wrap: wrap; }
.form-group { margin-bottom: 18px; flex: 1; min-width: 240px; width: 100%; text-align: right; }

.form-label { display: block; font-size: 0.9rem; font-weight: 700; color: var(--text-main); margin-bottom: 10px; text-align: right; }

.form-control, .form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 16px; border-radius: 16px; 
    border: 2px solid transparent; /* حذف کادر پیش‌فرض */
    background-color: var(--input-bg); color: var(--text-main); 
    font-size: 0.95rem; text-align: right; /* راست‌چین قطعی */
    transition: var(--transition);
}

.form-control:focus, .form-group input:focus, .form-group select:focus {
    background-color: var(--card-bg); 
    border-color: var(--primary); 
    box-shadow: 0 0 0 4px var(--primary-shadow); 
}

/* اصلاح پلیس‌هولدر (مثال: علی احمدی) */
.form-control::placeholder, input::placeholder { color: #a0aec0; text-align: right; }

/* باکس راهنمای "توجه" (Alert Inline) */
.auth-container p:not(.auth-header p), .info-box {
    background-color: var(--info-bg); color: var(--info-text); 
    padding: 15px; border-radius: 14px; 
    font-size: 0.85rem; line-height: 1.8; text-align: right; 
    margin-bottom: 25px; border: 1px solid #bfdbfe;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
}

/* --- دکمه‌ها (فیکس شده و شیک) --- */
.btn-app, .btn-primary, .btn-submit {
    width: 100%; background-color: var(--primary); color: white !important; 
    border: none; padding: 18px; border-radius: 16px; 
    font-weight: 700; font-size: 1rem; cursor: pointer;
    box-shadow: 0 8px 20px var(--primary-shadow); 
    transition: var(--transition);
    text-align: center; display: block;
}

.btn-app:hover, .btn-primary:hover, .btn-submit:hover { 
    background-color: var(--primary-hover); 
    transform: translateY(-3px); 
    box-shadow: 0 12px 25px var(--primary-shadow); 
}
.btn-app:active, .btn-primary:active, .btn-submit:active { transform: translateY(-1px) scale(0.98); }

.btn-outline {
    width: 100%; background-color: transparent; color: var(--primary) !important; 
    border: 2px solid var(--primary); padding: 16px; border-radius: 16px; 
    font-weight: 700; font-size: 1rem; text-align: center; display: block;
    transition: var(--transition);
}
.btn-outline:hover { background-color: #fee2e2; transform: translateY(-2px); }

/* --- صفحه اول (Landing) --- */
.site-header { background-color: rgba(255, 255, 255, 0.9); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border-soft); padding: 15px 5%; display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; z-index: 100; box-shadow: var(--shadow-sm); }
.logo-box { display: flex; align-items: center; gap: 12px; }
.logo-icon { font-size: 1.8rem; }
.logo-text { font-size: 1.3rem; font-weight: 900; color: var(--text-main); }
.logo-text span { color: var(--primary); }
.header-contact { font-size: 0.9rem; display: flex; align-items: center; gap: 8px; background: var(--input-bg); padding: 10px 18px; border-radius: 50px; border: 1px solid var(--border-soft); color: var(--text-muted); }

.main-content { flex: 1; display: flex; align-items: center; justify-content: center; padding: 60px 20px; min-height: 80vh;}
.hero-container { background: #ffffff; border-radius: 30px; padding: 4rem 3rem; max-width: 500px; width: 100%; text-align: center; box-shadow: var(--shadow-lg); border: 1px solid rgba(226, 232, 240, 0.6); }
.hero-icon { font-size: 4rem; margin-bottom: 1.5rem; display: inline-block; filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1)); }
.title { font-size: 2rem; font-weight: 900; margin-bottom: 1rem; color: var(--text-main); letter-spacing: -0.5px; }
.subtitle { color: var(--text-muted); font-size: 1rem; line-height: 1.8; margin-bottom: 3rem; font-weight: 500;}

.site-footer { background-color: #ffffff; border-top: 1px solid var(--border-soft); padding: 50px 5% 30px; margin-top: auto; }
.footer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 40px; margin-bottom: 40px; text-align: right; }
.footer-col h3 { color: var(--primary); font-size: 1.15rem; margin-bottom: 20px; font-weight: 800; display: inline-block; padding-bottom: 5px; border-bottom: 3px solid #fee2e2; }
.footer-col p { color: var(--text-muted); font-size: 0.95rem; line-height: 1.9; margin-bottom: 10px; }
.footer-bottom { text-align: center; border-top: 1px solid var(--border-soft); padding-top: 25px; color: var(--text-muted); font-size: 0.85rem; font-weight: 500;}

/* --- صفحات احراز هویت (Login/Register) --- */
.auth-wrapper { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; background: linear-gradient(135deg, #f8fafc 0%, #fee2e2 100%); }
.auth-container { background-color: var(--card-bg); width: 100%; max-width: 450px; padding: 3rem 2.5rem; border-radius: 28px; box-shadow: var(--shadow-lg); border: 1px solid rgba(226, 232, 240, 0.7); margin: auto; text-align: right; }
.auth-header { text-align: center; margin-bottom: 2.5rem; }
.auth-header h2 { font-size: 1.6rem; margin-bottom: 0.8rem; font-weight: 900; color: var(--text-main); }
.auth-header p { color: var(--text-muted); font-size: 0.9rem; font-weight: 500; }
.link-text { text-align: center; margin-top: 2rem; font-size: 0.9rem; color: var(--text-muted); font-weight: 500; }
.link-text a { color: var(--primary); font-weight: 700; }
.link-text a:hover { text-decoration: underline; }

/* --- صفحه انتخاب پرونده (Profile Selector) --- */
.app-bar { background-color: rgba(255, 255, 255, 0.95); backdrop-filter: blur(10px); padding: 20px; text-align: center; border-bottom-left-radius: 24px; border-bottom-right-radius: 24px; box-shadow: var(--shadow-sm); margin-bottom: 25px; width: 100%; position: sticky; top: 0; z-index: 50; border-bottom: 1px solid var(--border-soft); }
.app-bar h1 { font-size: 1.25rem; font-weight: 900; color: var(--text-main); margin-bottom: 6px; }
.app-bar p { font-size: 0.85rem; color: var(--text-muted); font-weight: 500; }

.profiles-list { display: flex; flex-direction: column; gap: 15px; margin-bottom: 35px; }
.profile-card { background-color: var(--card-bg); border: 1px solid var(--border-soft); border-radius: 20px; padding: 18px; display: flex; align-items: center; box-shadow: var(--shadow-sm); transition: var(--transition); }
.profile-card:hover { transform: scale(1.02); box-shadow: var(--shadow-md); border-color: var(--primary); }
.profile-card:active { transform: scale(0.98); }

.profile-avatar { width: 55px; height: 55px; background-color: #fee2e2; color: var(--primary); border-radius: 18px; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; font-weight: 900; margin-left: 18px; border: 1px solid #fecaca; }
.profile-info { flex: 1; text-align: right; }
.profile-name { font-weight: 800; font-size: 1.05rem; margin-bottom: 5px; color: var(--text-main); }
.profile-role { font-size: 0.8rem; color: var(--text-muted); font-weight: 600; background: var(--input-bg); display: inline-block; padding: 3px 8px; border-radius: 6px; }
.profile-arrow { color: var(--text-muted); font-size: 1.3rem; margin-right: 10px; opacity: 0.5; }

.logout-link { display: block; text-align: center; color: var(--error); font-weight: 700; font-size: 0.95rem; margin-top: 25px; padding: 12px; border-radius: 12px; transition: var(--transition); }
.logout-link:hover { background-color: #fef2f2; }

/* --- ویسجت‌های شناور (Chat & eNamad) --- */
.chat-widget-btn { position: fixed; bottom: 85px; left: 25px; width: 65px; height: 65px; background-color: #dc2626; color: white; border-radius: 50%; display: flex; justify-content: center; align-items: center; font-size: 1.9rem; box-shadow: 0 8px 25px rgba(220, 38, 38, 0.4); cursor: pointer; z-index: 1000; transition: var(--transition); border: 2px solid white; }
.chat-widget-btn:hover { transform: scale(1.1) rotate(5deg); background-color: #b91c1c; }
.chat-box { position: fixed; bottom: 165px; right: 25px; width: 360px; height: 500px; background: var(--card-bg); border-radius: 28px; box-shadow: var(--shadow-lg); border: 1px solid var(--border-soft); display: none; flex-direction: column; z-index: 1000; overflow: hidden; transition: var(--transition); }
.chat-box.active { display: flex; animation: slideIn 0.4s ease forwards; }

/* =========================================
   Floating e-Namad (Left Aligned - Fixed Size)
========================================= */
.floating-enamad { 
    position: fixed; 
    bottom: 40px; /* کمی پایین‌تر آوردم تا تو صفحه اصلی زیباتر بشه */
    left: 25px; 
    z-index: 990; 
    background: #ffffff; 
    border: 1px solid var(--border-soft); 
    border-radius: 16px; 
    box-shadow: var(--shadow-md); 
    padding: 8px; 
    width: 115px; /* عرض استاندارد برای خوانا بودن اینماد */
    transition: var(--transition); 
    display: flex; 
    justify-content: center; 
    align-items: center; 
}

.floating-enamad:hover { 
    transform: scale(1.05) translateY(-5px); 
    box-shadow: var(--shadow-lg); 
}

.floating-enamad a {
    display: block;
    width: 100%;
}

.floating-enamad img { 
    width: 100% !important; 
    height: auto !important; 
    object-fit: contain; /* جلوگیری از کش آمدن یا دفرمه شدن عکس */
    display: block; 
    border-radius: 8px;
}

@media (max-width: 600px) {
    .floating-enamad { width: 95px; bottom: 30px; left: 15px; padding: 6px; }
}

/* --- پاپ‌آپ‌ها و مدال‌ها --- */
.modal-overlay { background: rgba(15, 23, 42, 0.7); backdrop-filter: blur(5px); transition: var(--transition); }
.modal-box { border-radius: 28px; padding: 30px; box-shadow: var(--shadow-lg); border: 1px solid var(--border-soft); animation: modalIn 0.3s ease; }

/* --- انیمیشن‌ها --- */
@keyframes slideIn { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes modalIn { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* --- بهینه‌سازی موبایل --- */
@media (max-width: 600px) {
    body { font-size: 15px; }
    .container { padding: 15px 10px 90px 10px; }
    .hero-container, .auth-container, .app-card { padding: 2rem 1.5rem; border-radius: 20px; }
    .title { font-size: 1.7rem; }
    .form-row { gap: 0; }
    .chat-box { width: calc(100% - 40px); bottom: 160px; right: 20px; left: 20px; height: 450px;}
    .chat-widget-btn { width: 60px; height: 60px; bottom: 85px; right: 20px; }
    .floating-enamad { width: 70px; bottom: 85px; left: 20px; padding: 8px; }
    .site-header { padding: 12px 15px; }
    .logo-text { font-size: 1.1rem; }
    .header-contact { display: none; }
}
/* =========================================
   داشبوردها (پنل ادمین و اپراتور) - جداول و آمار
========================================= */

/* کارت‌های آماری بالای پنل (Stat Cards) */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-bottom: 30px; }
.stat-card { background: var(--card-bg); padding: 20px; border-radius: 20px; box-shadow: var(--shadow-sm); border: 1px solid var(--border-soft); display: flex; align-items: center; gap: 15px; transition: var(--transition); }
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.stat-icon { font-size: 2.2rem; background: #f8fafc; width: 65px; height: 65px; display: flex; align-items: center; justify-content: center; border-radius: 18px; border: 1px solid var(--border-soft); }
.stat-info { flex: 1; text-align: right; }
.stat-value { font-size: 1.6rem; font-weight: 900; color: var(--text-main); margin-bottom: 2px; }
.stat-title { font-size: 0.85rem; color: var(--text-muted); font-weight: 600; }

/* جداول اطلاعات (بیماران، داروها و...) */
.table-responsive { width: 100%; overflow-x: auto; background: var(--card-bg); border-radius: 20px; box-shadow: var(--shadow-sm); border: 1px solid var(--border-soft); margin-bottom: 25px; }
.table { width: 100%; border-collapse: collapse; min-width: 650px; text-align: right; }
.table th { background: #f8fafc; color: var(--text-muted); font-weight: 800; font-size: 0.9rem; padding: 18px 20px; border-bottom: 2px solid var(--border-soft); white-space: nowrap; }
.table td { padding: 16px 20px; font-size: 0.95rem; color: var(--text-main); border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr { transition: var(--transition); }
.table tbody tr:hover { background: #f1f5f9; }

/* نشان‌ها و برچسب‌های نقش و وضعیت (Badges) */
.badge { padding: 6px 14px; border-radius: 10px; font-size: 0.8rem; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; white-space: nowrap; }
.badge-admin { background: #fee2e2; color: #dc2626; border: 1px solid #fecaca; }
.badge-operator { background: #e0e7ff; color: #4f46e5; border: 1px solid #c7d2fe; }
.badge-bimar { background: #f1f5f9; color: #64748b; border: 1px solid #e2e8f0; }
.badge-success { background: #d1fae5; color: #059669; border: 1px solid #a7f3d0; }
.badge-warning { background: #fef3c7; color: #d97706; border: 1px solid #fde68a; }

/* دکمه‌های کوچک اکشن در جداول (ویرایش/حذف) */
.action-buttons { display: flex; gap: 8px; align-items: center; }
.btn-sm { padding: 8px 15px; border-radius: 10px; font-size: 0.85rem; font-weight: 700; text-decoration: none; cursor: pointer; border: none; display: inline-flex; align-items: center; justify-content: center; transition: var(--transition); }
.btn-edit { background: #eff6ff; color: #2563eb; border: 1px solid #bfdbfe; }
.btn-edit:hover { background: #dbeafe; transform: translateY(-2px); }
.btn-delete { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.btn-delete:hover { background: #fee2e2; transform: translateY(-2px); }

/* نوار جستجو در پنل مدیریت */
.search-box { display: flex; gap: 10px; margin-bottom: 20px; }
.search-box input { flex: 1; padding: 14px 20px; border-radius: 14px; border: 1px solid var(--border-soft); background: var(--input-bg); outline: none; font-size: 0.95rem; }
.search-box input:focus { border-color: var(--primary); background: white; box-shadow: 0 0 0 3px var(--primary-shadow); }
.search-box button { padding: 14px 25px; border-radius: 14px; background: var(--primary); color: white; border: none; font-weight: 700; cursor: pointer; transition: var(--transition); }
.search-box button:hover { background: var(--primary-hover); transform: translateY(-2px); }
/* =========================================
 /* =========================================
   نوار دسترسی پایین (Bottom Navigation) - نسخه ظریف و باریک
========================================= */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(15px);
    box-shadow: 0 -4px 20px rgba(0,0,0,0.06);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 6px 10px 8px 10px; /* پدینگ‌ها به شدت کم شد */
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    z-index: 1000;
    border-top: 1px solid var(--border-soft);
}
.bottom-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.65rem; /* فونت متن کوچکتر شد */
    font-weight: 800;
    gap: 3px; /* فاصله بین آیکون و متن کم شد */
    transition: all 0.3s ease;
}
.bottom-nav a span.nav-icon {
    font-size: 1.2rem; /* سایز آیکون‌ها کوچکتر شد */
    transition: transform 0.3s ease;
}
.bottom-nav a:hover, .bottom-nav a.active {
    color: var(--primary);
}
.bottom-nav a:hover span.nav-icon {
    transform: translateY(-2px);
}

/* فاصله دادن به محتوای اصلی تا زیر منو مخفی نشود */
.bimar-panel-body {
    padding-bottom: 65px !important; /* فضای پایین صفحه هم کمتر شد */
}
/* =========================================
   ویجت چت شناور (پنل بیمار)
========================================= */
.chat-widget-btn {
    position: fixed;
    bottom: 85px; /* قرارگیری دقیق بالای منوی اپلیکیشنی پایین */
    left: 20px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #dc2626, #ef4444);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    cursor: pointer;
    box-shadow: 0 5px 20px rgba(220, 38, 38, 0.4);
    z-index: 1000;
    transition: transform 0.3s ease;
}
.chat-widget-btn:hover {
    transform: scale(1.1);
}

.chat-widget-window {
    position: fixed;
    bottom: 160px;
    left: 20px;
    width: 340px;
    height: 450px;
    background: white;
    border-radius: 24px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    display: none; /* در حالت عادی مخفی است */
    flex-direction: column;
    overflow: hidden;
    z-index: 1001;
    border: 1px solid var(--border-soft);
}
.chat-widget-window.active {
    display: flex; /* با کلیک روی دکمه، این کلاس اضافه می‌شود */
}

.chat-widget-header {
    background: linear-gradient(135deg, #1e293b, #0f172a);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 800;
    font-size: 1.05rem;
}
.chat-widget-close {
    cursor: pointer;
    font-size: 1.2rem;
    opacity: 0.8;
    transition: 0.3s;
}
.chat-widget-close:hover { opacity: 1; color: #ef4444; }

.chat-widget-body {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-widget-footer {
    padding: 15px;
    background: white;
    border-top: 1px solid var(--border-soft);
    display: flex;
    gap: 10px;
}
.chat-widget-input {
    flex: 1;
    padding: 12px 15px;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    outline: none;
    background: #f8fafc;
    font-family: inherit;
    font-size: 0.9rem;
    transition: 0.3s;
}
.chat-widget-input:focus {
    border-color: #3b82f6;
    background: white;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}
.chat-widget-send {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    border: none;
    width: 50px;
    border-radius: 14px;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.3s;
}
.chat-widget-send:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(37, 99, 235, 0.3);
}