/* ═══════════════════════════════════════════════
   Clouds Platform — Global Shell CSS
   platform.css · loaded by base.html
   ═══════════════════════════════════════════════ */

/* ─── Reset ───────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
a { text-decoration: none; }
button { border: none; background: none; cursor: pointer; }

/* ─── Design Tokens ───────────────────────────── */
:root {
  /* Brand */
  --royal:        #1B3FAB;
  --royal-dark:   #132D7A;
  --cobalt:       #2952CC;
  --alice:        #F0F8FF;
  --alice-tint:   #DAEcFF;
  --navy:         #0D1F5C;
  --muted:        #5571A8;
  --border:       #DDE8F5;
  --white:        #ffffff;

  /* Sidebar */
  --sb-bg:          #0C1A4E;
  --sb-w:           220px;
  --sb-w-sm:        64px;
  --sb-text:        rgba(255,255,255,0.52);
  --sb-text-hover:  rgba(255,255,255,0.88);
  --sb-active-bg:   rgba(27,63,171,0.72);
  --sb-active-line: #93C5FD;
  --sb-hover-bg:    rgba(255,255,255,0.06);
  --sb-label:       rgba(255,255,255,0.28);
  --sb-border:      rgba(255,255,255,0.07);

  /* Topbar */
  --tb-h:  58px;
  --tb-bg: #ffffff;

  /* Misc */
  --r:      10px;
  --r-sm:   7px;
  --easing: cubic-bezier(0.4,0,0.2,1);
  --t:      240ms;

  --font-h: 'Nunito', sans-serif;
  --font-b: 'Nunito Sans', sans-serif;
}

/* ─── Base ────────────────────────────────────── */
html, body {
  height: 100%;
  font-family: var(--font-b);
  background: var(--alice);
  color: var(--navy);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ─── App Shell ───────────────────────────────── */
.app {
  display: flex;
  height: 100vh;
}

/* ═══════════════════════════════════════════════
   SIDEBAR
   ═══════════════════════════════════════════════ */
.sidebar {
  width: var(--sb-w);
  min-width: var(--sb-w);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  z-index: 40;
  background: linear-gradient(180deg, #101F56 0%, #0C1A4E 60%, #0A1642 100%);
  transition: width var(--t) var(--easing), min-width var(--t) var(--easing);
}

.sidebar.is-collapsed {
  width: var(--sb-w-sm);
  min-width: var(--sb-w-sm);
}

/* Bottom glow */
.sidebar::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 220px;
  height: 180px;
  background: radial-gradient(ellipse at 50% 100%, rgba(41,82,204,0.4) 0%, transparent 70%);
  pointer-events: none;
}

/* Cloud watermark */
.sidebar-watermark {
  position: absolute;
  bottom: 60px;
  right: -12px;
  width: 130px;
  opacity: 0.09;
  pointer-events: none;
  transition: opacity var(--t) var(--easing);
}

.sidebar.is-collapsed .sidebar-watermark { opacity: 0.04; }

/* ── Logo ────────────────────────────────────── */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px 16px;
  border-bottom: 1px solid var(--sb-border);
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.logo-mark {
  width: 33px;
  height: 33px;
  min-width: 33px;
  border-radius: 9px;
  background: var(--royal);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(27,63,171,0.5);
  flex-shrink: 0;
}

.logo-mark svg {
  width: 19px;
  height: 19px;
  fill: white;
}

.logo-name {
  font-family: var(--font-h);
  font-weight: 900;
  font-size: 17px;
  color: #fff;
  letter-spacing: -0.3px;
  white-space: nowrap;
  transition: opacity var(--t) var(--easing), transform var(--t) var(--easing);
}

.sidebar.is-collapsed .logo-name {
  opacity: 0;
  transform: translateX(-6px);
  pointer-events: none;
}

/* ── Nav ─────────────────────────────────────── */
.sidebar-nav {
  flex: 1;
  padding: 14px 0 12px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
  position: relative;
  z-index: 1;
}

.sidebar-nav::-webkit-scrollbar { display: none; }

.nav-group { margin-bottom: 18px; }

.nav-group-label {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--sb-label);
  padding: 0 18px;
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity var(--t) var(--easing);
}

