/* ===== NDS Premium Design System ===== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
    --primary: #1e3a5f;
    --primary-light: #2d5a8e;
    --primary-dark: #0f1f33;
    --accent: #f59e0b;
    --accent-light: #fbbf24;
    --secondary: #3b82f6;
    --secondary-light: #60a5fa;
    --success: #10b981;
    --success-light: #d1fae5;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --info: #06b6d4;
    --info-light: #cffafe;
    --bg-body: #f0f4f8;
    --bg-card: #ffffff;
    --bg-sidebar: linear-gradient(180deg, #0f1f33 0%, #1e3a5f 50%, #2d5a8e 100%);
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.12);
    --shadow-xl: 0 20px 50px rgba(0,0,0,0.15);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --sidebar-width: 260px;
    --topbar-height: 64px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ===== Watermark ===== */
.watermark {
    position: fixed; top: 50%; left: 55%; transform: translate(-50%, -50%);
    opacity: 0.04; z-index: 0; max-width: 45%; max-height: 45%;
    pointer-events: none; filter: grayscale(100%);
}

/* ===== Sidebar ===== */
.sidebar {
    width: var(--sidebar-width); background: var(--bg-sidebar);
    color: #fff; position: fixed; left: 0; top: 0; height: 100vh;
    display: flex; flex-direction: column; z-index: 1000;
    transition: var(--transition); box-shadow: 4px 0 20px rgba(0,0,0,0.15);
}
.sidebar-header {
    padding: 24px 20px; text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    background: rgba(0,0,0,0.15);
}
.sidebar-header img { max-width: 70px; height: auto; border-radius: 12px; margin-bottom: 8px; filter: drop-shadow(0 2px 8px rgba(0,0,0,0.3)); }
.sidebar-header .sidebar-title { font-size: 0.8rem; font-weight: 600; letter-spacing: 1.5px; text-transform: uppercase; color: rgba(255,255,255,0.7); margin-top: 4px; }
.sidebar-menu { list-style: none; padding: 12px 0; flex: 1; overflow-y: auto; }
.sidebar-menu li a {
    display: flex; align-items: center; padding: 12px 24px; gap: 14px;
    color: rgba(255,255,255,0.7); text-decoration: none; font-size: 0.9rem;
    font-weight: 500; transition: var(--transition); position: relative;
    border-left: 3px solid transparent; margin: 2px 0;
}
.sidebar-menu li a:hover { color: #fff; background: rgba(255,255,255,0.08); border-left-color: var(--accent); }
.sidebar-menu li a.active { color: #fff; background: rgba(255,255,255,0.12); border-left-color: var(--accent); }
.sidebar-menu li a.active::after { content: ''; position: absolute; right: 0; top: 50%; transform: translateY(-50%); width: 3px; height: 60%; background: var(--accent); border-radius: 3px 0 0 3px; }
.sidebar-menu li a i { width: 20px; text-align: center; font-size: 1rem; }
.sidebar-footer { padding: 16px 24px; border-top: 1px solid rgba(255,255,255,0.08); font-size: 0.75rem; color: rgba(255,255,255,0.4); text-align: center; }

/* ===== Main Content ===== */
.main-content { margin-left: var(--sidebar-width); min-height: 100vh; display: flex; flex-direction: column; position: relative; }

/* ===== Topbar ===== */
.topbar {
    height: var(--topbar-height); background: var(--bg-card);
    border-bottom: 1px solid var(--border); display: flex;
    align-items: center; justify-content: space-between;
    padding: 0 28px; position: sticky; top: 0; z-index: 100;
    box-shadow: var(--shadow-sm); backdrop-filter: blur(10px);
    background: rgba(255,255,255,0.95);
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
#sidebar-toggle { display: none; background: none; border: none; font-size: 1.4rem; cursor: pointer; color: var(--text-primary); padding: 8px; border-radius: var(--radius-sm); transition: var(--transition); }
#sidebar-toggle:hover { background: var(--border-light); }
.org-name { font-size: 1.15rem; font-weight: 700; color: var(--primary); letter-spacing: -0.3px; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.user-info { display: flex; align-items: center; gap: 10px; padding: 6px 14px; background: var(--border-light); border-radius: var(--radius-xl); }
.user-info .user-avatar { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--secondary)); display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 0.8rem; }
.user-info .user-details { line-height: 1.3; }
.user-info .user-name { font-size: 0.85rem; font-weight: 600; color: var(--text-primary); }
.user-info .user-role { font-size: 0.7rem; color: var(--text-muted); }

/* ===== Content Wrapper ===== */
.content-wrapper { padding: 28px; flex: 1; position: relative; z-index: 1; }

/* ===== Page Header ===== */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.page-header h1 { font-size: 1.6rem; font-weight: 700; color: var(--text-primary); display: flex; align-items: center; gap: 12px; }
.page-header h1 i { color: var(--secondary); font-size: 1.3rem; }
.page-header .breadcrumb { font-size: 0.82rem; color: var(--text-muted); }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ===== Cards ===== */
.card {
    background: var(--bg-card); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm); padding: 24px; margin-bottom: 24px;
    border: 1px solid var(--border-light); transition: var(--transition);
    animation: fadeInUp 0.4s ease-out;
}
.card:hover { box-shadow: var(--shadow-md); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--border-light); }
.card-header h2 { font-size: 1.15rem; font-weight: 700; color: var(--text-primary); display: flex; align-items: center; gap: 10px; }
.card-header h2 i { color: var(--secondary); }

