@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@400;500;600;700&family=Plus+Jakarta+Sans:wght@700;800&display=swap');

/* ═══════════════════════════════════════════════════════
   CSS VARIABLES — RANJ Brand
═══════════════════════════════════════════════════════ */
:root {
  --navy:        #1E2B8F;
  --navy-dark:   #141C6B;
  --navy-mid:    #2D3EB5;
  --navy-light:  #EEF0FD;
  --orange:      #E85A1A;
  --orange-soft: #FEF0E8;
  --orange-mid:  #FF6B2B;

  --white:   #FFFFFF;
  --bg:      #F0F2FA;
  --bg-2:    #E8EAF5;

  --text:         #1A1F3A;
  --text-muted:   #6B7299;
  --text-light:   #9BA3C7;

  --border:       #E2E5F5;
  --border-dark:  #CDD1EF;

  --green:        #059669;
  --green-soft:   #ECFDF5;
  --red:          #DC2626;
  --red-soft:     #FEF2F2;
  --yellow:       #D97706;
  --yellow-soft:  #FFFBEB;
  --blue-soft:    #EFF6FF;
  --blue:         #2563EB;

  --radius-sm:  8px;
  --radius-md:  12px;
  --radius-lg:  16px;
  --radius-xl:  20px;

  --shadow-sm: 0 1px 3px rgba(30,43,143,0.08);
  --shadow-md: 0 4px 16px rgba(30,43,143,0.10);
  --shadow-lg: 0 8px 32px rgba(30,43,143,0.14);

  --sidebar-w: 240px;
  --topbar-h:  56px;
  --bottom-nav-h: 64px;

  --font:    'IBM Plex Sans Arabic', sans-serif;
  --font-en: 'Plus Jakarta Sans', sans-serif;
}

/* ═══════════════════════════════════════════════════════
   RESET & BASE
═══════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }
a  { text-decoration: none; color: inherit; }
button, input, select, textarea { font-family: inherit; }

/* ═══════════════════════════════════════════════════════
   LAYOUT — Mobile first, Desktop via media query
═══════════════════════════════════════════════════════ */

/* Mobile: full screen stack */
.layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Desktop sidebar */
.sidebar {
  display: none; /* hidden on mobile */
}

/* Mobile topbar */
.mob-topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--navy-dark);
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  gap: 12px;
}

.main-content {
  flex: 1;
  padding: 16px 14px calc(var(--bottom-nav-h) + 16px);
  overflow-x: hidden;
}

/* Mobile bottom nav */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--white);
  border-top: 1px solid var(--border);
  height: var(--bottom-nav-h);
  display: flex;
  align-items: center;
  padding: 0 4px 8px;
  /* safe area for iPhone notch */
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
}

/* Desktop layout */
@media (min-width: 768px) {
  .layout {
    flex-direction: row;
  }
  .sidebar {
    display: flex;
    flex-direction: column;
    width: var(--sidebar-w);
    min-height: 100vh;
    position: sticky;
    top: 0;
    background: var(--navy-dark);
    flex-shrink: 0;
    overflow-y: auto;
    overflow-x: hidden;
  }
  .mob-topbar {
    display: none;
  }
  .main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
  }
  .desktop-topbar {
    display: flex !important;
  }
  .main-content {
    padding: 24px;
    padding-bottom: 24px;
  }
  .bottom-nav {
    display: none;
  }
}

/* ═══════════════════════════════════════════════════════
   LOGO — used in sidebar + mobile topbar
═══════════════════════════════════════════════════════ */
.logo-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo-img-circle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--white);
  padding: 3px;
  object-fit: contain;
  flex-shrink: 0;
}
.logo-text-en {
  font-family: var(--font-en);
  font-weight: 800;
  font-size: 16px;
  color: var(--white);
  line-height: 1.1;
  letter-spacing: 0.3px;
}
.logo-text-ku {
  font-size: 9px;
  color: rgba(255,255,255,0.45);
  margin-top: 1px;
}