.sidebar.is-collapsed .nav-group-label { opacity: 0; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7.5px 10px 7.5px 13px;
  margin: 1px 8px;
  border-radius: var(--r-sm);
  color: var(--sb-text);
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  position: relative;
  transition: color var(--t) var(--easing), background var(--t) var(--easing);
}

.nav-link:hover {
  background: var(--sb-hover-bg);
  color: var(--sb-text-hover);
}

.nav-link.is-active {
  background: var(--sb-active-bg);
  color: #fff;
}

.nav-link.is-active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 22%;
  bottom: 22%;
  width: 3px;
  background: var(--sb-active-line);
  border-radius: 0 3px 3px 0;
}

.nav-ico {
  width: 20px;
  height: 20px;
  min-width: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.nav-ico svg {
  width: 17px;
  height: 17px;
  stroke-width: 2;
}

.nav-txt {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity var(--t) var(--easing), transform var(--t) var(--easing);
}

.sidebar.is-collapsed .nav-txt {
  opacity: 0;
  transform: translateX(-4px);
  pointer-events: none;
}

.nav-badge {
  flex-shrink: 0;
  background: var(--cobalt);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1.5px 6px;
  border-radius: 99px;
  transition: opacity var(--t) var(--easing);
}

.sidebar.is-collapsed .nav-badge { opacity: 0; }

/* Collapsed: centre icons */
.sidebar.is-collapsed .nav-link {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}

.sidebar.is-collapsed .nav-link.is-active::before {
  top: 20%;
  bottom: 20%;
}

/* ── External tools ──────────────────────────── */
.sidebar-external {
  border-top: 1px solid var(--sb-border);
  padding: 8px 8px 4px;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.ext-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px 7px 13px;
  border-radius: var(--r-sm);
  color: var(--sb-label);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  transition: color var(--t) var(--easing), background var(--t) var(--easing);
}

.ext-link:hover {
  background: var(--sb-hover-bg);
  color: var(--sb-text-hover);
}

.ext-arrow {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  margin-left: auto;
  opacity: 0.6;
  transition: opacity var(--t) var(--easing);
}

.sidebar.is-collapsed .ext-arrow { opacity: 0; }

/* ── User footer ─────────────────────────────── */
.sidebar-foot {
  border-top: 1px solid var(--sb-border);
  padding: 10px 8px;
  display: flex;
  align-items: center;
  gap: 9px;
  flex-shrink: 0;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  z-index: 1;
  transition: background var(--t) var(--easing);
}

.sidebar-foot:hover { background: var(--sb-hover-bg); }

.foot-avatar {
  width: 34px;
  height: 34px;
  min-width: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--royal), var(--cobalt));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-h);
  font-weight: 800;
  font-size: 12px;
  color: #fff;
}

.foot-info {
  flex: 1;
  min-width: 0;
  transition: opacity var(--t) var(--easing), transform var(--t) var(--easing);
}

.sidebar.is-collapsed .foot-info {
  opacity: 0;
  transform: translateX(-4px);
  pointer-events: none;
}

.foot-name {
  font-size: 12.5px;
  font-weight: 600;
  color: rgba(255,255,255,0.82);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.foot-role {
  font-size: 11px;
  color: var(--sb-label);
  margin-top: 1px;
}

/* ═══════════════════════════════════════════════
   MAIN AREA
   ═══════════════════════════════════════════════ */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ── Topbar ──────────────────────────────────── */
.topbar {
  height: var(--tb-h);
  min-height: var(--tb-h);
  background: var(--tb-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 22px 0 14px;
  gap: 10px;
  flex-shrink: 0;
  z-index: 30;
}

.tb-toggle {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm);
  color: var(--muted);
  flex-shrink: 0;
  transition: background var(--t) var(--easing), color var(--t) var(--easing);
}

.tb-toggle:hover { background: var(--alice-tint); color: var(--royal); }
.tb-toggle svg { width: 19px; height: 19px; stroke-width: 2; }

.tb-crumb {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: var(--muted);
  overflow: hidden;
}

.tb-crumb-sep { color: var(--border); font-size: 15px; user-select: none; }

.tb-crumb-cur {
  font-weight: 600;
  color: var(--navy);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tb-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

button.tb-btn { background: none; border: none; cursor: pointer; font: inherit; padding: 0; }
.tb-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm);
  color: var(--muted);
  position: relative;
  transition: background var(--t) var(--easing), color var(--t) var(--easing);
}

