/* ================================================================ */
/*  LS PAINT — STYLE.CSS                                            */
/*  Tema Dark Neon · Glassmorphism · Design Profissional            */
/* ================================================================ */

/* ---------------------------------------------------------------- */
/*  VARIÁVEIS                                                       */
/* ---------------------------------------------------------------- */
:root {
    --bg-primary: #0a0a1a;
    --bg-secondary: #0f0f2a;
    --bg-tertiary: #151535;
    --bg-card: rgba(255, 255, 255, 0.04);
    --bg-card-hover: rgba(255, 255, 255, 0.08);
    --border-glass: rgba(255, 255, 255, 0.08);
    --border-glass-hover: rgba(255, 255, 255, 0.15);
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.4);
    --theme-color: #00d4ff;
    --theme-glow: rgba(0, 212, 255, 0.3);
    --font-display: 'Orbitron', monospace;
    --font-body: 'Inter', -apple-system, sans-serif;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --header-height: 56px;
    --toolbar-height: 42px;
    --footer-height: 48px;
    --status-height: 32px;
}

.theme-light {
    --bg-primary: #f0f4ff;
    --bg-secondary: #e8edf8;
    --bg-tertiary: #dce3f0;
    --bg-card: rgba(0, 0, 0, 0.04);
    --bg-card-hover: rgba(0, 0, 0, 0.08);
    --border-glass: rgba(0, 0, 0, 0.08);
    --border-glass-hover: rgba(0, 0, 0, 0.15);
    --text-primary: #0a0a1a;
    --text-secondary: rgba(0, 0, 0, 0.6);
    --text-muted: rgba(0, 0, 0, 0.35);
}

/* ---------------------------------------------------------------- */
/*  RESET                                                           */
/* ---------------------------------------------------------------- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html { font-size: 16px; scroll-behavior: smooth; -webkit-tap-highlight-color: transparent; }

body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: background var(--transition-base), color var(--transition-base);
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    outline: none;
    background: none;
    color: inherit;
    -webkit-tap-highlight-color: transparent;
}

a { text-decoration: none; color: inherit; }
input[type="range"] { cursor: pointer; }
canvas { display: block; }
.hidden { display: none !important; }

/* ---------------------------------------------------------------- */
/*  LOADING                                                         */
/* ---------------------------------------------------------------- */
.loading-overlay {
    position: fixed; inset: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    background: var(--bg-primary); z-index: 9999;
    transition: opacity 0.5s, visibility 0.5s;
}
.loading-overlay.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.loading-spinner {
    width: 48px; height: 48px;
    border: 3px solid var(--border-glass);
    border-top-color: var(--theme-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
.loading-text {
    font-family: var(--font-display);
    font-size: 1.2rem; letter-spacing: 6px;
    color: var(--theme-color); margin-top: 16px;
    text-shadow: 0 0 20px var(--theme-glow);
    animation: pulseGlow 2s ease-in-out infinite;
}

/* ---------------------------------------------------------------- */
/*  TOP BAR                                                         */
/* ---------------------------------------------------------------- */
.top-bar {
    position: fixed; top: 0; left: 0; right: 0;
    z-index: 100;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.top-bar-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 16px;
    height: var(--header-height);
}

/* Logo */
.app-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.logo-icon {
    font-size: 1.5rem;
    color: var(--theme-color);
    filter: drop-shadow(0 0 8px var(--theme-glow));
    animation: floatIcon 3s ease-in-out infinite;
}
.app-title {
    font-family: var(--font-display);
    font-size: 1rem;
    letter-spacing: 3px;
    color: var(--text-primary);
    white-space: nowrap;
}

/* Centro - ferramentas */
.top-center {
    flex: 1;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.top-center::-webkit-scrollbar { height: 3px; }
.top-center::-webkit-scrollbar-thumb { background: var(--border-glass); border-radius: 99px; }

.tools-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: max-content;
    padding: 2px 0;
}

.tool-group {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 2px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-glass);
}

.tool-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    color: var(--text-secondary);
    border-radius: 4px;
    transition: all var(--transition-fast);
    position: relative;
}
.tool-btn:hover { color: var(--text-primary); background: var(--bg-card-hover); }
.tool-btn.active {
    color: var(--theme-color);
    background: rgba(0, 212, 255, 0.12);
    box-shadow: 0 0 12px var(--theme-glow);
}
.tool-btn::after {
    content: attr(title);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%) scale(0.9);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 0.6rem;
    padding: 3px 8px;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: all var(--transition-fast);
    border: 1px solid var(--border-glass);
}
.tool-btn:hover::after { opacity: 1; transform: translateX(-50%) scale(1); }

