@import url('https://fonts.googleapis.com/css2?family=VT323&display=swap');

:root {
    --lcd-bg: #c4d4a8;
    --lcd-off: #b0c095;
    --lcd-on: #1f2216;
    --case-color: #f0f0f0;
    --axis-color: rgba(255, 0, 0, 0.5);
    --grid-color: rgba(255, 255, 255, 0.2);

    --cols: 64;
    --rows: 48;
    --pixel-size: min(1.96vh, 1.96vw);
}

* { box-sizing: border-box; user-select: none; }

body {
    margin: 0; padding: 0; background: #222 url("../bg.jpg") repeat;
    font-family: 'VT323', monospace; min-height: 100vh;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 20px 0;
}

.device-case {
    background-color: var(--case-color);
    width: 95%; max-width: 1200px;
    max-height: 95vh;
    border-radius: 30px; padding: 20px 33px 21px 20px;
    display: flex; flex-direction: column; gap: 15px;
    box-shadow: inset -5px -5px 15px rgba(0,0,0,0.2), 0 0 20px rgba(0,0,0,0.5);
    position: relative;
}

.main-content {
    display: flex; flex-direction: row; gap: 20px; flex: 1; min-height: 0;
}

/* COLUNA ESQUERDA - mais larga para evitar quebras */
.left-column {
    flex: 0 0 43%;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    padding-right: 10px;
}

/* COLUNA DIREITA - 60% */
.right-column {
    flex: 0 0 57%;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    padding: 10px;
}

.screen-bezel {
    background-color: #555;
    padding: 30px 32px 90px 32px; /* Aumentado padding superior e inferior para alinhar com área de funções */
    border-radius: 15px;
    width: 100%;
    max-height: calc(95vh - 100px);
    display: flex; justify-content: center; flex-direction: column; align-items: center;
    box-shadow: inset 2px 2px 5px rgba(0,0,0,0.5);
    position: relative;
}

.brand-logo {
    position: absolute;
    bottom: 12px;
    left: 32px; right: 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #aaa;
    font-size: 14px;
    letter-spacing: 2px;
    opacity: 0.8;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
    line-height: 1.4;
    padding-top: 12px;
}

.brand-version {
    flex: 1;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.brand-title {
    font-size: 16px;
    letter-spacing: 3px;
}

.history-btn {
    background: #c4d4a8;
    color: #1f2216;
    border: none;
    border-radius: 5px;
    padding: 16px 24px;
    cursor: pointer;
    font-family: 'VT323', monospace;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 6px rgba(0,0,0,0.3);
    transition: all 0.2s;
}

.history-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 10px rgba(0,0,0,0.4);
}

