/**
 * assets/css/style.css
 * نسخه نهایی و فوق حرفه‌ای پلاتینیوم (فاز ۱۱.۸ - نهایی‌سازی طاها تایم)
 * ---------------------------------------------------
 * سیستم طراحی: Glassmorphism / Modern Dark UI
 * هدف: پایداری کامل در موبایل و دسکتاپ (Responsive Excellence)
 */

@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;700;900&display=swap');

/* =========================================
   1. متغیرهای سیستمی (Design Tokens)
   ========================================= */
:root {
    /* پالت رنگی اصلی پلاتینیوم */
    --primary: #6366f1;       /* Indigo */
    --primary-glow: rgba(99, 102, 241, 0.4);
    --primary-hover: #4f46e5;
    
    --success: #10b981;       /* Emerald */
    --success-bg: rgba(16, 185, 129, 0.1);
    
    --danger: #ef4444;        /* Rose */
    --danger-bg: rgba(239, 68, 68, 0.1);
    
    --warning: #f59e0b;       /* Amber */
    --warning-bg: rgba(245, 158, 11, 0.1);
    
    --info: #0ea5e9;          /* Sky */
    /* رنگ آبی پررنگ برای دکمه ثانویه */
    --secondary: #1565c0;
    --secondary-hover: #0d47a1;
    --secondary-glow: rgba(21, 101, 192, 0.12);
    
    /* رنگ‌های متن */
    --text-main: #f8fafc;     /* متن روشن اصلی */
    --text-muted: #94a3b8;    /* متن خاکستری/توضیحات */
    --text-dim: #64748b;      /* متن بسیار کم‌رنگ */

    /* تنظیمات شیشه‌ای (Glassmorphism Core) */
    --glass-bg: rgba(15, 23, 42, 0.6);
    --glass-card: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
    --blur-std: 12px;
    --blur-heavy: 20px;

    /* پس‌زمینه اصلی */
    --bg-gradient: radial-gradient(circle at top right, #1e1b4b 0%, #0f172a 100%);
}

/* =========================================
   2. ریست و تنظیمات پایه (Global Resets)
   ========================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent; /* حذف هایلایت آبی کلیک در موبایل */
    outline: none;
}

html, body {
    width: 100%;
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto; /* آزاد کردن اسکرول و رفرش موبایل */
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: auto;
}

body {
    font-family: 'Vazirmatn', sans-serif;
    background: var(--bg-gradient);
    color: var(--text-main);
    line-height: 1.6;
    direction: rtl;
    user-select: none; /* جلوگیری از سلکت تصادفی در اپ موبایل */
}

section {
    min-height: 100vh;
    height: auto; /* اجازه اسکرول عمودی */
    display: flex;
    flex-direction: column;
}

input, textarea, select {
    user-select: text; /* فعال کردن سلکت فقط برای فیلدها */
    font-family: inherit;
}

/* اسکرول‌بار مدرن و ظریف */
::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

.hidden {
    display: none !important;
}

/* =========================================
   3. کانتینر اصلی و لایه‌بندی (Layout)
   ========================================= */
.app-container {
    width: 100%;
    min-height: 100vh;
    height: auto; /* آزاد کردن اسکرول عمودی */
    max-width: 1280px;
    margin: 0 auto;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* پنل‌های شیشه‌ای */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--blur-heavy));
    -webkit-backdrop-filter: blur(var(--blur-heavy));
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
}

.glass-card {
    background: var(--glass-card);
    border: 1px solid var(--glass-border);
    border-radius: 18px;
    padding: 20px;
    margin-bottom: 20px;
    backdrop-filter: blur(var(--blur-std));
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), background 0.3s;
}

.glass-card:hover {
    background: rgba(255, 255, 255, 0.08);
}

/* =========================================
   4. هدرهای داشبورد (Header Design)
   ========================================= */
.glass-header {
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-bottom: 1px solid var(--glass-border);
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
    flex-shrink: 0;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar-sm {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    border: 2px solid var(--primary);
    background: #fff;
    object-fit: cover;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.user-info h3 {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 2px;
}

.date-badge {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 8px;
    border-radius: 6px;
}

.admin-badge {
    background: var(--primary-bg);
    color: var(--primary);
    font-size: 0.7rem;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid var(--primary);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 4px;
}

/* =========================================
   5. صفحه ورود (Login View)
   ========================================= */
#login-view {
    display: block;          /* override section flex */
    height: auto;            /* جلوگیری از کشیده شدن عمودی */
    width: min(92%, 420px);
    max-width: 420px;
    margin: 56px auto;
    padding: 32px 28px;
    text-align: center;
    border-radius: 28px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.35);
}

