:root {
    --bg-body: #f3f4f6;
    --bg-panel: #ffffff;
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --border: #e5e7eb;
    --radius: 8px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --success: #22c55e;
    --warning: #f59e0b;
    --error: #ef4444;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
    background-color: var(--bg-body);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* === LOADING OVERLAY === */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    z-index: 9999;
    gap: 15px;
}

.loading-overlay.active {
    display: flex;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay p {
    color: white;
    font-size: 14px;
    font-weight: 600;
}

/* === TOAST NOTIFICATIONS === */
#toastContainer {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: white;
    padding: 15px 20px;
    border-radius: var(--radius);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    animation: slideIn 0.3s ease;
    border-left: 4px solid var(--primary);
}

.toast.success { border-left-color: var(--success); }
.toast.warning { border-left-color: var(--warning); }
.toast.error { border-left-color: var(--error); }

.toast i {
    font-size: 20px;
}

.toast.success i { color: var(--success); }
.toast.warning i { color: var(--warning); }
.toast.error i { color: var(--error); }

.toast-message {
    flex: 1;
    font-size: 13px;
    font-weight: 500;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* === MODAL === */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9998;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    max-width: 450px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-content h3 {
    font-size: 18px;
    margin-bottom: 15px;
    text-transform: none;
    border: none;
    padding: 0;
    color: var(--text-main);
}

.modal-content p {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 25px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* === TOP BAR === */
.top-bar {
    height: 60px;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 20px;
    justify-content: space-between;
}

.logo {
    font-weight: 700;
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-main);
}

.logo i { color: var(--primary); }

.top-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.divider {
    width: 1px;
    height: 20px;
    background: var(--border);
    margin: 0 5px;
}

.icon-btn {
    background: none;
    border: 1px solid transparent;
    cursor: pointer;
    color: var(--text-main);
    padding: 8px;
    border-radius: var(--radius);
    transition: 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover { background-color: var(--bg-body); border-color: var(--border); }
.icon-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-upload {
    background-color: var(--text-main);
    color: white;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn-upload:hover { opacity: 0.9; }

/* === WORKSPACE === */
.workspace {
    display: grid;
    grid-template-columns: 70px 1fr 300px;
    height: calc(100vh - 60px);
    transition: grid-template-columns 0.3s ease;
}

.workspace.sidebar-hidden {
    grid-template-columns: 70px 1fr 0;
}

/* === LEFT SIDEBAR === */
.left-sidebar {
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 20px;
    gap: 15px;
}

.tool-item {
    width: 44px;
    height: 44px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s ease;
    position: relative;
}

.tool-item:hover {
    background-color: var(--bg-body);
    color: var(--primary);
}

.tool-item.active {
    background-color: #eff6ff;
    color: var(--primary);
    border: 1px solid #bfdbfe;
}

.tool-item::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 60px;
    background: #1f2937;
    color: white;
    padding: 5px 10px;
    font-size: 12px;
    border-radius: 4px;
    opacity: 0;
    pointer-events: none;
    transition: 0.2s;
    white-space: nowrap;
    z-index: 10;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.tool-item:hover::after { opacity: 1; }

/* === CANVAS AREA === */
.canvas-area {
    background-color: #e5e5e5;
    background-image: 
        linear-gradient(45deg, #ccc 25%, transparent 25%), 
        linear-gradient(-45deg, #ccc 25%, transparent 25%), 
        linear-gradient(45deg, transparent 75%, #ccc 75%), 
        linear-gradient(-45deg, transparent 75%, #ccc 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: auto;
    padding: 40px;
}

.canvas-area.drag-over {
    background-color: #dbeafe;
}

.canvas-area.drag-over::after {
    content: 'Solte o arquivo aqui';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
    pointer-events: none;
}

.canvas-wrapper {
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    max-width: 100%;
    max-height: 100%;
    display: flex;
    transform-origin: center center;
    transition: transform 0.2s ease;
    position: relative;
}

canvas {
    display: block;
    max-width: 100%;
    max-height: 80vh;
}

canvas.drawing { cursor: crosshair; }
canvas.eyedropper { cursor: copy; }
canvas.shape-drawing { cursor: crosshair; }

/* === CROP OVERLAY === */
.crop-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999; /* <--- ADICIONADO: Garante que fique acima de tudo */
    cursor: crosshair; /* <--- ADICIONADO: Indica que é área de seleção */
    display: none; /* Mantém oculto por padrão */
}

.crop-box {
    position: absolute;
    border: 2px dashed white;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
    cursor: move;
}

.crop-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: white;
    border: 2px solid var(--primary);
    border-radius: 50%;
}

.crop-handle.top-left { top: -6px; left: -6px; cursor: nw-resize; }
.crop-handle.top-right { top: -6px; right: -6px; cursor: ne-resize; }
.crop-handle.bottom-left { bottom: -6px; left: -6px; cursor: sw-resize; }
.crop-handle.bottom-right { bottom: -6px; right: -6px; cursor: se-resize; }

.crop-actions {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
}

/* === EMPTY STATE === */
.empty-state {
    text-align: center;
    color: var(--text-muted);
    border: 2px dashed #9ca3af;
    padding: 40px;
    border-radius: 12px;
    cursor: pointer;
    transition: 0.2s;
    background: rgba(255,255,255,0.5);
}

.empty-state:hover { 
    border-color: var(--primary); 
    color: var(--primary); 
    background: rgba(255,255,255,0.8); 
}

/* === RIGHT SIDEBAR === */
.right-sidebar {
    background: var(--bg-panel);
    border-left: 1px solid var(--border);
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
}

.right-sidebar.hidden {
    width: 0;
    padding: 0;
    opacity: 0;
    overflow: hidden;
}

.panel-section {
    display: none;
    animation: fadeIn 0.3s ease;
}

.panel-section.active { display: block; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

h3 {
    font-size: 13px;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 10px;
}

.control-group { margin-bottom: 24px; }

.control-label {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-main);
}

/* === SLIDERS === */
input[type=range] {
    width: 100%;
    -webkit-appearance: none;
    background: transparent;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 16px;
    width: 16px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    margin-top: -6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    cursor: pointer;
    background: #e5e7eb;
    border-radius: 2px;
}

input[type=range]::-moz-range-thumb {
    height: 16px;
    width: 16px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

input[type=range]::-moz-range-track {
    width: 100%;
    height: 4px;
    cursor: pointer;
    background: #e5e7eb;
    border-radius: 2px;
}

/* === INPUTS === */
.input-row {
    display: flex;
    gap: 10px;
}

input[type="number"], 
input[type="text"],
textarea,
select {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    background: #fff;
    color: var(--text-main);
}

input[type="number"]:focus, 
input[type="text"]:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
}

input[type="checkbox"] {
    cursor: pointer;
}

/* === BUTTONS === */
.btn-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.btn-secondary {
    background: white;
    border: 1px solid var(--border);
    padding: 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: var(--text-main);
    transition: 0.2s;
}

.btn-secondary:hover { 
    border-color: var(--primary); 
    color: var(--primary); 
    background: #f9fafb; 
}

.btn-secondary.active { 
    border-color: var(--primary); 
    color: var(--primary); 
    background: #eff6ff; 
}

.btn-primary {
    width: 100%;
    background-color: var(--primary);
    color: white;
    border: none;
    padding: 14px;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.3);
}

.btn-primary:hover { 
    background-color: var(--primary-hover); 
    transform: translateY(-1px); 
}

/* === FILTERS GRID === */
.filters-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr; /* 4 colunas ao invés de 2 */
    gap: 10px;
}

.filter-preset {
    cursor: pointer;
    text-align: center;
    transition: 0.2s;
}

.filter-preset:hover {
    transform: scale(1.05);
}

.filter-preview {
    width: 100%;
    height: 60px; /* Reduzido de 80px */
    border-radius: 6px;
    border: 2px solid var(--border);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    margin-bottom: 6px;
    transition: 0.2s;
}

.filter-preset:hover .filter-preview {
    border-color: var(--primary);
}

.filter-preset span {
    font-size: 10px; /* Reduzido de 11px */
    font-weight: 600;
    color: var(--text-muted);
}

/* === COLOR PALETTE === */
.color-palette { 
    display: flex; 
    gap: 8px; 
    margin-top: 5px;
    flex-wrap: wrap;
}

.color-dot { 
    width: 28px; 
    height: 28px; 
    border-radius: 50%; 
    cursor: pointer; 
    border: 2px solid #e5e7eb; 
    transition: 0.2s;
}

.color-dot:hover { transform: scale(1.1); }
.color-dot.active { 
    border-color: var(--text-main); 
    transform: scale(1.15);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* === EXPORT AREA === */
.export-area {
    margin-top: auto;
    border-top: 1px solid var(--border);
    padding-top: 20px;
    background: #f9fafb;
    margin-left: -20px;
    margin-right: -20px;
    margin-bottom: -20px;
    padding: 20px;
}

.size-estimate {
    font-size: 12px;
    color: var(--text-muted);
    text-align: right;
    margin-top: 5px;
    font-weight: 500;
}

/* === SCROLLBAR === */
.right-sidebar::-webkit-scrollbar {
    width: 8px;
}

.right-sidebar::-webkit-scrollbar-track {
    background: var(--bg-body);
}

.right-sidebar::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.right-sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}
/* === STYLES ADICIONAIS NÍVEL 1 === */

/* Stickers Grid */
.stickers-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    background: #f9fafb;
    padding: 10px;
    border-radius: 8px;
    max-height: 300px; /* Aumentado de 200px para 300px */
    overflow-y: auto;
}

.sticker-item {
    font-size: 24px;
    cursor: pointer;
    text-align: center;
    padding: 5px;
    border-radius: 4px;
    transition: 0.2s;
}

.sticker-item:hover {
    background: #e5e7eb;
    transform: scale(1.2);
}

/* Compare Slider Styles */
.compare-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: auto; /* Permite interagir com o slider */
    user-select: none;
    z-index: 50;
}

.compare-before {
    position: absolute;
    top: 0;
    left: 0;
    width: 50%; /* Inicial */
    height: 100%;
    overflow: hidden;
    border-right: 2px solid white;
    background: #e5e5e5; /* Fundo caso imagem carregue lento */
}

/* A imagem original dentro do slider deve ocupar 100% da área total (não do container cortado) */
#compareOriginalImg {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    /* Width será definido via JS para igualar ao Canvas */
    width: auto; 
    max-width: none;
    display: block;
    pointer-events: none;
}

