/* ==================== */
/* CSS Variables & Dark Mode */
/* ==================== */

:root {
    /* Light mode colors */
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f3f4f6;
    --text-primary: #1f2937;
    --text-secondary: #4b5563;
    --text-tertiary: #6b7280;
    --border-primary: #e5e7eb;
    --border-secondary: #d1d5db;
    --shadow-primary: rgba(0, 0, 0, 0.1);
    --shadow-secondary: rgba(0, 0, 0, 0.05);
    --accent-primary: #3b82f6;
    --accent-secondary: #9333ea;
    --accent-tertiary: #ec4899;
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;
}

[data-theme="dark"] {
    /* Dark mode colors */
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-tertiary: #94a3b8;
    --border-primary: #334155;
    --border-secondary: #475569;
    --shadow-primary: rgba(0, 0, 0, 0.3);
    --shadow-secondary: rgba(0, 0, 0, 0.2);
    --accent-primary: #60a5fa;
    --accent-secondary: #a78bfa;
    --accent-tertiary: #f472b6;
    --success: #34d399;
    --error: #f87171;
    --warning: #fbbf24;
}

/* ==================== */
/* Reset & Base Styles  */
/* ==================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: inherit;
}

html {
    overflow-x: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
        'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    background: linear-gradient(135deg, 
        var(--bg-primary) 0%, 
        var(--bg-secondary) 25%, 
        var(--bg-tertiary) 50%, 
        var(--bg-secondary) 75%, 
        var(--bg-primary) 100%);
    color: var(--text-primary);
    position: relative;
    overflow-x: hidden;
    transition: background 0.3s ease, color 0.3s ease;
}

/* ==================== */
/* Background Decoration */
/* ==================== */

.bg-decoration {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.bg-circle {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
}

.bg-circle-1 {
    top: -300px;
    right: -300px;
    width: 400px;
    height: 400px;
    background: linear-gradient(135deg, 
        rgba(59, 130, 246, 0.15) 0%, 
        rgba(147, 51, 234, 0.15) 50%, 
        rgba(236, 72, 153, 0.15) 100%);
    transition: background 0.3s ease;
    animation: float 6s ease-in-out infinite;
}

.bg-circle-2 {
    bottom: -300px;
    left: -300px;
    width: 400px;
    height: 400px;
    background: linear-gradient(135deg, 
        rgba(236, 72, 153, 0.15) 0%, 
        rgba(147, 51, 234, 0.15) 50%, 
        rgba(59, 130, 246, 0.15) 100%);
    transition: background 0.3s ease;
    animation: float 8s ease-in-out infinite reverse;
}

/* Floating animation for background circles */
@keyframes float {
    0%, 100% {
        transform: translateY(0px) translateX(0px);
    }
    25% {
        transform: translateY(-20px) translateX(10px);
    }
    50% {
        transform: translateY(-10px) translateX(-10px);
    }
    75% {
        transform: translateY(-30px) translateX(5px);
    }
}

/* Dark mode background decoration */
[data-theme="dark"] .bg-circle-1 {
    background: linear-gradient(135deg, 
        rgba(59, 130, 246, 0.25) 0%, 
        rgba(147, 51, 234, 0.25) 50%, 
        rgba(236, 72, 153, 0.25) 100%);
}

[data-theme="dark"] .bg-circle-2 {
    background: linear-gradient(135deg, 
        rgba(236, 72, 153, 0.25) 0%, 
        rgba(147, 51, 234, 0.25) 50%, 
        rgba(59, 130, 246, 0.25) 100%);
}

/* ==================== */
/* Container & Layout   */
/* ==================== */

.container {
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    min-height: 100vh;
}

@media (min-width: 640px) {
    .container {
        padding: 1.5rem;
    }
}

@media (min-width: 768px) {
    .container {
        padding: 2rem;
    }
}

/* ==================== */
/* Header Styles        */
/* ==================== */

.header {
    width: 100%;
    max-width: 42rem;
    text-align: center;
}

.header-title {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 2rem;
    position: relative;
}

.dark-mode-toggle {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    background: var(--bg-secondary);
    border: 2px solid var(--border-primary);
    border-radius: 0.75rem;
    padding: 0.75rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 6px -1px var(--shadow-secondary);
    color: var(--text-primary);
}

.dark-mode-toggle:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent-primary);
    transform: translateY(-50%) scale(1.05);
    box-shadow: 0 8px 15px -3px var(--shadow-primary);
}

