/* ============================================
   Trendzlib ToolBox – Shared Stylesheet
   Fixed: focus styles, contrast, mobile nav,
   palette grid, animation pause, toast a11y
   ============================================ */

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

:root {
    --primary: #6366f1;
    --secondary: #8b5cf6;
    --accent: #ec4899;
    --success: #10b981;
    --warning: #f59e0b;
    --dark: #0f172a;
    --darker: #020617;
    --light: #f8fafc;
    --gray: #94a3b8;
    --gray-light: #cbd5e1;
}

body {
    font-family: 'Outfit', sans-serif;
    background: var(--darker);
    color: var(--light);
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
}

/* ─── Skip Link (Accessibility) ─── */
.skip-link {
    position: absolute;
    left: -9999px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
    z-index: 9999;
}
.skip-link:focus {
    left: 1rem;
    top: 1rem;
    width: auto;
    height: auto;
    padding: 0.6rem 1.2rem;
    background: var(--primary);
    color: white;
    border-radius: 8px;
    font-weight: 700;
    text-decoration: none;
}

/* ─── Focus Styles (Accessibility) ─── */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 3px;
    border-radius: 4px;
}

/* ─── Animated Background ─── */
.gradient-bg {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: -1;
    background: linear-gradient(135deg, var(--darker) 0%, var(--dark) 100%);
    overflow: hidden;
}

.gradient-bg::before,
.gradient-bg::after {
    content: '';
    position: absolute;
    width: 800px; height: 800px;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.15;
    animation: float 20s ease-in-out infinite;
}

.gradient-bg::before {
    background: var(--primary);
    top: -200px; left: -200px;
}

.gradient-bg::after {
    background: var(--accent);
    bottom: -200px; right: -200px;
    animation-delay: -10s;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    33%       { transform: translate(30px, -50px) rotate(120deg); }
    66%       { transform: translate(-20px, 20px) rotate(240deg); }
}

/* ─── Header / Nav ─── */
header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(99, 102, 241, 0.2);
}

nav {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.25rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.logo {
    font-size: 1.8rem;
    font-weight: 900;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}

.logo i { font-size: 1.5rem; }

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

.nav-links a {
    color: var(--light);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    transition: color 0.3s;
    position: relative;
}

.nav-links a::after {
    content: '';
    position: absolute;
    bottom: -5px; left: 0;
    width: 0; height: 2px;
    background: var(--primary);
    transition: width 0.3s;
}

.nav-links a:hover { color: var(--primary); }
.nav-links a:hover::after { width: 100%; }

/* ─── Hamburger (Mobile Nav) ─── */
.hamburger {
    display: none;
    flex-direction: column;
    gap: 5px;
    cursor: pointer;
    padding: 0.5rem;
    background: none;
    border: none;
    z-index: 110;
}

.hamburger span {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--light);
    transition: all 0.3s;
    border-radius: 2px;
}

.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ─── Breadcrumb ─── */
.breadcrumb {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.2rem 2rem 0;
    font-size: 0.85rem;
    color: var(--gray);
}

.breadcrumb a {
    color: var(--gray);
    text-decoration: none;
    transition: color 0.2s;
}

.breadcrumb a:hover { color: var(--primary); }
.breadcrumb .sep { margin: 0 0.5rem; opacity: 0.4; }
.breadcrumb .current { color: var(--gray-light); }

/* ─── Hero (homepage) ─── */
.hero {
    max-width: 1400px;
    margin: 0 auto;
    padding: 5.5rem 2rem 3rem;
    text-align: center;
}

.hero h1 {
    font-size: 4rem;
    font-weight: 900;
    margin-bottom: 1.25rem;
    background: linear-gradient(135deg, var(--light), var(--primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.2;
    animation: fadeInUp 0.8s ease;
}

.hero p {
    font-size: 1.25rem;
    color: var(--gray);
    max-width: 680px;
    margin: 0 auto 2rem;
    animation: fadeInUp 0.8s ease 0.2s both;
}

/* Stats row */
.stats {
    display: flex;
    justify-content: center;
    gap: 3rem;
    margin-top: 2.5rem;
    animation: fadeInUp 0.8s ease 0.4s both;
}

.stat { text-align: center; }

.stat-number {
    font-size: 2.4rem;
    font-weight: 900;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-label {
    color: var(--gray);
    font-size: 0.88rem;
    margin-top: 0.35rem;
}

/* ─── Section Titles ─── */
.section-title {
    font-size: 2.4rem;
    font-weight: 900;
    margin-bottom: 2.5rem;
    text-align: center;
}

/* ─── Tools Grid (homepage) ─── */
.tools-section {
    max-width: 1400px;
    margin: 0 auto;
    padding: 3rem 2rem 4rem;
}

.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 1.8rem;
}

.tool-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 20px;
    padding: 2.2rem;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    text-decoration: none;
    color: inherit;
    display: block;
    position: relative;
    overflow: hidden;
}

.tool-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(99,102,241,0.1), rgba(236,72,153,0.1));
    opacity: 0;
    transition: opacity 0.4s;
}

