/* ==========================================================================
   SIMPEL-IF Layout System
   ========================================================================== */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Global Custom Sleek Scrollbar */
*::-webkit-scrollbar {
  height: 6px;
  width: 6px;
}

*::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 999px;
}

*::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 999px;
  transition: background 0.2s ease;
}

*::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-app);
  background-image: 
    radial-gradient(at 0% 0%, rgba(5, 150, 105, 0.045) 0px, transparent 50%),
    radial-gradient(at 100% 0%, rgba(217, 119, 6, 0.035) 0px, transparent 50%),
    radial-gradient(at 50% 100%, rgba(37, 99, 235, 0.04) 0px, transparent 60%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='60' viewBox='0 0 60 60'%3E%3Cg fill='none' stroke='%23065f46' stroke-width='0.7' stroke-opacity='0.032'%3E%3Cpath d='M30 0 L60 30 L30 60 L0 30 Z'/%3E%3Crect x='10' y='10' width='40' height='40' transform='rotate(45 30 30)'/%3E%3Ccircle cx='30' cy='30' r='8' stroke='%23d97706' stroke-opacity='0.028'/%3E%3Ccircle cx='30' cy='30' r='18'/%3E%3Cpath d='M0 0 L60 60 M60 0 L0 60'/%3E%3C/g%3E%3C/svg%3E");
  background-attachment: fixed;
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* App Wrapper */
.app-container {
  display: flex;
  min-height: 100vh;
  position: relative;
}

/* ==========================================================================
   Role Switcher Bar (Hidden in Production Deployment)
   ========================================================================== */
.role-switcher-banner,
#role-switcher-banner,
.role-buttons-group,
.role-buttons-container {
  display: none !important;
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  height: 0 !important;
  width: 0 !important;
  z-index: -9999 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

/* ==========================================================================
   Guest / Unauthenticated Mode (Login Portal Full-Screen Layout)
   ========================================================================== */
body.guest-mode .role-switcher-banner,
body.guest-mode .sidebar,
body.guest-mode .topbar {
  display: none !important;
}

body.guest-mode .main-wrapper {
  margin-left: 0 !important;
  margin-top: 0 !important;
  width: 100% !important;
  max-width: 100vw !important;
  min-height: 100vh !important;
}

body.guest-mode .content-area {
  padding: 16px 20px 40px !important;
  min-height: 100vh !important;
}

.role-switcher-banner::-webkit-scrollbar {
  display: none;
}

.role-brand-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #e0f2fe;
  flex-shrink: 0;
}

.role-brand-badge .badge-tag {
  background: rgba(2, 132, 199, 0.35);
  border: 1px solid rgba(56, 189, 248, 0.5);
  color: #7dd3fc;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  text-transform: uppercase;
}

.islamic-rub-badge {
  background: rgba(16, 185, 129, 0.2);
  border: 1px solid rgba(52, 211, 153, 0.5);
  color: #a7f3d0;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.role-buttons-group {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.08);
  padding: 3px 4px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(255, 255, 255, 0.12);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  flex-wrap: nowrap;
  scrollbar-width: none;
  cursor: grab;
}

.role-buttons-group::-webkit-scrollbar {
  display: none;
}

.role-btn {
  background: transparent;
  border: none;
  color: #cbdcf8;
  padding: 5px 14px;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition-fast);
  white-space: nowrap;
  flex-shrink: 0;
}

.role-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.15);
}

.role-btn.active {
  background: #2563eb;
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}

.role-quick-info {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.78rem;
  color: #94a3b8;
  flex-shrink: 0;
}

.role-quick-info .current-user-name {
  color: #f8fafc;
  font-weight: 600;
}

/* ==========================================================================
   Sidebar Navigation
   ========================================================================== */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-sidebar);
  color: var(--text-sidebar);
  position: fixed;
  top: var(--role-bar-height);
  bottom: 0;
  left: 0;
  z-index: 900;
  display: flex;
  flex-direction: column;
  transition: width var(--transition-normal), transform var(--transition-normal);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  overflow-y: auto;
}

.sidebar-header {
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.15);
}

.sidebar-logo-img {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  object-fit: cover;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  background: #fff;
}

.sidebar-brand-text {
  display: flex;
  flex-direction: column;
}

.sidebar-brand-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: 0.5px;
  line-height: 1.2;
}

.sidebar-brand-subtitle {
  font-size: 0.7rem;
  color: #7dd3fc;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.sidebar-brand-motto {
  font-family: var(--font-arabic);
  font-size: 0.82rem;
  color: #a7f3d0;
  line-height: 1.2;
  margin-top: 3px;
  direction: rtl;
  opacity: 0.92;
  letter-spacing: 0.3px;
}

.sidebar-nav {
  padding: 16px 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-section-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #7dd3fc;
  opacity: 0.85;
  padding: 12px 12px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  color: var(--text-sidebar);
  text-decoration: none;
  font-size: 0.86rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
}

.nav-item:hover {
  background-color: var(--bg-sidebar-hover);
  color: var(--text-sidebar-bright);
  transform: translateX(2px);
}

