/* ============================================
   ELINOM SCHOOL MANAGEMENT SYSTEM
   Modern Enterprise CSS Styles
   ============================================ */

/* CSS Variables */
:root {
  --sch-primary: #4f46e5;      /* Indigo 600 */
  --sch-primary-light: #6366f1; /* Indigo 500 */
  --sch-primary-dark: #4338ca;  /* Indigo 700 */
  --sch-secondary: #0ea5e9;    /* Sky 500 */
  --sch-success: #10b981;      /* Emerald 500 */
  --sch-warning: #f59e0b;      /* Amber 500 */
  --sch-danger: #ef4444;       /* Red 500 */
  --sch-info: #3b82f6;         /* Blue 500 */
  
  --sch-bg: #f8fafc;           /* Slate 50 */
  --sch-card-bg: #ffffff;
  --sch-text: #0f172a;         /* Slate 900 */
  --sch-text-muted: #64748b;   /* Slate 500 */
  --sch-border: #e2e8f0;       /* Slate 200 */
  
  --sch-sidebar-width: 260px;
  --sch-sidebar-collapsed: 70px;
  
  --sch-shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --sch-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --sch-shadow-lg: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  
  --sch-radius: 12px;
  --sch-radius-sm: 8px;
  --sch-radius-lg: 20px;
  
  --sch-transition: all 0.3s ease;
}

/* Reset & Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--sch-bg);
  color: var(--sch-text);
  line-height: 1.6;
  min-height: 100vh;
}

/* Embedded View Mode (Inside Iframe) */
/* In embedded mode we hide top chrome, but KEEP the module's own sidebar
   so submenus remain available inside the iframe. */
body.embedded-view .security-bar,
body.embedded-view .system-controls {
  display: none !important;
}

body.embedded-view .sidebar {
  display: flex !important;
}

body.embedded-view .app-container {
  min-height: 100vh;
}

body.embedded-view .main-content {
  padding: 24px;
}

/* Security Bar */
.security-bar {
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 100%);
  padding: 8px 24px;
  display: flex;
  justify-content: center;
  gap: 32px;
  flex-wrap: wrap;
}

.security-item {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #a5b4fc;
  font-size: 0.75rem;
  font-weight: 500;
}

.security-item i {
  color: var(--sch-success);
  font-size: 0.875rem;
}

/* System Controls */
.system-controls {
  background: var(--sch-card-bg);
  border-bottom: 1px solid var(--sch-border);
  padding: 8px 24px;
  display: flex;
  justify-content: flex-end;
  gap: 16px;
}

.switcher-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--sch-bg);
  border: 1px solid var(--sch-border);
  border-radius: var(--sch-radius-sm);
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--sch-text);
  transition: var(--sch-transition);
}

.switcher-btn:hover {
  background: var(--sch-border);
}

/* App Container */
.app-container {
  display: flex;
  min-height: calc(100vh - 80px);
}

/* Sidebar */
.sidebar {
  width: var(--sch-sidebar-width);
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
  color: #fff;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  transition: var(--sch-transition);
  z-index: 100;
}

.sidebar.collapsed {
  width: var(--sch-sidebar-collapsed);
}

.sidebar-header {
  padding: 20px 24px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  position: relative;
}

.sidebar-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 24px;
  right: 24px;
  height: 2px;
  background: linear-gradient(90deg, var(--sch-primary) 0%, var(--sch-secondary) 100%);
  border-radius: 2px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-icon-wrap {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--sch-primary) 0%, var(--sch-primary-dark) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.45);
  flex-shrink: 0;
}

.logo-icon-wrap i {
  font-size: 1.2rem;
  color: #fff;
}

.logo-text-wrap {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.logo-name {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  background: linear-gradient(90deg, #fff 0%, var(--sch-primary-light) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.2;
}

.logo-tagline {
  font-size: 0.7rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.5);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1;
}

.sidebar-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  color: rgba(255, 255, 255, 0.75);
  border-radius: var(--sch-radius-sm);
  transition: var(--sch-transition);
}

.sidebar-toggle:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0;
  overflow-y: auto;
}

.nav-list {
  list-style: none;
}

.nav-item {
  margin-bottom: 4px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0.75rem 1.5rem;
  color: rgba(255, 255, 255, 0.75);
  text-decoration: none;
  transition: all 0.2s;
  font-weight: 500;
  position: relative;
  border-left: 3px solid transparent;
  border-radius: 0;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.nav-link.active {
  background: rgba(99, 102, 241, 0.2);
  color: #fff;
  border-left-color: var(--sch-primary-light);
}

.nav-link i {
  font-size: 1.125rem;
  width: 20px;
  text-align: center;
  color: var(--sch-primary-light);
}

.nav-link:hover i,
.nav-link.active i {
  color: #fff;
}

.nav-link .badge {
  margin-left: auto;
  background: var(--sch-danger);
  color: white;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--sch-border);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--sch-primary) 0%, var(--sch-info) 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
}

.user-details {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-weight: 600;
  font-size: 0.875rem;
}