/* ═══════════════════════════════════════════════════════
   SIDEBAR (Desktop)
═══════════════════════════════════════════════════════ */
.sidebar-logo {
  padding: 18px 16px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
.sidebar-nav {
  flex: 1;
  padding: 8px 8px;
  overflow-y: auto;
}
.nav-section-label {
  font-size: 9.5px;
  font-weight: 600;
  color: rgba(255,255,255,0.3);
  padding: 10px 10px 4px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: rgba(255,255,255,0.6);
  cursor: pointer;
  transition: background .15s, color .15s;
  margin-bottom: 2px;
  position: relative;
}
.nav-item:hover { background: rgba(255,255,255,0.06); color: rgba(255,255,255,.9); }
.nav-item.active { background: var(--orange); color: var(--white); font-weight: 600; }
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; opacity: .7; }
.nav-item.active svg { opacity: 1; }
.nav-badge {
  margin-right: auto;
  background: rgba(255,255,255,0.15);
  color: white;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 20px;
}
.nav-item.active .nav-badge { background: rgba(255,255,255,.3); }
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,0.07);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 9px;
}
.sidebar-avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--orange);
  color: white;
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sidebar-username { font-size: 12.5px; font-weight: 600; color: white; }
.sidebar-userrole { font-size: 10px; color: rgba(255,255,255,.4); margin-top: 1px; }

/* ═══════════════════════════════════════════════════════
   DESKTOP TOPBAR
═══════════════════════════════════════════════════════ */
.desktop-topbar {
  display: none;
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-title { font-size: 15px; font-weight: 700; color: var(--text); }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: background .15s;
}
.icon-btn:hover { background: var(--border); }
.icon-btn svg { width: 16px; height: 16px; color: var(--text-muted); }
.notif-dot {
  position: absolute;
  top: 7px;
  left: 7px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--orange);
  border: 1.5px solid var(--white);
}
.year-badge {
  background: var(--navy);
  color: white;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 6px;
  font-family: var(--font-en);
}

/* ═══════════════════════════════════════════════════════
   MOBILE TOPBAR
═══════════════════════════════════════════════════════ */
.mob-topbar-icons {
  display: flex;
  align-items: center;
  gap: 6px;
}
.mob-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
}
.mob-icon svg { width: 17px; height: 17px; color: white; }
.mob-notif-dot {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--orange);
  border: 1.5px solid var(--navy-dark);
}

/* ═══════════════════════════════════════════════════════
   BOTTOM NAV (Mobile)
═══════════════════════════════════════════════════════ */
.bn-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 9.5px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px 0 0;
  position: relative;
  transition: color .15s;
  -webkit-tap-highlight-color: transparent;
}
.bn-item.active { color: var(--navy-dark); font-weight: 600; }
.bn-item svg { width: 22px; height: 22px; }
.bn-fab {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--orange);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: -22px;
  box-shadow: 0 4px 14px rgba(232,90,26,.45);
  transition: transform .15s;
  -webkit-tap-highlight-color: transparent;
}
.bn-fab:active { transform: scale(.94); }
.bn-fab svg { width: 22px; height: 22px; color: white; }
.bn-badge {
  position: absolute;
  top: 4px;
  left: 50%;
  margin-left: 6px;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  background: var(--orange);
  color: white;
  font-size: 8px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  border: 2px solid var(--white);
}

