/* Enhanced styles for ComicGenius Pro */

/* Global styles with shadcn theme */
:root {
  --radius: 0.65rem;
  --background: oklch(1 0 0);
  --foreground: oklch(0.141 0.005 285.823);
  --card: oklch(1 0 0);
  --card-foreground: oklch(0.141 0.005 285.823);
  --popover: oklch(1 0 0);
  --popover-foreground: oklch(0.141 0.005 285.823);
  --primary: oklch(0.645 0.246 16.439);
  --primary-foreground: oklch(0.969 0.015 12.422);
  --secondary: oklch(0.967 0.001 286.375);
  --secondary-foreground: oklch(0.21 0.006 285.885);
  --muted: oklch(0.967 0.001 286.375);
  --muted-foreground: oklch(0.552 0.016 285.938);
  --accent: oklch(0.627 0.233 296.803);
  --accent-foreground: oklch(0.969 0.015 12.422);
  --destructive: oklch(0.577 0.245 27.325);
  --destructive-foreground: oklch(0.969 0.015 12.422);
  --border: oklch(0.92 0.004 286.32);
  --input: oklch(0.92 0.004 286.32);
  --ring: oklch(0.645 0.246 16.439);
  --chart-1: oklch(0.646 0.222 41.116);
  --chart-2: oklch(0.6 0.118 184.704);
  --chart-3: oklch(0.398 0.07 227.392);
  --chart-4: oklch(0.828 0.189 84.429);
  --chart-5: oklch(0.769 0.188 70.08);
  --sidebar: oklch(0.985 0 0);
  --sidebar-foreground: oklch(0.141 0.005 285.823);
  --sidebar-primary: oklch(0.645 0.246 16.439);
  --sidebar-primary-foreground: oklch(0.969 0.015 12.422);
  --sidebar-accent: oklch(0.967 0.001 286.375);
  --sidebar-accent-foreground: oklch(0.21 0.006 285.885);
  --sidebar-border: oklch(0.92 0.004 286.32);
  --sidebar-ring: oklch(0.645 0.246 16.439);
  
  /* Legacy variables mapped to new theme */
  --primary-color: var(--primary);
  --secondary-color: var(--secondary);
}

/* Dark mode theme */
.dark {
  --background: oklch(0.141 0.005 285.823);
  --foreground: oklch(0.969 0.015 12.422);
  --card: oklch(0.185 0.009 285.883);
  --card-foreground: oklch(0.969 0.015 12.422);
  --popover: oklch(0.185 0.009 285.883);
  --popover-foreground: oklch(0.969 0.015 12.422);
  --primary: oklch(0.678 0.224 14.751);
  --primary-foreground: oklch(0.141 0.005 285.823);
  --secondary: oklch(0.247 0.021 285.748);
  --secondary-foreground: oklch(0.969 0.015 12.422);
  --muted: oklch(0.247 0.021 285.748);
  --muted-foreground: oklch(0.706 0.011 285.945);
  --accent: oklch(0.627 0.233 296.803);
  --accent-foreground: oklch(0.969 0.015 12.422);
  --destructive: oklch(0.43 0.146 27.472);
  --destructive-foreground: oklch(0.969 0.015 12.422);
  --border: oklch(0.247 0.021 285.748);
  --input: oklch(0.247 0.021 285.748);
  --ring: oklch(0.645 0.246 16.439);
  --chart-1: oklch(0.646 0.222 41.116);
  --chart-2: oklch(0.6 0.118 184.704);
  --chart-3: oklch(0.398 0.07 227.392);
  --chart-4: oklch(0.828 0.189 84.429);
  --chart-5: oklch(0.769 0.188 70.08);
  --sidebar: oklch(0.185 0.009 285.883);
  --sidebar-foreground: oklch(0.969 0.015 12.422);
  --sidebar-primary: oklch(0.678 0.224 14.751);
  --sidebar-primary-foreground: oklch(0.141 0.005 285.823);
  --sidebar-accent: oklch(0.247 0.021 285.748);
  --sidebar-accent-foreground: oklch(0.969 0.015 12.422);
  --sidebar-border: oklch(0.247 0.021 285.748);
  --sidebar-ring: oklch(0.645 0.246 16.439);
  
  /* Additional colors */
  --accent-color: var(--accent);
  --dark-color: var(--foreground);
  --light-color: var(--background);
  --success-color: oklch(0.464 0.191 142.77);
  --warning-color: oklch(0.76 0.183 49.77);
  --danger-color: var(--destructive);
  
  /* Animation durations */
  --transition-fast: 0.2s;
  --transition-normal: 0.3s;
  --transition-slow: 0.5s;
}

