/* ============================================================
   EduManage Pro — Main Stylesheet
   ============================================================ */

/* ── Variables ─────────────────────────────────────────── */
:root {
  --primary:       #1565c0;
  --primary-dark:  #0d47a1;
  --primary-light: #e3f2fd;
  --accent:        #0097a7;
  --accent-dark:   #006064;
  --sidebar-bg:    #0f172a;
  --sidebar-width: 265px;
  --navbar-height: 60px;
  --card-radius:   14px;
  --transition:    0.25s ease;
  --shadow-sm:     0 2px 8px rgba(0,0,0,.08);
  --shadow-md:     0 4px 20px rgba(0,0,0,.12);
  --shadow-lg:     0 8px 40px rgba(0,0,0,.16);
  --font-main:     'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* ── Base ──────────────────────────────────────────────── */
* { box-sizing: border-box; }

body {
  font-family: var(--font-main);
  font-size: 14px;
  color: #1e293b;
  background: #f1f5f9;
  overflow-x: hidden;
}

a { text-decoration: none; }

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

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition);
}

.main-content.sidebar-collapsed {
  margin-left: 64px;
}

.page-content {
  flex: 1;
  padding: 24px;
  padding-top: calc(var(--navbar-height) + 20px);
}

/* ── Sidebar ───────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 1030;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width var(--transition), transform var(--transition);
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.1) transparent;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 4px; }

.sidebar.collapsed { width: 64px; }
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-section-title,
.sidebar.collapsed .sidebar-user-info,
.sidebar.collapsed .brand-text,
.sidebar.collapsed .sidebar-footer,
.sidebar.collapsed .sidebar-arrow { display: none !important; }

/* Brand */
.sidebar-brand {
  padding: 18px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  min-height: 72px;
}

.brand-icon {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 18px; flex-shrink: 0;
}

