/* ========================================
   CSS Variables & Theme
   ======================================== */
:root {
    /* Colors */
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --secondary-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --accent-gradient: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    
    --bg-primary: #0f0f1e;
    --bg-secondary: #1a1a2e;
    --bg-tertiary: #16213e;
    
    --text-primary: #ffffff;
    --text-secondary: #b8b8d1;
    --text-muted: #6b6b8c;
    
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 40px rgba(102, 126, 234, 0.3);
    
    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.5rem;
    --font-size-2xl: 2rem;
    
    /* Spacing */
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;
    
    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 300ms ease;
    --transition-slow: 500ms ease;
}

/* ========================================
   Reset & Base Styles
   ======================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ========================================
   Background Effects
   ======================================== */
.background-gradient {
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 20% 50%, rgba(102, 126, 234, 0.15) 0%, transparent 50%),
                radial-gradient(circle at 80% 80%, rgba(118, 75, 162, 0.15) 0%, transparent 50%),
                radial-gradient(circle at 40% 20%, rgba(79, 172, 254, 0.1) 0%, transparent 50%);
    animation: gradientShift 20s ease infinite;
    z-index: -1;
}

@keyframes gradientShift {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    33% { transform: translate(5%, 5%) rotate(120deg); }
    66% { transform: translate(-5%, 5%) rotate(240deg); }
}

/* ========================================
   Container & Layout
   ======================================== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--spacing-lg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ========================================
   Header
   ======================================== */
.header {
    text-align: center;
    margin-bottom: var(--spacing-xl);
    animation: fadeInDown 0.8s ease;
}

.logo-section {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
}

.logo-icon {
    animation: float 3s ease-in-out infinite;
}

.logo-text {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    font-size: var(--font-size-lg);
    color: var(--text-secondary);
    font-weight: 300;
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

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

/* ========================================
   Main Content
   ======================================== */
.main-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 1s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ========================================
   Loading State
   ======================================== */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-xl);
}

.spinner {
    width: 60px;
    height: 60px;
    border: 4px solid var(--glass-border);
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    font-size: var(--font-size-lg);
    color: var(--text-secondary);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ========================================
   Error State
   ======================================== */
.error-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-xl);
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(10px);
    max-width: 500px;
    text-align: center;
}

.error-icon {
    font-size: 4rem;
    animation: shake 0.5s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.error-title {
    font-size: var(--font-size-xl);
    font-weight: 600;
    color: var(--text-primary);
}

.error-message {
    font-size: var(--font-size-base);
    color: var(--text-secondary);
    line-height: 1.6;
}

.retry-button {
    margin-top: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-lg);
    background: var(--primary-gradient);
    color: var(--text-primary);
    border: none;
    border-radius: var(--radius-md);
    font-size: var(--font-size-base);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    box-shadow: var(--shadow-md);
}

.retry-button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.retry-button:active {
    transform: translateY(0);
}

/* ========================================
   Chat Container
   ======================================== */
.chat-wrapper {
    width: 100%;
    max-width: 900px;
    height: 600px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: scaleIn 0.5s ease;
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ChatKit Component Styling */
#chatkit-component {
    width: 100%;
    height: 100%;
    display: block;
}

/* ========================================
   Footer
   ======================================== */
.footer {
    text-align: center;
    padding: var(--spacing-lg) 0;
    margin-top: var(--spacing-xl);
    color: var(--text-muted);
    font-size: var(--font-size-sm);
}

.footer strong {
    color: var(--text-secondary);
    font-weight: 600;
}

.footer-links {
    margin-top: var(--spacing-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
}

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.footer-links a:hover {
    color: var(--text-primary);
}

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

/* ========================================
   Floating Chatbot Bubble Button
   ======================================== */
.chat-bubble-button {
  position: fixed;
  bottom: 32px;
  right: 32px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--primary-gradient);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 9999;
  transition: transform 0.2s cubic-bezier(.4,2,.6,1), box-shadow var(--transition-fast);
  border: none;
  outline: none;
}

.chat-bubble-button:active {
  transform: scale(0.95);
}

.chat-bubble-icon {
  width: 2rem;
  height: 2rem;
  display: block;
  color: white;
  filter: drop-shadow(0 2px 8px rgba(102, 126, 234, 0.5));
}

/* ========================================
   Floating Chat Window
   ======================================== */
.floating-chat-window {
  position: fixed;
  bottom: 32px;
  right: 32px;
  width: 380px;
  max-width: 98vw;
  height: 540px;
  background: var(--glass-bg);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  backdrop-filter: blur(30px) saturate(1.2);
  border-radius: var(--radius-xl);
  border: 1.5px solid var(--glass-border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: fadeInUp 0.5s cubic-bezier(.33,1,.68,1);
  z-index: 9999;
}

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

.floating-chat-window .chat-header {
  display: flex;
  align-items: center;
  padding: 0.75rem 1.25rem;
  background: var(--primary-gradient);
  color: white;
  font-size: 1rem;
  font-weight: 500;
  border-top-left-radius: var(--radius-xl);
  border-top-right-radius: var(--radius-xl);
  box-shadow: 0 4px 24px rgba(118,75,162,0.09);
}

.floating-chat-window .chat-header .close-btn {
  margin-left: auto;
  cursor: pointer;
  font-size: 1.5rem;
  color: #efeefe;
  background: none;
  border: none;
  transition: color var(--transition-fast);
}
.floating-chat-window .chat-header .close-btn:hover {
  color: #fafafa;
}

.floating-chat-window .chat-wrapper {
  max-width: none;
  height: 100%;
  border: none;
  border-radius: 0;
  box-shadow: none;
  backdrop-filter: none;
  animation: none;
}

.floating-chat-window .footer { display:none; }

.floating-chat-window.closed { display: none; }

@media (max-width: 500px) {
  .floating-chat-window {
    width: 99vw;
    height: 99svh;
    min-height: 320px;
    max-height: 100svh;
    right: 0;
    bottom: 0;
    border-radius: 0 0 0 0;
  }
}

/* Hide normal .container and header/footer when floating chat is open for immersive widget mode. */
.container.hide-for-chat {
  opacity: 0.16 !important;
  pointer-events: none !important;
  filter: blur(2px) grayscale(0.4) brightness(0.95);
  transition: opacity 0.45s, filter 0.45s;
}

.footer.hide-for-chat {
  opacity: 0 !important;
  pointer-events: none !important;
  transition: opacity 0.3s;
}
/* Ensure .chat-wrapper fits floating window context */
.floating-chat-window .chat-wrapper {
    background: transparent;
    box-shadow: none;
    padding: 0;
}

/* ========================================
   Responsive Design
   ======================================== */
@media (max-width: 768px) {
    :root {
        --font-size-2xl: 1.5rem;
        --font-size-xl: 1.25rem;
    }
    
    .container {
        padding: var(--spacing-sm);
    }
    
    .chat-wrapper {
        height: 500px;
        border-radius: var(--radius-lg);
    }
    
    .header {
        margin-bottom: var(--spacing-lg);
    }
    
    .logo-section {
        flex-direction: column;
        gap: var(--spacing-xs);
    }
}

@media (max-width: 480px) {
    .chat-wrapper {
        height: 400px;
    }
    
    .error-container {
        padding: var(--spacing-lg);
    }
}

/* ========================================
   Accessibility
   ======================================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus styles for keyboard navigation */
button:focus-visible,
a:focus-visible {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}