.tool-separator {
    width: 1px;
    height: 28px;
    background: var(--border-glass);
}

/* Paleta de cores */
.color-palette-wrapper {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 2px 6px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-glass);
}
.color-row {
    display: flex;
    gap: 2px;
}
.color-swatch {
    width: 18px;
    height: 18px;
    border-radius: 3px;
    background: var(--swatch);
    border: 1.5px solid transparent;
    transition: all var(--transition-fast);
    cursor: pointer;
}
.color-swatch:hover { transform: scale(1.25); z-index: 2; }
.color-swatch.active { border-color: var(--theme-color); box-shadow: 0 0 8px var(--theme-glow); }
.color-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}
.color-picker-input {
    width: 22px;
    height: 22px;
    border: none;
    padding: 0;
    cursor: pointer;
    border-radius: 4px;
    background: none;
}
.color-picker-input::-webkit-color-swatch-wrapper { padding: 0; }
.color-picker-input::-webkit-color-swatch { border: 1px solid var(--border-glass); border-radius: 3px; }
.current-color {
    width: 22px;
    height: 22px;
    border-radius: 4px;
    border: 1.5px solid var(--border-glass);
    transition: background var(--transition-fast);
}
.recent-colors {
    display: flex;
    align-items: center;
    gap: 3px;
}
.recent-label { font-size: 0.55rem; color: var(--text-muted); white-space: nowrap; }
.recent-swatches {
    display: flex;
    gap: 2px;
}
.recent-swatch {
    width: 14px;
    height: 14px;
    border-radius: 2px;
    border: 1px solid var(--border-glass);
    cursor: pointer;
    transition: transform var(--transition-fast);
}
.recent-swatch:hover { transform: scale(1.3); }

/* Lado direito */
.top-right {
    flex-shrink: 0;
}
.action-group {
    display: flex;
    align-items: center;
    gap: 4px;
}
.action-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    white-space: nowrap;
}
.action-btn:hover { color: var(--text-primary); background: var(--bg-card-hover); border-color: var(--border-glass-hover); }
.action-btn-primary {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #fff;
    border: none;
    box-shadow: 0 2px 12px rgba(37, 99, 235, 0.3);
}
.action-btn-primary:hover { box-shadow: 0 4px 24px rgba(37, 99, 235, 0.5); transform: translateY(-1px); }

/* Barra de opções */
.tool-options-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 4px 16px;
    height: var(--toolbar-height);
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-glass);
    overflow-x: auto;
}
.tool-option-group {
    display: flex;
    align-items: center;
    gap: 6px;
}
.option-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}
.option-slider {
    -webkit-appearance: none;
    width: 80px;
    height: 3px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    outline: none;
}
.option-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px; height: 12px;
    border-radius: 50%;
    background: var(--theme-color);
    box-shadow: 0 0 6px var(--theme-glow);
    cursor: pointer;
}
.option-value { font-size: 0.7rem; color: var(--text-muted); min-width: 30px; }
.option-btn {
    padding: 4px 10px;
    font-size: 0.7rem;
    color: var(--text-secondary);
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: 4px;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 4px;
}
.option-btn:hover { color: var(--text-primary); background: var(--bg-card-hover); }
.option-btn-danger:hover { color: #ef4444; border-color: #ef4444; }

/* ---------------------------------------------------------------- */
/*  MAIN AREA                                                       */
/* ---------------------------------------------------------------- */
.main-area {
    position: fixed;
    top: calc(var(--header-height) + var(--toolbar-height));
    left: 0;
    right: 0;
    bottom: calc(var(--footer-height) + var(--status-height));
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    overflow: hidden;
}

/* Réguas */
.ruler {
    position: absolute;
    background: var(--bg-secondary);
    border: 1px solid var(--border-glass);
    z-index: 10;
}
.ruler-top {
    top: 0; left: 24px; right: 0;
    height: 20px;
    border-top: none;
}
.ruler-left {
    top: 20px; left: 0; bottom: 0;
    width: 20px;
    border-left: none;
}

/* Container do Canvas */
.canvas-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    width: 100%;
    overflow: auto;
    background: repeating-conic-gradient(var(--bg-tertiary) 0% 25%, var(--bg-secondary) 0% 50%) 0 0 / 20px 20px;
}