.dark {
  --background: oklch(0.141 0.005 285.823);
  --foreground: oklch(0.985 0 0);
  --card: oklch(0.21 0.006 285.885);
  --card-foreground: oklch(0.985 0 0);
  --popover: oklch(0.21 0.006 285.885);
  --popover-foreground: oklch(0.985 0 0);
  --primary: oklch(0.645 0.246 16.439);
  --primary-foreground: oklch(0.969 0.015 12.422);
  --secondary: oklch(0.274 0.006 286.033);
  --secondary-foreground: oklch(0.985 0 0);
  --muted: oklch(0.274 0.006 286.033);
  --muted-foreground: oklch(0.705 0.015 286.067);
  --accent: oklch(0.274 0.006 286.033);
  --accent-foreground: oklch(0.985 0 0);
  --destructive: oklch(0.704 0.191 22.216);
  --border: oklch(1 0 0 / 10%);
  --input: oklch(1 0 0 / 15%);
  --ring: oklch(0.645 0.246 16.439);
  --chart-1: oklch(0.488 0.243 264.376);
  --chart-2: oklch(0.696 0.17 162.48);
  --chart-3: oklch(0.769 0.188 70.08);
  --chart-4: oklch(0.627 0.265 303.9);
  --chart-5: oklch(0.645 0.246 16.439);
  --sidebar: oklch(0.21 0.006 285.885);
  --sidebar-foreground: oklch(0.985 0 0);
  --sidebar-primary: oklch(0.645 0.246 16.439);
  --sidebar-primary-foreground: oklch(0.969 0.015 12.422);
  --sidebar-accent: oklch(0.274 0.006 286.033);
  --sidebar-accent-foreground: oklch(0.985 0 0);
  --sidebar-border: oklch(1 0 0 / 10%);
  --sidebar-ring: oklch(0.645 0.246 16.439);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--background);
    color: var(--foreground);
    line-height: 1.6;
}

/* Main layout with sidebar */
.app-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 280px;
    background-color: var(--sidebar);
    color: var(--sidebar-foreground);
    border-right: 1px solid var(--sidebar-border);
    padding: 1.5rem;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 40;
}

.main-content {
    flex: 1;
    margin-left: 280px;
    padding: 2rem;
}

/* Header styling */
header {
    background: var(--card);
    color: var(--card-foreground);
    box-shadow: 0 1px 3px var(--border);
    border-radius: var(--radius);
    margin-bottom: 2rem;
    padding: 1.5rem;
}

header h1 {
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

/* Card styling */
.bg-white {
    background: var(--card);
    color: var(--card-foreground);
    border-radius: var(--radius);
    box-shadow: 0 1px 3px var(--border);
    border: 1px solid var(--border);
    transition: all var(--transition-normal) ease;
}

.bg-white:hover {
    box-shadow: 0 4px 12px var(--border);
}

/* Canvas styling */
#characterCanvas {
    border: 2px solid var(--primary-color);
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(67, 97, 238, 0.2);
    transition: all 0.3s ease;
    background: white;
}

#characterCanvas:hover {
    border-color: var(--accent-color);
    box-shadow: 0 8px 25px rgba(67, 97, 238, 0.3);
}

/* Button enhancements */
button {
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border: none;
    font-weight: 600;
    letter-spacing: 0.5px;
    position: relative;
    overflow: hidden;
}

button:hover {
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

button:active {
    transform: translateY(1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

button::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 5px;
    background: rgba(255, 255, 255, 0.5);
    opacity: 0;
    border-radius: 100%;
    transform: scale(1, 1) translate(-50%);
    transform-origin: 50% 50%;
}

button:focus:not(:active)::after {
    animation: ripple 1s ease-out;
}

@keyframes ripple {
    0% {
        transform: scale(0, 0);
        opacity: 0.5;
    }
    100% {
        transform: scale(50, 50);
        opacity: 0;
    }
}

/* Panel styling */
#comicPanels {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

#comicPanels > div {
    transition: all 0.3s ease;
    border-radius: 12px;
    overflow: hidden;
}

#comicPanels > div:hover {
    transform: translateY(-8px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2);
}

.regenerate-panel-btn {
    transition: all 0.2s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.regenerate-panel-btn:hover {
    transform: rotate(180deg);
}

/* Progress bar animation */
#generationProgress {
    transition: width 0.5s ease;
    background-size: 200% 100%;
    animation: moveGradient 2s linear infinite;
}

