/* =============================================
 * ZPL Exploder — Estilos (versão PHP)
 * Desenvolvido por Sander Lemos Mizael
 * sander@motivo.digital
 * ============================================= */

@font-face {
    font-family: 'MotivoDigital';
    src: url('motivo-digital.ttf') format('truetype');
    font-weight: lighter;
    font-style: normal;
    font-display: swap;
}

.motivo-font {
    font-family: 'MotivoDigital', sans-serif;
}

/* ---- Reset e Base ---- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --color-bg: #0f1117;
    --color-surface: #1a1d27;
    --color-surface-alt: #222633;
    --color-border: #2e3346;
    --color-border-hover: #4a5170;
    --color-primary: #6c8dfa;
    --color-primary-soft: rgba(108, 141, 250, 0.12);
    --color-accent: #f0b429;
    --color-accent-soft: rgba(240, 180, 41, 0.12);
    --color-success: #34d399;
    --color-error: #f87171;
    --color-text: #e2e4ed;
    --color-text-muted: #8b8fa8;
    --color-text-dim: #5c6280;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

body {
    font-family: var(--font-sans);
    background: var(--color-bg);
    color: var(--color-text);
    min-height: 100vh;
    line-height: 1.5;
}

/* ---- Layout ---- */
.app-wrapper {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
}

/* ---- Cabeçalho / Navbar ---- */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--color-border);
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
}

.navbar-logo {
    width: 56px;
    height: 56px;
    flex-shrink: 0;
}

.navbar-title {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--color-text);
}

.navbar-title span {
    color: var(--color-primary);
}

.navbar-subtitle {
    font-size: 13px;
    color: var(--color-text-muted);
    font-weight: 400;
}

.navbar-credits {
    font-size: 13px;
    color: var(--color-text-muted);
    text-align: right;
    line-height: 1.6;
}

.social-links {
    display: flex;
    gap: 6px;
    margin-top: 4px;
    justify-content: flex-end;
}

.social-links a {
    color: var(--color-text-muted);
    text-decoration: none;
    transition: color 0.2s, transform 0.2s, background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: rgba(255,255,255,0.04);
}

.social-links a:hover {
    transform: translateY(-2px);
    background: rgba(255,255,255,0.1);
}

