/* ============================================
   ADMIN SHELL - Core Layout & Structure
   ============================================
   Fresh implementation - dark theme, collapsible sidebar
*/

/* --- CSS Variables --- */
:root {
  --color-canvas: #18181b;
  --color-canvas-elevated: #1f1f23;
  --color-canvas-subtle: #0f0f10;
  --color-text-primary: rgba(255,255,255,0.85);
  --color-text-secondary: rgba(255,255,255,0.65);
  --color-text-muted: rgba(255,255,255,0.4);
  --color-border: rgba(255,255,255,0.08);
  --color-accent: #a78bfa;
  --color-accent-hover: #c4b5fd;
  --sidebar-width-collapsed: 48px;
  --sidebar-width-expanded: 220px;
  --topbar-height: 48px;
}

/* --- Base Reset --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--color-canvas-subtle);
  color: var(--color-text-primary);
  -webkit-font-smoothing: antialiased;
}

/* --- App Container --- */
.app {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  background: var(--color-canvas-subtle);
}

.app.hidden {
  display: none;
}

/* --- Admin Shell --- */
.admin-shell {
  display: flex;
  flex: 1;
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: var(--color-canvas-subtle);
}

/* --- Sidebar --- */
.admin-sidebar {
  width: var(--sidebar-width-collapsed);
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--color-canvas);
  border-right: 1px solid var(--color-border);
  transition: width 0.2s ease;
  overflow: hidden;
  flex-shrink: 0;
  position: relative;
  z-index: 100;
}

.admin-sidebar.expanded {
  width: var(--sidebar-width-expanded);
}

/* Sidebar expand button */
.sidebar-expand-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  color: var(--color-text-muted);
  transition: background 0.15s, color 0.15s, transform 0.2s;
  z-index: 10;
}

.sidebar-expand-btn:hover {
  background: rgba(255,255,255,0.05);
  color: var(--color-text-secondary);
}

.sidebar-expand-btn svg {
  width: 14px;
  height: 14px;
  stroke-width: 2;
}

.admin-sidebar.expanded .sidebar-expand-btn svg {
  transform: rotate(180deg);
}

/* Sidebar brand */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 12px;
  height: 48px;
  flex-shrink: 0;
}

.sidebar-brand-text {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--color-text-primary);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.15s;
}

.admin-sidebar.expanded .sidebar-brand-text {
  opacity: 1;
}

/* Sidebar navigation */
.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 8px 6px;
  gap: 2px;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-section-label {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  padding: 12px 10px 6px;
  white-space: nowrap;
  opacity: 0;
  height: 0;
  overflow: hidden;
  transition: opacity 0.15s, height 0.15s;
}

.admin-sidebar.expanded .sidebar-section-label {
  opacity: 1;
  height: auto;
}

/* Sidebar items */
.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--color-text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  width: 100%;
  text-align: left;
}

.sidebar-item i {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.sidebar-item span {
  opacity: 0;
  transition: opacity 0.15s;
}

.admin-sidebar.expanded .sidebar-item span {
  opacity: 1;
}

.sidebar-item:hover {
  background: rgba(255,255,255,0.05);
  color: var(--color-text-primary);
}

.sidebar-item.active {
  background: rgba(167, 139, 250, 0.12);
  color: var(--color-accent);
}

/* Sidebar badge */
.sidebar-badge {
  margin-left: auto;
  padding: 2px 6px;
  font-size: 10px;
  font-weight: 600;
  border-radius: 10px;
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

/* Sidebar footer */
.sidebar-footer {
  padding: 8px 6px;
  border-top: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-ai-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: none;
  border-radius: 8px;
  background: rgba(167, 139, 250, 0.1);
  color: var(--color-accent);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
  width: 100%;
  text-align: left;
}

.sidebar-ai-btn:hover {
  background: rgba(167, 139, 250, 0.18);
}

.sidebar-ai-btn i {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.sidebar-ai-btn span {
  opacity: 0;
  transition: opacity 0.15s;
}

.admin-sidebar.expanded .sidebar-ai-btn span {
  opacity: 1;
}

.sidebar-logout {
  color: var(--color-text-muted);
}

.sidebar-logout:hover {
  color: #f87171;
  background: rgba(248, 113, 113, 0.1);
}

/* --- Main Content Area --- */
.admin-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  background: var(--color-canvas-subtle);
  min-width: 0;
}

/* Top bar */
.admin-topbar {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  padding: 0 16px;
  background: var(--color-canvas);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
  gap: 12px;
}

.topbar-hamburger {
  display: none;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--color-text-secondary);
  cursor: pointer;
}

.topbar-hamburger:hover {
  background: rgba(255,255,255,0.05);
}

.topbar-hamburger i {
  width: 20px;
  height: 20px;
}

.topbar-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text-primary);
}

