/* Enhanced CSS Animations and Keyframes */
@keyframes floatUp {
  0%,
  100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-5px);
  }
}

@keyframes slideInFromLeft {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes tooltipFadeIn {
  from {
    opacity: 0;
    transform: translateY(-50%) translateX(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
  }
}

/* Theme Variables - Matching Webflow Design System */
:root {
  /* Webflow color palette */
  --dark-blue-0: #000;
  --dark-blue-1: #050d15;
  --dark-blue-2: #121f2d;
  --dark-blue-3: #132436;
  --blue-1: #030a39;
  --blue-2: #56f;
  --blue-3: #6472f3;
  --green-1: #186f44;
  --green-2: #35a670;
  --white: white;
  --gradient: #bdd7f180;
  --paragraphs: #ffffffeb;
  --paragraphs-dark: #ffffff99;
  --transparent-bg: #02090fcc;
  --blur-blue: #2a3ded66;
  --circle-1: #2a3dedcc;
  --circle-2: #000000b3;
  --circle-border: #ffffff26;
  --circle-accent: #fff;

  /* Dashboard specific mappings */
  --bg-primary: var(--dark-blue-0);
  --bg-secondary: var(--dark-blue-3);
  --bg-tertiary: var(--dark-blue-2);
  --text-primary: var(--white);
  --text-secondary: var(--paragraphs);
  --text-light: var(--paragraphs-dark);
  --text-white: var(--white);
  --border-color: var(--circle-border);
  --shadow-color: rgba(0, 0, 0, 0.3);
  --shadow-hover: rgba(42, 61, 237, 0.4);
}

[data-theme="light"] {
  --bg-primary: var(--white);
  --bg-secondary: #f8fafc;
  --bg-tertiary: var(--dark-blue-3);
  --text-primary: var(--dark-blue-0);
  --text-secondary: var(--paragraphs);
  --text-light: var(--paragraphs-dark);
  --text-white: var(--white);
  --border-color: #e2e8f0;
  --shadow-color: rgba(0, 0, 0, 0.1);
  --shadow-hover: rgba(42, 61, 237, 0.2);
}

[data-theme="dark"] {
  --bg-primary: var(--dark-blue-0);
  --bg-secondary: var(--dark-blue-3);
  --bg-tertiary: var(--dark-blue-2);
  --text-primary: var(--white);
  --text-secondary: var(--paragraphs);
  --text-light: var(--paragraphs-dark);
  --text-white: var(--white);
  --border-color: var(--circle-border);
  --shadow-color: rgba(0, 0, 0, 0.3);
  --shadow-hover: rgba(42, 61, 237, 0.4);
}

* {
  font-family: "Creato Display", -apple-system, BlinkMacSystemFont, sans-serif;
}

body {
  background: #000;
  background-image: radial-gradient(
      circle at 20% 80%,
      rgba(42, 61, 237, 0.05) 0%,
      transparent 50%
    ),
    radial-gradient(
      circle at 80% 20%,
      rgba(100, 114, 243, 0.03) 0%,
      transparent 50%
    );
  color: var(--text-secondary);
  min-height: 100vh;
  margin: 0;
  padding: 0;
  transition: all 0.3s ease;
  font-size: 16px;
  line-height: 1.62em;
}

/* Sidebar Styles */
.sidebar {
  width: 280px;
  background: #132436;
  background-image: linear-gradient(140deg, #0b1040, #000002);
  padding: 20px 25px;
  position: fixed;
  left: 0;
  top: 0;
  height: 100vh;
  min-height: 0;
  max-height: 100vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transition: all 0.3s ease;
  border-right: 1px solid var(--border-color);
  -webkit-backdrop-filter: blur(100px);
  backdrop-filter: blur(100px);
  animation: slideInFromLeft 0.6s ease-out;
  scrollbar-width: none; /* Firefox */
}

.sidebar::-webkit-scrollbar {
  display: none; /* Safari and Chrome */
}

.sidebar.minimized {
  width: 80px;
  padding: 20px 15px;
}

/* Header Section */
.header-section {
  margin-bottom: 25px;
}

.logo-section {
  display: flex;
  align-items: center;
  margin-bottom: 20px;
  position: relative;
}

.minimize-btn {
  position: absolute;
  top: -15px;
  right: -10px;
  background: linear-gradient(20deg, var(--blue-1), var(--blue-3));
  border: none;
  color: white;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  z-index: 1001;
  box-shadow: 0 7px 30px -12px var(--blue-2);
}

.minimize-btn:hover {
  box-shadow: 0 0 0 -10px var(--blue-2),
    inset -15px 13px 30px 0 var(--dark-blue-3),
    inset 20px -55px 30px 0 var(--dark-blue-3);
  transform: scale(1.1);
}

.sidebar.minimized .minimize-btn {
  right: 5px;
}

/* User Header */
.user-header {
  display: flex;
  align-items: center;
  background: var(--transparent-bg);
  -webkit-backdrop-filter: blur(100px);
  backdrop-filter: blur(100px);
  border-radius: 16px;
  padding: 12px 16px;
  border: 1px solid var(--border-color);
  transition: all 0.3s ease;
  gap: 12px;
}

.sidebar.minimized .user-header {
  justify-content: center;
  padding: 12px 8px;
  gap: 0;
}

.user-avatar-small {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--circle-accent);
  box-shadow: 0 2px 8px var(--shadow-color);
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.sidebar.minimized .user-avatar-small {
  width: 32px;
  height: 32px;
}

.user-info {
  flex-grow: 1;
  min-width: 0;
  transition: all 0.3s ease;
}

.sidebar.minimized .user-info {
  display: none;
}

.user-name-small {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-logout-btn {
  background: none;
  border: none;
  color: var(--paragraphs-dark);
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.3s ease;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.header-logout-btn:hover {
  background: var(--blue-2);
  color: white;
  transform: scale(1.05);
}

.sidebar.minimized .header-logout-btn {
  display: none;
}

.logo-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(20deg, var(--blue-1), var(--blue-3));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 12px;
  box-shadow: 0 7px 30px -12px var(--blue-2);
  animation: floatUp 6s ease-in-out infinite;
}

.logo-text {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-white);
  transition: all 0.3s ease;
}

.sidebar.minimized .logo-text {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

.nav-menu {
  flex-grow: 1;
  margin-top: 10px;
}

.nav-item {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  margin-bottom: 8px;
  border-radius: 12px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  color: var(--paragraphs-dark);
  transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  position: relative;
}

.sidebar.minimized .nav-item {
  padding: 14px 12px;
  justify-content: center;
}

.nav-item:hover {
  background: var(--transparent-bg);
  color: white;
  -webkit-backdrop-filter: blur(100px);
  backdrop-filter: blur(100px);
  transform: translateX(3px);
  box-shadow: 0 3px 15px -10px var(--blue-2);
}

.nav-item.active {
  background: linear-gradient(20deg, var(--blue-1), var(--blue-3));
  color: white;
  font-weight: 600;
  box-shadow: 0 7px 30px -12px var(--blue-2);
}

.nav-item i {
  width: 20px;
  margin-right: 12px;
  text-align: center;
  transition: all 0.3s ease;
}

.sidebar.minimized .nav-item i {
  margin-right: 0;
}

.nav-item span {
  transition: all 0.3s ease;
}

.sidebar.minimized .nav-item span {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

/* Theme Toggle */
.theme-section {
  margin-bottom: 16px;
  transition: all 0.3s ease;
}

.theme-btn {
  display: flex;
  align-items: center;
  width: 100%;
  background: var(--transparent-bg);
  -webkit-backdrop-filter: blur(100px);
  backdrop-filter: blur(100px);
  border: 1px solid var(--border-color);
  color: var(--paragraphs-dark);
  padding: 12px 16px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  position: relative;
}

.sidebar.minimized .theme-btn {
  padding: 12px;
  justify-content: center;
}

.theme-btn:hover {
  background: var(--transparent-bg);
  color: white;
  -webkit-backdrop-filter: blur(100px);
  backdrop-filter: blur(100px);
}

.theme-icon {
  width: 20px;
  margin-right: 12px;
  text-align: center;
  transition: all 0.3s ease;
}

.sidebar.minimized .theme-icon {
  margin-right: 0;
}

.theme-text {
  transition: all 0.3s ease;
}

.sidebar.minimized .theme-text {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

/* Tooltips for minimized sidebar */
.sidebar.minimized .nav-item:hover::after,
.sidebar.minimized .theme-btn:hover::after,
.sidebar.minimized .header-logout-btn:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--dark-blue-3);
  color: white;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  white-space: nowrap;
  z-index: 1002;
  opacity: 1;
  pointer-events: none;
  box-shadow: 0 5px 25px var(--shadow-color);
  animation: tooltipFadeIn 0.2s ease;
  border: 1px solid var(--border-color);
}

.sidebar.minimized .nav-item:hover::before,
.sidebar.minimized .theme-btn:hover::before,
.sidebar.minimized .header-logout-btn:hover::before {
  content: "";
  position: absolute;
  left: calc(100% + 6px);
  top: 50%;
  transform: translateY(-50%);
  border: 6px solid transparent;
  border-right-color: var(--dark-blue-3);
  z-index: 1002;
}

/* Mobile Responsiveness - neutralized to avoid overriding page-specific headers */
.mobile-header {
  /* default hidden; pages should provide visible rules in their own CSS */
  display: none;
}

.mobile-overlay {
  /* keep overlay element but avoid imposing a heavy background here */
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: transparent; /* let page CSS decide overlay darkness */
  z-index: 999;
}

/* FIXED MOBILE STYLES - Proper Open/Close Functionality */
@media (max-width: 768px) {
  body {
    padding: 0;
    background-attachment: local;
  }

  /* Sidebar - Hidden by default on mobile */
  .sidebar {
    position: fixed;
    top: 0;
    left: -280px; /* Hidden off-screen */
    width: 280px;
    height: 100vh;
    min-height: 0;
    max-height: 100vh;
    z-index: 1000;
    transition: left 0.3s ease; /* Smooth transition */
    padding: 20px 25px;
    animation: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    scrollbar-width: none; /* Firefox */
  }

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

  /* Sidebar shown when .open class is added */
  .sidebar.open {
    left: 0;
  }

  .sidebar.minimized {
    width: 280px;
    padding: 20px 25px;
    left: -280px;
  }

  .sidebar.minimized.open {
    left: 0;
  }

  /* Hide minimize button on mobile */
  .minimize-btn {
    display: none;
  }

  /* Mobile overlay: show state is left to page CSS to style (avoids conflicting darkness) */
  .mobile-overlay.show {
    display: block;
    animation: fadeInUp 0.3s ease forwards;
  }

  /* Mobile header: keep minimal layout only, avoid setting colors/gradients here */
  .mobile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: transparent; /* page-level CSS (e.g. templates.css) should set the exact gradient */
    color: inherit;
    position: sticky;
    top: 0;
    z-index: 500;
    box-shadow: none;
    border-bottom: none;
    position: relative;
    overflow: visible;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
      .mobile-menu-btn {
      background: none;
      border: none;
      color: inherit;
      font-size: 20px;
      cursor: pointer;
      padding: 8px;
      border-radius: 8px;
      transition: all 0.3s ease;
    }

    .mobile-menu-btn:hover {
      background: transparent;
      transform: scale(1.05);
    }

    .mobile-logo {
      display: flex;
      align-items: center;
      font-size: 18px;
      font-weight: 600;
    }

    .mobile-logo i { margin-right: 8px; font-size: 16px; }

    .mobile-profile { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }

  /* Show user-header elements on mobile */
  .sidebar.minimized .user-header {
    justify-content: flex-start;
    padding: 12px 16px;
    gap: 12px;
  }

  .sidebar.minimized .user-info {
    display: block;
  }

  .sidebar.minimized .header-logout-btn {
    display: flex;
  }

  .sidebar.minimized .user-avatar-small {
    width: 36px;
    height: 36px;
  }
}

@media (max-width: 768px) {
  .sidebar {
    height: 100vh !important;
    min-height: 0 !important;
    max-height: 100vh !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
    overscroll-behavior: contain !important;
    position: fixed !important;
    transform: translate3d(0, 0, 0) !important;
    will-change: transform !important;
  }

  .sidebar::-webkit-scrollbar {
    display: none !important;
    width: 0 !important;
    background: transparent !important;
  }

  .sidebar.open {
    height: 100vh !important;
    min-height: 0 !important;
    max-height: 100vh !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior: contain !important;
    transform: translate3d(0, 0, 0) !important;
    will-change: transform !important;
  }
}

@media (max-height: 700px) {
  .sidebar {
    height: 100vh;
    min-height: 0;
    max-height: 100vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 768px) and (max-height: 700px) {
  .sidebar {
    height: 100vh;
    min-height: 0;
    max-height: 100vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 390px) and (max-height: 844px) {
  .sidebar {
    height: 100vh;
    min-height: 0;
    max-height: 100vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-height: 500px) and (orientation: landscape) {
  .sidebar {
    height: 100vh;
    min-height: 0;
    max-height: 100vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

@media (pointer: coarse) {
  .sidebar {
    height: 100vh !important;
    min-height: 0 !important;
    max-height: 200vh !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
    overscroll-behavior: contain !important;
    touch-action: pan-y !important;
    transform: translate3d(0, 0, 0) !important;
  }

  .sidebar::-webkit-scrollbar {
    display: none !important;
    width: 0 !important;
    background: transparent !important;
  }
}

/* iOS Safari specific fix */
@supports (-webkit-touch-callout: none) {
  .sidebar {
    height: 100vh !important;
    min-height: 0 !important;
    max-height: 100vh !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
    overscroll-behavior: contain !important;
    touch-action: pan-y !important;
    transform: translate3d(0, 0, 0) !important;
    will-change: transform !important;
  }

  .sidebar::-webkit-scrollbar {
    display: none !important;
    width: 0 !important;
    background: transparent !important;
  }
}

#sidebar.minimized + .calendar-content {
  margin-left: 80px;
}

#sidebar.closed + .calendar-content {
  margin-left: 0;
}

/* Content margin adjustments for sidebar states */
.calendar-content.sidebar-minimized {
  margin-left: 80px;
  transition: margin-left 0.3s ease;
}

.calendar-content {
  margin-left: 280px;
  transition: margin-left 0.3s ease;
}

.ai-builder-content.sidebar-minimized {
  margin-left: 80px;
  transition: margin-left 0.3s ease;
}

.ai-builder-content {
  margin-left: 280px;
  transition: margin-left 0.3s ease;
}

.content-section.sidebar-minimized {
  margin-left: 80px;
  transition: margin-left 0.3s ease;
}

.content-section {
  margin-left: 280px;
  transition: margin-left 0.3s ease;
}

/* Mobile responsiveness for calendar content */
@media (max-width: 768px) {
  .calendar-content {
    margin-left: 0 !important;
  }
  
  .calendar-content.sidebar-minimized {
    margin-left: 0 !important;
  }
  
  .ai-builder-content {
    margin-left: 0 !important;
  }
  
  .ai-builder-content.sidebar-minimized {
    margin-left: 0 !important;
  }
  
  .content-section {
    margin-left: 0 !important;
  }
  
  .content-section.sidebar-minimized {
    margin-left: 0 !important;
  }
}
