/* ================================================================
   DevSubmit — main.css
   Auteur: DevSubmit
   ================================================================ */

/* ─── Variables ───────────────────────────────────────────────── */
:root {
  --primary: #4F46E5;
  --primary-dark: #3730A3;
  --primary-light: #EEF2FF;
  --secondary: #7C3AED;
  --success: #059669;
  --warning: #D97706;
  --danger: #DC2626;
  --info: #0891B2;

  --sidebar-bg: #0F172A;
  --sidebar-w: 260px;
  --header-h: 64px;
  --mobile-bar-h: 56px;

  --bg-body: #F1F5F9;
  --bg-card: #FFFFFF;
  --text-main: #1E293B;
  --text-muted: #64748B;
  --text-light: #94A3B8;
  --border-color: #E2E8F0;

  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .07), 0 1px 2px rgba(0, 0, 0, .05);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, .08);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, .12);

  --transition: .18s ease;
}

/* ─── Reset / Base ────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: .925rem;
  color: var(--text-main);
  background: var(--bg-body);
  margin: 0;
}

/* ─── Loader ─────────────────────────────────────────────────── */
#global-loader {
  position: fixed;
  inset: 0;
  background: #fff;
  z-index: 9999;
  transition: opacity .35s ease, visibility .35s;
}

#global-loader.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loader-spinner {
  width: 44px;
  height: 44px;
  border: 4px solid var(--primary-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .75s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loader-text {
  color: var(--primary);
  font-size: .85rem;
  font-weight: 600;
  letter-spacing: .04em;
}

/* ─── Auth Pages ─────────────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.auth-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 440px;
}

.auth-logo {
  width: 60px;
  height: 60px;
  background: var(--primary);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  color: #fff;
  margin: 0 auto 1.25rem;
}

.auth-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-main);
}

.auth-subtitle {
  color: var(--text-muted);
  font-size: .88rem;
}

/* ─── App Layout ─────────────────────────────────────────────── */
.app-page {
  overflow: hidden;
}

#page-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ─── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 1030;
  transition: transform var(--transition);
  overflow-y: auto;
}

.sidebar::-webkit-scrollbar {
  width: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
  background: #334155;
  border-radius: 2px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .875rem;
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid #1E293B;
}

.brand-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1rem;
  flex-shrink: 0;
}

.brand-name {
  display: block;
  color: #fff;
  font-weight: 700;
  font-size: .95rem;
  line-height: 1.2;
}

.brand-role {
  display: block;
  color: #64748B;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.sidebar-nav {
  padding: .75rem .75rem 0;
}

.sidebar-section-title {
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .1em;
  color: #475569;
  text-transform: uppercase;
  padding: .5rem .5rem .25rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .6rem .875rem;
  border-radius: var(--radius-sm);
  color: #94A3B8;
  text-decoration: none;
  font-size: .875rem;
  font-weight: 500;
  transition: all var(--transition);
  margin-bottom: 2px;
}

.sidebar-link:hover {
  background: #1E293B;
  color: #fff;
}

.sidebar-link.active {
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  color: #fff;
  box-shadow: 0 2px 8px rgba(79, 70, 229, .4);
}

.sidebar-icon {
  width: 18px;
  text-align: center;
  font-size: .95rem;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: .875rem;
  border-top: 1px solid #1E293B;
  margin-top: auto;
}

.user-info-mini {
  display: flex;
  align-items: center;
  gap: .625rem;
}

.user-avatar-sm {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: .85rem;
  flex-shrink: 0;
}

.user-name-mini {
  color: #E2E8F0;
  font-size: .8rem;
  font-weight: 600;
}

.user-role-mini {
  margin-top: 2px;
}

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

.content-area {
  padding: 1.5rem;
  flex: 1;
}