.dark-mode-toggle:active {
    transform: translateY(-50%) scale(0.95);
}

.dark-mode-toggle svg {
    color: var(--text-primary);
    transition: color 0.3s ease;
}

@media (max-width: 768px) {
    .dark-mode-toggle {
        position: static;
        transform: none;
        margin-left: 1rem;
    }
    
    .header-title {
        justify-content: space-between;
    }
}

.icon-wrapper {
    padding: 1rem;
    border-radius: 1rem;
    margin-right: 1rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.icon-gradient {
    background: linear-gradient(to bottom right, #3b82f6, #9333ea);
}

.main-title {
    font-size: 3rem;
    font-weight: bold;
    background: linear-gradient(to right, #2563eb, #9333ea, #db2777);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

@media (min-width: 640px) {
    .main-title {
        font-size: 3.75rem;
    }
}

.subtitle {
    font-size: 1.25rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 3rem;
    max-width: 48rem;
    margin-left: auto;
    margin-right: auto;
    transition: color 0.3s ease;
}

.highlight {
    background: linear-gradient(to right, #2563eb, #9333ea);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: bold;
}

/* ==================== */
/* API Key Section      */
/* ==================== */

.api-key-section {
    margin-bottom: 2rem;
    width: 100%;
    max-width: 42rem;
    margin-left: auto;
    margin-right: auto;
}

.api-key-container {
    background: var(--bg-primary);
    padding: 1.5rem;
    border-radius: 1rem;
    box-shadow: 0 10px 15px -3px var(--shadow-primary);
    border: 1px solid var(--border-primary);
    transition: all 0.3s ease;
}

.api-key-input-wrapper {
    position: relative;
}

.api-key-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    margin-left: 0;
    padding-left: 0;
    font-size: 0.875rem;
    text-align: left;
    justify-content: flex-start;
    transition: color 0.3s ease;
}

.api-key-label svg {
    color: var(--text-primary);
    transition: color 0.3s ease;
}

.api-key-input {
    width: 100%;
    padding: 0.875rem 3rem 0.875rem 1rem;
    border: 2px solid var(--border-secondary);
    border-radius: 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.5;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: 'Courier New', 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    box-shadow: 0 1px 2px 0 var(--shadow-secondary);
    background: var(--bg-primary);
    color: var(--text-primary);
}

.api-key-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1), 0 4px 6px -1px var(--shadow-primary);
    transform: translateY(-1px);
}

.api-key-input:hover {
    border-color: var(--text-tertiary);
    box-shadow: 0 4px 6px -1px var(--shadow-primary);
    transform: translateY(-1px);
}

.api-key-input:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.toggle-visibility-btn {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    padding: 0.5rem;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-tertiary);
    transition: color 0.3s ease;
    z-index: 10;
}

.toggle-visibility-btn:hover {
    color: var(--accent-primary);
}

.toggle-visibility-btn svg {
    color: inherit;
    transition: color 0.3s ease;
}

.api-key-hint {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-tertiary);
    transition: color 0.3s ease;
}

.api-key-hint a {
    color: var(--accent-primary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s ease;
}

.api-key-hint a:hover {
    text-decoration: underline;
}

.api-key-test-container {
    display: flex;
    justify-content: center;
    margin-top: 1rem;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
}

.test-connection-btn {
    transition: all 0.3s ease;
}

.test-connection-btn.success {
    background-color: var(--success);
    border-color: var(--success);
    color: white;
}

.test-connection-btn.error {
    background-color: var(--error);
    border-color: var(--error);
    color: white;
}

/* ==================== */
/* Parameter Selection  */
/* ==================== */

.parameter-selection-section {
    margin-bottom: 2rem;
    width: 100%;
    max-width: 42rem;
    margin-left: auto;
    margin-right: auto;
}

.parameter-selection-container {
    background: var(--bg-primary);
    padding: 1.5rem;
    border-radius: 1rem;
    box-shadow: 0 10px 15px -3px var(--shadow-primary);
    border: 1px solid var(--border-primary);
    transition: all 0.3s ease;
}

.parameter-section-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    text-align: center;
    transition: color 0.3s ease;
}

