/* ═══════════════════════════════════════
   V2 LAYOUT — Icon Rail + Flyout
   ═══════════════════════════════════════ */
:root {
  --v2-bg: #f5f6fa;
  --v2-surface: #ffffff;
  --v2-surface-hover: #f0f0f5;
  --v2-text: #1a1a2e;
  --v2-text-muted: #6b7280;
  --v2-border: rgba(0,0,0,0.08);
  --v2-accent: #7556F9;
  --v2-accent-hover: #6344e0;
  --v2-rail-bg: #edeef2;
  --v2-rail-icon: #6b7280;
  --v2-rail-icon-hover: #1a1a2e;
  --v2-rail-active-bg: rgba(117,86,249,0.12);
  --v2-rail-active-icon: #7556F9;
  --v2-rail-border: rgba(0,0,0,0.06);
  --v2-panel-bg: #0c0e1a;
  --v2-topbar-bg: #ffffff;
  --v2-topbar-border: rgba(0,0,0,0.06);
}

body.dark-mode {
  --v2-bg: #07080f;
  --v2-surface: rgba(255,255,255,0.04);
  --v2-surface-hover: rgba(255,255,255,0.07);
  --v2-text: #f0f0f5;
  --v2-text-muted: rgba(255,255,255,0.45);
  --v2-border: rgba(255,255,255,0.08);
  --v2-rail-bg: #0a0c16;
  --v2-rail-icon: rgba(255,255,255,0.4);
  --v2-rail-icon-hover: rgba(255,255,255,0.8);
  --v2-rail-active-bg: rgba(117,86,249,0.2);
  --v2-rail-active-icon: #fff;
  --v2-rail-border: rgba(255,255,255,0.06);
  --v2-panel-bg: #0c0e1a;
  --v2-topbar-bg: rgba(12,14,26,0.85);
  --v2-topbar-border: rgba(255,255,255,0.06);
}

.v2-app {
  display: flex;
  min-height: 100vh;
}

