@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;600;700;800&family=JetBrains+Mono:wght@300;400;600;700&display=swap');

/**
 * =====================================================================
 * COLORBOOK v2.0 — Advanced Interaction Engine (CSS Architecture)
 * Estrutura: ITCSS Adaptado (Tokens > Base > Layout > Components > Utils)
 * Foco: Alta Performance (GPU Acceleration), Escalabilidade e Manutenibilidade.
 * =====================================================================
 */

/* ── 1. DESIGN TOKENS (Variables) ───────────────────────────────────── */
:root {
    /* Superfícies e Profundidade (Fluent UI) */
    --surface-0:       rgba(8, 8, 20, 0.98);
    --surface-1:       rgba(15, 15, 35, 0.90);
    --surface-2:       rgba(22, 22, 48, 0.85);
    --surface-card:    rgba(255, 255, 255, 0.035);
    --surface-hover:   rgba(255, 255, 255, 0.065);
    
    /* Bordas e Acentos */
    --border-subtle:   rgba(255, 255, 255, 0.07);
    --border-accent:   rgba(120, 160, 255, 0.18);
    --accent:          #60a5fa;
    --accent-glow:     rgba(96, 165, 250, 0.25);

    /* Liquid Glass Constants */
    --glass-bg:        rgba(255, 255, 255, 0.04);
    --glass-border:    rgba(255, 255, 255, 0.10);
    --glass-shine:     rgba(255, 255, 255, 0.15);
    --glass-blur:      saturate(180%) blur(24px);

    /* Tipografia */
    --font-display:    'Syne', system-ui, sans-serif;
    --font-mono:       'JetBrains Mono', monospace;

    /* Cinemática e Transições (Física de Interface) */
    --ease-spring:     cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-out:        cubic-bezier(0.16, 1, 0.3, 1);
    --dur-fast:        180ms;
    --dur-med:         320ms;
    --dur-slow:        500ms;

    /* Sistema de Sombras (Elevação) */
    --shadow-2:  0 1px 4px rgba(0,0,0,0.4), 0 2px 8px rgba(0,0,0,0.2);
    --shadow-4:  0 4px 16px rgba(0,0,0,0.45), 0 2px 6px rgba(0,0,0,0.3);
    --shadow-8:  0 8px 32px rgba(0,0,0,0.55), 0 4px 12px rgba(0,0,0,0.35);
    --shadow-16: 0 16px 48px rgba(0,0,0,0.6), 0 6px 20px rgba(0,0,0,0.4);
}

/* ── 2. BASE & RESET ────────────────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scrollbar-width: thin;
    scrollbar-color: rgba(96, 165, 250, 0.3) transparent;
}

body {
    font-family: var(--font-display);
    background-color: #060612; /* Fundo base escuro otimizado */
    color: #e2e8f0;
    min-height: 100dvh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color 0.8s ease-in-out;
}

/* Malha Animada e Textura de Ruído (Noise Overlay) combinados para eficiência */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 60% at 20% 10%, rgba(37, 58, 130, 0.18) 0%, transparent 60%),
        radial-gradient(ellipse 60% 50% at 80% 80%, rgba(76, 29, 149, 0.14) 0%, transparent 55%),
        radial-gradient(ellipse 40% 70% at 50% 50%, rgba(15, 23, 60, 0.5) 0%, transparent 80%);
    pointer-events: none;
    z-index: 0;
}

body::after {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(255,255,255,0.015) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.015) 1px, transparent 1px);
    background-size: 48px 48px;
    pointer-events: none;
    z-index: 0;
    opacity: 0.5;
}

/* Scrollbars Unificadas */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 99px;
    transition: background var(--dur-fast);
}
::-webkit-scrollbar-thumb:hover { background: rgba(96, 165, 250, 0.55); }

/* ── 3. CORE LAYOUT (Scaffolding) ───────────────────────────────────── */
.app-shell {
    display: flex;
    width: 100vw;
    height: 100dvh;
    position: relative;
    z-index: 1;
}

.main-content {
    flex: 1;
    overflow-y: auto;
    position: relative;
    background: transparent;
    perspective: 1200px; /* Prepara o container para as rotações 3D filhas */
}

/* ── 4. COMPONENTS ──────────────────────────────────────────────────── */