.login-header img.logo-img {
    width: 100px;
    height: 100px;
    margin: 0 auto 20px;
    border-radius: 50%;
    border: 4px solid var(--primary);
    box-shadow: 0 0 30px var(--primary-glow);
    background: #fff;
    padding: 5px;
}

.login-header h1 { font-size: 1.8rem; font-weight: 900; color: #fff; letter-spacing: -1px; }
.login-header p { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 30px; }

#login-view form { display: flex; flex-direction: column; gap: 14px; }
#login-view .input-group { margin-bottom: 0; }
#login-view .input-group input {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #e2e8f0;
    padding: 14px 48px 14px 16px;
    border-radius: 14px;
}
#login-view .input-group i { color: #cbd5e1; }
#login-view .input-group input:focus {
    background: rgba(255, 255, 255, 0.12);
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.18);
}
#login-view .btn-primary {
    width: 100%;
    padding: 14px;
    font-size: 1.05rem;
    border-radius: 16px;
    box-shadow: 0 12px 30px rgba(99, 102, 241, 0.28);
}
#login-view .btn-primary:active { transform: translateY(1px); }

.login-footer { margin-top: 18px; }
.login-footer small { color: #cbd5e1; display: block; }

/* =========================================
   6. فرم‌ها و دکمه‌ها (Inputs & Buttons)
   ========================================= */
.input-group {
    position: relative;
    margin-bottom: 15px;
}

.input-group i {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    transition: 0.3s;
}

.input-group input {
    width: 100%;
    padding: 14px 45px 14px 15px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    color: #fff;
    font-size: 1rem;
    transition: 0.3s;
}

.input-group input:focus {
    background: rgba(0, 0, 0, 0.5);
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15);
}

.input-group input:focus + i { color: var(--primary); }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    border-radius: 14px;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: 0.3s;
    color: #fff;
}

.btn:active { transform: scale(0.95); }
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); box-shadow: 0 4px 15px var(--primary-glow); }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-2px); }
.btn-success { background: var(--success); }
.btn-danger { background: var(--danger); }
.btn-secondary {
    background: var(--secondary);
    color: #fff;
    box-shadow: 0 4px 15px var(--secondary-glow);
    transition: background 0.2s, box-shadow 0.2s, transform 0.2s;
}
.btn-secondary:hover, .btn-secondary:focus {
    background: var(--secondary-hover);
    box-shadow: 0 6px 24px var(--secondary-glow);
    transform: translateY(-2px) scale(1.03);
}

.btn-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border: 1px solid var(--glass-border);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: 0.3s;
    position: relative;
}

.btn-icon:hover { background: rgba(255, 255, 255, 0.15); color: var(--primary); }

.notif-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--danger);
    width: 18px;
    height: 18px;
    border-radius: 50%;
    font-size: 0.65rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #0f172a;
    animation: status-pulse 2s infinite;
}

/* =========================================
   7. محتوای داشبورد (Dashboard Content)
   ========================================= */
.dashboard-content {
    flex: 1;
    overflow-y: auto; /* فیکس اسکرول: اسکرول محلی برای داشبورد */
    padding: 20px;
    -webkit-overflow-scrolling: touch; /* اسکرول نرم در iOS */
    min-height: 0; /* جلوگیری از گیر کردن اسکرول در فلکس */
}

/* کارت تایمر پرسنل */
.timer-card {
    text-align: center;
    padding: 35px 20px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.06) 0%, transparent 100%);
}

.status-indicator {
    font-size: 0.85rem;
    color: var(--text-muted);
    background: rgba(0, 0, 0, 0.2);
    padding: 4px 15px;
    border-radius: 20px;
    margin-bottom: 15px;
    display: inline-block;
}

.timer-display {
    font-size: 3.8rem;
    font-weight: 900;
    font-family: 'Courier New', Courier, monospace;
    margin: 15px 0 25px;
    color: #fff;
    text-shadow: 0 0 25px rgba(255, 255, 255, 0.15);
    letter-spacing: 2px;
}

.clock-btn {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    background: var(--success);
    border: 8px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 1.2rem;
    font-weight: 900;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 0 auto;
    transition: 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 10px 30px rgba(16, 185, 129, 0.3);
}

.clock-btn i { font-size: 2.2rem; }
.clock-btn span { font-size: 0.95rem; }

.clock-btn:hover { transform: scale(1.05) rotate(5deg); }
.clock-btn.end-mode { background: var(--danger); box-shadow: 0 10px 30px rgba(239, 68, 68, 0.3); animation: heartbeat 2s infinite; }

/* =========================================
   8. آمار مدیر (Admin Stats & Grid)
   ========================================= */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-bottom: 25px;
}