/* ── Rail ── */
.v2-rail {
  width: 64px;
  min-height: 100vh;
  background: var(--v2-rail-bg);
  border-right: 1px solid var(--v2-rail-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem 0;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 200;
  transition: background 0.3s, border-color 0.3s;
}

.v2-rail-logo {
  width: 34px;
  height: 34px;
  margin-bottom: 1.25rem;
  flex-shrink: 0;
}

.v2-rail-logo img { width: 100%; border-radius: 8px; }

.v2-rail-item {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  color: var(--v2-rail-icon);
  cursor: pointer;
  margin-bottom: 4px;
  position: relative;
  transition: all 0.15s;
  text-decoration: none;
  border: none;
  background: none;
  flex-shrink: 0;
}

.v2-rail-item:hover {
  color: var(--v2-rail-icon-hover);
  background: var(--v2-rail-active-bg);
}

.v2-rail-item.active,
.v2-rail-item.panel-open {
  color: var(--v2-rail-active-icon);
  background: var(--v2-rail-active-bg);
}

.v2-rail-item svg, .v2-rail-item i { width: 20px; height: 20px; flex-shrink: 0; }

.v2-rail-item .v2-tip {
  position: absolute;
  left: 52px;
  background: #1a1a2e;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 300;
}

.v2-rail-item:hover .v2-tip { opacity: 1; }
.v2-rail-item.panel-open .v2-tip { opacity: 0; }

.v2-rail-item .v2-notif {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  border: 2px solid var(--v2-rail-bg);
  transition: border-color 0.3s;
}

.v2-notif-green { background: #34d399; }
.v2-notif-red { background: #ef4444; }
.v2-notif-yellow { background: #fbbf24; }

.v2-rail-sep {
  width: 24px;
  height: 1px;
  background: var(--v2-rail-border);
  margin: 0.5rem 0;
  flex-shrink: 0;
}

.v2-rail-spacer { flex: 1; }

.v2-rail-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin-top: 0.25rem;
  border: 2px solid transparent;
  transition: border-color 0.15s;
  flex-shrink: 0;
  overflow: hidden;
}

.v2-rail-avatar:hover { border-color: var(--v2-accent); }
.v2-rail-avatar img { width: 100%; height: 100%; border-radius: 50%; }

/* ── Flyout Panel ── */
.v2-panel-overlay {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: none;
}

.v2-panel-overlay.show { display: block; }

.v2-panel {
  position: fixed;
  top: 0;
  left: 64px;
  width: 260px;
  height: 100vh;
  background: var(--v2-panel-bg);
  border-right: 1px solid rgba(255,255,255,0.06);
  z-index: 160;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  overflow-y: auto;
  padding: 1.25rem 0.75rem;
}

.v2-panel.show { transform: translateX(0); }

.v2-panel-title {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.25);
  padding: 0.5rem 0.5rem 0.75rem;
}

.v2-panel-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.6rem;
  border-radius: 8px;
  color: rgba(255,255,255,0.6);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 600;
  transition: all 0.15s;
  margin-bottom: 2px;
}

.v2-panel-link:hover {
  background: rgba(255,255,255,0.06);
  color: #fff;
  text-decoration: none;
}

.v2-panel-link.active {
  background: rgba(117,86,249,0.15);
  color: #fff;
}

.v2-panel-badge {
  margin-left: auto;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
}

.v2-panel-badge-green { background: rgba(52,211,153,0.15); color: #34d399; }
.v2-panel-badge-purple { background: rgba(117,86,249,0.15); color: #a78bfa; }
.v2-panel-badge-yellow { background: rgba(251,191,36,0.15); color: #fbbf24; }
.v2-panel-badge-red { background: rgba(239,68,68,0.15); color: #f87171; }

.v2-panel-divider {
  height: 1px;
  background: rgba(255,255,255,0.06);
  margin: 0.75rem 0;
}

/* ── Main Area ── */
.v2-main {
  flex: 1;
  margin-left: 64px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Topbar ── */
.v2-topbar {
  height: 56px;
  background: var(--v2-topbar-bg);
  border-bottom: 1px solid var(--v2-topbar-border);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: background 0.3s, border-color 0.3s;
  flex-shrink: 0;
}

.v2-topbar-hamburger {
  display: none;
  background: none;
  border: none;
  color: var(--v2-text);
  cursor: pointer;
  padding: 0.25rem;
  width: 34px;
  height: 34px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}

.v2-topbar-hamburger:hover { background: var(--v2-surface-hover); }

.v2-topbar-search {
  position: relative;
  width: 280px;
  flex-shrink: 0;
}

.v2-topbar-search input {
  width: 100%;
  background: var(--v2-surface);
  border: 1px solid var(--v2-border);
  border-radius: 8px;
  padding: 0.4rem 0.6rem 0.4rem 2rem;
  font-size: 0.82rem;
  color: var(--v2-text);
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s;
}

.v2-topbar-search input::placeholder { color: var(--v2-text-muted); }
.v2-topbar-search input:focus { border-color: var(--v2-accent); box-shadow: 0 0 0 3px rgba(117,86,249,0.1); }

.v2-topbar-search svg {
  position: absolute;
  left: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--v2-text-muted);
}

.v2-topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: auto;
  flex-shrink: 0;
}

.v2-topbar-btn {
  background: none;
  border: none;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: var(--v2-text-muted);
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
}

.v2-topbar-btn:hover { background: var(--v2-surface-hover); color: var(--v2-text); }
.v2-topbar-btn svg, .v2-topbar-btn i { width: 17px; height: 17px; }

.v2-wiggle { color: #7556F9; transition: none; animation: v2-glow 2s ease-in-out infinite; }
.v2-wiggle:hover { color: #9b7bff; }
@keyframes v2-glow {
  0%, 100% { color: #7556F9; filter: drop-shadow(0 0 0 transparent); }
  50% { color: #9b7bff; filter: drop-shadow(0 0 6px rgba(117,86,249,0.6)); }
}

/* ── Content ── */
.v2-content {
  flex: 1;
  padding: 0;
}

/* ── Mobile Nav Overlay ── */
.v2-mobile-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: none;
}

.v2-mobile-overlay.show { display: flex; }

.v2-mobile-bg {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.v2-mobile-nav {
  position: relative;
  width: 280px;
  height: 100%;
  background: var(--v2-panel-bg);
  padding: 1.5rem 1rem;
  overflow-y: auto;
  z-index: 1;
}

.v2-mobile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  padding: 0 0.25rem;
}

.v2-mobile-logo {
  height: 24px;
}

.v2-mobile-close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.4);
  cursor: pointer;
  padding: 0.25rem;
}

.v2-mobile-close:hover { color: #fff; }

/* ── Footer ── */
.v2-footer {
  padding: 1rem 2rem;
  font-size: 0.72rem;
  color: var(--v2-text-muted);
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-top: auto;
  flex-shrink: 0;
}

.v2-footer a { color: var(--v2-text-muted); text-decoration: none; }
.v2-footer a:hover { color: var(--v2-text); }

/* ── Page Components (cards, tables, badges, buttons) ── */
.v2-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  padding: 0 0.25rem;
}

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

.v2-card {
  background: var(--v2-surface);
  border: 1px solid var(--v2-border);
  border-radius: 12px;
  margin-bottom: 1.25rem;
  overflow: clip;
  transition: background 0.3s, border-color 0.3s;
}

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

.v2-card-header h5,
.v2-card-header .v2-card-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--v2-text);
  margin: 0;
}

.v2-card-body {
  padding: 1rem 1.25rem;
}

.v2-card-body-flush { padding: 0; }

.v2-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.v2-table th {
  padding: 0.6rem 1rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--v2-text-muted);
  border-bottom: 1px solid var(--v2-border);
  text-align: left;
}

.v2-table td {
  padding: 0.65rem 1rem;
  color: var(--v2-text);
  border-bottom: 1px solid var(--v2-border);
  vertical-align: middle;
}

.v2-table tbody tr:last-child td { border-bottom: none; }

.v2-table tbody tr:hover {
  background: var(--v2-surface-hover);
}

.v2-table a {
  color: var(--v2-accent);
  text-decoration: none;
  font-weight: 500;
}

.v2-table a:hover { text-decoration: underline; }

.v2-pill {
  display: inline-flex;
  align-items: center;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  white-space: nowrap;
}

.v2-pill-green { background: rgba(52,211,153,0.12); color: #22c55e; }
body.dark-mode .v2-pill-green { background: rgba(52,211,153,0.15); color: #34d399; }
.v2-pill-red { background: rgba(239,68,68,0.1); color: #ef4444; }
body.dark-mode .v2-pill-red { background: rgba(239,68,68,0.15); color: #f87171; }
.v2-pill-yellow { background: rgba(251,191,36,0.1); color: #d97706; }
body.dark-mode .v2-pill-yellow { background: rgba(251,191,36,0.15); color: #fbbf24; }
.v2-pill-blue { background: rgba(59,130,246,0.1); color: #3b82f6; }
body.dark-mode .v2-pill-blue { background: rgba(59,130,246,0.15); color: #60a5fa; }
.v2-pill-purple { background: rgba(117,86,249,0.1); color: #7556F9; }
body.dark-mode .v2-pill-purple { background: rgba(117,86,249,0.15); color: #a78bfa; }
.v2-pill-gray { background: rgba(107,114,128,0.1); color: #6b7280; }
body.dark-mode .v2-pill-gray { background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.5); }

.v2-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 700;
}

.v2-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.7rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid var(--v2-border);
  background: transparent;
  color: var(--v2-text);
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
  white-space: nowrap;
}

a.v2-btn, a.v2-btn:visited {
  color: var(--v2-text);
}

.v2-btn:hover, a.v2-btn:hover {
  background: var(--v2-surface-hover);
  text-decoration: none;
  color: var(--v2-text);
}

.v2-btn-accent, a.v2-btn-accent, a.v2-btn-accent:visited {
  background: var(--v2-accent);
  border-color: var(--v2-accent);
  color: #fff !important;
}

.v2-btn-accent:hover, a.v2-btn-accent:hover {
  background: var(--v2-accent-hover);
  color: #fff !important;
}

.v2-btn-green, a.v2-btn-green, a.v2-btn-green:visited {
  background: rgba(52,211,153,0.12);
  border-color: rgba(52,211,153,0.3);
  color: #22c55e !important;
}

body.dark-mode .v2-btn-green, body.dark-mode a.v2-btn-green { color: #34d399 !important; }

.v2-btn-green:hover, a.v2-btn-green:hover {
  background: rgba(52,211,153,0.2);
  color: #22c55e !important;
}

.v2-btn-yellow, a.v2-btn-yellow, a.v2-btn-yellow:visited {
  background: rgba(251,191,36,0.12);
  border-color: rgba(251,191,36,0.3);
  color: #d97706 !important;
}

body.dark-mode .v2-btn-yellow, body.dark-mode a.v2-btn-yellow { color: #fbbf24 !important; }

.v2-btn-yellow:hover, a.v2-btn-yellow:hover {
  background: rgba(251,191,36,0.2);
  color: #d97706 !important;
}

.v2-btn-red, a.v2-btn-red, a.v2-btn-red:visited {
  background: rgba(239,68,68,0.08);
  border-color: rgba(239,68,68,0.2);
  color: #ef4444 !important;
}

.v2-btn-red:hover, a.v2-btn-red:hover {
  background: rgba(239,68,68,0.15);
  color: #ef4444 !important;
}

.v2-empty {
  padding: 1.5rem;
  text-align: center;
  font-size: 0.82rem;
  color: var(--v2-text-muted);
}

.v2-actions {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.v2-alert {
  padding: 0.75rem 1rem;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 500;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.v2-alert-success {
  background: rgba(52,211,153,0.1);
  color: #22c55e;
  border: 1px solid rgba(52,211,153,0.2);
}

.v2-alert-error {
  background: rgba(239,68,68,0.1);
  color: #ef4444;
  border: 1px solid rgba(239,68,68,0.2);
}

/* ── Dropdowns (notifications, assignments) ── */
.v2-dropdown {
  position: relative;
}

.v2-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 340px;
  max-height: 480px;
  background: var(--v2-surface);
  border: 1px solid var(--v2-border);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.12);
  z-index: 300;
  display: none;
  overflow: hidden;
}

body.dark-mode .v2-dropdown-menu {
  background: #161825;
  box-shadow: 0 12px 40px rgba(0,0,0,0.4);
}

.v2-dropdown-menu.show { display: block; }

.v2-dropdown-header {
  padding: 0.75rem 1rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--v2-text-muted);
  border-bottom: 1px solid var(--v2-border);
}

.v2-dropdown-body {
  max-height: 360px;
  overflow-y: auto;
  padding: 0.25rem 0;
}

.v2-dropdown-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  text-decoration: none;
  color: var(--v2-text);
  transition: background 0.1s;
}

.v2-dropdown-item:hover {
  background: var(--v2-surface-hover);
  color: var(--v2-text);
  text-decoration: none;
}

.v2-dropdown-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin-top: 2px;
  color: var(--v2-text-muted);
}

.v2-dropdown-item-content {
  flex: 1;
  min-width: 0;
}

.v2-dropdown-item-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--v2-text);
}

.v2-dropdown-item-sub {
  font-size: 0.75rem;
  color: var(--v2-text-muted);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.v2-dropdown-item-time {
  font-size: 0.7rem;
  color: var(--v2-text-muted);
  margin-top: 2px;
}

.v2-dropdown-empty {
  padding: 1.5rem 1rem;
  text-align: center;
  font-size: 0.82rem;
  color: var(--v2-text-muted);
}

.v2-dropdown-footer {
  padding: 0.6rem 1rem;
  border-top: 1px solid var(--v2-border);
  text-align: center;
}

.v2-dropdown-footer a {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--v2-accent);
  text-decoration: none;
}

.v2-dropdown-footer a:hover { text-decoration: underline; }

.v2-badge-dot {
  position: absolute;
  top: -4px;
  right: -6px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  font-size: 0.6rem;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  color: #fff;
  background: var(--v2-accent);
}

.v2-badge-dot-red { background: #ef4444; }
.v2-badge-dot-yellow { background: #f59e0b; }

/* ── Responsive ── */
@media (max-width: 700px) {
  .v2-rail { display: none !important; }
  .v2-main { margin-left: 0 !important; }
  .v2-topbar-hamburger { display: flex; }
  .v2-topbar-search { width: auto; flex: 1; min-width: 0; }
  .v2-content { padding: 0; }
  .v2-panel { left: 0; }
  .v2-dropdown-menu { width: 300px; right: -40px; }
}