#main-canvas, #overlay-canvas {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    image-rendering: auto;
    border: 1px solid var(--border-glass);
    box-shadow: 0 4px 40px rgba(0,0,0,0.4);
}

#main-canvas {
    background: #ffffff;
}

#overlay-canvas {
    background: transparent !important;
    pointer-events: none !important;
}
.grid-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: none;
}
.grid-overlay.active {
    display: block;
    background-image:
        linear-gradient(rgba(255,255,255,0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.05) 1px, transparent 1px);
    background-size: 20px 20px;
}

/* Mini mapa */
.minimap {
    position: absolute;
    bottom: 8px;
    right: 8px;
    width: 120px;
    height: 90px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    overflow: hidden;
    z-index: 10;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity var(--transition-fast);
}
.minimap:hover { opacity: 1; }
.minimap canvas { width: 100%; height: 100%; }

/* Zoom indicator */
.zoom-indicator {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 4px 10px;
    font-size: 0.7rem;
    font-family: var(--font-display);
    color: var(--text-muted);
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    backdrop-filter: blur(8px);
    z-index: 10;
    pointer-events: none;
}

/* ---------------------------------------------------------------- */
/*  STATUS BAR                                                      */
/* ---------------------------------------------------------------- */
.status-bar {
    position: fixed;
    bottom: var(--footer-height);
    left: 0;
    right: 0;
    height: var(--status-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-glass);
    border-bottom: 1px solid var(--border-glass);
    font-size: 0.65rem;
    color: var(--text-muted);
    z-index: 50;
}
.status-bar span { display: flex; align-items: center; gap: 8px; }
.status-btn {
    width: 20px; height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    color: var(--text-muted);
    border-radius: 3px;
    transition: all var(--transition-fast);
}
.status-btn:hover { color: var(--text-primary); background: var(--bg-card); }

/* ---------------------------------------------------------------- */
/*  FOOTER                                                          */
/* ---------------------------------------------------------------- */
.site-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--footer-height);
    z-index: 50;
    background: linear-gradient(180deg, transparent, rgba(10,10,26,0.98));
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--border-glass);
    display: flex;
    align-items: center;
    padding: 0 16px;
}
.footer-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}
.footer-brand {
    font-size: 0.65rem;
    color: var(--text-muted);
    background: linear-gradient(90deg, var(--text-muted), var(--theme-color), var(--text-muted));
    background-size: 200% 100%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: shimmerText 6s linear infinite;
}
.footer-right { display: flex; gap: 8px; }
.footer-social {
    width: 28px; height: 28px;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.9rem;
    color: var(--text-muted);
    border-radius: 50%;
    transition: all var(--transition-fast);
    position: relative;
}
.footer-social::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%) scale(0.9);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 0.55rem;
    padding: 3px 8px;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: all var(--transition-fast);
    border: 1px solid var(--border-glass);
}
.footer-social:hover::after { opacity: 1; transform: translateX(-50%) scale(1); }
.footer-social:hover { color: var(--theme-color); transform: translateY(-2px); }

/* ---------------------------------------------------------------- */
/*  MODAL                                                           */
/* ---------------------------------------------------------------- */
.modal-overlay {
    position: fixed; inset: 0;
    display: flex; align-items: center; justify-content: center;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(8px);
    z-index: 200;
    animation: fadeIn 0.2s both;
    padding: 16px;
}
.modal-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-xl);
    padding: 28px;
    max-width: 400px;
    width: 100%;
    position: relative;
    box-shadow: 0 0 60px rgba(0,0,0,0.5);
    animation: scaleIn 0.25s both;
}
.modal-title {
    font-family: var(--font-display);
    font-size: 1.1rem;
    letter-spacing: 3px;
    margin-bottom: 16px;
}
.settings-grid {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 16px;
}
.setting-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition-fast);
}
.setting-item:hover { background: var(--bg-card); }
.setting-item span { font-size: 0.85rem; display: flex; align-items: center; gap: 8px; }
.setting-item span i { color: var(--theme-color); width: 18px; }
.toggle-input { display: none; }
.toggle-slider {
    width: 36px; height: 20px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-glass);
    border-radius: 99px;
    position: relative;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}
