/* ============================================
   Z Task Management System - Custom Styles
   ============================================ */

:root {
    --primary: #4F46E5;
    --primary-rgb: 79,70,229;
    --primary-light: #818CF8;
    --primary-dark: #3730A3;
    --primary-bg: #EEF2FF;
    --success: #10B981;
    --success-rgb: 16,185,129;
    --success-bg: #D1FAE5;
    --warning: #F59E0B;
    --warning-rgb: 245,158,11;
    --warning-bg: #FEF3C7;
    --danger: #EF4444;
    --danger-rgb: 239,68,68;
    --danger-bg: #FEE2E2;
    --info: #06B6D4;
    --info-bg: #CFFAFE;
    --bg-main: #F1F5F9;
    --bg-card: #FFFFFF;
    --text-dark: #1E293B;
    --text-muted: #94A3B8;
    --text-light: #CBD5E1;
    --border: #E2E8F0;
    --sidebar-bg: #1E293B;
    --sidebar-text: #CBD5E1;
    --sidebar-active: #4F46E5;
    --brand-icon-bg: #4F46E5;

    /* ── Messenger-specific colors ── */
    --msng-avatar-gradient: #C7D2FE;
    --msng-group-color: #D97706;
    --msng-group-color-rgb: 217,119,6;
    --msng-group-gradient: #FDE68A;
    --msng-notif-accent: #7C3AED;
    --msng-notif-accent-rgb: 124,58,237;
    --msng-mute-color: #94A3B8;

    --sidebar-width: 260px;
    --topbar-height: 64px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --transition: all 0.3s ease;
}

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

body {
    font-family: 'Vazirmatn', 'Segoe UI', Tahoma, sans-serif;
    background: var(--bg-main);
    color: var(--text-dark);
    font-size: 14px;
    line-height: 1.7;
    overflow-x: hidden;
}

/* ---- App Layout ---- */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    overflow-y: auto;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-icon {
    width: 42px;
    height: 42px;
    background: var(--brand-icon-bg);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #fff;
    flex-shrink: 0;
}

.brand-text h5 {
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    margin: 0;
    line-height: 1.4;
}

.brand-text small {
    color: var(--text-muted);
    font-size: 11px;
}

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

.user-avatar {
    font-size: 36px;
    color: var(--primary-light);
    flex-shrink: 0;
}

.user-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.user-name {
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    color: var(--text-muted);
    font-size: 11px;
}

/* ---- Navigation ---- */
.sidebar-nav {
    flex: 1;
    padding: 12px 10px;
}

.nav-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-item {
    margin-bottom: 2px;
}

.nav-item .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 16px;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    font-size: 13.5px;
    position: relative;
}

.nav-item .nav-link:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
}

.nav-item.active .nav-link {
    background: var(--primary);
    color: #fff;
    font-weight: 600;
}

.nav-item .nav-link i {
    width: 20px;
    text-align: center;
    font-size: 15px;
}

.nav-badge {
    background: var(--danger);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
    margin-right: auto;
    min-width: 22px;
    text-align: center;
}

.nav-badge.pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(239,68,68,0.4); }
    70% { box-shadow: 0 0 0 8px rgba(239,68,68,0); }
    100% { box-shadow: 0 0 0 0 rgba(239,68,68,0); }
}

.sidebar-footer {
    padding: 12px 10px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.logout-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 16px;
    color: var(--danger) !important;
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    font-size: 13.5px;
}

.logout-link:hover {
    background: rgba(239,68,68,0.1);
}

/* ---- Main Content ---- */
.main-content {
    flex: 1;
    margin-right: var(--sidebar-width);
    min-height: 100vh;
    transition: var(--transition);
}

/* ---- Top Bar ---- */
.top-bar {
    height: var(--topbar-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.sidebar-toggle {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-dark);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-xs);
    display: none;
}

.sidebar-toggle:hover {
    background: var(--bg-main);
}

.top-bar-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-dark);
}

.top-bar-actions {
    margin-right: auto;
    display: flex;
    align-items: center;
    gap: 16px;
}