.compare-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%; /* Inicial */
    width: 40px;
    margin-left: -20px;
    cursor: ew-resize;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: center;
}

.handle-line {
    width: 2px;
    height: 100%;
    background: white;
    box-shadow: 0 0 5px rgba(0,0,0,0.5);
}

.handle-circle {
    position: absolute;
    width: 32px;
    height: 32px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
}

.label-before, .label-after {
    position: absolute;
    top: 20px;
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    pointer-events: none;
}

.label-before { left: 20px; }
.label-after { right: 20px; }

/* Canvas Area Hand Cursor */
.canvas-area.hand-active {
    cursor: grab;
}
.canvas-area.hand-active:active {
    cursor: grabbing;
}
/* ==========================================================================
   MODO NOITE (DARK MODE) - Adicione ao final do arquivo style.css
   ========================================================================== */

/* 1. Definição das Cores Escuras */
body.dark-mode {
    --bg-body: #111827;       /* Fundo da página (quase preto) */
    --bg-panel: #1f2937;      /* Painéis laterais e header (cinza escuro) */
    --text-main: #f3f4f6;     /* Texto principal (branco suave) */
    --text-muted: #9ca3af;    /* Texto secundário (cinza) */
    --border: #374151;        /* Bordas (cinza escuro) */
    --primary: #60a5fa;       /* Azul mais claro para dar contraste no escuro */
    
    /* Variáveis locais para elementos específicos */
    --input-bg: #374151;
    --hover-bg: #4b5563;
    --checker-dark: #2d3748;  /* Cor dos quadrados do fundo do canvas */
}