.toggle-slider::after {
    content: '';
    position: absolute;
    top: 2px; left: 2px;
    width: 14px; height: 14px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: all var(--transition-fast);
}
.toggle-input:checked + .toggle-slider {
    background: var(--theme-color);
    border-color: var(--theme-color);
    box-shadow: 0 0 8px var(--theme-glow);
}
.toggle-input:checked + .toggle-slider::after { left: 18px; background: #fff; }
.color-picker-small {
    width: 28px; height: 28px;
    padding: 0; border: 1px solid var(--border-glass);
    border-radius: 4px; cursor: pointer;
    background: none;
}
.modal-actions { margin-top: 8px; }
.modal-close-x {
    position: absolute; top: 12px; right: 12px;
    width: 28px; height: 28px;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted);
    border-radius: 50%;
    transition: all var(--transition-fast);
}
.modal-close-x:hover { color: var(--text-primary); background: var(--bg-card); }

.btn-secondary {
    padding: 10px 24px;
    font-family: var(--font-display);
    font-size: 0.75rem;
    letter-spacing: 2px;
    color: var(--theme-color);
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    cursor: pointer;
    width: 100%;
}
.btn-secondary:hover { background: var(--bg-card-hover); border-color: var(--theme-color); box-shadow: 0 0 16px var(--theme-glow); }

/* ---------------------------------------------------------------- */
/*  ANIMAÇÕES                                                       */
/* ---------------------------------------------------------------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.9); } to { opacity: 1; transform: scale(1); } }
@keyframes pulseGlow { 0%,100% { opacity: 0.6; } 50% { opacity: 1; } }
@keyframes floatIcon { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
@keyframes shimmerText { 0% { background-position: 0% 50%; } 100% { background-position: 200% 50%; } }

/* ---------------------------------------------------------------- */
/*  RESPONSIVIDADE                                                   */
/* ---------------------------------------------------------------- */
@media (max-width: 900px) {
    .top-bar-inner { padding: 4px 10px; }
    .app-title { font-size: 0.8rem; letter-spacing: 2px; }
    .logo-icon { font-size: 1.2rem; }
    .tool-btn { width: 28px; height: 28px; font-size: 0.8rem; }
    .color-swatch { width: 15px; height: 15px; }
    .action-btn { padding: 4px 8px; font-size: 0.75rem; }
    .action-btn span { display: none; }
    .action-btn-primary { padding: 4px 10px; font-size: 0.65rem; }
    .top-center { overflow-x: auto; }
    .tool-options-bar { gap: 8px; padding: 3px 10px; }
    .option-slider { width: 60px; }
    .site-footer { padding: 0 10px; }
    .footer-social { width: 24px; height: 24px; font-size: 0.75rem; }
    .footer-brand { font-size: 0.55rem; }
    .status-bar { font-size: 0.55rem; padding: 0 10px; }
}

@media (max-width: 520px) {
    :root {
        --header-height: 48px;
        --toolbar-height: 36px;
        --footer-height: 40px;
        --status-height: 28px;
    }
    .top-bar-inner { padding: 3px 6px; gap: 6px; }
    .app-title { display: none; }
    .logo-icon { font-size: 1rem; }
    .tool-btn { width: 24px; height: 24px; font-size: 0.7rem; }
    .color-swatch { width: 13px; height: 13px; }
    .color-actions .recent-colors { display: none; }
    .action-btn { padding: 3px 6px; }
    .action-btn i { font-size: 0.8rem; }
    .tool-options-bar { gap: 6px; padding: 2px 6px; }
    .option-slider { width: 50px; }
    .option-label { font-size: 0.6rem; }
    .site-footer { padding: 0 6px; }
    .footer-social { width: 20px; height: 20px; font-size: 0.65rem; }
    .footer-brand { font-size: 0.5rem; }
    .status-bar { font-size: 0.5rem; padding: 0 6px; gap: 4px; }
    .status-bar span { gap: 4px; }
    .minimap { width: 80px; height: 60px; }
    .zoom-indicator { font-size: 0.55rem; padding: 2px 6px; }
}