.parameter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.parameter-group {
    display: flex;
    flex-direction: column;
    margin-left: 0;
    padding-left: 0;
}

.parameter-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    margin-left: 0;
    padding-left: 0;
    font-size: 0.875rem;
    text-align: left;
    justify-content: flex-start;
    transition: color 0.3s ease;
}

.parameter-label svg {
    color: var(--text-primary);
    transition: color 0.3s ease;
}

.parameter-select {
    width: 100%;
    padding: 0.875rem 2.5rem 0.875rem 1rem;
    border: 2px solid var(--border-secondary);
    border-radius: 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.5;
    background: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.75rem center;
    background-repeat: no-repeat;
    background-size: 1.25em 1.25em;
    appearance: none;
    box-shadow: 0 1px 2px 0 var(--shadow-secondary);
}

.parameter-select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1), 0 4px 6px -1px var(--shadow-primary);
    transform: translateY(-1px);
}

.parameter-select:hover {
    border-color: var(--text-tertiary);
    box-shadow: 0 4px 6px -1px var(--shadow-primary);
    transform: translateY(-1px);
}

.parameter-select:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

/* Enhanced dropdown option styling */
.parameter-select option {
    padding: 0.75rem 1rem;
    font-weight: 500;
    color: var(--text-primary);
    background: var(--bg-primary);
    border: none;
    border-radius: 0.5rem;
    margin: 0.25rem;
}

.parameter-select option:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.parameter-select option:checked {
    background-color: var(--accent-primary);
    color: white;
    font-weight: 600;
}

/* Optgroup styling for hair style sections */
.parameter-select optgroup {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem 0.25rem 0.75rem;
    border-bottom: 1px solid var(--border-primary);
    margin-bottom: 0.25rem;
}

.parameter-select optgroup option {
    padding-left: 1rem;
    font-weight: 400;
    font-size: 0.9rem;
}

/* Enhanced dropdown appearance for better consistency */
.parameter-select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

/* Custom dropdown styling for webkit browsers */
.parameter-select::-webkit-list-button {
    display: none;
}

.parameter-select::-webkit-calendar-picker-indicator {
    display: none;
}

/* Firefox dropdown styling */
.parameter-select::-moz-list-bullet {
    display: none;
}

@media (max-width: 768px) {
    .parameter-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .parameter-selection-container {
        padding: 1.5rem;
    }
}

/* ==================== */
/* Prompt Editor        */
/* ==================== */

.prompt-editor-section {
    margin-top: 1.5rem;
    border-top: 1px solid var(--border-primary);
    padding-top: 1.5rem;
    transition: border-color 0.3s ease;
}

.prompt-editor-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background: var(--bg-secondary);
    border: 2px solid var(--border-primary);
    border-radius: 0.75rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.prompt-editor-toggle:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent-primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px var(--shadow-primary);
}

.prompt-editor-toggle:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.prompt-editor-toggle .chevron {
    transition: transform 0.3s ease;
    color: var(--text-tertiary);
}

.prompt-editor-toggle.expanded .chevron {
    transform: rotate(180deg);
}

.prompt-editor-content {
    margin-top: 1rem;
    padding: 1.5rem;
    background: var(--bg-secondary);
    border: 2px solid var(--border-primary);
    border-radius: 0.75rem;
    transition: all 0.3s ease;
}

.prompt-editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.prompt-editor-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: color 0.3s ease;
}

.prompt-editor-label svg {
    color: var(--text-primary);
    transition: color 0.3s ease;
}

.prompt-editor-actions {
    display: flex;
    gap: 0.5rem;
}

.prompt-textarea {
    width: 100%;
    padding: 1rem;
    border: 2px solid var(--border-secondary);
    border-radius: 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.6;
    font-family: 'Courier New', 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    background: var(--bg-primary);
    color: var(--text-primary);
    resize: vertical;
    min-height: 200px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 2px 0 var(--shadow-secondary);
}

.prompt-textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1), 0 4px 6px -1px var(--shadow-primary);
    transform: translateY(-1px);
}