.topbar-avatar {
  margin-left: auto;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(167, 139, 250, 0.15);
  color: var(--color-accent);
  font-size: 13px;
  font-weight: 600;
  border-radius: 50%;
}

/* Content area */
.admin-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--color-canvas-subtle);
}

/* View containers */
.view-container {
  display: none;
  flex: 1;
  flex-direction: column;
  overflow: hidden;
  background: var(--color-canvas-subtle);
}

.view-container.active {
  display: flex;
}

.view-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  background: var(--color-canvas-subtle);
}

/* --- Mobile Drawer --- */
.drawer-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.drawer-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

/* --- Mobile Responsive --- */
@media (max-width: 768px) {
  .admin-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100%;
    width: var(--sidebar-width-expanded);
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 200;
  }

  .admin-sidebar.open {
    transform: translateX(0);
  }

  .admin-sidebar .sidebar-brand-text,
  .admin-sidebar .sidebar-section-label,
  .admin-sidebar .sidebar-item span,
  .admin-sidebar .sidebar-ai-btn span {
    opacity: 1;
    height: auto;
  }

  .sidebar-expand-btn {
    display: none;
  }

  .drawer-backdrop {
    display: block;
  }

  .topbar-hamburger {
    display: flex;
  }

  .view-content {
    padding: 16px;
  }
}

/* --- Login Screen --- */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--color-canvas-subtle);
  padding: 20px;
}

.login-screen.hidden {
  display: none;
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--color-canvas);
  border: 1px solid var(--color-border);
  border-radius: 16px;
  padding: 32px;
}

.login-brand {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-align: center;
  color: var(--color-accent);
  margin-bottom: 4px;
}

.login-subtitle {
  font-size: 12px;
  color: var(--color-text-muted);
  text-align: center;
  margin-bottom: 28px;
}

.login-footer {
  font-size: 10px;
  color: var(--color-text-muted);
  text-align: center;
  margin-top: 24px;
}

.login-error {
  font-size: 12px;
  color: #f87171;
  text-align: center;
  margin-top: 12px;
  min-height: 18px;
}

/* --- Toast --- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 12px 20px;
  background: var(--color-canvas-elevated);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  font-size: 13px;
  color: var(--color-text-primary);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 9999;
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.toast.error {
  border-color: rgba(248, 113, 113, 0.3);
  color: #f87171;
}

.toast.success {
  border-color: rgba(74, 222, 128, 0.3);
  color: #4ade80;
}

/* --- Modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 1000;
}

.modal-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  width: 100%;
  max-width: 480px;
  max-height: 80vh;
  background: var(--color-canvas);
  border: 1px solid var(--color-border);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal.large {
  max-width: 720px;
}

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

.modal-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text-primary);
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 8px;
  font-size: 20px;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.modal-close:hover {
  background: rgba(255,255,255,0.05);
  color: var(--color-text-primary);
}

.modal-body {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
}

.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.modal-footer:empty {
  display: none;
}
