/* ============================================
   SERENO - App de Pintura Relaxante
   Design: Aesthetic minimalista e acolhedor
   ============================================ */

:root {
    /* Paleta de cores - Tons noturnos relaxantes */
    --bg-deep: #0f0f1a;
    --bg-main: #1a1a2e;
    --bg-card: #252542;
    --bg-elevated: #2d2d4a;
    --bg-hover: #3a3a5c;
    
    --accent-primary: #7c5ce0;
    --accent-secondary: #e05c8a;
    --accent-tertiary: #5ce0c4;
    --accent-warm: #e0a85c;
    
    --text-primary: #f5f5f7;
    --text-secondary: #a8a8b8;
    --text-muted: #6b6b7b;
    
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-light: rgba(255, 255, 255, 0.12);
    
    --shadow-soft: 0 8px 32px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 40px rgba(124, 92, 224, 0.15);
    
    /* Tipografia */
    --font-display: 'Crimson Pro', Georgia, serif;
    --font-body: 'DM Sans', -apple-system, sans-serif;
    
    /* Espaçamentos */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 40px;
    --space-2xl: 64px;
    
    /* Bordas */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-full: 9999px;
    
    /* Transições */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 300ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-spring: 500ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-body);
    background: var(--bg-main);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

/* Background atmosférico */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: 
        radial-gradient(ellipse 80% 50% at 20% 20%, rgba(124, 92, 224, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse 60% 40% at 80% 80%, rgba(224, 92, 138, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse 50% 30% at 50% 100%, rgba(92, 224, 196, 0.04) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

#app {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100vh;
    height: 100dvh;
}

/* ============================================
   TELAS
   ============================================ */
.screen {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-smooth), visibility var(--transition-smooth);
}

.screen.active {
    opacity: 1;
    visibility: visible;
}

/* ============================================
   GALERIA
   ============================================ */
.gallery-header {
    text-align: center;
    padding: var(--space-xl) var(--space-lg) var(--space-lg);
    animation: fadeInDown 0.8s ease-out;
}

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

.logo {
    font-family: var(--font-display);
    font-size: 3.5rem;
    font-weight: 300;
    letter-spacing: 0.08em;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent-primary) 50%, var(--accent-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: var(--space-xs);
}

.tagline {
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 400;
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

.gallery-tabs {
    display: flex;
    justify-content: center;
    gap: var(--space-sm);
    padding: 0 var(--space-lg) var(--space-lg);
    animation: fadeIn 0.8s ease-out 0.2s both;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.tab-btn {
    background: transparent;
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
    padding: var(--space-sm) var(--space-lg);
    border-radius: var(--radius-full);
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.tab-btn:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

.tab-btn.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

.gallery-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0 var(--space-lg) var(--space-xl);
    -webkit-overflow-scrolling: touch;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.4s ease-out;
}

.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: var(--space-md);
    padding-bottom: var(--space-xl);
}

@media (min-width: 768px) {
    .image-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
        gap: var(--space-lg);
    }
}

.image-card {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius-lg);
    overflow: hidden;
    cursor: pointer;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    transition: all var(--transition-smooth);
    animation: cardAppear 0.5s ease-out both;
}

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

.image-card:nth-child(1) { animation-delay: 0.1s; }
.image-card:nth-child(2) { animation-delay: 0.15s; }
.image-card:nth-child(3) { animation-delay: 0.2s; }
.image-card:nth-child(4) { animation-delay: 0.25s; }
.image-card:nth-child(5) { animation-delay: 0.3s; }
.image-card:nth-child(6) { animation-delay: 0.35s; }

.image-card:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: var(--shadow-soft), var(--shadow-glow);
    border-color: var(--accent-primary);
}

.image-card:active {
    transform: scale(0.98);
}

.image-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-smooth);
}

.image-card:hover img {
    transform: scale(1.05);
}

.image-card-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(15, 15, 26, 0.8) 0%, transparent 50%);
    display: flex;
    align-items: flex-end;
    padding: var(--space-md);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

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