/* 2. Inputs e Elementos de Formulário */
body.dark-mode input[type="text"],
body.dark-mode input[type="number"],
body.dark-mode textarea,
body.dark-mode select {
    background-color: var(--input-bg);
    color: var(--text-main);
    border-color: var(--border);
}

/* 3. Botões Secundários e Ícones */
body.dark-mode .btn-secondary,
body.dark-mode .icon-btn {
    color: var(--text-main);
    background-color: transparent;
    border-color: var(--border);
}

body.dark-mode .btn-secondary:hover,
body.dark-mode .icon-btn:hover {
    background-color: var(--hover-bg);
    border-color: var(--text-muted);
}

body.dark-mode .btn-secondary.active,
body.dark-mode .tool-item.active {
    background-color: rgba(59, 130, 246, 0.2); /* Azul translúcido */
    color: #93c5fd;
    border-color: var(--primary);
}

body.dark-mode .tool-item:hover {
    background-color: var(--hover-bg);
}

/* 4. Ajuste do Fundo Xadrez (Canvas Area) */
body.dark-mode .canvas-area {
    background-color: #0f172a; /* Fundo base bem escuro */
    /* Recria o padrão xadrez com cores escuras para não ofuscar */
    background-image: 
        linear-gradient(45deg, var(--checker-dark) 25%, transparent 25%), 
        linear-gradient(-45deg, var(--checker-dark) 25%, transparent 25%), 
        linear-gradient(45deg, transparent 75%, var(--checker-dark) 75%), 
        linear-gradient(-45deg, transparent 75%, var(--checker-dark) 75%);
}