.today-date {
    color: var(--text-muted);
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ---- Page Content ---- */
.page-content {
    padding: 24px;
}

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

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

.z-card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.z-card-header h6 {
    font-size: 14px;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.z-card-body {
    padding: 20px;
}

.z-card-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    background: var(--bg-main);
}

/* ---- Stat Cards ---- */
.stat-card {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.stat-icon.primary { background: var(--primary-bg); color: var(--primary); }
.stat-icon.success { background: var(--success-bg); color: var(--success); }
.stat-icon.warning { background: var(--warning-bg); color: var(--warning); }
.stat-icon.danger { background: var(--danger-bg); color: var(--danger); }
.stat-icon.info { background: var(--info-bg); color: var(--info); }

.stat-info h3 {
    font-size: 26px;
    font-weight: 800;
    margin: 0;
    line-height: 1.2;
}

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

/* ---- Priority Badges ---- */
.badge-normal {
    background: var(--info-bg);
    color: #0891B2;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 600;
}

.badge-important {
    background: var(--warning-bg);
    color: #D97706;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 600;
}

.badge-very-important {
    background: var(--danger-bg);
    color: var(--danger);
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 600;
}

/* ---- Task List ---- */
.task-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.task-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    transition: var(--transition);
}

.task-item:last-child {
    border-bottom: none;
}

.task-item:hover {
    background: #FAFBFF;
}

.task-item.completed {
    opacity: 0.55;
}

.task-item.completed .task-title {
    text-decoration: line-through;
}

.task-checkbox {
    margin-top: 3px;
    flex-shrink: 0;
}

.task-checkbox input[type="checkbox"] {
    width: 20px;
    height: 20px;
    border-radius: 6px;
    border: 2px solid var(--border);
    cursor: pointer;
    accent-color: var(--primary);
}

.task-content {
    flex: 1;
    min-width: 0;
}

.task-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
    word-break: break-word;
}

.task-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 12px;
    color: var(--text-muted);
}

.task-meta i {
    margin-left: 4px;
}

.task-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.btn-icon {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    color: var(--text-muted);
    border-radius: var(--radius-xs);
    cursor: pointer;
    transition: var(--transition);
    font-size: 13px;
    padding: 0;
}

.btn-icon:hover {
    background: var(--bg-main);
    color: var(--text-dark);
}

.btn-icon.delete:hover {
    background: var(--danger-bg);
    color: var(--danger);
}

.task-actions .btn-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    color: var(--text-muted);
    border-radius: var(--radius-xs);
    cursor: pointer;
    transition: var(--transition);
    font-size: 13px;
}

.task-actions .btn-icon:hover {
    background: var(--bg-main);
    color: var(--text-dark);
}

.task-actions .btn-icon.delete:hover {
    background: var(--danger-bg);
    color: var(--danger);
}

/* ---- Forms ---- */
.form-control, .form-select {
    border-radius: var(--radius-xs);
    border: 1.5px solid var(--border);
    padding: 10px 14px;
    font-family: 'Vazirmatn', sans-serif;
    font-size: 13.5px;
    transition: var(--transition);
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}

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

textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

/* ---- Buttons ---- */
.btn {
    font-family: 'Vazirmatn', sans-serif;
    font-weight: 600;
    border-radius: var(--radius-xs);
    padding: 9px 20px;
    font-size: 13.5px;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

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

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

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

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

.btn-light {
    background: var(--bg-main);
    border-color: var(--border);
    color: var(--text-dark);
}

.btn-light:hover {
    background: var(--border);
}

.btn-success {
    background: var(--success);
    border-color: var(--success);
}

.btn-danger {
    background: var(--danger);
    border-color: var(--danger);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 12.5px;
}

/* ---- Tables ---- */
.table {
    font-size: 13.5px;
}

.table th {
    font-weight: 700;
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom-width: 2px;
    padding: 12px 16px;
    white-space: nowrap;
}

.table td {
    padding: 12px 16px;
    vertical-align: middle;
}

.table-hover tbody tr:hover {
    background: #FAFBFF;
}

/* ---- Modals ---- */
.modal-content {
    border-radius: var(--radius);
    border: none;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    border-bottom: 1px solid var(--border);
    padding: 16px 20px;
}

.modal-title {
    font-size: 15px;
    font-weight: 700;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    border-top: 1px solid var(--border);
    padding: 12px 20px;
}

/* ---- Department Tree ---- */
.dept-tree {
    list-style: none;
    padding: 0;
    margin: 0;
}

.dept-tree .dept-tree {
    padding-right: 24px;
    border-right: 2px solid var(--border);
    margin-right: 12px;
    margin-top: 4px;
}

.dept-item {
    margin-bottom: 4px;
}

.dept-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius-xs);
    text-decoration: none;
    color: var(--text-dark);
    transition: var(--transition);
    font-size: 13.5px;
    cursor: pointer;
}