.image-card-title {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
}

/* Projeto salvo - card */
.project-card {
    position: relative;
}

.project-card .delete-btn {
    position: absolute;
    top: var(--space-sm);
    right: var(--space-sm);
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    background: rgba(0, 0, 0, 0.6);
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all var(--transition-fast);
    z-index: 2;
}

.project-card:hover .delete-btn {
    opacity: 1;
}

.project-card .delete-btn:hover {
    background: var(--accent-secondary);
    color: white;
}

.project-card .delete-btn svg {
    width: 16px;
    height: 16px;
}

/* Empty state */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-2xl);
    text-align: center;
    animation: fadeIn 0.6s ease-out;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: var(--space-lg);
    opacity: 0.6;
}

.empty-state p {
    font-size: 1.2rem;
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
}

.empty-state span {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* ============================================
   TELA DE PINTURA
   ============================================ */
.paint-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-lg);
    background: rgba(15, 15, 26, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-subtle);
    z-index: 10;
}

.btn-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.btn-icon:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-light);
}

.btn-icon:active {
    transform: scale(0.95);
}

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

.project-title {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 400;
    color: var(--text-primary);
    letter-spacing: 0.02em;
}

.header-actions {
    display: flex;
    gap: var(--space-sm);
}

/* Canvas Container */
.canvas-container {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-deep);
    overflow: hidden;
}

.canvas-container canvas {
    position: absolute;
    max-width: 100%;
    max-height: 100%;
    touch-action: none;
    border-radius: var(--radius-sm);
}

#base-canvas {
    z-index: 1;
    box-shadow: var(--shadow-soft);
}

#paint-canvas {
    z-index: 2;
}

/* ============================================
   TOOLBAR - ESTILO LAKE (SIMPLES)
   ============================================ */
.toolbar {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(30, 30, 45, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-subtle);
    border-bottom: none;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: var(--space-md) var(--space-lg);
    padding-bottom: calc(var(--space-md) + env(safe-area-inset-bottom));
    display: flex;
    align-items: center;
    gap: var(--space-md);
    z-index: 10;
    box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.3);
}

/* Divisor vertical */
.toolbar-divider {
    width: 1px;
    height: 36px;
    background: var(--border-light);
    opacity: 0.5;
}

/* Container de pincéis */
.toolbar-brushes {
    display: flex;
    gap: 4px;
}

