/* =========================================
   1. VARIABLES & RESET
   ========================================= */
:root {
    --primary: #6366f1;
    --secondary: #ec4899;
    --accent: #06b6d4;
    --success: #10b981;
    --danger: #ef4444;
    
    --bg: #fafbff;
    --card: #ffffff;
    --text: #1a1a2e;
    --text-light: #6b7280;
    --border: #e5e7eb;
    
    --gradient-hero: linear-gradient(135deg, #6366f1 0%, #ec4899 50%, #06b6d4 100%);
    --gradient-1: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-2: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --gradient-3: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --gradient-4: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
    
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1);
    
    --radius: 16px;
    --radius-sm: 8px;
    --radius-lg: 24px;
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

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

img, svg {
    max-width: 100%;
    display: block;
}

a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s ease;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
}

input, textarea, select {
    font-family: inherit;
    font-size: inherit;
}

/* =========================================
   2. TYPOGRAPHY & LAYOUT
   ========================================= */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.2;
    color: var(--text);
}

h1 { font-size: clamp(2rem, 5vw, 3.5rem); }
h2 { font-size: clamp(1.75rem, 4vw, 2.5rem); }
h3 { font-size: 1.5rem; }

p { color: var(--text-light); }

.container {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.section { padding: 5rem 0; }

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

/* =========================================
   3. HEADER & NAVIGATION
   ========================================= */
.header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(229, 231, 235, 0.5);
}

.nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 72px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 800;
    font-size: 1.25rem;
    text-decoration: none;
}

.logo-icon {
    width: 42px;
    height: 42px;
    background: var(--gradient-hero);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
    flex-shrink: 0;
}

.logo-icon svg {
    width: 22px;
    height: 22px;
}

.logo-text {
    display: flex;
    align-items: center;
}

.logo-text span {
    background: var(--gradient-hero);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-links {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.nav-links a {
    font-weight: 500;
    color: var(--text-light);
    position: relative;
}

.nav-links a:hover, .nav-links a.active {
    color: var(--primary);
}

.nav-links a.active::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 0; right: 0;
    height: 2px;
    background: var(--gradient-hero);
    border-radius: 2px;
}

.hamburger {
    display: none;
    flex-direction: column;
    gap: 5px;
    padding: 8px;
}

.hamburger span {
    width: 26px; height: 3px;
    background: var(--text);
    border-radius: 3px;
    transition: 0.3s;
}

/* =========================================
   4. BUTTONS
   ========================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.75rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.25s ease;
    white-space: nowrap;
}

.btn-primary {
    background: var(--gradient-hero);
    color: white;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.45);
}

.btn-secondary {
    background: white;
    color: var(--text);
    border: 2px solid var(--border);
}

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

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}

.btn-outline:hover {
    background: var(--primary);
    color: white;
}

.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* =========================================
   5. HERO SECTION & 3D ANIMATION
   ========================================= */
.hero {
    position: relative;
    min-height: 88vh;
    display: flex;
    align-items: center;
    padding: 4rem 0;
    overflow: hidden;
    background: linear-gradient(180deg, #fafbff 0%, #f0f4ff 100%);
}

.hero-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
    align-items: center;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
    border-radius: 100px;
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 1.5rem;
}

.hero h1 { margin-bottom: 1.25rem; }
.hero h1 .gradient-text {
    background: var(--gradient-hero);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero p {
    font-size: 1.15rem;
    margin-bottom: 2rem;
    max-width: 540px;
}

.hero-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.hero-visual {
    position: relative;
    height: 520px;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.05) 0%, rgba(236, 72, 153, 0.05) 100%);
    border: 1px solid rgba(99, 102, 241, 0.1);
}

/* Three.js Canvas */
#three-canvas {
    width: 100% !important;
    height: 100% !important;
    display: block;
}

/* Pure CSS 3D Fallback Animation */
.hero-fallback {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    perspective: 1000px;
}

.hero-fallback.active {
    display: flex;
}

.fallback-world {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    animation: floatWorld 10s infinite ease-in-out;
}

@keyframes floatWorld {
    0%, 100% { transform: rotateX(10deg) rotateY(0deg); }
    50% { transform: rotateX(15deg) rotateY(10deg); }
}