/* ═══════════════════════════════════════════════════════
   CARDS
═══════════════════════════════════════════════════════ */
.card {
  background: var(--white);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.card-title { font-size: 13.5px; font-weight: 700; color: var(--text); }
.card-action { font-size: 11px; color: var(--navy-mid); font-weight: 600; }
.card-body { padding: 16px; }

/* ═══════════════════════════════════════════════════════
   STAT CARDS
═══════════════════════════════════════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
}
@media (min-width: 768px) {
  .stats-grid { grid-template-columns: repeat(4, 1fr); gap: 14px; }
}
.stat-card {
  background: var(--white);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  padding: 14px;
}
.stat-card.accent {
  background: var(--navy-dark);
  border-color: var(--navy-dark);
}
.stat-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
}
.stat-icon svg { width: 17px; height: 17px; }
.stat-label { font-size: 10.5px; color: var(--text-muted); margin-bottom: 3px; }
.stat-card.accent .stat-label { color: rgba(255,255,255,.5); }
.stat-value {
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  font-family: var(--font-en);
  color: var(--text);
}
.stat-card.accent .stat-value { color: white; }
.stat-sub { font-size: 10px; color: var(--text-muted); margin-top: 4px; }
.stat-card.accent .stat-sub { color: rgba(255,255,255,.4); }

/* ═══════════════════════════════════════════════════════
   SECTION HEADER
═══════════════════════════════════════════════════════ */
.sec-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  margin-top: 20px;
}
.sec-title { font-size: 13.5px; font-weight: 700; color: var(--text); }
.sec-link  { font-size: 11px; color: var(--navy-mid); font-weight: 600; }

/* ═══════════════════════════════════════════════════════
   BADGES
═══════════════════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 10.5px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-success { background: var(--green-soft); color: var(--green); }
.badge-danger  { background: var(--red-soft);   color: var(--red); }
.badge-warning { background: var(--yellow-soft); color: var(--yellow); }
.badge-info    { background: var(--blue-soft);   color: var(--blue); }
.badge-navy    { background: var(--navy-light);  color: var(--navy); }
.badge-orange  { background: var(--orange-soft); color: var(--orange); }

/* ═══════════════════════════════════════════════════════
   BUTTONS
═══════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  border: none;
  transition: all .15s;
  min-height: 42px; /* touch friendly */
  -webkit-tap-highlight-color: transparent;
}
.btn svg { width: 16px; height: 16px; }
.btn:active { transform: scale(.97); }

.btn-primary { background: var(--navy); color: white; }
.btn-primary:hover { background: var(--navy-mid); }

.btn-orange  { background: var(--orange); color: white; }
.btn-orange:hover { background: var(--orange-mid); }

.btn-secondary {
  background: var(--white);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg); }

.btn-danger  { background: var(--red); color: white; }
.btn-danger:hover { background: #b91c1c; }

.btn-success { background: var(--green); color: white; }
.btn-sm { padding: 6px 12px; font-size: 12px; min-height: 34px; }
.btn-full { width: 100%; }

/* ═══════════════════════════════════════════════════════
   FORMS
═══════════════════════════════════════════════════════ */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 5px;
}
.form-required { color: var(--red); margin-right: 2px; }
.form-hint { font-size: 10.5px; color: var(--text-muted); margin-top: 4px; }
.form-error-msg { font-size: 11px; color: var(--red); margin-top: 4px; }

.form-control {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-family: var(--font);
  color: var(--text);
  background: var(--white);
  transition: border-color .15s, box-shadow .15s;
  direction: rtl;
  -webkit-appearance: none;
}
.form-control:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(30,43,143,.10);
}
.form-control.is-invalid { border-color: var(--red); }
.form-control.is-invalid:focus { box-shadow: 0 0 0 3px rgba(220,38,38,.10); }

textarea.form-control { height: auto; padding: 10px 12px; resize: vertical; }

select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236B7299'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 10px center;
  background-size: 16px;
  padding-left: 32px;
  cursor: pointer;
}

.form-row { display: grid; gap: 12px; }
@media (min-width: 480px) {
  .form-row.cols-2 { grid-template-columns: 1fr 1fr; }
  .form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
}