.dept-link:hover {
    background: var(--primary-bg);
    color: var(--primary);
}

.dept-link.active {
    background: var(--primary);
    color: #fff;
}

.dept-link .dept-badge {
    margin-right: auto;
    background: var(--bg-main);
    color: var(--text-muted);
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
}

.dept-link.active .dept-badge {
    background: rgba(255,255,255,0.2);
    color: #fff;
}

/* ---- Notification Card ---- */
.notification-item {
    display: flex;
    gap: 14px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    transition: var(--transition);
}

.notification-item:last-child {
    border-bottom: none;
}

.notification-item:hover {
    background: #FAFBFF;
}

.notification-item.unread {
    background: var(--primary-bg);
    border-right: 3px solid var(--primary);
}

.notification-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 16px;
}

.notification-icon.normal { background: var(--info-bg); color: var(--info); }
.notification-icon.important { background: var(--warning-bg); color: var(--warning); }
.notification-icon.very_important { background: var(--danger-bg); color: var(--danger); }

.notification-content {
    flex: 1;
    min-width: 0;
}

.notification-title {
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 4px;
}

.notification-message {
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.6;
}

.notification-time {
    color: var(--text-muted);
    font-size: 11.5px;
    margin-top: 6px;
}

/* ---- Role Tags ---- */
.role-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 600;
    margin: 2px;
}

.role-tag.ceo { background: #FEF3C7; color: #92400E; }
.role-tag.executive_manager { background: #DBEAFE; color: #1E40AF; }
.role-tag.unit_manager { background: #D1FAE5; color: #065F46; }
.role-tag.member { background: #F1F5F9; color: #475569; }

/* ---- Overview Cards ---- */
.overview-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 16px;
    margin-bottom: 12px;
    transition: var(--transition);
}

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

.overview-card .dept-name {
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.overview-card .dept-name i {
    color: var(--primary);
}

.overview-card .task-count {
    font-size: 24px;
    font-weight: 800;
    color: var(--primary);
}

.overview-card .task-label {
    font-size: 11.5px;
    color: var(--text-muted);
}

/* ---- Login Page ---- */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}

.login-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
    padding: 40px;
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo .icon {
    width: 64px;
    height: 64px;
    background: var(--primary);
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: #fff;
    margin-bottom: 16px;
}

.login-logo h4 {
    font-size: 20px;
    font-weight: 800;
    margin: 0;
    color: var(--text-dark);
}

.login-logo p {
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 4px;
}

/* ---- Install Page ---- */
.install-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #10B981 0%, #059669 100%);
    padding: 20px;
}

.install-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 600px;
    padding: 40px;
}

.install-card h4 {
    font-weight: 800;
    margin-bottom: 20px;
}

.step-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    font-size: 14px;
}

.step-item .step-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.step-item .step-icon.done { background: var(--success-bg); color: var(--success); }
.step-item .step-icon.pending { background: var(--bg-main); color: var(--text-muted); }
.step-item .step-icon.error { background: var(--danger-bg); color: var(--danger); }

/* ---- Empty State ---- */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-state h6 {
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 13px;
    max-width: 300px;
    margin: 0 auto;
}

/* ---- Tabs ---- */
.z-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid var(--border);
    margin-bottom: 20px;
    padding: 0 4px;
}

.z-tab {
    padding: 10px 18px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-muted);
    border: none;
    background: none;
    cursor: pointer;
    position: relative;
    transition: var(--transition);
    border-radius: var(--radius-xs) var(--radius-xs) 0 0;
}

.z-tab:hover {
    color: var(--text-dark);
    background: var(--bg-main);
}

.z-tab.active {
    color: var(--primary);
}

.z-tab.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    right: 0;
    left: 0;
    height: 2px;
    background: var(--primary);
    border-radius: 2px 2px 0 0;
}

/* ---- Visibility Toggle ---- */
.visibility-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: var(--radius-xs);
    border: 1px solid var(--border);
    background: var(--bg-card);
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
}

.visibility-toggle:hover {
    border-color: var(--primary);
}

.visibility-toggle.granted {
    background: var(--success-bg);
    border-color: var(--success);
    color: var(--success);
}