.fallback-shape {
    position: absolute;
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    animation: floatShape 6s infinite ease-in-out;
}

.shape-1 { width: 180px; height: 130px; background: var(--gradient-1); top: 20%; left: 20%; animation-delay: 0s; }
.shape-2 { width: 120px; height: 120px; background: var(--gradient-2); top: 50%; left: 60%; border-radius: 50%; animation-delay: -2s; }
.shape-3 { width: 150px; height: 100px; background: var(--gradient-3); top: 60%; left: 10%; animation-delay: -4s; }
.shape-4 { width: 80px; height: 80px; background: var(--gradient-4); top: 10%; left: 70%; border-radius: 12px; animation-delay: -1s; }
.shape-5 { width: 100px; height: 100px; border: 8px solid var(--secondary); top: 30%; left: 45%; border-radius: 50%; animation-delay: -3s; }

@keyframes floatShape {
    0%, 100% { transform: translateY(0) translateZ(50px); }
    50% { transform: translateY(-20px) translateZ(80px); }
}

/* =========================================
   6. SEARCH & TOOL CARDS
   ========================================= */
.search-wrapper {
    max-width: 640px;
    margin: -2rem auto 3rem;
    position: relative;
    z-index: 10;
}

.search-box {
    background: white;
    border-radius: 100px;
    padding: 0.5rem 0.75rem 0.5rem 1.75rem;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border: 1px solid var(--border);
}

.search-box input {
    flex: 1;
    border: none;
    outline: none;
    padding: 0.75rem 0;
    font-size: 1rem;
    background: transparent;
}

.search-box .search-icon { color: var(--text-light); }

.tool-card {
    background: white;
    border-radius: var(--radius);
    padding: 1.75rem;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    cursor: pointer;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    position: relative;
    overflow: hidden;
}

.tool-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: var(--gradient-hero);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.3s ease;
}

.tool-card:hover::before { transform: scaleX(1); }
.tool-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-xl);
    border-color: transparent;
}

.tool-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: white;
}

.icon-purple { background: var(--gradient-1); }
.icon-pink { background: var(--gradient-2); }
.icon-blue { background: var(--gradient-3); }
.icon-green { background: var(--gradient-4); }

.tool-card h3 { font-size: 1.15rem; margin-bottom: 0.5rem; }
.tool-card p { font-size: 0.9rem; flex: 1; margin-bottom: 1rem; }

.tool-arrow {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--primary);
    font-weight: 600;
    font-size: 0.9rem;
}

.tool-card .tool-arrow svg { transition: transform 0.2s; }
.tool-card:hover .tool-arrow svg { transform: translateX(4px); }

/* =========================================
   7. TOOL PAGE WORKSPACE
   ========================================= */
.tool-page { padding: 3rem 0; }

.tool-header {
    text-align: center;
    margin-bottom: 3rem;
}

.tool-icon-large {
    width: 80px;
    height: 80px;
    margin: 0 auto 1rem;
    border-radius: 20px;
    font-size: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: var(--shadow-lg);
}

.tool-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 2rem;
    align-items: start;
}

.tool-main, .tool-sidebar {
    background: white;
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 3rem 1.5rem;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    background: #fafbff;
}

.upload-area:hover, .upload-area.dragover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
    transform: scale(1.01);
}

.upload-area svg {
    width: 56px; height: 56px;
    color: var(--primary);
    margin: 0 auto 1rem;
}

.upload-area h4 { margin-bottom: 0.5rem; color: var(--text); }
.upload-area p { font-size: 0.9rem; }
.upload-area input[type="file"] { display: none; }

.preview-box {
    border-radius: var(--radius);
    overflow: hidden;
    background: #f3f4f6;
    min-height: 280px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 1.5rem 0;
}

.preview-box img {
    max-width: 100%;
    max-height: 500px;
    object-fit: contain;
}

.control-group { margin-bottom: 1.25rem; }
.control-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--text);
}

.control-group input[type="text"],
.control-group input[type="number"],
.control-group input[type="color"],
.control-group select,
.control-group textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color 0.2s;
    background: white;
}

.control-group input:focus,
.control-group select:focus,
.control-group textarea:focus {
    border-color: var(--primary);
}

.range-slider {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    background: var(--border);
    border-radius: 100px;
    outline: none;
}