.social-links a[title="LinkedIn"]:hover    { color: #0A66C2; }
.social-links a[title="Behance"]:hover     { color: #1769FF; }
.social-links a[title="Instagram"]:hover   { color: #E4405F; }
.social-links a[title="Steam"]:hover       { color: #ffffff; }

/* ---- Área de Entrada (Editor) ---- */
.input-section {
    display: block;
    margin-bottom: 24px;
}

/* Drag-and-drop no editor */
.editor-wrapper.dragover {
    outline: 2px dashed var(--color-primary);
    outline-offset: -2px;
    background: var(--color-primary-soft);
}

/* Editor ZPL com Syntax Highlighting */
.editor-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Wrapper do editor overlay (textarea transparente + highlight por baixo) */
.editor-wrapper {
    position: relative;
    display: flex;
    min-height: 300px;
    max-height: 600px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: border-color 0.2s, min-height 0.3s, max-height 0.3s;
}

.editor-wrapper.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    min-height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    border: none;
    z-index: 9999;
}

.editor-fullscreen-btn {
    position: absolute;
    top: 8px;
    right: 20px;
    z-index: 4;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    color: var(--color-text-muted);
    font-size: 18px;
    width: 30px;
    height: 30px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    line-height: 1;
}

.editor-fullscreen-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: var(--color-text);
}

body.editor-fullscreen-active {
    overflow: hidden;
}

.editor-wrapper:focus-within {
    border-color: var(--color-primary);
}

/* Números de linha */
.editor-line-numbers {
    flex-shrink: 0;
    width: 44px;
    padding: 16px 8px 16px 0;
    background: var(--color-bg);
    border-right: 1px solid var(--color-border);
    text-align: right;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.6;
    color: var(--color-text-dim);
    user-select: none;
    overflow: hidden;
    white-space: pre;
}

/* Área de edição (contém highlight + textarea sobrepostos) */
.editor-code-area {
    position: relative;
    flex: 1;
    overflow: hidden;
}

/* Camada de highlight (por baixo) */
.editor-highlight {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    min-height: 100%;
    margin: 0;
    padding: 16px;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.6;
    white-space: pre;
    color: #b0b8c8;
    pointer-events: none;
    z-index: 1;
    overflow: hidden;
}

/* Textarea transparente (por cima para capturar input) */
.editor-textarea {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    min-height: 100%;
    margin: 0;
    padding: 16px;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.6;
    white-space: pre;
    color: transparent;
    caret-color: var(--color-text);
    background: transparent;
    border: none;
    outline: none;
    resize: none;
    z-index: 2;
    overflow: auto;
    -webkit-text-fill-color: transparent;
}

.editor-textarea::placeholder {
    -webkit-text-fill-color: var(--color-text-dim);
    color: var(--color-text-dim);
}

/* ---- Tokens de Syntax Highlight ZPL ---- */
.zpl-block-delim  { color: #f0b429; font-weight: 700; }   /* ^XA, ^XZ */
.zpl-comment      { color: #6b7394; font-style: italic; }  /* ^FX ... */
.zpl-template     { color: #e879f9; font-weight: 600; }    /* ^DF, ^XF */
.zpl-variable     { color: #38bdf8; }                       /* ^FN */
.zpl-field-data   { color: #a3e635; }                       /* ^FD...^FS */
.zpl-position     { color: #6c8dfa; }                       /* ^FO, ^FT */
.zpl-font         { color: #fb923c; }                       /* ^A0, ^CF */
.zpl-barcode      { color: #f472b6; }                       /* ^BC, ^BQ, ^B3, ^BY */
.zpl-graphic      { color: #2dd4bf; }                       /* ^GB, ^GC, ^GD, ^GE, ^GF */
.zpl-config       { color: #facc15; }                       /* ^PW, ^LL, ^CI, ^LH, etc */
.zpl-quantity     { color: #34d399; font-weight: 600; }     /* ^PQ, ^SN */
.zpl-separator    { color: #4a5170; }                       /* ^FS */
.zpl-storage      { color: #c084fc; }                       /* R:, E: */
.zpl-command      { color: #94a3b8; }                       /* Outros comandos ^ ou ~ */

.editor-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

/* ---- Escalonamento de DPI ---- */
.dpi-scaler {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    padding-left: 12px;
    border-left: 1px solid var(--color-border);
}

.dpi-scaler select {
    background: var(--color-surface);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    font-size: 12px;
    font-family: 'JetBrains Mono', monospace;
    cursor: pointer;
    transition: border-color 0.2s;
}

.dpi-scaler select:hover,
.dpi-scaler select:focus {
    border-color: var(--color-primary);
    outline: none;
}

.dpi-arrow {
    color: var(--color-text-dim);
    font-size: 14px;
    font-weight: 600;
}

/* ---- Botões ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn svg {
    flex-shrink: 0;
}

.btn-primary {
    background: var(--color-primary);
    color: #fff;
}

.btn-primary:hover {
    background: #5a7de8;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(108, 141, 250, 0.3);
}

.btn-secondary {
    background: var(--color-surface-alt);
    color: var(--color-text-muted);
    border: 1px solid var(--color-border);
}

.btn-secondary:hover {
    color: var(--color-text);
    border-color: var(--color-border-hover);
}

.btn-danger {
    background: rgba(248, 113, 113, 0.15);
    color: var(--color-error);
    border: 1px solid rgba(248, 113, 113, 0.25);
}

.btn-danger:hover {
    background: rgba(248, 113, 113, 0.25);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-sm svg {
    vertical-align: -2px;
    margin-right: 4px;
}

/* ---- Status / Info Panels ---- */
.status-bar {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 24px;
    display: none;
}

.status-bar.visible {
    display: block;
}

.status-loading {
    color: var(--color-primary);
    font-size: 14px;
}

.status-success {
    color: var(--color-success);
    font-weight: 600;
    font-size: 14px;
}

.status-error {
    color: var(--color-error);
    font-weight: 600;
    font-size: 14px;
}

.status-info {
    color: var(--color-text-muted);
    font-size: 14px;
}

.info-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    margin: 4px 2px;
}

.info-badge--dimensions {
    background: rgba(108, 141, 250, 0.1);
    border: 1px solid rgba(108, 141, 250, 0.2);
    color: var(--color-primary);
}

.info-badge--config {
    background: var(--color-accent-soft);
    border: 1px solid rgba(240, 180, 41, 0.2);
    color: var(--color-accent);
}

.info-badge--serial {
    background: rgba(52, 211, 153, 0.1);
    border: 1px solid rgba(52, 211, 153, 0.2);
    color: var(--color-success);
}

/* Log de parsing */
.parse-log {
    margin-top: 12px;
}

.parse-log summary {
    cursor: pointer;
    font-size: 12px;
    color: var(--color-text-muted);
    font-weight: 500;
}

.parse-log pre {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-top: 8px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--color-text-muted);
    max-height: 180px;
    overflow-y: auto;
    line-height: 1.7;
}

/* ---- Grid de Etiquetas ---- */
.labels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.label-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.label-card:hover {
    border-color: var(--color-border-hover);
    box-shadow: var(--shadow);
}

/* Imagem da etiqueta — fundo branco para legibilidade */
.label-image-wrapper {
    background: #ffffff;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: zoom-in;
    min-height: 160px;
}

.label-image-wrapper img {
    max-width: 100%;
    max-height: 300px;
    object-fit: contain;
}

/* Detalhes abaixo da imagem */
.label-details {
    padding: 14px 16px;
    border-top: 1px solid var(--color-border);
}

.label-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 6px;
}

.label-meta {
    font-size: 12px;
    color: var(--color-text-muted);
    margin-bottom: 4px;
}

.label-vars {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 8px;
}

.label-var {
    font-family: var(--font-mono);
    font-size: 11px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    padding: 2px 7px;
    border-radius: 4px;
    color: var(--color-text-muted);
}

.label-actions {
    display: flex;
    gap: 6px;
    padding: 0 16px 14px;
}

/* ---- Fullscreen Modal ---- */
.fullscreen-overlay {
    display: none;
    position: fixed;
    z-index: 9999;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    cursor: zoom-out;
    justify-content: center;
    align-items: center;
}

.fullscreen-overlay.active {
    display: flex;
}

.fullscreen-overlay img {
    max-width: 92%;
    max-height: 92%;
    object-fit: contain;
    border-radius: var(--radius-sm);
    box-shadow: 0 0 60px rgba(255, 255, 255, 0.08);
    background: #fff;
    padding: 20px;
}

.fullscreen-close {
    position: absolute;
    top: 20px;
    right: 28px;
    color: #fff;
    font-size: 36px;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s;
    line-height: 1;
}

.fullscreen-close:hover {
    opacity: 1;
}

/* ---- Footer ---- */
.app-footer {
    margin-top: 48px;
    padding: 24px 0;
    border-top: 1px solid var(--color-border);
    text-align: center;
    font-size: 14px;
    color: var(--color-text-muted);
    line-height: 1.8;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.app-footer .footer-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    color: var(--color-text);
}

.app-footer .footer-brand span {
    color: var(--color-primary);
}

.app-footer .footer-brand img {
    width: 22px;
    height: 22px;
    opacity: 0.7;
}

.app-footer .footer-version {
    font-size: 11px;
    color: var(--color-text-dim);
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    padding: 1px 6px;
    font-family: var(--font-mono);
}

.app-footer a {
    color: inherit;
    text-decoration: none;
}

.app-footer a:hover {
    text-decoration: underline;
    color: var(--color-primary);
}

/* ---- Responsividade ---- */
@media (max-width: 768px) {
    .app-wrapper {
        padding: 16px;
    }

    .navbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .navbar-credits {
        text-align: left;
    }

    .labels-grid {
        grid-template-columns: 1fr;
    }

    .editor-textarea {
        min-height: 180px;
    }
}

/* ---- Loading Overlay para Editor ---- */
.editor-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 17, 23, 0.85);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.editor-loading-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.editor-loading-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.editor-loading-text {
    color: var(--color-text);
    font-size: 14px;
    font-weight: 500;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ---- ZPL Command Tooltip ---- */
.zpl-tooltip {
    position: fixed;
    z-index: 10000;
    max-width: 360px;
    padding: 10px 14px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    font-size: 12px;
    line-height: 1.5;
    color: var(--color-text);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
}

.zpl-tooltip.visible {
    opacity: 1;
}

.zpl-tooltip-cmd {
    font-weight: 700;
    font-size: 13px;
    color: var(--color-primary);
    margin-bottom: 4px;
}

.zpl-tooltip-name {
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 4px;
}

.zpl-tooltip-desc {
    color: var(--color-text-muted);
}

.zpl-tooltip-syntax {
    margin-top: 6px;
    padding: 4px 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--color-text-muted);
}