.stat-card {
    background: var(--glass-card);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.stat-card i {
    width: 50px;
    height: 50px;
    border-radius: 14px;
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-card div span { font-size: 1.5rem; font-weight: 900; display: block; }
.stat-card div small { color: var(--text-muted); font-size: 0.75rem; }

.active-stat i { background: rgba(16, 185, 129, 0.15); color: var(--success); }

/* =========================================
   9. جداول واکنش‌گرا (Modern Tables)
   ========================================= */
.table-responsive { width: 100%; overflow-x: auto; border-radius: 12px; }

.modern-table { width: 100%; border-collapse: collapse; text-align: right; }
.modern-table th { padding: 15px; font-size: 0.8rem; color: var(--text-muted); border-bottom: 1px solid var(--glass-border); }
.modern-table td { padding: 15px; font-size: 0.9rem; border-bottom: 1px solid rgba(255, 255, 255, 0.05); vertical-align: middle; }
.modern-table tr:hover { background: rgba(255, 255, 255, 0.03); }

/* =========================================
   10. گزارش آکاردئونی (Accordions)
   ========================================= */
.accordion-item { border-radius: 15px; overflow: hidden; margin-bottom: 12px; border: 1px solid var(--glass-border); }
.accordion-header { padding: 15px 20px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; background: rgba(255, 255, 255, 0.03); transition: 0.3s; }
.accordion-header:hover { background: rgba(255, 255, 255, 0.07); }
.accordion-title { display: flex; align-items: center; gap: 10px; font-weight: bold; }
.accordion-icon { transition: 0.4s; color: var(--text-muted); }
.accordion-item.active .accordion-icon { transform: rotate(180deg); color: var(--primary); }
.accordion-body { max-height: 0; overflow: hidden; transition: max-height 0.4s ease-out; background: rgba(0, 0, 0, 0.2); }
.accordion-content { padding: 10px; }
.log-item { display: flex; justify-content: space-between; padding: 12px; border-bottom: 1px solid rgba(255, 255, 255, 0.05); font-size: 0.85rem; }
.total-hours-badge { background: var(--primary-bg); color: var(--primary); padding: 2px 10px; border-radius: 20px; font-size: 0.8rem; border: 1px solid var(--primary); }

/* =========================================
   11. مودال‌ها (Professional Modals)
   ========================================= */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 15px;
}

.modal-glass {
    background: #1e293b;
    border: 1px solid var(--glass-border);
    width: 100%;
    max-width: 500px;
    border-radius: 25px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.modal-header { padding: 20px; background: rgba(0, 0, 0, 0.2); border-bottom: 1px solid var(--glass-border); text-align: center; }
.modal-body { padding: 20px; overflow-y: auto; max-height: 70vh; }
.modal-footer { padding: 15px 20px; display: flex; justify-content: space-between; background: rgba(0, 0, 0, 0.2); }

/* SweetAlert Platinum Theme */
.swal2-popup { background: #1e293b !important; color: #fff !important; border-radius: 20px !important; font-family: inherit !important; }
.swal2-title { color: #fff !important; font-weight: 900 !important; }
.swal2-html-container { color: var(--text-muted) !important; }
.swal2-input, .swal2-textarea, .swal2-select {
    background: rgba(0, 0, 0, 0.3) !important;
    color: #fff !important;
    border: 1px solid var(--glass-border) !important;
    border-radius: 12px !important;
    text-align: right !important;
}

/* اصلاح رنگ تیترها در مودال‌های خاص (فیکس رنگ بک‌گراند) */
.swal2-html-container span[style*="color:#1e293b"],
.swal2-html-container span[style*="color: #1e293b"],
.swal2-html-container b[style*="color:#1e293b"] {
    color: var(--text-main) !important; /* تبدیل رنگ تیره به روشن برای خوانایی در تم دارک */
}

/* اصلاح تیترهای لیست مرخصی و مشغول به کار */
.leave-item b, .swal2-html-container b { color: #ffffff !important; }
.leave-item div, .swal2-html-container div { color: #ffffff !important; }

/* خوانایی لیست درخواست‌های مرخصی در مودال مدیریت */
.leave-item {
    color: #f8fafc;
}
.leave-item .leave-name { color: #f8fafc; font-weight: 800; }
.leave-item .leave-meta { color: #cbd5e1; font-weight: 600; }
.leave-item .leave-reason,
.leave-item input,
.leave-item textarea,
.leave-item .leave-note {
    background: #f8fafc;
    color: #1e293b !important;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    font-weight: 600;
    padding: 8px 10px;
    width: 100%;
    display: block;
    line-height: 1.6;
}
.leave-item input[disabled],
.leave-item textarea[disabled] {
    opacity: 1;
}
.leave-item input::placeholder,
.leave-item textarea::placeholder {
    color: #475569;
    opacity: 1;
}

/* =========================================
   12. وضعیت‌های خاص و نشانگرها
   ========================================= */
.status-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.status-dot.online { background-color: var(--success); box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2); animation: status-pulse 2s infinite; }
.status-dot.offline { background-color: var(--text-dim); opacity: 0.5; }

@keyframes status-pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); opacity: 0.5; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes heartbeat {
    0% { transform: scale(1); }
    10% { transform: scale(1.05); }
    20% { transform: scale(1); }
}

/* بج‌های نوع فعالیت */
.work-mode-badge { font-size: 0.65rem; padding: 2px 8px; border-radius: 10px; font-weight: bold; }
.wm-onsite { background: var(--success-bg); color: var(--success); border: 1px solid var(--success); }
.wm-remote { background: var(--primary-bg); color: var(--primary); border: 1px solid var(--primary); }
.wm-hybrid { background: var(--warning-bg); color: var(--warning); border: 1px solid var(--warning); }

/* =========================================
   13. بخش PWA و نصب
   ========================================= */
.pwa-banner-show { display: flex !important; position: fixed; bottom: 20px; left: 20px; right: 20px; z-index: 9999; }
.pwa-banner-content {
    background: rgba(30, 41, 59, 0.98);
    border: 1px solid var(--primary);
    border-radius: 18px;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
}

/* =========================================
   14. تنظیمات واکنش‌گرا (Responsive Overrides)
   ========================================= */
@media screen and (max-width: 768px) {
    html, body { min-height: 100dvh; }
    .app-container { min-height: 100dvh; height: auto; max-width: 100%; }
    .dashboard-content { padding: 15px; height: auto; max-height: none; }
    .timer-display { font-size: 3rem; }
    .clock-btn { width: 140px; height: 140px; }
    #login-view { margin: 32px auto; padding: 28px 24px; }
    
    .stats-grid { grid-template-columns: 1fr; }
    
    /* تبدیل جدول به کارت در موبایل */
    .modern-table thead { display: none; }
    .modern-table tr { display: block; background: rgba(255, 255, 255, 0.03); margin-bottom: 12px; border-radius: 15px; padding: 10px; border: 1px solid var(--glass-border); }
    .modern-table td { display: flex; justify-content: space-between; align-items: center; border: none; padding: 8px 5px; }
    .modern-table td::before { content: attr(data-label); font-weight: bold; color: var(--text-muted); font-size: 0.8rem; }
    
    .modal-glass { border-radius: 20px 20px 0 0; position: absolute; bottom: 0; animation: slideUp 0.4s ease-out; width: 100%; }
}

@media screen and (max-width: 480px) {
    #login-view {
        width: 94%;
        padding: 24px 20px;
        margin: 28px auto;
    }
    #login-view .btn-primary { font-size: 1rem; padding: 13px; }
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

/* فیکس نمایش تقویم در مودال */
.datepicker-plot-area { z-index: 10001 !important; font-family: inherit !important; }

/* ======= Calendar Dark Text Fix ======= */
.calendar-wrapper {
    background: #fff !important;
    color: #222 !important;
    border-radius: 18px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.04);
}
.calendar-wrapper * {
    color: #222 !important;
    font-family: inherit !important;
}
.calendar-header {
    background: #fff !important;
    color: #222 !important;
    border-radius: 18px 18px 0 0;
    font-weight: bold;
}
.week-days > div {
    color: #222 !important;
    background: #f3f4f6 !important;
    border-radius: 8px;
    margin: 0 2px;
    padding: 2px 0;
    font-weight: 700;
}
.calendar-grid {
    background: #fff !important;
    border-radius: 0 0 18px 18px;
    padding-bottom: 10px;
}
.cal-cell.day {
    color: #222 !important;
    background: #fff !important;
    border-radius: 8px;
    transition: background 0.2s, color 0.2s;
    font-weight: 500;
}
.cal-cell.day.selected {
    background: #6366f1 !important;
    color: #fff !important;
}
.cal-nav-btn {
    color: #1565c0 !important;
    background: #f3f4f6 !important;
    border: 1px solid #e5e7eb !important;
    border-radius: 8px;
    padding: 4px 14px;
    font-weight: 700;
    font-size: 0.95rem;
    transition: background 0.2s, color 0.2s;
}
.cal-nav-btn:hover {
    background: #e0e7ef !important;
    color: #0d47a1 !important;
}
.range-text, #range-display {
    color: #6366f1 !important;
    font-weight: bold;
}
/* استایل نشانه‌های راهنما پایین تقویم */
.calendar-wrapper > div[style*="margin-top:20px"] span {
    border: 2px solid #10b981 !important;
    background: #fff !important;
}
.calendar-wrapper > div[style*="margin-top:20px"] span[style*="background:#6366f1"] {
    background: #6366f1 !important;
    border: none !important;
}