.user-role {
  font-size: 0.75rem;
  color: var(--sch-text-muted);
}

/* Main Content */
.main-content {
  flex: 1;
  padding: 32px;
  overflow-y: auto;
  background: var(--sch-bg);
}

.section {
  display: none;
  animation: fadeIn 0.3s ease-out;
}

.section.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
}

.section-title {
  font-size: 1.875rem;
  font-weight: 800;
  color: var(--sch-text);
  margin-bottom: 8px;
  letter-spacing: -0.025em;
}

.section-divider {
  height: 4px;
  width: 60px;
  background: linear-gradient(to right, var(--sch-primary), transparent);
  border-radius: 2px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--sch-primary) 0%, var(--sch-primary-dark) 100%);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: var(--sch-radius-sm);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: var(--sch-transition);
  box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.2);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 8px -1px rgba(79, 70, 229, 0.3);
}

.btn-outline {
  background: transparent;
  color: var(--sch-text);
  border: 1px solid var(--sch-border);
  padding: 12px 24px;
  border-radius: var(--sch-radius-sm);
  font-weight: 500;
  cursor: pointer;
  transition: var(--sch-transition);
}

.btn-outline:hover {
  background: var(--sch-bg);
  border-color: var(--sch-primary);
  color: var(--sch-primary);
}

/* Dashboard Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--sch-card-bg);
  padding: 24px;
  border-radius: var(--sch-radius);
  box-shadow: var(--sch-shadow-sm);
  display: flex;
  align-items: center;
  gap: 20px;
  transition: var(--sch-transition);
  border: 1px solid var(--sch-border);
}

.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--sch-shadow);
  border-color: var(--sch-primary-light);
}

.stat-icon {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  background: #eef2ff;
  color: var(--sch-primary);
}

.stat-content h3 {
  font-size: 0.875rem;
  color: var(--sch-text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--sch-text);
  margin-bottom: 0;
  line-height: 1.2;
}

/* Quick Actions Grid */
.actions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.action-card {
  background: var(--sch-card-bg);
  padding: 20px;
  border-radius: var(--sch-radius);
  border: 1px solid var(--sch-border);
  text-align: center;
  cursor: pointer;
  transition: var(--sch-transition);
}

.action-card:hover {
  border-color: var(--sch-primary);
  background: #fdfafa;
}

.action-card i {
  font-size: 2rem;
  color: var(--sch-primary);
  margin-bottom: 12px;
  display: block;
}

.action-card span {
  font-weight: 600;
  color: var(--sch-text);
}

/* Charts & Lists */
.content-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
  margin-bottom: 32px;
}

.card {
  background: var(--sch-card-bg);
  border-radius: var(--sch-radius);
  box-shadow: var(--sch-shadow-sm);
  border: 1px solid var(--sch-border);
  overflow: hidden;
}

.card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--sch-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-title {
  font-size: 1.125rem;
  font-weight: 700;
}

.card-body {
  padding: 24px;
}

/* Tables */
.table-container {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  text-align: left;
  padding: 16px 24px;
  background: #f8fafc;
  color: var(--sch-text-muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--sch-border);
}

td {
  padding: 16px 24px;
  border-bottom: 1px solid var(--sch-border);
  color: var(--sch-text);
  font-size: 0.875rem;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: #f8fafc;
}

/* Profiles */
.profile-card {
  display: flex;
  align-items: center;
  gap: 12px;
}

.profile-img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
}

/* Status Badges */
.status-badge {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.status-badge.success { background: #dcfce7; color: #166534; }
.status-badge.warning { background: #fef3c7; color: #92400e; }
.status-badge.danger { background: #fee2e2; color: #991b1b; }
.status-badge.info { background: #e0f2fe; color: #075985; }

/* Utilities */
@media (max-width: 1024px) {
  .content-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .sidebar {
    width: 68px; min-width: 68px; overflow: hidden;
  }
  .sidebar .nav-text, .sidebar .sidebar-label { display: none; }
  .sidebar .nav-link { justify-content: center; padding: 12px 0; }
  .sidebar .nav-link i { margin-right: 0; }
  .main-content { margin-left: 68px; }
}

@media (max-width: 900px) {
  .sidebar {
    position: fixed; left: -280px; top: 0;
    width: 260px; min-width: 260px; height: 100vh;
    z-index: 9999; transition: left 0.3s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,0.3); overflow-y: auto;
  }
  .sidebar.mobile-open { left: 0; }
  .sidebar.mobile-open .nav-text, .sidebar.mobile-open .sidebar-label { display: initial; }
  .sidebar.mobile-open .nav-link { justify-content: flex-start; padding: 12px 20px; }
  .sidebar.mobile-open .nav-link i { margin-right: 12px; }
  .main-content { margin-left: 0; padding: 16px; width: 100%; }
  .header-area { flex-direction: column; align-items: flex-start; gap: 12px; }
}

@media (max-width: 768px) {
  .stats-grid { grid-template-columns: 1fr; }
  .action-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}

@media (max-width: 600px) {
  .main-content { padding: 12px; }
  .action-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .stats-grid { gap: 8px; }
}