.prompt-textarea:hover {
    border-color: var(--text-tertiary);
    box-shadow: 0 4px 6px -1px var(--shadow-primary);
    transform: translateY(-1px);
}

.prompt-textarea:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.prompt-editor-hint {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin-top: 1rem;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-secondary);
    border-radius: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.5;
    text-align: left;
    transition: all 0.3s ease;
}

.prompt-editor-hint svg {
    color: var(--accent-primary);
    margin-top: 0.125rem;
    flex-shrink: 0;
    transition: color 0.3s ease;
}


/* ==================== */
/* Main Content         */
/* ==================== */

.main-content {
    width: 100%;
    max-width: 42rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}


/* ==================== */
/* Slidable Container   */
/* ==================== */

.slidable-container {
    position: relative;
    width: 100%;
    max-width: 42rem;
    margin-left: auto;
    margin-right: auto;
    padding: 0 0 1rem 0;
}

.slide-navigation {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 1.5rem;
    padding: 1rem;
    position: relative;
    z-index: 3;
}

.slide-indicators {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--border-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
}

.indicator.active {
    background: var(--accent-primary);
    transform: scale(1.2);
}

.indicator:hover {
    background: var(--text-tertiary);
}

.slide-wrapper {
    position: relative;
    width: 100%;
    min-height: 500px;
    overflow: hidden;
}

.slide {
    width: 100%;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    position: absolute;
    top: 0;
    left: 0;
    min-height: 500px;
    z-index: 1;
    pointer-events: none;
}

.slide.active {
    opacity: 1;
    transform: translateX(0);
    position: relative;
    z-index: 2;
    pointer-events: auto;
}

.slide.prev {
    transform: translateX(-100%);
}