/* Sidebar Navigation */
.sidebar {
    width: 280px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, rgba(10, 10, 28, 0.92) 0%, rgba(8, 8, 22, 0.95) 100%);
    border-right: 1px solid var(--border-subtle);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    position: relative;
    z-index: 20;
    transition: width var(--dur-slow) var(--ease-out);
}

.sidebar::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--glass-shine), transparent);
    pointer-events: none;
}

.sidebar::after {
    content: '';
    position: absolute;
    top: 0; right: -1px;
    width: 1px;
    height: 100%;
    background: linear-gradient(180deg, transparent 0%, var(--accent) 30%, var(--border-accent) 70%, transparent 100%);
    opacity: 0.4;
    pointer-events: none;
}

/* Header & Logo */
.sidebar-header {
    padding: 24px 20px 20px;
    border-bottom: 1px solid var(--border-subtle);
    position: relative;
}

.sidebar-logo {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    line-height: 1;
    color: #f1f5f9;
}

.sidebar-logo span {
    background: linear-gradient(135deg, #60a5fa, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-meta {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: rgba(148, 163, 184, 0.6);
    margin-top: 6px;
    letter-spacing: 0.1em;
}

/* Search Bar */
.sidebar-search {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-subtle);
}

.search-input-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    padding: 8px 12px;
    transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}

.search-input-wrap:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-input-wrap input {
    background: none;
    border: none;
    outline: none;
    color: #e2e8f0;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    width: 100%;
    caret-color: var(--accent);
}

.search-input-wrap input::placeholder { color: rgba(148, 163, 184, 0.4); }

/* Navigation List & Buttons */
.nav-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Estilo de scrollbar específico para navegação */
.nav-list::-webkit-scrollbar { width: 4px; }
.nav-list::-webkit-scrollbar-track { background: transparent; }
.nav-list::-webkit-scrollbar-thumb { background: rgba(96,165,250,0.2); }
.nav-list:hover::-webkit-scrollbar-thumb { background: rgba(96,165,250,0.4); }

.nav-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 9px 12px;
    border-radius: 10px;
    border: 1px solid transparent;
    background: transparent;
    color: rgba(226, 232, 240, 0.75);
    cursor: pointer;
    font-family: var(--font-display);
    font-size: 0.78rem;
    font-weight: 500;
    text-align: left;
    transition: background var(--dur-fast), color var(--dur-fast), border-color var(--dur-fast), box-shadow var(--dur-fast), transform var(--dur-fast);
    position: relative;
    overflow: hidden;
}

.nav-btn:hover {
    background: var(--surface-hover);
    color: #f1f5f9;
    border-color: var(--border-subtle);
    transform: translateX(2px);
}

.nav-btn.active {
    background: linear-gradient(135deg, rgba(96, 165, 250, 0.15), rgba(167, 139, 250, 0.1));
    color: #f1f5f9;
    border-color: rgba(96, 165, 250, 0.25);
    box-shadow: 0 0 0 1px rgba(96, 165, 250, 0.12) inset, var(--shadow-2);
}

.nav-btn.active::after {
    content: '';
    position: absolute;
    left: 0; top: 20%; bottom: 20%;
    width: 2.5px;
    background: linear-gradient(180deg, #60a5fa, #a78bfa);
    border-radius: 0 99px 99px 0;
}

.nav-btn.search-match { border-color: rgba(96,165,250,0.15); }
.nav-btn[style*="none"] { pointer-events: none; }

/* Page Rendering (Transitions) */
.page-section {
    display: none;
    padding: 40px 48px 60px;
    min-height: 100%;
    opacity: 0;
    transform: rotateY(-8deg) translateX(40px) scale(0.97);
    transform-origin: left center;
    transition: opacity var(--dur-slow) var(--ease-out), transform var(--dur-slow) var(--ease-out);
    will-change: transform, opacity;
    animation-fill-mode: both;
}

.page-section.active {
    display: block;
    opacity: 1;
    transform: rotateY(0deg) translateX(0) scale(1);
}

/* Stagger Entrance Elements */
.page-section.active .page-header { animation: slideUpFade 420ms cubic-bezier(0.16,1,0.3,1) 40ms both; }
.page-section.active .gradient-preview { animation: slideUpFade 420ms cubic-bezier(0.16,1,0.3,1) 100ms both; }
.page-section.active .swatches-grid { animation: slideUpFade 380ms cubic-bezier(0.16,1,0.3,1) 160ms both; }
.page-section.active .section-title { animation: slideUpFade 380ms cubic-bezier(0.16,1,0.3,1) 220ms both; }
.page-section.active .mockup-card { animation: slideUpFade 400ms cubic-bezier(0.16,1,0.3,1) 280ms both; }

/* Swatch & Card Components */
.glass-panel {
    background: linear-gradient(135deg, rgba(255,255,255,0.03) 0%, rgba(255,255,255,0.01) 100%);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-8);
}