.visibility-toggle.locked {
    background: var(--success-bg);
    border-color: var(--success);
    color: var(--success);
    pointer-events: none;
    opacity: 0.85;
}

/* ---- Responsive ---- */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-right: 0;
    }
    
    .sidebar-toggle {
        display: block;
    }
    
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 999;
    }
    
    .sidebar-overlay.show {
        display: block;
    }
}

@media (max-width: 768px) {
    /* ---- Z-Tabs: horizontal scroll ---- */
    .z-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
        flex-wrap: nowrap !important;
        padding-bottom: 4px;
    }
    .z-tabs::-webkit-scrollbar { display: none; }

    /* ---- Cards tighter padding ---- */
    .z-card-body {
        padding: 14px;
    }
    .z-card-header {
        padding: 12px 14px;
        flex-wrap: wrap;
        gap: 8px;
    }
    .z-card-header h6 {
        font-size: 13px;
    }

    /* ---- Role tags ---- */
    .role-tag {
        font-size: 10px !important;
        padding: 2px 6px !important;
        margin: 1px;
    }

    /* ---- Task items ---- */
    .task-item {
        gap: 8px;
    }
    .task-meta {
        flex-wrap: wrap;
        gap: 4px;
    }
    .task-meta span {
        font-size: 11px;
    }
    .task-actions {
        flex-direction: column;
        gap: 2px;
    }

    /* ---- Tables general ---- */
    .table th, .table td {
        font-size: 12px;
        padding: 8px 6px;
        white-space: nowrap;
    }

    /* ---- Notification items ---- */
    .notification-item {
        padding: 12px;
    }
    .notification-time {
        flex-wrap: wrap;
        font-size: 11px !important;
    }

    /* ---- Overview cards ---- */
    .overview-card {
        padding: 12px;
    }

    /* ---- Stat cards ---- */
    .stat-card {
        padding: 14px;
    }
    .stat-info h3 {
        font-size: 20px;
    }
    .stat-icon {
        width: 42px;
        height: 42px;
        font-size: 18px;
    }

    /* ---- Department tree sidebar (department-management) ---- */
    .dept-tree .dept-link {
        font-size: 12.5px;
        padding: 8px 10px;
    }
    .dept-badge {
        font-size: 10px;
        padding: 1px 6px;
    }

    /* ---- Filter / action bars ---- */
    .form-select-sm {
        font-size: 12px;
    }

    /* ---- Modals ---- */
    .modal-dialog {
        margin: 8px;
    }

    /* ---- Page title ---- */
    .page-content h4, .page-content h5 {
        font-size: 16px;
    }
}

@media (max-width: 576px) {
    .page-content {
        padding: 16px;
    }

    .stat-info h3 {
        font-size: 18px;
    }
    
    .stat-card {
        padding: 12px;
        gap: 10px;
    }
    .stat-icon {
        width: 38px;
        height: 38px;
        font-size: 16px;
    }
    
    .top-bar {
        padding: 0 16px;
    }
    
    .today-date {
        display: none;
    }

    /* ---- Task items compact ---- */
    .task-title {
        font-size: 13px;
    }
    .task-checkbox input[type="checkbox"] {
        width: 18px;
        height: 18px;
    }

    /* ---- Tables: very compact ---- */
    .table th, .table td {
        font-size: 11px;
        padding: 6px 4px;
    }

    /* ---- Buttons smaller ---- */
    .btn-sm {
        font-size: 11px;
        padding: 4px 8px;
    }
    .btn-icon {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }

    /* ---- Z-card header stacking ---- */
    .z-card-header {
        flex-direction: column;
        align-items: flex-start !important;
    }
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--text-light);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

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

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

/* ---- Misc ---- */
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.gap-3 { gap: 12px; }

.cursor-pointer { cursor: pointer; }

.deadline-passed {
    color: var(--danger) !important;
    font-weight: 600;
}

.deadline-today {
    color: var(--warning) !important;
    font-weight: 600;
}

.search-box {
    position: relative;
}

.search-box input {
    padding-right: 36px;
}