.range-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px; height: 20px;
    background: var(--gradient-hero);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

/* =========================================
   8. FOOTER
   ========================================= */
.footer {
    background: #0f0f1e;
    color: #d1d5db;
    padding: 4rem 0 1.5rem;
    margin-top: 5rem;
}

.footer-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 2rem;
    margin-bottom: 3rem;
}

.footer h4 { color: white; margin-bottom: 1rem; font-size: 1rem; }
.footer ul { list-style: none; }
.footer ul li { margin-bottom: 0.5rem; }
.footer a { color: #9ca3af; font-size: 0.9rem; }
.footer a:hover { color: white; }

.footer-logo {
    color: white;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 800;
    font-size: 1.25rem;
    margin-bottom: 1rem;
}

.footer-about {
    color: #9ca3af;
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.social-icons { display: flex; gap: 0.75rem; }
.social-icons a {
    width: 40px; height: 40px;
    border-radius: 10px;
    background: rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}
.social-icons a:hover {
    background: var(--gradient-hero);
    transform: translateY(-3px);
}

.footer-bottom {
    border-top: 1px solid rgba(255,255,255,0.1);
    padding-top: 1.5rem;
    text-align: center;
    font-size: 0.875rem;
    color: #9ca3af;
}

/* =========================================
   9. TOAST NOTIFICATIONS
   ========================================= */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: white;
    padding: 1rem 1.5rem;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-xl);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    z-index: 2000;
    transform: translateY(150%);
    transition: transform 0.3s ease;
    border-left: 4px solid var(--success);
    max-width: 360px;
    font-weight: 500;
}

.toast.show { transform: translateY(0); }
.toast.error { border-left-color: var(--danger); }

/* =========================================
   10. RESPONSIVE DESIGN
   ========================================= */
@media (max-width: 968px) {
    .hero-grid, .tool-layout { grid-template-columns: 1fr; }
    .hero-visual { height: 380px; order: -1; }
    .footer-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
    .hamburger { display: flex; }
    
    .nav-links {
        position: fixed;
        top: 72px; left: 0; right: 0;
        background: white;
        flex-direction: column;
        padding: 2rem;
        gap: 1.5rem;
        transform: translateY(-120%);
        transition: transform 0.3s ease;
        box-shadow: var(--shadow-lg);
        border-top: 1px solid var(--border);
    }
    
    .nav-links.active { transform: translateY(0); }
    
    .section { padding: 3rem 0; }
    .footer-grid { grid-template-columns: 1fr; }
    .hero { min-height: auto; padding: 2rem 0 4rem; }
    
    .hero-visual { height: 300px; }
}