/* Slide transition animations */
.slide.slide-in-right {
    animation: slideInRight 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.slide.slide-in-left {
    animation: slideInLeft 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.slide.slide-out-right {
    animation: slideOutRight 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.slide.slide-out-left {
    animation: slideOutLeft 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

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

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideOutRight {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

@keyframes slideOutLeft {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(-100%);
    }
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
    /* Header adjustments */
    .main-title {
        font-size: 2.5rem;
    }
    
    .subtitle {
        font-size: 1rem;
        margin-bottom: 2rem;
    }
    
    .icon-wrapper {
        padding: 0.75rem;
        margin-right: 0.75rem;
    }
    
    .icon-large {
        width: 1.5rem;
        height: 1.5rem;
    }
    
    /* Card adjustments */
    .card {
        padding: 1.5rem;
        height: 500px;
        min-height: 500px;
        max-height: 500px;
    }
    
    .card-title {
        font-size: 1.25rem;
    }
    
    .card-subtitle {
        font-size: 0.75rem;
    }
    
    /* Parameter section adjustments */
    .parameter-section-title {
        font-size: 1.125rem;
        margin-bottom: 1rem;
    }
    
    .parameter-label {
        font-size: 0.75rem;
        margin-bottom: 0.5rem;
    }
    
    .parameter-select {
        padding: 0.75rem 2rem 0.75rem 0.75rem;
        font-size: 0.75rem;
    }
    
    /* API key section adjustments */
    .api-key-label {
        font-size: 0.75rem;
    }
    
    .api-key-input {
        padding: 0.75rem 2.5rem 0.75rem 0.75rem;
        font-size: 0.75rem;
    }
    
    /* Button adjustments */
    .btn-large {
        padding: 0.875rem;
        font-size: 1rem;
    }
    
    /* Slide navigation adjustments */
    .slide-navigation {
        padding: 0 0.5rem;
        margin-bottom: 1rem;
    }
    
    .indicator {
        width: 10px;
        height: 10px;
    }
    
    .slide-wrapper {
        min-height: 500px;
    }
    
    .slide {
        min-height: 500px;
    }
    
    .upload-area,
    .result-area {
        height: 350px;
    }
    
    /* Footer adjustments */
    .footer-content {
        padding: 1rem;
    }
    
    .footer-text {
        font-size: 0.75rem;
    }
    
    .footer-author {
        font-size: 0.625rem;
    }
}

/* Extra small mobile adjustments */
@media (max-width: 480px) {
    .main-title {
        font-size: 2rem;
    }
    
    .subtitle {
        font-size: 0.875rem;
    }
    
    .card {
        padding: 1rem;
    }
    
    .card-title {
        font-size: 1.125rem;
    }
    
    .parameter-section-title {
        font-size: 1rem;
    }
    
    .parameter-grid {
        gap: 1rem;
    }
    
    .btn-large {
        padding: 0.75rem;
        font-size: 0.875rem;
    }
}

/* ==================== */
/* Card Styles          */
/* ==================== */

.card {
    background: var(--bg-primary);
    padding: 2rem;
    border-radius: 1.5rem;
    box-shadow: 0 20px 25px -5px var(--shadow-primary);
    border: 1px solid var(--border-primary);
    width: 100%;
    height: 550px;
    min-height: 550px;
    max-height: 550px;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
}

.card-header {
    display: flex;
    align-items: center;
    margin-bottom: 1.5rem;
}

.card-icon {
    padding: 0.75rem;
    border-radius: 1rem;
    margin-right: 1rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.card-icon-blue {
    background: linear-gradient(to right, #3b82f6, #9333ea);
}

.card-icon-purple {
    background: linear-gradient(to right, #a855f7, #ec4899);
}

.card-title {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--text-primary);
    transition: color 0.3s ease;
}

.card-subtitle {
    color: var(--accent-primary);
    font-size: 0.875rem;
    font-weight: 500;
    transition: color 0.3s ease;
}

.card-subtitle-purple {
    color: var(--accent-secondary);
}

/* ==================== */
/* Upload Area          */
/* ==================== */

.upload-area {
    width: 100%;
    height: 400px;
    min-height: 400px;
    max-height: 400px;
    border: 2px dashed var(--border-secondary);
    border-radius: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
    flex: 1;
    background: var(--bg-primary);
}

.upload-area:hover {
    border-color: var(--accent-primary);
    background: var(--bg-secondary);
}

.upload-area.drag-over {
    border-color: var(--accent-primary);
    background: var(--bg-secondary);
    transform: scale(1.02);
}

.upload-placeholder {
    text-align: center;
    padding: 2rem;
}

.upload-icon {
    background: linear-gradient(to bottom right, #3b82f6, #9333ea);
    padding: 1.5rem;
    border-radius: 1rem;
    margin-bottom: 1.5rem;
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.upload-title {
    font-size: 1.25rem;
    font-weight: bold;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    transition: color 0.3s ease;
}

.upload-text {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    transition: color 0.3s ease;
}

.file-types {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    font-size: 0.875rem;
}

.file-type {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-weight: 500;
}

.file-type-green {
    background: #d1fae5;
    color: #047857;
    border: 1px solid #6ee7b7;
}

.file-type-blue {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #93c5fd;
}

.file-type-purple {
    background: #e9d5ff;
    color: #7e22ce;
    border: 1px solid #c084fc;
}

.image-preview {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    overflow: auto;
}

.image-preview img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 0.75rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.image-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.3s;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-preview:hover .image-overlay {
    opacity: 1;
}

.overlay-text {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(4px);
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    color: #1f2937;
    font-weight: 600;
}

/* ==================== */
/* Result Area          */
/* ==================== */

.result-area {
    height: 400px;
    border-radius: 1rem;
    overflow: hidden;
    flex: 1;
}

.result-placeholder,
.result-loading,
.result-error {
    text-align: center;
    padding: 4rem 2rem;
}

.result-icon,
.error-icon {
    background: var(--bg-tertiary);
    padding: 1rem;
    border-radius: 1rem;
    margin: 0 auto 1.5rem;
    width: fit-content;
    border: 1px solid var(--border-primary);
    transition: all 0.3s ease;
}

.result-icon {
    background: linear-gradient(to bottom right, #3b82f6, #9333ea);
}

.error-icon {
    background: var(--error);
    padding: 1rem;
    border-radius: 50%;
}

.result-title,
.loading-title,
.error-title {
    font-size: 1.25rem;
    font-weight: bold;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    transition: color 0.3s ease;
}

.error-title {
    color: var(--error);
}

.result-text,
.loading-text,
.error-text {
    color: var(--text-secondary);
    transition: color 0.3s ease;
}

.error-text {
    color: var(--error);
}

/* Loading State */
.result-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.spinner {
    width: 64px;
    height: 64px;
    border: 4px solid var(--border-primary);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 2rem;
}

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

.loading-dots {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1rem;
}

.dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.dot-1 {
    background: var(--accent-primary);
    animation-delay: -0.32s;
}

.dot-2 {
    background: var(--accent-secondary);
    animation-delay: -0.16s;
}

.dot-3 {
    background: var(--accent-tertiary);
}

@keyframes bounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

/* Error State */
.result-error {
    padding: 2rem;
}

.result-error .error-icon {
    display: inline-block;
}

/* Success State */
.result-success {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.result-info {
    display: flex;
    align-items: center;
}

.success-icon {
    background: var(--success);
    padding: 0.75rem;
    border-radius: 1rem;
    margin-right: 1rem;
}

.result-count {
    font-size: 1.25rem;
    font-weight: bold;
    color: var(--text-primary);
    transition: color 0.3s ease;
}

.result-ready {
    color: var(--success);
    font-size: 0.875rem;
    font-weight: 500;
    transition: color 0.3s ease;
}

.result-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    max-height: 320px;
    overflow-y: auto;
}

@media (min-width: 640px) {
    .result-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Single result item styling */
.result-item-single {
    grid-column: 1 / -1;
    max-width: 500px;
    margin: 0 auto;
    aspect-ratio: 1;
}

.result-item-single img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 0.75rem;
}

.result-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 0.75rem;
    overflow: hidden;
    background: var(--bg-tertiary);
    box-shadow: 0 10px 15px -3px var(--shadow-primary);
    transition: all 0.3s ease;
}

.result-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}


/* ==================== */
/* Buttons              */
/* ==================== */

.action-buttons {
    width: 100%;
    max-width: 42rem;
    margin: 2rem auto 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.btn {
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px -1px var(--shadow-primary);
    outline: none;
    transition: all 0.2s;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(to right, #3b82f6, #a855f7, #ec4899);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(to right, #2563eb, #9333ea, #db2777);
    transform: scale(1.05);
}

.btn-primary:disabled:hover {
    transform: none;
}

.btn-large {
    width: 100%;
    padding: 1rem;
    font-size: 1.125rem;
    border-radius: 1rem;
}

.btn-gradient {
    background: linear-gradient(to right, #3b82f6, #9333ea);
    color: white;
    font-weight: 600;
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
}

.btn-gradient:hover {
    background: linear-gradient(to right, #2563eb, #7e22ce);
}

.btn-secondary {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-secondary);
    color: var(--text-primary);
    transition: all 0.3s ease;
}

.btn-secondary:hover:not(:disabled) {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.btn-icon {
    margin-right: 0.5rem;
}

/* ==================== */
/* Icons                */
/* ==================== */

.icon-tiny {
    width: 1rem;
    height: 1rem;
    color: inherit;
}

.icon-small {
    width: 1.25rem;
    height: 1.25rem;
    color: white;
}

.icon-medium {
    width: 1.5rem;
    height: 1.5rem;
    color: white;
}

.icon-large {
    width: 2rem;
    height: 2rem;
    color: white;
}

.icon-xlarge {
    width: 4rem;
    height: 4rem;
    color: white;
}

/* ==================== */
/* Footer               */
/* ==================== */

.footer {
    margin-top: 4rem;
    text-align: center;
}

.footer-content {
    background: var(--bg-primary);
    backdrop-filter: blur(4px);
    padding: 1.5rem;
    border-radius: 1rem;
    border: 1px solid var(--border-primary);
    box-shadow: 0 10px 15px -3px var(--shadow-primary);
    max-width: 42rem;
    margin: 0 auto;
    transition: all 0.3s ease;
}

.footer-text {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
    transition: color 0.3s ease;
}

.footer-author {
    color: var(--text-tertiary);
    font-size: 0.75rem;
    transition: color 0.3s ease;
}

.footer-author a {
    color: var(--accent-primary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s ease;
}

.footer-author a:hover {
    color: var(--accent-secondary);
}

/* ==================== */
/* Modal (Cropper)      */
/* ==================== */

.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    padding: 1rem;
}

.modal-content {
    background: #1f2937;
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    max-width: 42rem;
    width: 100%;
    min-height: 500px; /* Ensure minimum height for cropper */
}

.modal-title {
    font-size: 1.5rem;
    font-weight: bold;
    color: white;
    margin-bottom: 1rem;
}

.modal-subtitle {
    color: #9ca3af;
    margin-bottom: 1rem;
}

.crop-container {
    max-height: 60vh;
    min-height: 300px; /* Ensure minimum height for cropping */
    overflow: auto;
    display: flex;
    justify-content: center;
    background: #111827;
    border-radius: 0.5rem;
    position: relative;
}

/* Mobile-friendly crop container */
@media (max-width: 768px) {
    .crop-container {
        max-height: 50vh; /* Slightly smaller on mobile for better usability */
        min-height: 250px; /* Minimum height for mobile cropping */
        border-radius: 0.75rem;
    }
}

/* Small phone optimizations */
@media (max-width: 480px) {
    .crop-container {
        max-height: 40vh; /* Even smaller on small phones */
        min-height: 200px; /* Minimum height for small phones */
        border-radius: 0.5rem;
    }
    
    .modal-content {
        padding: 1rem; /* Reduce padding on small screens */
        margin: 0.5rem;
        min-height: 400px; /* Minimum height for small phones */
    }
    
    .modal-title {
        font-size: 1.25rem; /* Smaller title on small screens */
    }
    
    .modal-subtitle {
        font-size: 0.875rem; /* Smaller subtitle on small screens */
    }
}

#cropCanvas {
    max-height: 60vh;
    display: block;
}

/* Small phone canvas sizing */
@media (max-width: 480px) {
    #cropCanvas {
        max-height: 40vh; /* Match the container height */
    }
}

.crop-box {
    position: absolute;
    border: 2px solid #3b82f6;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
    cursor: move;
    overflow: hidden;
    user-select: none; /* Prevent text selection during drag */
}

/* Mobile-friendly crop box */
@media (max-width: 768px) {
    .crop-box {
        border-width: 2px;
        border-color: #60a5fa; /* Slightly lighter blue for better visibility */
    }
}

.crop-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: white;
    border: 2px solid #3b82f6;
    border-radius: 50%;
    transition: all 0.2s ease;
}

/* Mobile-friendly crop handles */
@media (max-width: 768px) {
    .crop-handle {
        width: 16px;
        height: 16px;
        border-width: 2px;
    }
}

.crop-handle-nw {
    top: -6px;
    left: -6px;
    cursor: nw-resize;
}

.crop-handle-ne {
    top: -6px;
    right: -6px;
    cursor: ne-resize;
}

.crop-handle-sw {
    bottom: -6px;
    left: -6px;
    cursor: sw-resize;
}

.crop-handle-se {
    bottom: -6px;
    right: -6px;
    cursor: se-resize;
}

/* Mobile crop handle positioning */
@media (max-width: 768px) {
    .crop-handle-nw {
        top: -8px;
        left: -8px;
    }
    
    .crop-handle-ne {
        top: -8px;
        right: -8px;
    }
    
    .crop-handle-sw {
        bottom: -8px;
        left: -8px;
    }
    
    .crop-handle-se {
        bottom: -8px;
        right: -8px;
    }
}

.modal-actions {
    margin-top: 1.5rem;
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

/* Ensure modal buttons work properly on mobile */
.modal-actions .btn {
    touch-action: manipulation; /* Allow touch events on buttons */
    -webkit-tap-highlight-color: transparent; /* Remove tap highlight */
}

/* Mobile-friendly modal */
@media (max-width: 768px) {
    .modal-actions {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .modal-actions .btn {
        width: 100%;
        padding: 1rem;
        font-size: 1rem;
    }
}

/* ==================== */
/* Utility Classes      */
/* ==================== */

.hidden {
    display: none !important;
}

/* ==================== */
/* Scrollbar Styling    */
/* ==================== */

.result-grid::-webkit-scrollbar,
.upload-area::-webkit-scrollbar {
    width: 8px;
}

.result-grid::-webkit-scrollbar-track,
.upload-area::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

.result-grid::-webkit-scrollbar-thumb,
.upload-area::-webkit-scrollbar-thumb {
    background: var(--border-secondary);
    border-radius: 4px;
}

.result-grid::-webkit-scrollbar-thumb:hover,
.upload-area::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