.tb-btn:hover { background: var(--alice-tint); color: var(--royal); }
.tb-btn svg { width: 17px; height: 17px; stroke-width: 2; }

.notif-dot {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 7px;
  height: 7px;
  background: #EF4444;
  border-radius: 50%;
  border: 1.5px solid #fff;
}

.tb-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 6px;
}

.tb-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--royal), var(--cobalt));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-h);
  font-weight: 800;
  font-size: 11px;
  color: #fff;
  cursor: pointer;
  transition: box-shadow var(--t) var(--easing);
}

.tb-avatar:hover { box-shadow: 0 0 0 3px var(--alice-tint); }

/* ── Content area ────────────────────────────── */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 30px 32px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.content::-webkit-scrollbar { width: 5px; }
.content::-webkit-scrollbar-track { background: transparent; }
.content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ═══════════════════════════════════════════════
   SHARED PAGE COMPONENTS
   (reusable across all module pages)
   ═══════════════════════════════════════════════ */

/* ── Page header ─────────────────────────────── */
.page-header { margin-bottom: 28px; }

.page-title {
  font-family: var(--font-h);
  font-weight: 800;
  font-size: 22px;
  color: var(--navy);
  letter-spacing: -0.4px;
}

.page-sub {
  margin-top: 5px;
  font-size: 14px;
  color: var(--muted);
}

/* ── Stat cards ──────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--white);
  border-radius: var(--r);
  padding: 20px 20px 16px;
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(13,31,92,0.04);
  transition: box-shadow var(--t) var(--easing), transform var(--t) var(--easing);
}

.stat-card:hover {
  box-shadow: 0 4px 16px rgba(13,31,92,0.08);
  transform: translateY(-1px);
}

.stat-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 7px;
}

.stat-label-icon {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--alice-tint);
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-label-icon svg { width: 14px; height: 14px; stroke: var(--royal); stroke-width: 2; }

.stat-val {
  font-family: var(--font-h);
  font-weight: 800;
  font-size: 30px;
  color: var(--navy);
  letter-spacing: -1px;
  line-height: 1;
}

.stat-hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
}

/* ── Generic card ────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--r);
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(13,31,92,0.04);
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-family: var(--font-h);
  font-weight: 800;
  font-size: 15px;
  color: var(--navy);
}

.card-body { padding: 20px; }

/* ── Buttons ─────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--r-sm);
  font-family: var(--font-b);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background var(--t) var(--easing), box-shadow var(--t) var(--easing);
}

.btn-primary {
  background: var(--royal);
  color: #fff;
}

.btn-primary:hover {
  background: var(--royal-dark);
  box-shadow: 0 2px 8px rgba(27,63,171,0.3);
}

.btn-secondary {
  background: var(--alice-tint);
  color: var(--royal);
}

.btn-secondary:hover { background: #C8DFFF; }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}

.btn-ghost:hover { background: var(--alice); color: var(--navy); }

/* ── Badge / pill ────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
}

.badge-blue   { background: var(--alice-tint); color: var(--royal); }
.badge-green  { background: #D9F1DE; color: #1A6B30; }
.badge-yellow { background: #FFF1C9; color: #7A5900; }
.badge-red    { background: #FBD9D9; color: #8B1A1A; }
.badge-grey   { background: #EEEEEE; color: #555; }

/* ── Flash messages ──────────────────────────── */
.messages-stack { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }

.flash {
  padding: 10px 16px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 600;
  border-left: 3px solid transparent;
}

.flash-success { background: #D9F1DE; color: #1A6B30; border-left-color: #2E9B4E; }
.flash-error   { background: #FBD9D9; color: #8B1A1A; border-left-color: #D63B3B; }
.flash-warning { background: #FFF1C9; color: #7A5900; border-left-color: #D4A017; }
.flash-info    { background: var(--alice-tint); color: var(--royal); border-left-color: var(--cobalt); }