@keyframes moveGradient {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

.comic-panel-image {
    transition: transform 0.3s ease;
}

.comic-panel-image:hover {
    transform: scale(1.05);
}

/* Loading animation */
#loadingIndicator {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    max-width: 500px;
    margin: 2rem auto;
    padding: 2rem;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.02);
    }
}

#loadingIndicator > div {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Form elements */
input, select, textarea {
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    transition: all 0.3s ease;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.2);
    outline: none;
}

/* Character display */
#characterDisplay {
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f0f4f8, #e2e8f0);
    border-radius: 12px;
    padding: 1rem;
}

#characterDisplay img {
    max-width: 100%;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

/* Download button */
#downloadComicBtn {
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
    border-radius: 12px;
    padding: 1rem 2rem;
    font-size: 1.1rem;
    font-weight: 600;
    box-shadow: 0 6px 20px rgba(67, 97, 238, 0.3);
    transition: all 0.3s ease;
}

#downloadComicBtn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(67, 97, 238, 0.4);
}

/* Popup styling */
#image-popup-overlay {
    backdrop-filter: blur(5px);
    background-color: var(--popover);
}

#image-popup-overlay img {
    max-height: 80vh;
    object-fit: contain;
}

/* Carousel container and content */
.carousel-container {
    position: relative;
    width: 100%;
    overflow: hidden;
    padding: 0 2.5rem;
    margin: 2rem 0;
}

.carousel-content {
    display: flex;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 1rem;
    padding: 1rem 0;
    -ms-overflow-style: none;  /* Hide scrollbar in IE and Edge */
    scrollbar-width: none;  /* Hide scrollbar in Firefox */
}

.carousel-content::-webkit-scrollbar {
    display: none; /* Hide scrollbar in Chrome, Safari and Opera */
}

.carousel-content > * {
    scroll-snap-align: start;
    flex: 0 0 auto;
}

/* Carousel navigation */
.carousel-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background-color: var(--background);
    color: var(--foreground);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0.8;
    transition: all var(--transition-fast) ease;
    border: 1px solid var(--border);
    z-index: 60;
}

.carousel-nav-btn:hover {
    opacity: 1;
    background-color: var(--primary);
    color: var(--primary-foreground);
    transform: translateY(-50%) scale(1.1);
}

.carousel-nav-left {
    left: 0;
}

.carousel-nav-right {
    right: 0;
}

.carousel-indicators {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 1rem;
}

.carousel-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--muted-foreground);
    opacity: 0.5;
    transition: opacity var(--transition-fast) ease, transform var(--transition-fast) ease;
}

.carousel-dot.active {
    opacity: 1;
    transform: scale(1.2);
    background-color: var(--primary);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    #characterCanvas {
        width: 100%;
        height: 250px;
    }
    
    .grid {
        grid-template-columns: 1fr;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    #comicPanels {
        grid-template-columns: 1fr;
    }
}

/* Notification styling */
.toast-notification {
    position: fixed;
    top: 1rem;
    right: 1rem;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    color: white;
    font-weight: 600;
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    animation: slideIn 0.3s ease-out;
    backdrop-filter: blur(10px);
    transition: opacity 0.3s ease;
}

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

/* Tooltip styling */
#dynamic-tooltip {
    animation: fadeIn 0.2s ease-out;
    pointer-events: none;
    white-space: nowrap;
    z-index: 1000;
}

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

/* Character counter */
.char-counter {
    font-size: 0.8rem;
    color: #64748b;
    text-align: right;
    margin-top: 0.25rem;
}

/* API key section */
#apiKey {
    background: var(--input);
    font-family: monospace;
    color: var(--foreground);
    border: 1px solid var(--border);
}

/* Panel headers */
#comicPanels > div .p-4 {
    background: var(--card);
    color: var(--card-foreground);
    border-bottom: 1px solid var(--border);
}

/* Sidebar styling */
.sidebar-logo {
    margin-bottom: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.sidebar-logo h1 {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--sidebar-foreground);
}

.sidebar-logo p {
    font-size: 0.875rem;
    color: var(--sidebar-muted-foreground);
    margin-top: 0.5rem;
}

.sidebar-section {
    margin-bottom: 2rem;
}

.sidebar-section h2 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--sidebar-muted-foreground);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--sidebar-border);
    font-size: 0.875rem;
    color: var(--sidebar-muted-foreground);
}