.swatches-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 36px;
}

.swatch-btn {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform, box-shadow;
}

.swatch-btn:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 12px 24px -8px rgba(0,0,0,0.5);
}

.swatch-btn:active {
    transform: translateY(0) scale(0.98);
}

.swatch-btn.copied {
    animation: copyConfirm 500ms ease-out;
}

.mockup-card {
    position: relative;
    overflow: hidden;
    border-radius: 18px;
    padding: 24px;
    max-width: 580px;
    box-shadow: var(--shadow-8);
    border: 1px solid rgba(255,255,255,0.07);
    transition: box-shadow var(--dur-med), transform var(--dur-med) var(--ease-spring);
    will-change: transform;
}

.mockup-card:hover {
    box-shadow: var(--shadow-16);
    transform: translateY(-2px);
}

.mockup-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.18) 50%, transparent 100%);
    pointer-events: none;
}

/* Toast System */
#toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: rgba(15, 20, 40, 0.9);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(96, 165, 250, 0.3);
    border-radius: 14px;
    padding: 14px 20px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 0 0 1px rgba(96,165,250,0.08) inset;
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 0.85rem;
    color: #f1f5f9;
    pointer-events: none;
    min-width: 220px;
    
    /* Hardware Accelerated State */
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    will-change: transform, opacity;
}

.toast-icon {
    width: 28px; height: 28px;
    background: linear-gradient(135deg, #34d399, #059669);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    font-size: 0.7rem;
    color: white;
}

/* Tratamento em classes vinculadas via JS */
.toast-enter { animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards; pointer-events: auto; }
.toast-exit { animation: slideDown 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards; }

/* ── 5. UTILITIES & ANIMATIONS ──────────────────────────────────────── */

/* Dynamic Ambient / Engine Effects */
#bg-glow {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 80vw; height: 80vh;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.15;
    transition: background 0.8s ease;
    z-index: -1;
    pointer-events: none;
    will-change: background;
}

.noise-layer, .noise-overlay {
    position: fixed;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    opacity: 0.025;
    pointer-events: none;
    z-index: 999;
    mix-blend-mode: overlay;
}

/* Reusable Typography/State Utils */
.font-mono { font-family: var(--font-mono); }
.tilt-active { transform-style: preserve-3d; }

/* Keyframes de Alta Performance (somente Transform/Opacity) */
@keyframes slideUp {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes slideDown {
    from { transform: translateY(0); opacity: 1; }
    to { transform: translateY(100%); opacity: 0; }
}

@keyframes slideUpFade {
    from { opacity: 0; transform: translateY(18px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes copyConfirm {
    0%   { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.6); }
    50%  { box-shadow: 0 0 0 8px rgba(52, 211, 153, 0); }
    100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

@keyframes orbFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33%       { transform: translate(12px, -8px) scale(1.03); }
    66%       { transform: translate(-8px, 6px) scale(0.98); }
}

/* Progress bar transitions */
[class*="rounded-full"][class*="h-"] [class*="rounded-full"] {
    transition: width 800ms var(--ease-out);
}

/* ── 6. RESPONSIVE DESIGN (Media Queries) ───────────────────────────── */
@media (max-width: 768px) {
    .app-shell { flex-direction: column; }

    .sidebar {
        width: 100%;
        height: auto;
        max-height: 44vh;
        border-right: none;
        border-bottom: 1px solid var(--border-subtle);
    }

    .sidebar::after { display: none; }

    .page-section {
        padding: 24px 20px 48px;
        transform: perspective(800px) rotateX(-4deg) translateY(20px) scale(0.98);
    }

    .page-section.active {
        transform: perspective(800px) rotateX(0deg) translateY(0) scale(1);
    }
}

@media (max-width: 640px) {
    .swatches-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .gradient-preview { height: 140px; }
    .sidebar-search { padding: 8px 12px; }
}