.brush-btn {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: transparent;
    border: 2px solid transparent;
    font-size: 1.4rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.brush-btn:hover {
    background: var(--bg-hover);
    transform: scale(1.05);
}

.brush-btn.active {
    background: var(--bg-elevated);
    border-color: var(--accent-primary);
    box-shadow: 0 0 12px rgba(124, 92, 224, 0.3);
}

/* Container de ferramentas */
.toolbar-tools {
    display: flex;
    gap: 4px;
}

/* Container de tamanho */
.toolbar-size {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

/* Container de cores */
.toolbar-colors {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.color-wheel {
    display: flex;
    gap: 3px;
}

.color-picker-btn {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    background: conic-gradient(red, yellow, lime, aqua, blue, magenta, red);
    padding: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.color-picker-btn::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-picker-btn::-webkit-color-swatch {
    border: none;
    border-radius: var(--radius-full);
}

/* Responsivo */
@media (max-width: 700px) {
    .toolbar {
        left: 0;
        right: 0;
        transform: none;
        border-radius: 0;
        justify-content: center;
        flex-wrap: wrap;
        gap: var(--space-sm);
    }
    
    .toolbar-divider {
        display: none;
    }
    
    .brush-btn {
        width: 38px;
        height: 38px;
        font-size: 1.2rem;
    }
}

.tool-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: transparent;
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

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

.tool-btn.active {
    background: var(--accent-secondary);
    border-color: var(--accent-secondary);
    color: white;
}

.tool-btn svg {
    width: 20px;
    height: 20px;
}

/* Botão de modo confinado */
.tool-btn.mode-btn {
    border-color: var(--accent-tertiary);
    color: var(--accent-tertiary);
    opacity: 0.6;
}

.tool-btn.mode-btn.active {
    background: var(--accent-tertiary);
    border-color: var(--accent-tertiary);
    color: var(--bg-deep);
    opacity: 1;
}

/* Size slider */
.size-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 80px;
    height: 4px;
    background: var(--bg-elevated);
    border-radius: var(--radius-full);
    outline: none;
    cursor: pointer;
}

.size-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: var(--radius-full);
    background: white;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.size-preview {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: var(--bg-card);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-subtle);
}

.size-preview::after {
    content: '';
    width: var(--preview-size, 16px);
    height: var(--preview-size, 16px);
    max-width: 28px;
    max-height: 28px;
    border-radius: var(--radius-full);
    background: var(--current-color, var(--accent-primary));
    transition: all var(--transition-fast);
}

/* Color swatches */
.color-swatch {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-full);
    cursor: pointer;
    border: 2px solid transparent;
    transition: all var(--transition-fast);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.color-swatch:hover {
    transform: scale(1.15);
    z-index: 1;
}

.color-swatch.active {
    border-color: white;
    transform: scale(1.2);
    box-shadow: 0 0 10px var(--swatch-color), 0 2px 8px rgba(0, 0, 0, 0.3);
    z-index: 2;
}

/* ============================================
   ZOOM INDICATOR
   ============================================ */
.zoom-indicator {
    position: absolute;
    top: var(--space-lg);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-full);
    font-size: 0.9rem;
    font-weight: 500;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 20;
}

.zoom-indicator.visible {
    opacity: 1;
}

/* Botão de reset zoom */
.zoom-reset-btn {
    position: absolute;
    top: var(--space-lg);
    right: var(--space-lg);
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border-light);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 20;
}

.zoom-reset-btn.visible {
    opacity: 1;
}

.zoom-reset-btn:hover {
    background: rgba(0, 0, 0, 0.7);
}

.zoom-reset-btn svg {
    width: 20px;
    height: 20px;
}

/* ============================================
   MODAL
   ============================================ */
.modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-smooth);
}

.modal.active {
    opacity: 1;
    visibility: visible;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.modal-content {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    width: 90%;
    max-width: 400px;
    transform: scale(0.9) translateY(20px);
    transition: transform var(--transition-spring);
}

.modal.active .modal-content {
    transform: scale(1) translateY(0);
}

.modal-content h2 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 400;
    margin-bottom: var(--space-lg);
    text-align: center;
}

.modal-content input[type="text"] {
    width: 100%;
    padding: var(--space-md);
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 1rem;
    outline: none;
    transition: border-color var(--transition-fast);
}

.modal-content input[type="text"]:focus {
    border-color: var(--accent-primary);
}

.modal-content input[type="text"]::placeholder {
    color: var(--text-muted);
}

.modal-actions {
    display: flex;
    gap: var(--space-md);
    margin-top: var(--space-lg);
}

.btn {
    flex: 1;
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    border: none;
}

.btn-secondary {
    background: var(--bg-elevated);
    color: var(--text-secondary);
}

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

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

.btn-primary:hover {
    background: #8b6ce8;
    box-shadow: 0 4px 20px rgba(124, 92, 224, 0.4);
}

/* ============================================
   TOAST
   ============================================ */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-full);
    padding: var(--space-sm) var(--space-lg);
    color: var(--text-primary);
    font-size: 0.9rem;
    opacity: 0;
    transition: all var(--transition-spring);
    z-index: 200;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast.success {
    background: var(--accent-tertiary);
    color: var(--bg-deep);
    border-color: var(--accent-tertiary);
}

/* ============================================
   SCROLLBAR
   ============================================ */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--bg-hover);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ============================================
   UTILIDADES
   ============================================ */
.hidden {
    display: none !important;
}