.search-box i {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

/* ============================================
   Dark Mode
   ============================================ */
html.dark-mode {
    --bg-main: #0F172A;
    --bg-card: #1E293B;
    --text-dark: #E2E8F0;
    --text-muted: #94A3B8;
    --text-light: #64748B;
    --border: #334155;
    --sidebar-bg: #0F172A;
    --sidebar-text: #94A3B8;
    --primary-bg: rgba(79,70,229,0.15);
    --success-bg: rgba(16,185,129,0.15);
    --warning-bg: rgba(245,158,11,0.15);
    --danger-bg: rgba(239,68,68,0.15);
    --info-bg: rgba(6,182,212,0.15);
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.4), 0 2px 4px -2px rgba(0,0,0,0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.4), 0 4px 6px -4px rgba(0,0,0,0.3);
}

html.dark-mode body {
    background: var(--bg-main);
    color: var(--text-dark);
}

html.dark-mode .top-bar {
    background: var(--bg-card);
    border-bottom-color: var(--border);
}

html.dark-mode .form-control,
html.dark-mode .form-select {
    background: #0F172A;
    border-color: var(--border);
    color: var(--text-dark);
}

html.dark-mode .form-control:focus,
html.dark-mode .form-select:focus {
    background: #0F172A;
    border-color: var(--primary);
    color: var(--text-dark);
}

html.dark-mode .form-control::placeholder {
    color: var(--text-light);
}

html.dark-mode .modal-content {
    background: var(--bg-card);
    color: var(--text-dark);
}

html.dark-mode .modal-header {
    border-bottom-color: var(--border);
}

html.dark-mode .modal-footer {
    border-top-color: var(--border);
}

html.dark-mode .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

html.dark-mode .btn-light {
    background: #334155;
    border-color: #475569;
    color: var(--text-dark);
}

html.dark-mode .btn-light:hover {
    background: #475569;
    color: #fff;
}

html.dark-mode .btn-outline-secondary {
    border-color: #475569;
    color: var(--text-muted);
}

html.dark-mode .btn-outline-secondary:hover {
    background: #334155;
    color: var(--text-dark);
}

html.dark-mode .table {
    color: var(--text-dark);
}

html.dark-mode .table th {
    color: var(--text-muted);
    border-bottom-color: var(--border);
}

html.dark-mode .table td {
    border-bottom-color: var(--border);
}

html.dark-mode .table-hover tbody tr:hover {
    background: rgba(255,255,255,0.05);
}

html.dark-mode .table-active {
    background: rgba(79,70,229,0.15);
}

html.dark-mode .table-striped tbody tr:nth-of-type(odd) {
    background: rgba(255,255,255,0.02);
}

html.dark-mode tbody tr {
    border-bottom-color: var(--border);
}

html.dark-mode .task-item:hover,
html.dark-mode .notification-item:hover {
    background: rgba(255,255,255,0.03);
}

html.dark-mode .task-checkbox input[type="checkbox"] {
    border-color: #475569;
}

html.dark-mode .notification-item.unread {
    background: rgba(79,70,229,0.1);
}

html.dark-mode .overview-card {
    background: var(--bg-card);
    border-color: var(--border);
}

