@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700;800&display=swap');

/* ==========================================================================
   1. Dynamic CSS Custom Properties (Theme Variables)
   ========================================================================== */
:root {
    /* Fonts */
    --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

    /* Light Theme (Default) */
    --bg-base: #f8fafc;
    --bg-surface: rgba(255, 255, 255, 0.7);
    --bg-surface-opaque: #ffffff;
    --border-color: rgba(226, 232, 240, 0.8);
    --border-hover: rgba(108, 92, 231, 0.4);
    
    /* Text colors */
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    
    /* Accent brand colors (Canva Style) */
    --primary: #6c5ce7;
    --primary-rgb: 108, 92, 231;
    --secondary: #a29bfe;
    --accent: #ff7675;
    
    /* Dynamic Gradients */
    --gradient-brand: linear-gradient(135deg, #6c5ce7 0%, #a29bfe 50%, #e84393 100%);
    --gradient-glow: radial-gradient(circle at top left, rgba(108, 92, 231, 0.15), transparent 40%), radial-gradient(circle at bottom right, rgba(232, 67, 147, 0.15), transparent 40%);
    
    /* Glassmorphism shadow tokens */
    --shadow-glass: 0 8px 32px 0 rgba(31, 38, 135, 0.08);
    --shadow-glow: 0 0 20px rgba(108, 92, 231, 0.2);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
}

[data-theme="dark"] {
    /* Dark Theme Override */
    --bg-base: #0b0f19;
    --bg-surface: rgba(17, 24, 39, 0.65);
    --bg-surface-opaque: #111827;
    --border-color: rgba(55, 65, 81, 0.5);
    --border-hover: rgba(108, 92, 231, 0.6);
    
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #8fa0b5; /* Increased contrast from #64748b to align with WCAG AA compliance (5.5:1 ratio) */
    
    --gradient-glow: radial-gradient(circle at top left, rgba(108, 92, 231, 0.25), transparent 40%), radial-gradient(circle at bottom right, rgba(232, 67, 147, 0.2), transparent 40%);
    
    --shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

/* Dark theme specific fixes for light components and forms */
[data-theme="dark"] .bg-light {
    background-color: rgba(255, 255, 255, 0.06) !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
    color: var(--text-primary) !important;
}

[data-theme="dark"] .bg-light h6,
[data-theme="dark"] .bg-light span,
[data-theme="dark"] .bg-light label,
[data-theme="dark"] .bg-light div,
[data-theme="dark"] .bg-light input {
    color: var(--text-primary) !important;
}

[data-theme="dark"] .text-dark:not(.badge) {
    color: var(--text-primary) !important;
}

[data-theme="dark"] .text-secondary {
    color: var(--text-secondary) !important;
}

[data-theme="dark"] .text-muted {
    color: var(--text-muted) !important;
}

[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
    background-color: rgba(255, 255, 255, 0.05) !important;
    border-color: var(--border-color) !important;
    color: var(--text-primary) !important;
}

[data-theme="dark"] .form-control::placeholder {
    color: var(--text-muted) !important;
}

[data-theme="dark"] select option {
    background-color: #111827 !important;
    color: #f8fafc !important;
}

[data-theme="dark"] .dropdown-menu {
    background-color: var(--bg-surface-opaque);
    border: 1px solid var(--border-color) !important;
}

[data-theme="dark"] .dropdown-item {
    color: var(--text-primary);
}

[data-theme="dark"] .dropdown-item:hover,
[data-theme="dark"] .dropdown-item:focus {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

/* Premium global dark theme overrides and utilities */
[data-theme="dark"] .border,
[data-theme="dark"] .border-top,
[data-theme="dark"] .border-bottom,
[data-theme="dark"] .border-start,
[data-theme="dark"] .border-end {
    border-color: var(--border-color) !important;
}

.dropdown-item.active {
    background: var(--gradient-brand) !important;
    color: #ffffff !important;
}

[data-theme="dark"] .alert-success {
    background-color: rgba(46, 204, 113, 0.12) !important;
    border: 1px solid rgba(46, 204, 113, 0.25) !important;
    color: #2ecc71 !important;
}
[data-theme="dark"] .alert-success div,
[data-theme="dark"] .alert-success strong,
[data-theme="dark"] .alert-success i {
    color: #2ecc71 !important;
}

[data-theme="dark"] .alert-danger {
    background-color: rgba(231, 76, 60, 0.12) !important;
    border: 1px solid rgba(231, 76, 60, 0.25) !important;
    color: #e74c3c !important;
}
[data-theme="dark"] .alert-danger div,
[data-theme="dark"] .alert-danger strong,
[data-theme="dark"] .alert-danger i {
    color: #e74c3c !important;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 0.25rem rgba(108, 92, 231, 0.25) !important;
}

[data-theme="dark"] .form-select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23f8fafc' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e") !important;
}

.hover-primary {
    transition: color 0.2s ease;
}
.hover-primary:hover {
    color: var(--primary) !important;
}
/* ==========================================================================
   2. Core Styles & Typography
   ========================================================================== */
body {
    background-color: var(--bg-base);
    color: var(--text-primary);
    font-family: var(--font-body);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    position: relative;
    transition: background-color 0.4s ease, color 0.4s ease;
}

body::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--gradient-glow);
    z-index: -1;
    pointer-events: none;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* ==========================================================================
   3. Glassmorphism Components
   ========================================================================== */
.glass-panel {
    background: var(--bg-surface);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-glass);
    border-radius: 20px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.glass-panel:hover {
    border-color: var(--border-hover);
}

/* ==========================================================================
   4. Header & Navigation (Canva Style Blur Navbar)
   ========================================================================== */
.navbar-custom {
    background: var(--bg-surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.3s ease;
}

.navbar-brand-custom {
    font-family: var(--font-heading);
    font-weight: 800;
    background: var(--gradient-brand);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-size: 1.5rem;
}

/* ==========================================================================
   5. Dynamic Drag & Drop Upload Container
   ========================================================================== */
.upload-container {
    padding: 3.5rem 2rem;
    border: 2.5px dashed var(--border-color);
    border-radius: 24px;
    background: rgba(var(--primary-rgb), 0.02);
    text-align: center;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.upload-container.dragover {
    border-color: var(--primary);
    background: rgba(var(--primary-rgb), 0.08);
    box-shadow: var(--shadow-glow);
    transform: scale(1.01);
}

.upload-icon {
    font-size: 4rem;
    background: var(--gradient-brand);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: inline-block;
    margin-bottom: 1.5rem;
    transition: transform 0.4s ease;
}

.upload-container:hover .upload-icon {
    transform: translateY(-8px) scale(1.05);
}

/* ==========================================================================
   6. Custom Progress Bars & States
   ========================================================================== */
.custom-progress {
    height: 10px;
    background-color: var(--border-color);
    border-radius: 10px;
    overflow: hidden;
}

.custom-progress-bar {
    background: var(--gradient-brand);
    height: 100%;
    width: 0%;
    transition: width 0.4s cubic-bezier(0.1, 0.8, 0.25, 1);
}

/* ==========================================================================
   7. Card Grid & Tool Categories
   ========================================================================== */
.tool-card {
    padding: 1.5rem;
    height: 100%;
    display: flex;
    flex-direction: column;
    text-decoration: none !important;
}

.tool-card-icon {
    font-size: 2.2rem;
    width: 55px;
    height: 55px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    margin-bottom: 1.25rem;
    background: rgba(var(--primary-rgb), 0.08);
    color: var(--primary);
    transition: all 0.3s ease;
}

.tool-card:hover .tool-card-icon {
    background: var(--gradient-brand);
    color: #ffffff;
    transform: rotate(-8deg) scale(1.1);
}

.tool-card-title {
    color: var(--text-primary);
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.tool-card-desc {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.45;
    flex-grow: 1;
}

/* Category Headers */
.category-title {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    position: relative;
    padding-left: 1rem;
    color: var(--text-primary);
}

.category-title::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0.2rem;
    bottom: 0.2rem;
    width: 4px;
    background: var(--gradient-brand);
    border-radius: 10px;
}

/* ==========================================================================
   8. Premium Gradient Buttons & Custom Utilities
   ========================================================================== */
.btn-brand {
    background: var(--gradient-brand);
    color: #ffffff !important;
    border: none;
    border-radius: 12px;
    padding: 0.75rem 1.75rem;
    font-weight: 600;
    font-family: var(--font-heading);
    box-shadow: 0 4px 15px rgba(108, 92, 231, 0.25);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-brand:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(108, 92, 231, 0.4);
    opacity: 0.95;
}

.btn-brand:active {
    transform: translateY(0);
}

.btn-secondary-custom {
    background: var(--bg-surface-opaque);
    color: var(--text-primary) !important;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.75rem 1.75rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-secondary-custom:hover {
    background: var(--border-color);
    border-color: var(--text-muted);
}

/* Custom History Tags */
.history-item {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background-color 0.2s ease;
}

.history-item:last-child {
    border-bottom: none;
}

.history-item:hover {
    background-color: rgba(var(--primary-rgb), 0.03);
}

/* Theme Toggle Button & Lang Button */
.nav-btn-icon {
    font-size: 1.15rem;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    background: var(--bg-surface);
    transition: all 0.2s ease;
}

.nav-btn-icon:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* Footer styles */
.footer-custom {
    border-top: 1px solid var(--border-color);
    background: var(--bg-surface);
    margin-top: auto;
}

/* ==========================================================================
   9. Custom Animations
   ========================================================================== */
.pulse-glow {
    animation: pulseGlow 2s infinite ease-in-out;
}

@keyframes pulseGlow {
    0% {
        box-shadow: 0 0 0 0 rgba(108, 92, 231, 0.4);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(108, 92, 231, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(108, 92, 231, 0);
    }
}

.slide-up {
    animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}

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

/* Rotating Loader Spinner */
.spin-loader {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s infinite linear;
}

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

/* Responsive Overrides */
@media (max-width: 768px) {
    .upload-container {
        padding: 2rem 1rem;
    }
    .tool-card {
        padding: 1.25rem;
    }
}