.brand-name {
  font-size: 14px; font-weight: 700; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.brand-sub { font-size: 10px; color: rgba(255,255,255,.4); white-space: nowrap; }

/* Sidebar user */
.sidebar-user {
  padding: 14px 16px;
  display: flex; align-items: center; gap: 10px;
}

.avatar-circle {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 50%; color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; flex-shrink: 0;
  position: relative;
}

.avatar-circle-sm {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 50%; color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; flex-shrink: 0;
}

.user-status {
  position: absolute; bottom: 2px; right: 2px;
  width: 10px; height: 10px; border-radius: 50%;
  border: 2px solid var(--sidebar-bg);
}
.user-status.online { background: #22c55e; }
.user-status.away   { background: #f59e0b; }

.sidebar-user-info .user-name { font-size: 13px; font-weight: 600; color: #f1f5f9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.sidebar-user-info .user-role { font-size: 11px; color: rgba(255,255,255,.4); }

/* Nav */
.sidebar-nav { list-style: none; padding: 8px 0; margin: 0; flex: 1; }

.nav-section-title {
  padding: 14px 20px 4px;
  font-size: 10px; font-weight: 700;
  color: rgba(255,255,255,.3); letter-spacing: 1.2px; text-transform: uppercase;
}

.sidebar-nav .nav-item > .nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 16px 9px 20px;
  color: rgba(255,255,255,.65);
  border-radius: 8px; margin: 1px 8px;
  transition: all .2s;
  font-size: 13.5px; font-weight: 500;
  white-space: nowrap;
}

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

.sidebar-nav .nav-item > .nav-link.active {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: 0 4px 12px rgba(21,101,192,.4);
}

.nav-icon { width: 18px; text-align: center; flex-shrink: 0; font-size: 14px; }
.sidebar-arrow { margin-left: auto; transition: transform .2s; font-size: 10px; }
.nav-link:not(.collapsed) .sidebar-arrow { transform: rotate(90deg); }

/* Submenu */
.sidebar-nav .collapse .nav-link {
  padding: 8px 12px 8px 16px;
  font-size: 13px; color: rgba(255,255,255,.55);
  border-radius: 6px; margin: 1px 8px;
  display: flex; align-items: center; gap: 8px;
  transition: all .2s;
}
.sidebar-nav .collapse .nav-link:hover { color: #fff; background: rgba(255,255,255,.08); }

.sidebar-divider { height: 1px; background: rgba(255,255,255,.08); margin: 4px 16px; }

.sidebar-footer {
  padding: 12px 20px;
  border-top: 1px solid rgba(255,255,255,.08);
  text-align: center;
}

/* ── Navbar ─────────────────────────────────────────────── */
.main-navbar {
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  height: var(--navbar-height);
  position: fixed; top: 0; right: 0;
  left: var(--sidebar-width);
  z-index: 1020;
  padding: 0 20px;
  transition: left var(--transition);
  box-shadow: var(--shadow-md);
}

.main-navbar.sidebar-collapsed { left: 64px; }

.navbar-search .form-control {
  background: rgba(255,255,255,.15);
  border-color: rgba(255,255,255,.2);
  color: white; font-size: 13px;
  border-radius: 20px 0 0 20px;
}
.navbar-search .form-control::placeholder { color: rgba(255,255,255,.6); }
.navbar-search .form-control:focus { background: rgba(255,255,255,.25); box-shadow: none; }
.navbar-search .btn-light { border-radius: 0 20px 20px 0; border-color: rgba(255,255,255,.2); }

.notification-dropdown { border: none; border-radius: 12px; }

/* ── Cards ──────────────────────────────────────────────── */
.card {
  border-radius: var(--card-radius);
  border: 1px solid #e2e8f0;
  box-shadow: var(--shadow-sm);
  background: #fff;
}

.card-header {
  background: transparent;
  border-bottom: 1px solid #f1f5f9;
  padding: 16px 20px;
  border-radius: var(--card-radius) var(--card-radius) 0 0 !important;
}

.card-header h5, .card-header h6 { margin: 0; }
.card-body { padding: 20px; }

/* Stat cards */
.stat-card {
  border-radius: var(--card-radius);
  padding: 20px;
  color: white;
  position: relative;
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
}

.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }

.stat-card .stat-icon {
  width: 52px; height: 52px;
  background: rgba(255,255,255,.2);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
}

.stat-card .stat-value { font-size: 28px; font-weight: 800; }
.stat-card .stat-label { font-size: 12px; opacity: .85; font-weight: 500; text-transform: uppercase; letter-spacing: .5px; }
.stat-card .stat-change { font-size: 12px; font-weight: 600; }

.stat-card::after {
  content: '';
  position: absolute; right: -20px; top: -20px;
  width: 100px; height: 100px;
  border-radius: 50%;
  background: rgba(255,255,255,.1);
}

.stat-card-blue    { background: linear-gradient(135deg, #1565c0, #1976d2); }
.stat-card-green   { background: linear-gradient(135deg, #2e7d32, #43a047); }
.stat-card-orange  { background: linear-gradient(135deg, #e65100, #f57c00); }
.stat-card-purple  { background: linear-gradient(135deg, #4a148c, #7b1fa2); }
.stat-card-teal    { background: linear-gradient(135deg, #006064, #00838f); }
.stat-card-red     { background: linear-gradient(135deg, #b71c1c, #c62828); }
.stat-card-indigo  { background: linear-gradient(135deg, #283593, #3949ab); }
.stat-card-amber   { background: linear-gradient(135deg, #f57f17, #f9a825); }

/* ── Tables ─────────────────────────────────────────────── */
.table { font-size: 13.5px; }
.table thead th { background: #f8fafc; font-weight: 600; text-transform: uppercase; font-size: 11px; letter-spacing: .6px; color: #64748b; border-bottom: 2px solid #e2e8f0; padding: 12px 16px; white-space: nowrap; }
.table tbody td { padding: 12px 16px; vertical-align: middle; border-color: #f1f5f9; }
.table-hover tbody tr:hover { background: #f8fafc; }
.table img.avatar-img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }

/* ── Forms ──────────────────────────────────────────────── */
.form-control, .form-select {
  border-radius: 8px; border-color: #cbd5e1; font-size: 13.5px;
  padding: 9px 12px;
  transition: border-color .2s, box-shadow .2s;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(21,101,192,.15);
}
.form-label { font-size: 13px; font-weight: 600; color: #374151; margin-bottom: 5px; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn { border-radius: 8px; font-size: 13.5px; font-weight: 500; padding: 8px 18px; transition: all .2s; }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--accent)); border: none; }
.btn-primary:hover { background: linear-gradient(135deg, var(--primary-dark), var(--accent-dark)); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(21,101,192,.3); }
.btn-sm { padding: 5px 12px; font-size: 12.5px; }
.btn-icon { width: 34px; height: 34px; padding: 0; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; }

/* ── Badges ─────────────────────────────────────────────── */
.badge { font-size: 11px; font-weight: 600; padding: 4px 9px; border-radius: 20px; }

/* ── Page header ─────────────────────────────────────────── */
.page-header {
  margin-bottom: 24px;
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px;
}
.page-header h4 { margin: 0; font-size: 20px; font-weight: 700; color: #1e293b; }
.page-header .breadcrumb { margin: 0; font-size: 12.5px; }

/* ── Alerts ─────────────────────────────────────────────── */
.alert-float {
  position: fixed; top: 80px; right: 20px; z-index: 9999;
  max-width: 380px; border-radius: 12px; box-shadow: var(--shadow-lg);
  animation: slideInRight .3s ease;
}
@keyframes slideInRight { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Chat ────────────────────────────────────────────────── */
.chat-container { display: flex; height: calc(100vh - 180px); }
.chat-sidebar { width: 300px; border-right: 1px solid #e2e8f0; overflow-y: auto; flex-shrink: 0; }
.chat-main { flex: 1; display: flex; flex-direction: column; }
.chat-messages { flex: 1; overflow-y: auto; padding: 16px; }
.chat-input-area { padding: 12px 16px; border-top: 1px solid #e2e8f0; background: #f8fafc; }

.message-bubble { max-width: 65%; padding: 10px 14px; border-radius: 16px; font-size: 13.5px; margin-bottom: 4px; line-height: 1.5; }
.message-mine { background: linear-gradient(135deg, var(--primary), var(--accent)); color: white; border-bottom-right-radius: 4px; margin-left: auto; }
.message-other { background: #f1f5f9; color: #1e293b; border-bottom-left-radius: 4px; }
.message-time { font-size: 10px; opacity: .6; margin-top: 2px; }

.chat-room-item { padding: 12px 16px; cursor: pointer; border-bottom: 1px solid #f1f5f9; display: flex; align-items: center; gap: 10px; transition: background .15s; }
.chat-room-item:hover, .chat-room-item.active { background: var(--primary-light); }
.chat-unread-badge { font-size: 10px; background: #ef4444; color: white; border-radius: 10px; padding: 2px 7px; }

/* ── ID Card ─────────────────────────────────────────────── */
.id-card {
  width: 86mm; height: 54mm;
  border-radius: 8px; overflow: hidden;
  box-shadow: var(--shadow-md);
  position: relative; display: flex; flex-direction: column;
  font-family: var(--font-main);
  page-break-inside: avoid;
}
.id-card-header { padding: 8px 12px; display: flex; align-items: center; gap: 8px; }
.id-card-body { flex: 1; padding: 8px 12px; background: white; display: flex; gap: 10px; }
.id-card-photo { width: 48px; height: 58px; border-radius: 4px; object-fit: cover; flex-shrink: 0; }
.id-card-footer { padding: 5px 12px; display: flex; align-items: center; justify-content: space-between; }
.id-card .name { font-size: 12px; font-weight: 700; }
.id-card .role-label { font-size: 9px; opacity: .8; text-transform: uppercase; letter-spacing: .5px; }
.id-card .info-row { font-size: 9.5px; margin-bottom: 2px; }
.id-card .qr-container { display: flex; align-items: center; }

/* ── Dashboard charts ────────────────────────────────────── */
.chart-container { position: relative; }

/* ── Timetable ───────────────────────────────────────────── */
.timetable-table th { text-align: center; padding: 8px 6px !important; }
.timetable-table td { text-align: center; padding: 4px !important; vertical-align: middle; }
.timetable-slot {
  background: var(--primary-light); border-left: 3px solid var(--primary);
  border-radius: 6px; padding: 4px 8px; font-size: 11px;
  margin: 2px; cursor: pointer; transition: all .2s;
}
.timetable-slot:hover { background: var(--primary); color: white; }
.timetable-slot .subject { font-weight: 600; }
.timetable-slot .teacher { opacity: .75; font-size: 10px; }

/* ── Progress ────────────────────────────────────────────── */
.progress { border-radius: 20px; height: 8px; background: #e2e8f0; }
.progress-bar { border-radius: 20px; }

/* ── Quick stats strip ───────────────────────────────────── */
.quick-stat { text-align: center; padding: 16px 8px; }
.quick-stat .value { font-size: 24px; font-weight: 800; color: var(--primary); }
.quick-stat .label { font-size: 11px; color: #64748b; text-transform: uppercase; letter-spacing: .5px; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
    z-index: 1040;
    width: var(--sidebar-width) !important;
  }
  .sidebar.show { transform: translateX(0); }
  .main-content { margin-left: 0 !important; }
  .main-navbar { left: 0 !important; }
  .sidebar-backdrop {
    position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 1035;
    display: none;
  }
  .sidebar-backdrop.show { display: block; }
}

@media (max-width: 575.98px) {
  .page-content { padding: 12px; padding-top: calc(var(--navbar-height) + 12px); }
  .stat-card .stat-value { font-size: 22px; }
}

/* ── Print ───────────────────────────────────────────────── */
@media print {
  .sidebar, .main-navbar, .btn, .no-print { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .page-content { padding: 0 !important; padding-top: 0 !important; }
  .card { box-shadow: none !important; border: 1px solid #dee2e6 !important; }
}

/* ── DataTables ──────────────────────────────────────────── */
div.dataTables_wrapper div.dataTables_filter input { border-radius: 8px; border: 1px solid #cbd5e1; padding: 6px 12px; }
div.dataTables_wrapper div.dataTables_length select { border-radius: 8px; border: 1px solid #cbd5e1; }
table.dataTable thead th.sorting, table.dataTable thead th.sorting_asc, table.dataTable thead th.sorting_desc { cursor: pointer; }

/* ── Select2 overrides ───────────────────────────────────── */
.select2-container--bootstrap-5 .select2-selection { border-radius: 8px !important; }

/* ── Utilities ───────────────────────────────────────────── */
.text-truncate-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cursor-pointer { cursor: pointer; }
.rounded-xl { border-radius: 16px !important; }
.border-dashed { border-style: dashed !important; }
.hover-shadow:hover { box-shadow: var(--shadow-md) !important; transition: box-shadow .2s; }

.loading-overlay {
  position: fixed; inset: 0; background: rgba(255,255,255,.8);
  display: flex; align-items: center; justify-content: center; z-index: 9999;
  display: none;
}

.empty-state { text-align: center; padding: 60px 20px; color: #94a3b8; }
.empty-state i { font-size: 56px; margin-bottom: 16px; display: block; }
.empty-state h5 { color: #64748b; font-weight: 600; }

/* ── Superadmin specific ─────────────────────────────────── */
.institute-card { border-radius: var(--card-radius); border: 1px solid #e2e8f0; overflow: hidden; transition: all .2s; }
.institute-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.institute-card .card-img-top { height: 120px; object-fit: cover; background: linear-gradient(135deg, var(--primary), var(--accent)); }
.institute-logo-placeholder { height: 120px; background: linear-gradient(135deg, var(--primary), var(--accent)); display: flex; align-items: center; justify-content: center; }

.module-toggle-card { border: 2px solid #e2e8f0; border-radius: 12px; padding: 16px; transition: all .2s; cursor: pointer; }
.module-toggle-card.enabled { border-color: var(--primary); background: var(--primary-light); }
.module-toggle-card:hover { border-color: var(--primary); }

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