.nav-item.active {
  background-color: var(--bg-sidebar-active);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.nav-item .nav-icon {
  font-size: 1.15rem;
  width: 22px;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-item .nav-badge {
  margin-left: auto;
  background: #ef4444;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(96, 165, 250, 0.15);
  background: rgba(10, 25, 52, 0.5);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.user-mini-profile {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, #1e40af, #0284c7);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  border: 1.5px solid rgba(255, 255, 255, 0.3);
}

.user-info-text {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: #ffffff;
}

.user-role-tag {
  font-size: 0.7rem;
  color: #38bdf8;
}

/* ==========================================================================
   Main Content Area & Topbar
   ========================================================================== */
.main-wrapper {
  margin-left: var(--sidebar-width);
  margin-top: var(--role-bar-height);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - var(--role-bar-height));
  background-color: var(--bg-app);
}

.topbar {
  height: var(--header-height);
  background: rgba(245, 249, 255, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(191, 219, 254, 0.85);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: var(--role-bar-height);
  z-index: 800;
  box-shadow: 0 2px 10px 0 rgba(37, 99, 235, 0.04);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.mobile-menu-btn {
  display: none;
  background: transparent;
  border: none;
  font-size: 1.25rem;
  color: var(--text-dark);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-md);
}

.page-title-context {
  display: flex;
  flex-direction: column;
}

.page-main-title {
  font-size: 1.18rem;
  font-weight: 800;
  color: var(--text-dark);
  letter-spacing: -0.2px;
}

.page-breadcrumb {
  font-size: 0.76rem;
  color: var(--text-light);
  display: flex;
  align-items: center;
  gap: 6px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Islamic Hijri Calendar Date Badge */
.islamic-date-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: linear-gradient(135deg, rgba(236, 253, 245, 0.95) 0%, rgba(209, 250, 229, 0.85) 100%);
  border: 1px solid var(--islamic-emerald-200);
  border-radius: var(--radius-full);
  padding: 5px 13px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--islamic-emerald-900);
  box-shadow: 0 1px 3px rgba(16, 185, 129, 0.08);
  transition: all 0.2s ease;
  white-space: nowrap;
}

.islamic-date-badge:hover {
  background: #d1fae5;
  border-color: #6ee7b7;
  transform: translateY(-1px);
}

.islamic-star-icon {
  color: var(--islamic-gold-600);
  font-size: 1rem;
  line-height: 1;
  display: inline-block;
  animation: pulseRotate 16s infinite linear;
}

@keyframes pulseRotate {
  0% { transform: rotate(0deg); }
  50% { transform: rotate(180deg); }
  100% { transform: rotate(360deg); }
}

.academic-period-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--primary-50);
  border: 1px solid var(--primary-100);
  color: var(--primary-800);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.academic-period-badge .dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--primary-600);
  animation: pulse-dot 2s infinite ease-in-out;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

.btn-header-action {
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: all var(--transition-fast);
}

.btn-header-action:hover {
  background: var(--primary-50);
  color: var(--primary-700);
  border-color: var(--primary-100);
}

.notification-indicator {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 8px;
  height: 8px;
  background: #ef4444;
  border-radius: var(--radius-full);
  border: 1.5px solid #ffffff;
}

/* View Content Container */
.content-area {
  padding: 28px;
  flex: 1;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
}

.view-section {
  display: none;
  animation: fadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.view-section.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0.3;
    transform: translateX(40px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideInLeft {
  from {
    opacity: 0.3;
    transform: translateX(-40px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ==========================================================================
   Modals & Dialogs
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}

.modal-overlay.active {
  display: flex;
  animation: modalFadeIn 0.2s ease;
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-card {
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-modal);
  width: 100%;
  max-width: 650px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border-light);
  transform: scale(0.96);
  animation: modalZoomIn 0.2s ease forwards;
}

.modal-card.modal-lg {
  max-width: 900px;
}

.modal-card.modal-xl {
  max-width: 1100px;
}

@keyframes modalZoomIn {
  to {
    transform: scale(1);
  }
}

.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid #bfdbfe;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, #eff6ff 0%, #f0f7ff 100%);
}

.modal-header h3 {
  font-size: 1.12rem;
  font-weight: 800;
  color: #1e3a8a;
}

.modal-close-btn {
  background: transparent;
  border: none;
  font-size: 1.25rem;
  color: var(--text-light);
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.modal-close-btn:hover {
  background: #fee2e2;
  color: #ef4444;
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-light);
  background: var(--bg-surface-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

/* ==========================================================================
   Toast Notification Stack
   ========================================================================== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  min-width: 300px;
  max-width: 420px;
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  background: #ffffff;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border-left: 4px solid var(--primary-600);
  animation: toastSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  transition: all 0.25s ease;
}

.toast.toast-success { border-left-color: #10b981; }
.toast.toast-warning { border-left-color: #f59e0b; }
.toast.toast-danger  { border-left-color: #ef4444; }
.toast.toast-info    { border-left-color: #0284c7; }

.toast-icon {
  font-size: 1.2rem;
  line-height: 1;
}

.toast-content {
  flex: 1;
}

.toast-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-dark);
}

.toast-message {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateX(40px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}