body.dark-mode .canvas-area.drag-over {
    background-color: rgba(59, 130, 246, 0.2);
}

/* 5. Componentes Diversos */
body.dark-mode .empty-state {
    background-color: rgba(31, 41, 55, 0.6);
    border-color: var(--border);
    color: var(--text-muted);
}

body.dark-mode .stickers-grid {
    background-color: #111827;
    border: 1px solid var(--border);
}

body.dark-mode .sticker-item:hover {
    background-color: var(--hover-bg);
}

/* Ajuste dos Toasts (Notificações) */
body.dark-mode .toast {
    background-color: var(--bg-panel);
    color: var(--text-main);
    border: 1px solid var(--border);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

/* Ajuste do Painel de Exportação (rodapé da direita) */
body.dark-mode .export-area {
    background-color: #111827;
    border-top-color: var(--border);
}

/* Scrollbar escura para Chrome/Safari/Edge */
body.dark-mode ::-webkit-scrollbar-track {
    background: var(--bg-body);
}
body.dark-mode ::-webkit-scrollbar-thumb {
    background: var(--border);
}
body.dark-mode ::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}
/* Correção do Botão 'Abrir Imagem' no Modo Noite */
body.dark-mode .btn-upload {
    background-color: transparent;   /* Remove o fundo branco sólido */
    color: var(--text-main);         /* Texto na cor clara padrão */
    border: 1px solid var(--border); /* Adiciona a borda para igualar aos outros */
}

body.dark-mode .btn-upload:hover {
    background-color: var(--hover-bg); /* Efeito hover igual aos outros botões */
    border-color: var(--text-muted);
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

#proBadge {
    animation: pulse 3s infinite;
}
/* Correção do Modal no Modo Noite */
body.dark-mode .modal-content {
    background: var(--bg-panel); /* Fundo cinza escuro */
}

body.dark-mode #authSwitchText {
    /* Garante que o texto 'Não tem conta?' contraste */
    color: var(--text-muted) !important; 
}
/* === HISTÓRICO VISUAL === */
#historyPanel {
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#historyContent {
    padding: 15px;
}

.history-item {
    position: relative;
    overflow: hidden;
}

.history-item img {
    transition: transform 0.2s ease;
}

.history-item:hover img {
    transform: scale(1.05);
}

/* Scrollbar customizada para o histórico */
#historyContent::-webkit-scrollbar {
    width: 6px;
}

#historyContent::-webkit-scrollbar-track {
    background: var(--bg-body);
}

#historyContent::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

#historyContent::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Modo escuro */
body.dark-mode #historyPanel {
    background: var(--bg-panel);
    border-left-color: var(--border);
}

body.dark-mode .history-item {
    background: var(--bg-body) !important;
}

body.dark-mode .history-item img {
    background: #0f172a !important;
}