.history-btn:active:not(:disabled) {
    transform: translateY(1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.history-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.history-btn .material-symbols-outlined {
    font-size: 24px;
}
.release-link {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    color: inherit;
    font: inherit;
    cursor: pointer;
}
.release-link:hover { color: #e6a800; }
.material-symbols-outlined {
    font-family: 'Material Symbols Outlined';
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
    font-size: 18px;
    line-height: 1;
    display: inline-block;
    letter-spacing: 0;
    font-feature-settings: 'liga';
}

.brand-copyright {
    font-size: 15px;
    text-transform: lowercase;
    letter-spacing: 1px;
}

.lcd-grid {
    background-color: var(--lcd-bg);
    display: grid;
    grid-template-columns: repeat(var(--cols), 1fr);
    grid-template-rows: repeat(var(--rows), 1fr);
    gap: 1px; padding: 4px;
    border: 2px solid #889675;
    box-shadow: inset 2px 2px 4px rgba(0,0,0,0.2);
    width: 100%;
    max-height: calc(95vh - 200px); /* Ajustado para acomodar os botões de color schema */
    aspect-ratio: 64/48;
    cursor: crosshair; position: relative;
}

.pixel {
    background-color: var(--lcd-off); opacity: 0.2;
    border-radius: 10%; transition: background-color 0.05s; position: relative;
}
.pixel.active {
    background-color: var(--lcd-on); opacity: 1;
    box-shadow: 1px 1px 0px rgba(0,0,0,0.15);
}
.pixel.shade {
    background-color: var(--lcd-on);
    opacity: 0.5;
}

/* Eixos */
.pixel.axis-x::before {
    content: ''; position: absolute;
    right: -1px; top: 0; bottom: 0;
    width: 2px; background: var(--axis-color);
    z-index: 10; pointer-events: none; display: block;
}

.pixel.axis-y::after {
    content: ''; position: absolute;
    bottom: -1px; left: 0; right: 0;
    height: 2px; background: var(--axis-color);
    z-index: 10; pointer-events: none; display: block;
}

/* Ocultar eixos no modo preview */
.lcd-grid.preview-mode .pixel.axis-x::before,
.lcd-grid.preview-mode .pixel.axis-y::after {
    display: none;
}

/* Barra de pincel */
.brush-toolbar {
    display: flex; gap: 6px; width: 100%;
}
.brush-btn {
    flex: 1; border: none; border-radius: 6px; padding: 8px 10px;
    background: #666; color: #fff; cursor: pointer; font-family: 'VT323'; font-size: 1rem;
    box-shadow: 0 2px 0 #444; display: flex; justify-content: center; align-items: center; gap: 6px;
}
.brush-btn.active { background: #e6a800; color: #111; box-shadow: 0 2px 0 #b38300; }
.brush-btn:active { transform: translateY(2px); box-shadow: none; }

/* Barra de tamanho do brush */
.brush-size-toolbar {
    display: flex; gap: 6px; width: 100%;
}
.size-btn {
    flex: 1; border: none; border-radius: 6px; padding: 8px 10px;
    background: #888; color: #fff; cursor: pointer; font-family: 'VT323'; font-size: 1rem;
    box-shadow: 0 2px 0 #555; display: flex; justify-content: center; align-items: center;
}
.size-btn.active { background: #33cc33; color: #111; box-shadow: 0 2px 0 #228822; }
.size-btn:active { transform: translateY(2px); box-shadow: none; }

/* Painel Principal */
.studio-panel {
    flex: 1; width: 100%; background: #e0e0e0;
    border: 2px solid #999; border-radius: 10px; padding: 10px;
    display: flex; flex-direction: column; gap: 8px; overflow-y: auto;
    position: relative;
}

.studio-header {
    display: flex; justify-content: space-between; align-items: center;
    border-bottom: none; padding-bottom: 5px;
}

.title-label { font-size: 1.2rem; color: #444; font-weight: bold; }

.btn-main-clear, .anim-toggle, .btn-undo, .btn-redo, .btn-preview, .btn-move {
    color: white; border: none; padding: 6px 10px;
    border-radius: 4px; cursor: pointer; font-family: inherit; font-size: 0.95rem;
    box-shadow: 0 2px 0 rgba(0,0,0,0.3); white-space: nowrap;
}

.btn-main-clear { background: #cc3333; }
.btn-main-clear:active { transform: translateY(2px); box-shadow: none; }

.anim-toggle { background: #888; margin-left: 0; }
.anim-toggle.active { background: #e6a800; color: #000; }

.btn-preview { background: #888; margin-left: 0; }
.btn-preview.active { background: #cc6600; color: #fff; }
.btn-preview:active { transform: translateY(2px); box-shadow: none; }

.btn-move { background: #888; margin-left: 0; }
.btn-move.active { background: #9933cc; color: #fff; }
.btn-move:active { transform: translateY(2px); box-shadow: none; }

.btn-undo { background: #6666cc; }
.btn-undo:active { transform: translateY(2px); box-shadow: none; }
.btn-undo:disabled { background: #999; cursor: not-allowed; opacity: 0.5; }

.btn-redo { background: #66cc66; }
.btn-redo:active { transform: translateY(2px); box-shadow: none; }
.btn-redo:disabled { background: #999; cursor: not-allowed; opacity: 0.5; }

.play-pause-btn { background: #33cc33 !important; width: 72px; min-width: 72px; color: white; border: 1px solid #228822; }
.play-pause-btn.pause { background: #cc3333 !important; border-color: #992222; }

.btn-center {
    color: #fff; border: none; padding: 6px 12px;
    border-radius: 4px; cursor: pointer; font-family: inherit; font-size: 1rem;
    box-shadow: 0 2px 0 rgba(0,0,0,0.3); background: #555; margin-left: 0;
}
.btn-center:active { transform: translateY(2px); box-shadow: none; }

.btn-row { display: flex; gap: 4px; flex-wrap: nowrap; align-items: stretch; overflow-x: auto; }
.btn-row button:active {
    transform: none !important; /* evita deslocar e gerar scroll ao manter pressionado */
    box-shadow: inherit;
}
.row-divider { width: 100%; height: 2px; background: #bbb; margin: 6px 0; border-radius: 2px; }

.btn-reflect {
    color: #fff; border: none; padding: 6px 12px;
    border-radius: 4px; cursor: pointer; font-family: inherit; font-size: 1rem;
    box-shadow: 0 2px 0 #555; background: #777; flex: 1;
}
.btn-reflect:active { transform: translateY(2px); box-shadow: none; }

/* Seções de Ações (Centralizar e Espelhar) */
.action-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.section-header {
    background: #999;
    color: #fff;
    padding: 6px 12px;
    border-radius: 4px;
    font-family: inherit;
    font-size: 1rem;
    text-align: center;
    font-weight: bold;
    letter-spacing: 1px;
    cursor: default;
    user-select: none;
}

.section-actions {
    display: flex;
    gap: 4px;
}

.btn-action {
    flex: 1;
    color: #fff;
    border: none;
    padding: 6px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.95rem;
    box-shadow: 0 2px 0 rgba(0,0,0,0.3);
    background: #555;
}

.btn-action:active {
    transform: translateY(2px);
    box-shadow: none;
}

/* Controles de Animação */
.anim-controls {
    display: none; background: #d4d4d4; padding: 5px;
    border: 1px dashed #999; border-radius: 5px; flex-direction: column; gap: 5px;
}
.anim-controls.visible { display: flex; }

.frames-row { display: flex; gap: 5px; justify-content: center; }
.frame-btn {
    width: 30px; height: 30px; border-radius: 4px; border: none;
    background: #bbb; cursor: pointer; font-family: inherit; font-size: 1rem;
    box-shadow: 0 2px 0 #888;
}
.frame-btn.selected { background: #e6a800; color: black; font-weight: bold; transform: translateY(1px); box-shadow: 0 1px 0 #b38300; }
.play-btn { background: #33cc33; width: 40px; color: white; }
.pause-btn { background: #cc3333; width: 40px; color: white; }

.copy-row { display: flex; gap: 4px; justify-content: flex-start; margin-top: 3px; flex-wrap: nowrap; overflow-x: auto; }
#copyOptions { width: 100%; }
.mini-btn { padding: 2px 6px; font-size: 0.8rem; background: #999; border: none; border-radius: 3px; cursor: pointer; color: white; }

.input-group { display: flex; gap: 5px; margin-top: 5px; align-items: stretch; }
input[type="text"] {
    flex: 1; padding: 5px 7px; font-family: 'VT323', monospace; font-size: 1.1rem;
    text-transform: uppercase; border: 2px solid #999; border-radius: 4px; background: #fff;
}
.btn-save { background: #3366cc; box-shadow: 0 2px 0 #224499; font-weight: bold; color: white; border: none; padding: 6px 12px; border-radius: 4px; cursor: pointer; font-family: inherit; font-size: 1rem; }
.btn-new { background: #33cc33; color: white; border: none; padding: 6px 12px; border-radius: 4px; cursor: pointer; font-family: 'VT323'; font-size: 1rem; box-shadow: 0 2px 0 #228822; }
.btn-new:active { transform: translateY(2px); box-shadow: none; }

/* LISTA */
.asset-list {
    list-style: none; padding: 0; margin: 0; flex: 1; overflow-y: auto;
    border: 2px inset #ccc; background: #f4f4f4; border-radius: 4px;
}
.asset-item {
    padding: 6px 8px; border-bottom: 1px solid #ddd; display: flex;
    justify-content: space-between; align-items: center; font-size: 1.1rem;
}
.asset-item:nth-child(even) { background: #e9e9e9; }
.asset-item:hover { background: #fff; }
.asset-item.active {
    background: #c4d4a8 !important;
    border-left: 4px solid #889675;
    padding-left: 4px;
    font-weight: bold;
}

/* Feedback visual ao arrastar para reordenar */
.asset-item.dragging {
    opacity: 0.7;
    transform: scale(1.3);
    z-index: 2;
}
.asset-item.drag-over {
    outline: 2px dashed #666;
    outline-offset: 3px;
}

.asset-info { display: flex; align-items: center; gap: 8px; flex: 1; overflow: hidden; }
.asset-type { font-size: 0.75rem; background: #ccc; padding: 1px 4px; border-radius: 3px; color: #444; }
.asset-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 1rem;}

.item-actions { display: flex; gap: 4px; }
.action-icon-btn {
    border: none; border-radius: 3px; width: 28px; height: 26px;
    padding: 0; cursor: pointer; display: flex; align-items: center; justify-content: center;
    font-size: 1rem; color: white; transition: transform 0.1s;
}
.action-icon-btn:active { transform: scale(0.9); }

.btn-copy { background: #8833cc; }
.btn-edit { background: #3366cc; }
.btn-del { background: #cc3333; }
.btn-gif { background: #e6a800; }

/* Rodapé IO */
.io-row { display: flex; gap: 5px; margin-top: 5px; flex-wrap: wrap; }
.io-btn {
    flex: 1; background: #444; color: white; border: none; padding: 10px;
    font-family: inherit; font-size: 1.1rem; cursor: pointer; border-radius: 4px;
    box-shadow: 0 3px 0 #222; display: flex; justify-content: center; gap: 10px; align-items: center;
}
.io-btn-save { background: #2d8a2d; box-shadow: 0 3px 0 #1a521a; }
.io-btn:active { transform: translateY(3px); box-shadow: none; }
.io-btn-add { background: #3366cc; box-shadow: 0 3px 0 #224499; }
.io-btn-import { background: #555; box-shadow: 0 3px 0 #333; }
.io-btn-image { background: #cc6600; box-shadow: 0 3px 0 #994400; }
.io-btn-gif { background: #e6a800; box-shadow: 0 3px 0 #b38300; color: #111; }

/* Toast */
.toast {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    background: #c4d4a8; color: #1f2216; padding: 15px 30px;
    border-radius: 5px; font-size: 1.5rem; opacity: 0; pointer-events: none;
    transition: opacity 0.2s; z-index: 100; border: 1px solid #889675; box-shadow: 0 0 10px #889675;
    text-align: center; font-weight: bold;
}
.toast.show { opacity: 1; }

/* Painel de colagem manual */
.manual-panel {
    display: none; flex-direction: column; gap: 6px; margin-top: 6px;
    background: #dcdcdc; border: 1px dashed #999; border-radius: 6px; padding: 8px;
}
.manual-panel.visible { display: flex; }
.manual-panel textarea {
    width: 100%; min-height: 100px; resize: vertical;
    font-family: 'VT323', monospace; font-size: 1rem;
    padding: 6px; border: 2px solid #bbb; border-radius: 4px;
    background: #f9f9f9;
}
.manual-actions { display: flex; gap: 6px; justify-content: flex-end; }
.manual-actions .btn-apply { background: #2d8a2d; color: #fff; border: none; padding: 6px 12px; border-radius: 4px; cursor: pointer; }
.manual-actions .btn-cancel { background: #999; color: #fff; border: none; padding: 6px 12px; border-radius: 4px; cursor: pointer; }

/* FOOTER */
.app-footer {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 25px 10px 15px;
    min-height: 40px; /* altura aproximada do botão principal */
    background: #d0d0d0;
    border-radius: 8px;
    font-size: 0.9rem;
    color: #555;
}

.footer-left a, .footer-right a {
    color: #3366cc;
    text-decoration: none;
    cursor: pointer;
    transition: color 0.2s;
}

.footer-left a:hover, .footer-right a:hover {
    color: #e6a800;
    text-decoration: underline;
}

/* MODAL */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 200;
    align-items: center;
    justify-content: center;
}

.modal-overlay.visible {
    display: flex;
}

.modal-content {
    background: #f0f0f0;
    border-radius: 15px;
    padding: 25px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    border: 3px solid #999;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    border-bottom: 2px solid #999;
    padding-bottom: 10px;
}

.modal-title {
    font-size: 1.5rem;
    color: #333;
    font-weight: bold;
}

.modal-close {
    background: #cc3333;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 5px 12px;
    font-family: 'VT323', monospace;
    font-size: 1rem;
    cursor: pointer;
    box-shadow: 0 2px 0 #992222;
}

.modal-close:active {
    transform: translateY(2px);
    box-shadow: none;
}

.modal-body {
    font-size: 1.1rem;
    line-height: 1.6;
    color: #444;
}

.modal-body h3 {
    color: #333;
    margin-top: 15px;
    margin-bottom: 8px;
    font-size: 1.3rem;
}

.modal-body ul {
    margin-left: 20px;
    margin-bottom: 15px;
}

.modal-body li {
    margin-bottom: 5px;
}

.modal-body strong {
    color: #e6a800;
}

/* MOBILE NOTICE */
.mobile-notice {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 30px;
    min-height: 100vh;
    padding: 40px 20px;
}

.mobile-notice.visible {
    display: flex;
}

.mobile-logo {
    width: 150px;
    height: 150px;
    object-fit: contain;
    filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.3));
}

.mobile-message {
    font-size: 1.5rem;
    color: #000;
    text-align: center;
    letter-spacing: 2px;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(255, 255, 255, 0.3);
}

/* MODAL DE ESCOLHA GIF */
.gif-choice-modal {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 250;
    align-items: center;
    justify-content: center;
}

.gif-choice-modal.visible {
    display: flex;
}

.gif-choice-content {
    background: #c4d4a8;
    border-radius: 15px;
    padding: 30px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    border: 4px solid #889675;
    text-align: center;
}

.gif-choice-title {
    font-size: 1.5rem;
    color: #1f2216;
    font-weight: bold;
    margin-bottom: 20px;
    text-transform: uppercase;
}

.gif-choice-buttons {
    display: flex;
    gap: 15px;
    margin-top: 25px;
}

.gif-choice-btn {
    flex: 1;
    padding: 15px 20px;
    font-family: 'VT323', monospace;
    font-size: 1.2rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    color: white;
    font-weight: bold;
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.3);
    transition: transform 0.1s;
}

.gif-choice-btn:active {
    transform: translateY(4px);
    box-shadow: none;
}

.gif-choice-btn.with-bg {
    background: #33cc33;
}

.gif-choice-btn.without-bg {
    background: #3366cc;
}

/* === COLOR SCHEMA SELECTOR === */
.color-schema-section {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: auto 0 15px 0;
}

.color-schema-label {
    font-size: 1rem;
    color: #aaa;
    letter-spacing: 2px;
    font-weight: bold;
    text-transform: uppercase;
}

.color-schema-buttons {
    display: flex;
    gap: 8px;
    flex: 1;
    max-width: 550px;
}

.color-pill {
    flex: 1;
    height: 32px;
    border-radius: 16px;
    border: 3px solid transparent;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    display: flex;
    transition: all 0.2s;
    box-shadow: 0 3px 6px rgba(0,0,0,0.3);
}

.color-pill:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 10px rgba(0,0,0,0.4);
}

.color-pill.active {
    border-color: #fff;
    box-shadow: 0 0 12px rgba(255,255,255,0.6), 0 3px 6px rgba(0,0,0,0.3);
}

.color-pill-half {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Esquema 1: Verde Clarinho (Atual) */
.color-pill-classic .color-pill-half:first-child {
    background: #c4d4a8;
}
.color-pill-classic .color-pill-half:last-child {
    background: #1f2216;
}

/* Esquema 2: Fósforo Verde */
.color-pill-green .color-pill-half:first-child {
    background: #000000;
}
.color-pill-green .color-pill-half:last-child {
    background: #00ff41;
    box-shadow: inset 0 0 10px rgba(0,255,65,0.5);
}

/* Esquema 3: Fósforo Laranja */
.color-pill-orange .color-pill-half:first-child {
    background: #000000;
}
.color-pill-orange .color-pill-half:last-child {
    background: #ff6600;
    box-shadow: inset 0 0 10px rgba(255,102,0,0.5);
}