.tool-card:hover {
    transform: translateY(-8px);
    border-color: var(--primary);
    box-shadow: 0 20px 60px rgba(99, 102, 241, 0.25);
}

.tool-card:hover::before { opacity: 1; }

.tool-icon {
    width: 64px; height: 64px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    margin-bottom: 1.25rem;
    position: relative;
    z-index: 1;
}

.tool-card h3 {
    font-size: 1.4rem;
    margin-bottom: 0.7rem;
    position: relative;
    z-index: 1;
}

.tool-card p {
    color: var(--gray);
    margin-bottom: 1.4rem;
    font-size: 0.95rem;
    position: relative;
    z-index: 1;
}

.tool-card .btn-open {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border: none;
    padding: 0.7rem 1.6rem;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.92rem;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
    z-index: 1;
    text-decoration: none;
}

.tool-card .btn-open:hover {
    transform: scale(1.04);
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.4);
}

/* ─── Features Grid ─── */
.features-section {
    max-width: 1400px;
    margin: 2rem auto 4rem;
    padding: 0 2rem;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.8rem;
    margin-top: 2rem;
}

.feature {
    text-align: center;
    padding: 2rem 1.5rem;
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(99,102,241,0.1);
    border-radius: 16px;
    transition: border-color 0.3s;
}

.feature:hover { border-color: rgba(99,102,241,0.35); }

.feature i {
    font-size: 2.4rem;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.9rem;
}

.feature h3 { font-size: 1.2rem; margin-bottom: 0.6rem; }
.feature p { color: var(--gray); font-size: 0.92rem; }

/* ─── Tool Page Hero ─── */
.tool-hero {
    max-width: 860px;
    margin: 0 auto;
    padding: 3rem 2rem 2rem;
    text-align: center;
}

.tool-hero-icon {
    width: 86px; height: 86px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.6rem;
    margin: 0 auto 1.4rem;
    box-shadow: 0 12px 40px rgba(99,102,241,0.35);
}

.tool-hero h1 {
    font-size: 2.6rem;
    font-weight: 900;
    margin-bottom: 0.7rem;
    background: linear-gradient(135deg, var(--light), var(--primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tool-hero p {
    color: var(--gray);
    font-size: 1.05rem;
    max-width: 560px;
    margin: 0 auto;
}

/* ─── Tool Workspace ─── */
.tool-workspace {
    max-width: 860px;
    margin: 0 auto;
    padding: 0 2rem 4rem;
}

.workspace-card {
    background: rgba(255,255,255,0.035);
    border: 1px solid rgba(99,102,241,0.2);
    border-radius: 20px;
    padding: 2.2rem;
}

/* Upload area */
.upload-area {
    border: 2px dashed rgba(99, 102, 241, 0.45);
    border-radius: 16px;
    padding: 2.8rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    background: rgba(99, 102, 241, 0.04);
}

.upload-area:hover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.09);
}

/* Fix: prevent dragleave flash from child elements */
.upload-area * { pointer-events: none; }

.upload-area i {
    font-size: 2.6rem;
    color: var(--primary);
    margin-bottom: 0.8rem;
    display: block;
}

.upload-area p { color: var(--gray); margin-bottom: 0.4rem; }
.upload-area small { color: var(--gray); opacity: 0.7; }
.upload-area input[type="file"] { display: none; }

/* File list */
.file-item {
    padding: 0.55rem 0.9rem;
    background: rgba(99, 102, 241, 0.1);
    border-radius: 8px;
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: var(--gray-light);
}

/* Input group */
.input-group {
    margin-bottom: 1.4rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.45rem;
    color: var(--gray-light);
    font-weight: 600;
    font-size: 0.9rem;
}

.input-group input,
.input-group textarea,
.input-group select {
    width: 100%;
    padding: 0.85rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 10px;
    color: var(--light);
    font-family: 'Outfit', sans-serif;
    font-size: 0.95rem;
    transition: all 0.3s;
}

.input-group input:focus,
.input-group textarea:focus,
.input-group select:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}

.input-group select option { background: var(--dark); }

.input-group textarea {
    min-height: 140px;
    resize: vertical;
}

/* Range slider */
.range-row {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.range-row input[type="range"] {
    flex: 1;
    -webkit-appearance: none;
    height: 6px;
    border-radius: 3px;
    background: rgba(99,102,241,0.25);
    outline: none;
    border: none;
    padding: 0;
}

.range-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px; height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(99,102,241,0.4);
}

.range-label {
    font-weight: 700;
    color: var(--primary);
    font-size: 1rem;
    min-width: 48px;
    text-align: right;
}