html.dark-mode .overview-card:hover {
    background: rgba(255,255,255,0.03);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

html.dark-mode .dept-link:hover {
    background: rgba(79,70,229,0.15);
    color: var(--primary);
}

html.dark-mode .empty-state h6 {
    color: var(--text-dark);
}

html.dark-mode .sidebar-footer {
    border-top-color: rgba(255,255,255,0.06);
}

html.dark-mode .sidebar-header {
    border-bottom-color: rgba(255,255,255,0.06);
}

html.dark-mode .sidebar-user {
    border-bottom-color: rgba(255,255,255,0.06);
}

html.dark-mode .z-card-footer {
    background: #0F172A;
}

html.dark-mode .alert-info {
    background: rgba(6,182,212,0.1);
    border-color: rgba(6,182,212,0.2);
    color: #67E8F9;
}

html.dark-mode .alert-warning {
    background: rgba(245,158,11,0.1);
    border-color: rgba(245,158,11,0.2);
    color: #FCD34D;
}

html.dark-mode .alert-danger {
    background: rgba(239,68,68,0.1);
    border-color: rgba(239,68,68,0.2);
    color: #FCA5A5;
}

html.dark-mode .alert-success {
    background: rgba(16,185,129,0.1);
    border-color: rgba(16,185,129,0.2);
    color: #6EE7B7;
}

html.dark-mode .login-card,
html.dark-mode .install-card {
    background: var(--bg-card);
    color: var(--text-dark);
}

html.dark-mode .login-logo h4 {
    color: var(--text-dark);
}

html.dark-mode code {
    background: #334155;
    color: #F472B6;
}

html.dark-mode .progress {
    background: #334155;
}

html.dark-mode .form-check-input {
    background-color: #334155;
    border-color: #475569;
}

html.dark-mode .form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

html.dark-mode .dropdown-menu {
    background: var(--bg-card);
    border-color: var(--border);
    color: var(--text-dark);
}

html.dark-mode .dropdown-item {
    color: var(--text-dark);
}

html.dark-mode .dropdown-item:hover {
    background: rgba(255,255,255,0.05);
}

html.dark-mode .card {
    background: var(--bg-card);
    border-color: var(--border);
    color: var(--text-dark);
}

html.dark-mode .card .card-body {
    color: var(--text-dark);
}

html.dark-mode .visibility-toggle {
    background: var(--bg-card);
    border-color: var(--border);
    color: var(--text-dark);
}

html.dark-mode .visibility-toggle.granted,
html.dark-mode .visibility-toggle.locked {
    background: rgba(16,185,129,0.1);
    border-color: var(--success);
}

html.dark-mode .role-tag.ceo { background: rgba(146,64,14,0.2); color: #FCD34D; }
html.dark-mode .role-tag.executive_manager { background: rgba(30,64,175,0.2); color: #93C5FD; }
html.dark-mode .role-tag.unit_manager { background: rgba(6,95,70,0.2); color: #6EE7B7; }
html.dark-mode .role-tag.member { background: rgba(71,85,105,0.2); color: #94A3B8; }

html.dark-mode .z-tab:hover {
    background: rgba(255,255,255,0.05);
}

html.dark-mode .sidebar-toggle {
    color: var(--text-dark);
}

html.dark-mode .sidebar-toggle:hover {
    background: rgba(255,255,255,0.05);
}

html.dark-mode .btn-icon:hover {
    background: rgba(255,255,255,0.08);
}

html.dark-mode img {
    opacity: 0.92;
}

/* Dark Mode Toggle Button */
.dark-mode-toggle {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    transition: var(--transition);
}

.dark-mode-toggle:hover {
    background: var(--bg-main);
    color: var(--text-dark);
}

html.dark-mode .dark-mode-toggle:hover {
    background: rgba(255,255,255,0.1);
}

/* ---- Persian Datepicker Overrides ---- */
.datepicker-plot-area {
    font-family: 'Vazirmatn', sans-serif !important;
    direction: rtl;
}
.datepicker-container {
    z-index: 99999 !important;
}

html.dark-mode .datepicker-plot-area {
    background: var(--bg-card);
    color: var(--text-dark);
}

html.dark-mode .datepicker-plot-area .datepicker-navigator {
    color: var(--text-dark);
}

/* Dark mode overrides for inline-styled elements */
html.dark-mode [style*="background:#F8FAFC"],
html.dark-mode [style*="background: #F8FAFC"],
html.dark-mode [style*="background:#F1F5F9"],
html.dark-mode [style*="background: #F1F5F9"],
html.dark-mode [style*="background:#f8f9fa"],
html.dark-mode [style*="background: #f8f9fa"] {
    background: #0F172A !important;
}

html.dark-mode [style*="background:white"],
html.dark-mode [style*="background: white"],
html.dark-mode [style*="background:#fff"],
html.dark-mode [style*="background:#FFFFFF"],
html.dark-mode [style*="background: #fff"],
html.dark-mode [style*="background: #FFFFFF"] {
    background: var(--bg-card) !important;
}

html.dark-mode [style*="color:#1E293B"],
html.dark-mode [style*="color: #1E293B"] {
    color: var(--text-dark) !important;
}

html.dark-mode [style*="color:#334155"],
html.dark-mode [style*="color: #334155"] {
    color: #CBD5E1 !important;
}

html.dark-mode [style*="color:#64748B"],
html.dark-mode [style*="color: #64748B"] {
    color: var(--text-muted) !important;
}

html.dark-mode [style*="color:#475569"],
html.dark-mode [style*="color: #475569"] {
    color: #94A3B8 !important;
}

html.dark-mode [style*="color:#94A3B8"],
html.dark-mode [style*="color: #94A3B8"] {
    color: #64748B !important;
}

html.dark-mode [style*="border-bottom:1px solid #F1F5F9"],
html.dark-mode [style*="border-bottom: 1px solid #F1F5F9"],
html.dark-mode [style*="border-top:1px solid #F1F5F9"],
html.dark-mode [style*="border-top: 1px solid #F1F5F9"] {
    border-color: var(--border) !important;
}

html.dark-mode [style*="border:1px solid #E2E8F0"],
html.dark-mode [style*="border: 1px solid #E2E8F0"] {
    border-color: var(--border) !important;
}

html.dark-mode [style*="border:2px dashed #CBD5E1"],
html.dark-mode [style*="border: 2px dashed #CBD5E1"] {
    border-color: #475569 !important;
}

html.dark-mode [style*="border:2px dashed #dee2e6"],
html.dark-mode [style*="border: 2px dashed #dee2e6"] {
    border-color: #475569 !important;
}

html.dark-mode [style*="background:#E2E8F0"],
html.dark-mode [style*="background: #E2E8F0"] {
    background: #334155 !important;
}

html.dark-mode [style*="background:#FFFBEB"],
html.dark-mode [style*="background: #FFFBEB"],
html.dark-mode [style*="background:#FEF3C7"],
html.dark-mode [style*="background: #FEF3C7"] {
    background: rgba(245,158,11,0.1) !important;
}

html.dark-mode [style*="background:#ECFDF5"],
html.dark-mode [style*="background: #ECFDF5"] {
    background: rgba(16,185,129,0.1) !important;
}

html.dark-mode [style*="background:#F5F3FF"],
html.dark-mode [style*="background: #F5F3FF"] {
    background: rgba(124,58,237,0.1) !important;
}

html.dark-mode [style*="background:#FEF2F2"],
html.dark-mode [style*="background: #FEF2F2"] {
    background: rgba(239,68,68,0.1) !important;
}

html.dark-mode [style*="background:#F0F9FF"],
html.dark-mode [style*="background: #F0F9FF"] {
    background: rgba(14,165,233,0.1) !important;
}

html.dark-mode [style*="background:#EEF2FF"],
html.dark-mode [style*="background: #EEF2FF"] {
    background: rgba(79,70,229,0.1) !important;
}

html.dark-mode .text-muted {
    color: var(--text-muted) !important;
}

html.dark-mode strong {
    color: var(--text-dark);
}

html.dark-mode .form-label {
    color: var(--text-dark);
}

html.dark-mode .badge.bg-primary.bg-opacity-10 {
    background: rgba(79,70,229,0.15) !important;
}

html.dark-mode .badge.bg-info.bg-opacity-10 {
    background: rgba(6,182,212,0.15) !important;
}

html.dark-mode .members-section {
    background: #0F172A;
}

html.dark-mode .guide-content {
    color: #CBD5E1;
}

html.dark-mode .guide-content blockquote {
    background: rgba(255,255,255,0.05);
    border-right-color: var(--primary);
    color: #94A3B8;
}

html.dark-mode .guide-content pre {
    background: #0F172A;
}

html.dark-mode .ql-toolbar.ql-snow {
    border-color: var(--border);
    background: #0F172A;
}

html.dark-mode .ql-container.ql-snow {
    border-color: var(--border);
    background: var(--bg-card);
    color: var(--text-dark);
}

html.dark-mode .ql-editor {
    color: var(--text-dark);
}

html.dark-mode .ql-snow .ql-stroke {
    stroke: var(--text-muted);
}

html.dark-mode .ql-snow .ql-fill {
    fill: var(--text-muted);
}

html.dark-mode .ql-snow .ql-picker-label {
    color: var(--text-muted);
}

html.dark-mode .ql-snow .ql-picker-options {
    background: var(--bg-card);
    border-color: var(--border);
}

html.dark-mode .dept-item {
    background: var(--bg-card);
    border-bottom-color: var(--border);
}

html.dark-mode .dept-item:hover {
    background: rgba(255,255,255,0.03);
}

html.dark-mode .toast {
    background: var(--bg-card);
    color: var(--text-dark);
    border-color: var(--border);
}

/* ── Global Incoming Call Overlay ── */
#globalCallOverlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(6px);
    animation: fadeIn .25s ease;
}
.global-call-card {
    background: var(--bg-card, #fff);
    border-radius: 24px;
    padding: 36px 32px 28px;
    min-width: 320px;
    max-width: 380px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
    position: relative;
    animation: slideUp .35s ease;
}
.global-call-pulse {
    position: absolute; top: -60px; left: 50%; transform: translateX(-50%);
    width: 120px; height: 120px; border-radius: 50%;
    background: rgba(34,197,94,.15);
    animation: globalPulse 2s ease-in-out infinite;
}
.global-call-icon {
    width: 80px; height: 80px; border-radius: 50%;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    display: flex; align-items: center; justify-content: center;
    font-size: 2rem; color: #fff; margin: -40px auto 16px;
    box-shadow: 0 8px 24px rgba(34,197,94,.35);
    animation: callBtnPulseGlobal 1.5s ease infinite;
    position: relative; z-index: 1;
}
.global-call-name {
    font-size: 1.2rem; font-weight: 700;
    color: var(--text-dark, #1a1a2e); margin-bottom: 4px;
}
.global-call-type {
    font-size: .85rem; color: var(--text-muted, #6b7280); margin-bottom: 24px;
}
.global-call-actions {
    display: flex; gap: 20px; justify-content: center;
}
.global-call-accept, .global-call-reject {
    width: 60px; height: 60px; border-radius: 50%; border: none;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem; color: #fff; cursor: pointer;
    transition: transform .15s, box-shadow .15s;
}
.global-call-accept {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    box-shadow: 0 4px 15px rgba(34,197,94,.4);
    animation: callBtnPulseGlobal 1.5s ease infinite;
}
.global-call-reject {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    box-shadow: 0 4px 15px rgba(239,68,68,.4);
}
.global-call-accept:hover, .global-call-reject:hover { transform: scale(1.1); }
@keyframes globalPulse {
    0%,100% { transform: translateX(-50%) scale(1); opacity: .4; }
    50% { transform: translateX(-50%) scale(1.4); opacity: 0; }
}
@keyframes callBtnPulseGlobal {
    0%,100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } }

html.dark-mode .global-call-card {
    background: var(--bg-card);
}
html.dark-mode .global-call-name {
    color: var(--text-dark);
}

/* ── Floating Mini Call Widget ── */
#floatingCallWidget {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100000;
    animation: fcwSlideUp .35s cubic-bezier(.4,0,.2,1);
    pointer-events: auto;
}
@keyframes fcwSlideUp {
    from { opacity: 0; transform: translateX(-50%) translateY(40px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.fcw-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    background: linear-gradient(135deg, #1e293b, #0f172a);
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 60px;
    padding: 8px 16px 8px 12px;
    box-shadow: 0 8px 40px rgba(0,0,0,.45), 0 0 0 1px rgba(255,255,255,.06);
    backdrop-filter: blur(20px);
    min-width: 280px;
}
.fcw-info {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    flex: 1;
    min-width: 0;
}
.fcw-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: #fff;
    flex-shrink: 0;
    animation: fcwPulse 2s ease-in-out infinite;
}
@keyframes fcwPulse {
    0%,100% { box-shadow: 0 0 0 0 rgba(34,197,94,.4); }
    50%     { box-shadow: 0 0 0 8px rgba(34,197,94,0); }
}
.fcw-details {
    min-width: 0;
}
.fcw-name {
    font-size: .85rem;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
}
.fcw-timer {
    font-size: .75rem;
    color: rgba(255,255,255,.6);
    font-variant-numeric: tabular-nums;
}
.fcw-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.fcw-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .85rem;
    color: #fff;
    cursor: pointer;
    transition: transform .15s, background .2s;
}
.fcw-btn:hover {
    transform: scale(1.1);
}
.fcw-mute-btn {
    background: rgba(255,255,255,.15);
}
.fcw-mute-btn.muted {
    background: rgba(239,68,68,.5);
}
.fcw-end-btn {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}
.fcw-return-btn {
    background: linear-gradient(135deg, var(--primary), rgba(var(--primary-rgb),.8));
}
/* Mobile adjustments */
@media (max-width: 768px) {
    #floatingCallWidget {
        bottom: 16px;
        left: 12px;
        right: 12px;
        transform: none;
    }
    @keyframes fcwSlideUp {
        from { opacity: 0; transform: translateY(40px); }
        to   { opacity: 1; transform: translateY(0); }
    }
    .fcw-inner {
        min-width: auto;
        width: 100%;
    }
}
button#adminEyeBtn {
    display: none;
}