/* ==========================================================================
   Visual Dock - Global Stylesheet (main.css)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');
@import url('variables.css');

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  transition: background-color var(--transition-base), color var(--transition-base);
  overflow-x: hidden;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-app);
}
::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: var(--radius-full);
  opacity: 0.4;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

a {
  color: inherit;
  text-decoration: none;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  border: none;
  outline: none;
  background: none;
}

button {
  cursor: pointer;
}

img, svg {
  display: block;
  max-width: 100%;
}

/* ==========================================================================
   App Layout (Sidebar + Main Content Wrapper)
   ========================================================================== */

.app-container {
  display: flex;
  min-height: 100vh;
  position: relative;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-surface);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: width var(--transition-base), transform var(--transition-base), background var(--transition-base);
  padding: 24px 16px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 12px 28px 12px;
  border-bottom: 1px solid var(--border-light);
}

.brand-icon-wrap {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--primary-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 22px;
  font-weight: 800;
  box-shadow: var(--shadow-primary);
  flex-shrink: 0;
}

.brand-info {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text-main);
  line-height: 1.2;
}

.brand-title span {
  color: var(--primary);
}

.brand-subtitle {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
}

/* Navigation Links */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 24px 0;
  flex: 1;
  overflow-y: auto;
}

.nav-section-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  padding: 8px 14px 4px 14px;
  margin-top: 10px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.92rem;
  transition: all var(--transition-fast);
  position: relative;
}

.nav-item:hover {
  background: var(--bg-surface-secondary);
  color: var(--text-main);
  transform: translateX(3px);
}

.nav-item.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 700;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 15%;
  height: 70%;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background: var(--primary);
}

.nav-icon {
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: var(--primary);
  color: #fff;
}

.nav-badge.beta {
  background: linear-gradient(135deg, #AF52DE, #FF3823);
}

/* Sidebar Footer Profile Area */
.sidebar-footer {
  padding-top: 16px;
  border-top: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.user-snippet {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-surface-secondary);
  transition: background var(--transition-fast);
}

.user-snippet:hover {
  background: var(--bg-surface-tertiary);
}

.user-avatar-mini {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  object-fit: cover;
  background: var(--bg-surface-tertiary);
  border: 2px solid var(--primary);
  flex-shrink: 0;
}

.user-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.user-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ==========================================================================
   Main Content Area & Topbar
   ========================================================================== */

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition-base);
  background: var(--bg-app);
}

.topbar {
  height: var(--header-height);
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 90;
  transition: background var(--transition-base), border var(--transition-base);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 20px;
}

.mobile-menu-btn {
  display: none;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface-secondary);
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  color: var(--text-main);
}

.topbar-search {
  position: relative;
  width: 320px;
}

.topbar-search input {
  width: 100%;
  padding: 10px 16px 10px 42px;
  border-radius: var(--radius-full);
  background: var(--bg-surface-secondary);
  border: 1px solid transparent;
  color: var(--text-main);
  font-size: 0.88rem;
  font-weight: 500;
  transition: all var(--transition-fast);
}

.topbar-search input:focus {
  background: var(--bg-surface);
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.search-icon {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.95rem;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* Theme Toggle Button */
.theme-toggle-btn {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-full);
  background: var(--bg-surface-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-main);
  font-size: 1.2rem;
  transition: all var(--transition-fast);
  border: 1px solid var(--border-light);
}

.theme-toggle-btn:hover {
  background: var(--bg-surface-tertiary);
  transform: rotate(15deg);
}

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-full);
  font-size: 0.88rem;
  font-weight: 700;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.action-btn.primary {
  background: var(--primary-gradient);
  color: #fff;
  box-shadow: var(--shadow-primary);
}

.action-btn.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(255, 56, 35, 0.45);
}

.action-btn.secondary {
  background: var(--bg-surface-secondary);
  color: var(--text-main);
  border: 1px solid var(--border-light);
}

.action-btn.secondary:hover {
  background: var(--bg-surface-tertiary);
}

.action-btn.danger {
  background: rgba(235, 0, 0, 0.1);
  color: #eb0000;
}

.action-btn.danger:hover {
  background: #eb0000;
  color: #fff;
}

/* Page Container */
.page-body {
  flex: 1;
  padding: 32px;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
}

/* ==========================================================================
   Card Component System (Matches Reference Design)
   ========================================================================== */

.vd-card {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-card);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  transition: transform var(--transition-base), box-shadow var(--transition-base), background var(--transition-base);
  position: relative;
  overflow: hidden;
}

.vd-card:hover {
  box-shadow: var(--shadow-md);
}

.vd-card.interactive:hover {
  transform: translateY(-4px);
  border-color: var(--primary-light);
}

/* ==========================================================================
   Toast Notification System
   ========================================================================== */

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 9999;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-main);
  box-shadow: var(--shadow-lg);
  border-left: 5px solid var(--primary);
  font-size: 0.9rem;
  font-weight: 600;
  animation: slideInRight 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  min-width: 280px;
  max-width: 420px;
}

.toast.success {
  border-left-color: var(--accent-green);
}

.toast.error {
  border-left-color: #FF3B30;
}

.toast.info {
  border-left-color: var(--accent-blue);
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(40px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */

@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.4);
  }

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

  .mobile-menu-btn {
    display: flex;
  }

  .topbar-search {
    width: 220px;
  }
}

@media (max-width: 768px) {
  .topbar {
    padding: 0 16px;
  }

  .page-body {
    padding: 20px 16px;
  }

  .topbar-search {
    display: none;
  }
}