/* =========================================
   11. ANIMATIONS & UTILITIES
   ========================================= */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-in { animation: fadeInUp 0.6s ease-out both; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    #three-canvas { display: none; }
    .hero-fallback { display: flex !important; }
}
/* --- NEW 3D ANIMATION --- */
.hero-visual {
    position: relative;
    height: 520px;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.05) 0%, rgba(236, 72, 153, 0.05) 100%);
    border: 1px solid rgba(99, 102, 241, 0.1);
}
.hero-3d-wrapper {
    width: 100%; height: 100%; perspective: 1200px;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden; position: relative;
}
.hero-3d-scene {
    position: relative; width: 300px; height: 300px;
    transform-style: preserve-3d;
    animation: rotateScene 20s infinite linear;
}
@keyframes rotateScene {
    0% { transform: rotateX(15deg) rotateY(0deg); }
    100% { transform: rotateX(15deg) rotateY(360deg); }
}
.hero-3d-wrapper:hover .hero-3d-scene {
    animation-play-state: paused;
    transform: rotateX(10deg) rotateY(15deg) scale(1.05);
    transition: transform 0.5s ease;
}
.main-hub {
    position: absolute; top: 50%; left: 50%;
    width: 120px; height: 120px;
    transform: translate(-50%, -50%) translateZ(0px);
    background: var(--gradient-hero); border-radius: 24px;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 0 60px rgba(99,102,241,0.6);
    animation: pulseHub 4s infinite ease-in-out; z-index: 10;
}
.main-hub svg { width: 50px; height: 50px; stroke: white; }
@keyframes pulseHub {
    0%, 100% { transform: translate(-50%, -50%) translateZ(0px) scale(1); box-shadow: 0 0 60px rgba(99,102,241,0.6); }
    50% { transform: translate(-50%, -50%) translateZ(30px) scale(1.05); box-shadow: 0 0 80px rgba(236,72,153,0.8); }
}
.float-card {
    position: absolute; width: 80px; height: 80px;
    background: white; border-radius: 16px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.15);
    display: flex; align-items: center; justify-content: center;
    font-size: 2rem; transform-style: preserve-3d;
}
.card-1 { top: 10%; left: 10%; background: linear-gradient(135deg, #f093fb, #f5576c); color: white; animation: float1 6s infinite ease-in-out; }
.card-2 { top: 70%; left: 20%; background: linear-gradient(135deg, #4facfe, #00f2fe); color: white; animation: float2 7s infinite ease-in-out; }
.card-3 { top: 20%; left: 70%; background: linear-gradient(135deg, #43e97b, #38f9d7); color: white; animation: float3 5s infinite ease-in-out; }
.card-4 { top: 75%; left: 75%; background: linear-gradient(135deg, #fa709a, #fee140); color: white; animation: float4 8s infinite ease-in-out; }
@keyframes float1 { 0%,100% { transform: translateZ(120px) translateY(0); } 50% { transform: translateZ(140px) translateY(-15px); } }
@keyframes float2 { 0%,100% { transform: translateZ(160px) translateY(0); } 50% { transform: translateZ(140px) translateY(15px); } }
@keyframes float3 { 0%,100% { transform: translateZ(100px) translateY(0); } 50% { transform: translateZ(120px) translateY(-10px); } }
@keyframes float4 { 0%,100% { transform: translateZ(80px) translateY(0); } 50% { transform: translateZ(100px) translateY(10px); } }
.cube-3d {
    position: absolute; top: 50%; left: 50%; width: 50px; height: 50px;
    transform-style: preserve-3d;
    animation: spinCube 10s infinite linear;
}
@keyframes spinCube {
    0% { transform: translate(-50%, -50%) translateZ(180px) rotateX(0) rotateY(0); }
    100% { transform: translate(-50%, -50%) translateZ(180px) rotateX(360deg) rotateY(360deg); }
}
.cube-face {
    position: absolute; width: 50px; height: 50px;
    background: rgba(255, 255, 255, 0.9); border: 2px solid var(--primary);
    border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 1.2rem;
}
.face-front  { transform: rotateY(0deg) translateZ(25px); }
.face-back   { transform: rotateY(180deg) translateZ(25px); }
.face-right  { transform: rotateY(90deg) translateZ(25px); }
.face-left   { transform: rotateY(-90deg) translateZ(25px); }
.face-top    { transform: rotateX(90deg) translateZ(25px); }
.face-bottom { transform: rotateX(-90deg) translateZ(25px); }
.glow-orb {
    position: absolute; border-radius: 50%; filter: blur(40px); opacity: 0.5; transform: translateZ(-200px);
}
.orb-1 { width: 150px; height: 150px; background: #ec4899; top: 20%; left: 30%; }
.orb-2 { width: 200px; height: 200px; background: #06b6d4; bottom: 10%; right: 10%; }
/* Hamburger Button */
.hamburger {
    display: none;
    flex-direction: column;
    gap: 5px;
    padding: 8px;
    background: none;
    border: none;
    cursor: pointer;
    z-index: 1001;
}
.hamburger span {
    width: 26px; height: 3px;
    background: var(--text);
    border-radius: 3px;
    display: block;
}

/* Mobile Menu - Simple & Bulletproof */
@media (max-width: 768px) {
    .hamburger { display: flex; }
    
    .nav-links {
        display: none; /* Hides the menu completely by default */
        position: fixed;
        top: 72px;
        left: 0;
        right: 0;
        background: white;
        flex-direction: column;
        padding: 2rem;
        gap: 1.5rem;
        box-shadow: 0 10px 25px rgba(0,0,0,0.1);
        border-top: 1px solid var(--border);
        z-index: 999;
    }
    
    .nav-links a {
        display: block;
        font-size: 1.1rem;
        padding: 0.5rem 0;
    }
}