/* ═══════════════════════════════════════════════════════
   TABLE
═══════════════════════════════════════════════════════ */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  text-align: right;
}
.table th {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 10px 14px;
  background: #FAFBFF;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: #FAFBFF; }

/* ═══════════════════════════════════════════════════════
   PROGRESS BAR
═══════════════════════════════════════════════════════ */
.progress-wrap { display: flex; align-items: center; gap: 6px; }
.progress-bar  {
  flex: 1;
  height: 5px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  min-width: 50px;
}
.progress-fill { height: 100%; border-radius: 3px; transition: width .4s; }

/* ═══════════════════════════════════════════════════════
   FLASH MESSAGES
═══════════════════════════════════════════════════════ */
.flash {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-lg);
  animation: flashIn .25s ease;
  max-width: calc(100vw - 32px);
}
.flash-success { background: var(--green);  color: white; }
.flash-error   { background: var(--red);    color: white; }
.flash-info    { background: var(--navy);   color: white; }
@keyframes flashIn {
  from { opacity: 0; transform: translate(-50%, -10px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ═══════════════════════════════════════════════════════
   HORIZONTAL SCROLL CARDS (overdue, etc.)
═══════════════════════════════════════════════════════ */
.h-scroll {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  margin: 0 -14px;
  padding: 0 14px 6px;
}
.h-scroll::-webkit-scrollbar { display: none; }
@media (min-width: 768px) {
  .h-scroll { margin: 0; padding: 0 0 6px; flex-wrap: wrap; overflow: visible; }
}

/* ═══════════════════════════════════════════════════════
   STUDENT ITEM (list)
═══════════════════════════════════════════════════════ */
.student-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.student-item:last-child { border-bottom: none; }
.student-item:hover { background: #FAFBFF; }
.stu-avatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
}
.stu-info { flex: 1; min-width: 0; }
.stu-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stu-meta { font-size: 11px; color: var(--text-muted); margin-top: 1px; }

/* ═══════════════════════════════════════════════════════
   OVERDUE MINI CARD
═══════════════════════════════════════════════════════ */
.ov-card {
  min-width: 180px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  flex-shrink: 0;
}
.ov-card-top { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.ov-avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--red-soft);
  color: var(--red);
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ov-name  { font-size: 12.5px; font-weight: 600; color: var(--text); }
.ov-meta  { font-size: 10px; color: var(--text-muted); }
.ov-amount {
  font-family: var(--font-en);
  font-size: 15px;
  font-weight: 700;
  color: var(--red);
}
.ov-date { font-size: 10px; color: var(--text-muted); margin-top: 2px; }
.ov-days {
  display: inline-flex;
  background: var(--red-soft);
  color: var(--red);
  font-size: 9.5px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 6px;
  margin-top: 6px;
}

/* ═══════════════════════════════════════════════════════
   LOGIN PAGE
═══════════════════════════════════════════════════════ */
.login-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px 16px;
  background: var(--navy-dark);
  position: relative;
  overflow: hidden;
}
.login-page::before {
  content: '';
  position: absolute;
  bottom: -100px;
  left: -100px;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  background: rgba(255,255,255,.03);
}
.login-page::after {
  content: '';
  position: absolute;
  top: -60px;
  right: -60px;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  background: rgba(232,90,26,.07);
}
.login-card {
  background: var(--white);
  border-radius: var(--radius-xl);
  padding: 32px 24px;
  width: 100%;
  max-width: 400px;
  position: relative;
  z-index: 1;
  box-shadow: 0 24px 60px rgba(0,0,0,0.3);
}
.login-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 28px;
  gap: 10px;
}
.login-logo img {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 3px solid var(--border);
}
.login-logo-name {
  font-family: var(--font-en);
  font-size: 22px;
  font-weight: 800;
  color: var(--navy-dark);
}
.login-logo-sub { font-size: 11px; color: var(--text-muted); text-align: center; }

/* ═══════════════════════════════════════════════════════
   UTILS
═══════════════════════════════════════════════════════ */
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-5 { margin-top: 20px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-5 { margin-bottom: 20px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1; }
.text-muted { color: var(--text-muted); font-size: 12px; }
.text-danger { color: var(--red); }
.text-success { color: var(--green); }
.text-center { text-align: center; }
.font-en { font-family: var(--font-en); }
.w-100 { width: 100%; }
.hidden { display: none; }