/* ===== Dashboard Stats ===== */
.dashboard-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; margin-bottom: 28px; }
.stat-card {
    background: var(--bg-card); border-radius: var(--radius-lg);
    padding: 24px; position: relative; overflow: hidden;
    border: 1px solid var(--border-light); transition: var(--transition);
    animation: fadeInUp 0.4s ease-out;
}
.stat-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.stat-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.stat-card:nth-child(1)::before { background: linear-gradient(90deg, #3b82f6, #60a5fa); }
.stat-card:nth-child(2)::before { background: linear-gradient(90deg, #10b981, #34d399); }
.stat-card:nth-child(3)::before { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.stat-card:nth-child(4)::before { background: linear-gradient(90deg, #8b5cf6, #a78bfa); }
.stat-card .stat-icon { width: 48px; height: 48px; border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; font-size: 1.3rem; margin-bottom: 16px; }
.stat-card:nth-child(1) .stat-icon { background: #eff6ff; color: #3b82f6; }
.stat-card:nth-child(2) .stat-icon { background: #ecfdf5; color: #10b981; }
.stat-card:nth-child(3) .stat-icon { background: #fffbeb; color: #f59e0b; }
.stat-card:nth-child(4) .stat-icon { background: #f5f3ff; color: #8b5cf6; }
.stat-card .stat-label { font-size: 0.82rem; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.stat-card .stat-value { font-size: 2rem; font-weight: 800; color: var(--text-primary); line-height: 1; }

/* ===== Buttons ===== */
.btn {
    padding: 10px 20px; border-radius: var(--radius-sm); border: none;
    cursor: pointer; font-size: 0.875rem; font-weight: 600;
    font-family: inherit; text-decoration: none; display: inline-flex;
    align-items: center; justify-content: center; gap: 8px;
    transition: var(--transition); position: relative; overflow: hidden;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(0); }
.btn-primary { background: linear-gradient(135deg, var(--secondary), var(--secondary-light)); color: #fff; }
.btn-primary:hover { background: linear-gradient(135deg, #2563eb, var(--secondary)); }
.btn-success { background: linear-gradient(135deg, var(--success), #34d399); color: #fff; }
.btn-danger { background: linear-gradient(135deg, var(--danger), #f87171); color: #fff; }
.btn-warning { background: linear-gradient(135deg, var(--warning), var(--accent-light)); color: #fff; }
.btn-info { background: linear-gradient(135deg, var(--info), #22d3ee); color: #fff; }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--text-primary); }
.btn-outline:hover { border-color: var(--secondary); color: var(--secondary); background: rgba(59,130,246,0.05); }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-lg { padding: 14px 28px; font-size: 1rem; }
.btn-block { width: 100%; }
.btn i { font-size: 0.9em; }
.btn-group { display: flex; gap: 6px; }

/* ===== Forms ===== */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 600; font-size: 0.85rem; color: var(--text-primary); }
.form-group label .required { color: var(--danger); margin-left: 2px; }
.form-control {
    width: 100%; padding: 10px 14px; border: 1.5px solid var(--border);
    border-radius: var(--radius-sm); font-size: 0.9rem; font-family: inherit;
    background: var(--bg-card); color: var(--text-primary);
    transition: var(--transition);
}
.form-control:focus { outline: none; border-color: var(--secondary); box-shadow: 0 0 0 3px rgba(59,130,246,0.12); }
.form-control::placeholder { color: var(--text-muted); }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 16px; }
.form-check { display: flex; align-items: center; gap: 8px; }
.form-check input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--secondary); }

/* ===== Tables ===== */
.table-responsive { overflow-x: auto; border-radius: var(--radius-md); }
table { width: 100%; border-collapse: collapse; }
table th { background: var(--border-light); font-weight: 600; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-secondary); padding: 14px 16px; text-align: left; white-space: nowrap; border-bottom: 2px solid var(--border); }
table td { padding: 14px 16px; border-bottom: 1px solid var(--border-light); font-size: 0.9rem; vertical-align: middle; }
table tbody tr { transition: var(--transition); }
table tbody tr:hover { background: rgba(59,130,246,0.03); }
table tbody tr:last-child td { border-bottom: none; }

/* ===== Badges ===== */
.badge { display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 600; }
.badge-success { background: var(--success-light); color: #059669; }
.badge-danger { background: var(--danger-light); color: #dc2626; }
.badge-warning { background: var(--warning-light); color: #d97706; }
.badge-info { background: var(--info-light); color: #0891b2; }
.badge-primary { background: #eff6ff; color: #2563eb; }

/* ===== Tabs ===== */
.tabs { display: flex; gap: 4px; margin-bottom: 24px; background: var(--border-light); padding: 4px; border-radius: var(--radius-md); flex-wrap: wrap; }
.tabs a { padding: 10px 20px; border-radius: var(--radius-sm); text-decoration: none; color: var(--text-secondary); font-weight: 600; font-size: 0.875rem; transition: var(--transition); }
.tabs a:hover { color: var(--text-primary); background: rgba(255,255,255,0.5); }
.tabs a.active { background: var(--bg-card); color: var(--secondary); box-shadow: var(--shadow-sm); }

/* ===== Flash Messages ===== */
.flash-message { padding: 14px 20px; border-radius: var(--radius-md); margin-bottom: 20px; display: flex; align-items: center; gap: 12px; font-weight: 500; font-size: 0.9rem; animation: slideDown 0.3s ease-out; }
.flash-success { background: var(--success-light); color: #065f46; border: 1px solid #a7f3d0; }
.flash-error { background: var(--danger-light); color: #991b1b; border: 1px solid #fecaca; }
.flash-warning { background: var(--warning-light); color: #92400e; border: 1px solid #fde68a; }
.flash-info { background: var(--info-light); color: #155e75; border: 1px solid #a5f3fc; }

/* ===== Modal ===== */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); backdrop-filter: blur(4px); z-index: 2000; display: none; align-items: center; justify-content: center; animation: fadeIn 0.2s ease; }
.modal-overlay.show { display: flex; }
.modal { background: var(--bg-card); border-radius: var(--radius-lg); width: 90%; max-width: 560px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-xl); animation: scaleIn 0.3s ease; }
.modal-header { padding: 20px 24px; border-bottom: 1px solid var(--border-light); display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { font-size: 1.1rem; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--text-muted); padding: 4px; line-height: 1; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border-light); display: flex; justify-content: flex-end; gap: 10px; }

/* ===== Login Page ===== */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #0f1f33 0%, #1e3a5f 50%, #2d5a8e 100%); padding: 20px; position: relative; overflow: hidden; }
.login-page::before { content: ''; position: absolute; width: 400px; height: 400px; background: radial-gradient(circle, rgba(245,158,11,0.15), transparent 70%); top: -100px; right: -100px; border-radius: 50%; }
.login-page::after { content: ''; position: absolute; width: 300px; height: 300px; background: radial-gradient(circle, rgba(59,130,246,0.1), transparent 70%); bottom: -50px; left: -50px; border-radius: 50%; }
.login-card { background: rgba(255,255,255,0.97); padding: 48px 40px; border-radius: var(--radius-xl); box-shadow: var(--shadow-xl); width: 100%; max-width: 420px; text-align: center; position: relative; z-index: 1; backdrop-filter: blur(20px); animation: fadeInUp 0.6s ease-out; }
.login-card .login-logo { max-width: 90px; margin-bottom: 16px; border-radius: 16px; box-shadow: var(--shadow-md); }
.login-card h1 { font-size: 1.5rem; font-weight: 800; color: var(--primary); margin-bottom: 4px; }
.login-card .login-subtitle { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 32px; }
.login-card .form-control { text-align: left; margin-bottom: 16px; padding: 12px 16px; }
.login-card .btn { padding: 14px; font-size: 1rem; margin-top: 8px; }
.login-error { background: var(--danger-light); color: #991b1b; padding: 12px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 0.875rem; font-weight: 500; }

/* ===== Calendar Grid ===== */
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; background: var(--border); border-radius: var(--radius-md); overflow: hidden; }
.calendar-header-cell { background: var(--primary); color: #fff; padding: 10px; text-align: center; font-weight: 600; font-size: 0.82rem; }
.calendar-cell { background: var(--bg-card); min-height: 90px; padding: 8px; position: relative; transition: var(--transition); }
.calendar-cell:hover { background: var(--border-light); }
.calendar-cell .day-number { font-size: 0.85rem; font-weight: 600; color: var(--text-secondary); }
.calendar-cell.today .day-number { background: var(--secondary); color: #fff; width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.calendar-cell.other-month { opacity: 0.4; }
.calendar-event { font-size: 0.7rem; padding: 2px 6px; border-radius: 4px; margin-top: 4px; color: #fff; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===== Animations ===== */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }

/* ===== Empty State ===== */
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state i { font-size: 3rem; margin-bottom: 16px; color: var(--border); }
.empty-state h3 { color: var(--text-secondary); margin-bottom: 8px; }

/* ===== Print Styles ===== */
@media print {
    .sidebar, .topbar, .btn, .page-actions, form, #sidebar-toggle, .tabs { display: none !important; }
    .main-content { margin-left: 0 !important; }
    .card { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; }
    .watermark { display: none; }
    body { background: #fff; }
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
    .dashboard-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); }
    .main-content { margin-left: 0; }
    #sidebar-toggle { display: block !important; }
    .topbar { padding: 0 16px; }
    .content-wrapper { padding: 16px; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .form-row { grid-template-columns: 1fr; }
    .user-info .user-details { display: none; }
    .org-name { font-size: 0.95rem; }
    .calendar-grid { font-size: 0.75rem; }
    .calendar-cell { min-height: 60px; padding: 4px; }
}
@media (max-width: 480px) {
    .login-card { padding: 32px 24px; }
    .tabs { flex-direction: column; }
    .tabs a { text-align: center; }
}

/* ===== DataTables Override ===== */
.dataTables_wrapper .dataTables_filter input { border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 8px 12px; font-family: 'Inter', sans-serif; }
.dataTables_wrapper .dataTables_filter input:focus { border-color: var(--secondary); outline: none; box-shadow: 0 0 0 3px rgba(59,130,246,0.12); }
.dataTables_wrapper .dataTables_length select { border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 6px 8px; }
.dataTables_wrapper .dataTables_paginate .paginate_button.current { background: var(--secondary) !important; color: #fff !important; border: none !important; border-radius: var(--radius-sm); }

/* ===== Sidebar Overlay (mobile) ===== */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 999; }
.sidebar-overlay.show { display: block; }