/* Buttons */
.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border: none;
    padding: 0.9rem 2rem;
    border-radius: 10px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
    width: 100%;
    margin-top: 0.8rem;
    font-family: 'Outfit', sans-serif;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary:hover {
    transform: scale(1.02);
    box-shadow: 0 10px 30px rgba(99, 102, 241, 0.4);
}

.btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-download {
    background: linear-gradient(135deg, var(--success), #059669);
    color: white;
    border: none;
    padding: 0.75rem 1.8rem;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s;
    font-family: 'Outfit', sans-serif;
    margin-top: 0.8rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-download:hover {
    transform: scale(1.03);
    box-shadow: 0 8px 24px rgba(16,185,129,0.4);
}

/* Result area */
.result-area {
    margin-top: 1.8rem;
    padding: 1.8rem;
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.25);
    border-radius: 14px;
    display: none;
}

.result-area.show {
    display: block;
    animation: fadeInUp 0.45s ease;
}

.result-area h3 {
    color: var(--success);
    font-size: 1.15rem;
    margin-bottom: 0.5rem;
}

.result-area p { color: var(--gray-light); font-size: 0.92rem; }

/* Try another tool link */
.try-another {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    margin-top: 1rem;
    transition: gap 0.2s;
}
.try-another:hover { gap: 0.7rem; }

/* QR code container */
#qrcode {
    display: flex;
    justify-content: center;
    margin: 1.5rem 0;
}

#qrcode canvas { border-radius: 10px; }

/* Palette display */
.palette-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.8rem;
    margin: 1.5rem 0;
}

.palette-swatch { text-align: center; }

.palette-swatch .swatch-color {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 10px;
    margin-bottom: 0.4rem;
}

.palette-swatch code {
    font-size: 0.78rem;
    color: var(--gray-light);
    font-family: 'JetBrains Mono', monospace;
}

/* ─── Related Tools ─── */
.related-section {
    max-width: 860px;
    margin: 0 auto 4rem;
    padding: 0 2rem;
}

.related-section h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1.2rem;
    color: var(--gray-light);
}

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

.related-card {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(99,102,241,0.15);
    border-radius: 14px;
    padding: 1.2rem 1.4rem;
    text-decoration: none;
    color: inherit;
    display: flex;
    align-items: center;
    gap: 0.9rem;
    transition: all 0.3s;
}

.related-card:hover {
    border-color: var(--primary);
    background: rgba(99,102,241,0.07);
    transform: translateY(-3px);
}

.related-card i {
    width: 40px; height: 40px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.related-card span { font-weight: 600; font-size: 0.9rem; }

/* ─── Footer ─── */
footer {
    background: rgba(15, 23, 42, 0.8);
    border-top: 1px solid rgba(99, 102, 241, 0.15);
    padding: 2.5rem 2rem;
    text-align: center;
    margin-top: auto;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.footer-links a {
    color: var(--gray);
    text-decoration: none;
    font-size: 0.88rem;
    transition: color 0.3s;
}

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

footer p { color: var(--gray); font-size: 0.82rem; }

/* ─── Toast ─── */
.toast {
    position: fixed;
    bottom: 2rem; right: 2rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    padding: 0.85rem 1.6rem;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(99, 102, 241, 0.4);
    z-index: 2000;
    display: none;
    font-size: 0.92rem;
    font-weight: 600;
    animation: slideInRight 0.4s ease;
}

.toast.show { display: block; }

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

/* ─── Spinner ─── */
.spinner {
    border: 4px solid rgba(99, 102, 241, 0.2);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    width: 40px; height: 40px;
    animation: spin 0.8s linear infinite;
    margin: 1rem auto;
}

@keyframes spin {
    0%   { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ─── Animations ─── */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(24px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ─── Responsive ─── */
@media (max-width: 768px) {
    .hero h1 { font-size: 2.4rem; }
    .stats { flex-direction: column; gap: 1.2rem; }
    .tools-grid { grid-template-columns: 1fr; }
    .tool-hero h1 { font-size: 2rem; }
    .workspace-card { padding: 1.4rem; }

    /* Mobile nav */
    .hamburger { display: flex; }
    .nav-links {
        display: none;
        position: absolute;
        top: 100%;
        left: 0; right: 0;
        background: rgba(15,23,42,0.98);
        backdrop-filter: blur(20px);
        flex-direction: column;
        padding: 1.5rem 2rem;
        border-bottom: 1px solid rgba(99,102,241,0.2);
        gap: 1.2rem;
    }
    .nav-links.open { display: flex; }
}

@media (max-width: 580px) {
    .palette-grid { grid-template-columns: repeat(3, 1fr); }
    .palette-swatch code { font-size: 0.7rem; }
}

@media (max-width: 420px) {
    .palette-grid { grid-template-columns: repeat(3, 1fr); }
}