/* ─── Top Header ─────────────────────────────────────────────── */
.app-header {
  height: var(--header-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.page-title {
  font-size: 1.05rem;
  color: var(--text-main);
}

/* Mobile topbar */
.mobile-topbar {
  height: var(--mobile-bar-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: var(--shadow-sm);
}

.brand-icon-sm {
  width: 30px;
  height: 30px;
  background: var(--primary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: .8rem;
}

/* ─── Buttons ────────────────────────────────────────────────── */
.btn-ghost {
  background: transparent;
  border: none;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: .45rem .55rem;
  transition: all var(--transition);
}

.btn-ghost:hover {
  background: var(--bg-body);
  color: var(--text-main);
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  font-weight: 600;
  border-radius: var(--radius-sm);
}

.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

/* ─── Cards ──────────────────────────────────────────────────── */
.card {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  background: var(--bg-card);
}

.card-header {
  background: transparent;
  border-bottom: 1px solid var(--border-color);
  font-weight: 600;
  padding: 1rem 1.25rem;
}

/* Stat cards */
.stat-card {
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  border: none;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition);
}

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

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  flex-shrink: 0;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1;
}

.stat-label {
  color: var(--text-muted);
  font-size: .82rem;
  font-weight: 500;
  margin-top: .2rem;
}

/* ─── User Avatar ────────────────────────────────────────────── */
.user-avatar {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: .9rem;
  flex-shrink: 0;
}

.user-btn {
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  padding: .3rem .5rem;
}

.user-btn:hover {
  background: var(--bg-body);
}

/* ─── Badges ─────────────────────────────────────────────────── */
.badge-teacher {
  background: #EFF6FF;
  color: #1D4ED8;
  border-radius: 20px;
  font-size: .7rem;
  padding: .2rem .6rem;
  font-weight: 600;
}

.badge-student {
  background: #F0FDF4;
  color: #15803D;
  border-radius: 20px;
  font-size: .7rem;
  padding: .2rem .6rem;
  font-weight: 600;
}

.status-pending {
  background: #FEF3C7;
  color: #92400E;
}

.status-validated {
  background: #D1FAE5;
  color: #065F46;
}

.status-rejected {
  background: #FEE2E2;
  color: #991B1B;
}

.status-badge {
  border-radius: 20px;
  font-size: .72rem;
  padding: .2rem .7rem;
  font-weight: 600;
  display: inline-block;
}

/* ─── Notifications ──────────────────────────────────────────── */
.notif-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 18px;
  height: 18px;
  background: var(--danger);
  color: #fff;
  font-size: .6rem;
  font-weight: 700;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.notif-dropdown {
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.notif-list {
  max-height: 320px;
  overflow-y: auto;
}

.notif-item {
  display: flex;
  gap: .75rem;
  padding: .875rem 1rem;
  border-bottom: 1px solid var(--border-color);
  transition: background var(--transition);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}

.notif-item:hover {
  background: var(--bg-body);
}

.notif-item.unread {
  background: var(--primary-light);
}

.notif-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  flex-shrink: 0;
  margin-top: 5px;
}

/* ─── Exercise Cards ─────────────────────────────────────────── */
.exercise-card {
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  transition: all var(--transition);
  overflow: hidden;
}

.exercise-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.exercise-card .card-body {
  padding: 1.25rem;
}

.exercise-thumb {
  height: 6px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
}

/* ─── Table ──────────────────────────────────────────────────── */
.table-wrapper {
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.table {
  margin: 0;
  font-size: .875rem;
}

.table thead th {
  background: #F8FAFC;
  color: var(--text-muted);
  font-weight: 600;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid var(--border-color);
  padding: .75rem 1rem;
}

.table tbody td {
  padding: .875rem 1rem;
  vertical-align: middle;
  border-color: var(--border-color);
}

.table tbody tr:hover {
  background: #F8FAFC;
}

/* ─── Forms ──────────────────────────────────────────────────── */
.form-label {
  font-weight: 600;
  font-size: .85rem;
  color: var(--text-main);
  margin-bottom: .375rem;
}

.form-control,
.form-select {
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: .9rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control:focus,
.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .1);
}

.form-text {
  font-size: .78rem;
  color: var(--text-muted);
}

/* Upload zone */
.upload-zone {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-md);
  padding: 2.5rem;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: #FAFAFA;
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.upload-zone .upload-icon {
  font-size: 2.5rem;
  color: var(--primary);
  margin-bottom: .75rem;
}

/* ─── Breadcrumb ─────────────────────────────────────────────── */
.breadcrumb {
  font-size: .8rem;
  margin: 0;
}

.breadcrumb-item a {
  color: var(--primary);
  text-decoration: none;
}

.breadcrumb-item.active {
  color: var(--text-muted);
}

/* ─── Editor ────────────────────────────────────────────────── */
/* CodeMirror override */
.CodeMirror {
  height: calc(100vh - 240px) !important;
  font-size: .88rem;
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.editor-toolbar {
  background: var(--sidebar-bg);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  padding: .5rem .875rem;
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}

.editor-toolbar .btn {
  font-size: .78rem;
  padding: .3rem .6rem;
  border-radius: 4px;
}

.editor-filename {
  color: #94A3B8;
  font-size: .8rem;
  font-family: monospace;
  margin-left: auto;
}

/* ─── Preview ───────────────────────────────────────────────── */
.preview-frame {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  width: 100%;
  min-height: 500px;
  background: #fff;
}

.preview-toolbar {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-bottom: none;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  padding: .6rem 1rem;
}

/* ─── Empty state ────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 3.5rem;
  margin-bottom: 1rem;
  opacity: .3;
}

.empty-state h5 {
  color: var(--text-main);
  font-weight: 600;
}

/* ─── Page header ────────────────────────────────────────────── */
.page-header {
  margin-bottom: 1.5rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.page-header-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-main);
  margin: 0;
}

.page-header-sub {
  color: var(--text-muted);
  font-size: .88rem;
  margin-top: .2rem;
}

/* ─── File list item ─────────────────────────────────────────── */
.file-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  transition: all var(--transition);
}

.file-item:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.file-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.file-icon.html {
  background: #FEF3C7;
  color: #D97706;
}

.file-icon.css {
  background: #EFF6FF;
  color: #2563EB;
}

.file-icon.js {
  background: #FFFBEB;
  color: #B45309;
}

.file-icon.php {
  background: #EDE9FE;
  color: #7C3AED;
}

.file-icon.md {
  background: #F0FDF4;
  color: #15803D;
}

.file-icon.pdf {
  background: #FEE2E2;
  color: #DC2626;
}

.file-icon.img {
  background: #FCE7F3;
  color: #BE185D;
}

.file-icon.zip {
  background: #F5F3FF;
  color: #6D28D9;
}

.file-icon.txt {
  background: #F8FAFC;
  color: #475569;
}

.file-icon.other {
  background: #F8FAFC;
  color: #6B7280;
}

/* ─── Alert override ─────────────────────────────────────────── */
.alert {
  border-radius: var(--radius-sm);
  font-size: .875rem;
  border: none;
}

.alert-success {
  background: #D1FAE5;
  color: #065F46;
}

.alert-danger {
  background: #FEE2E2;
  color: #991B1B;
}

.alert-info {
  background: #E0F2FE;
  color: #075985;
}

.alert-warning {
  background: #FEF3C7;
  color: #92400E;
}

/* ─── Toasts ─────────────────────────────────────────────────── */
.toast {
  border-radius: var(--radius-md);
  border: none;
  box-shadow: var(--shadow-lg);
  font-size: .875rem;
  min-width: 320px;
}

.toast.success {
  background: #D1FAE5;
  border-left: 4px solid #059669;
}

.toast.error {
  background: #FEE2E2;
  border-left: 4px solid #DC2626;
}

.toast.info {
  background: #E0F2FE;
  border-left: 4px solid #0891B2;
}

.toast.warning {
  background: #FEF3C7;
  border-left: 4px solid #D97706;
}

/* ─── Sidebar Overlay (mobile) ────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .5);
  z-index: 1025;
  backdrop-filter: blur(2px);
}

.sidebar-overlay.visible {
  display: block;
}

/* ─── Mobile Responsive ──────────────────────────────────────── */
@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(calc(-1 * var(--sidebar-w)));
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  .main-content {
    margin-left: 0;
  }

  .content-area {
    padding: 1rem;
  }
}

@media (max-width: 575.98px) {
  .auth-card {
    padding: 1.75rem 1.25rem;
  }

  .content-area {
    padding: .875rem;
  }

  .stat-value {
    font-size: 1.4rem;
  }
}

/* ─── 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;
}

/* ─── Animations ─────────────────────────────────────────────── */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in-up {
  animation: fadeInUp .3s ease both;
}

/* ─── Misc ───────────────────────────────────────────────────── */
.cursor-pointer {
  cursor: pointer;
}

.text-primary {
  color: var(--primary) !important;
}

.bg-primary {
  background: var(--primary) !important;
}

a {
  color: var(--primary);
}

hr {
  border-color: var(--border-color);
}