/* ============================================================
   SPACE ZPL TO PDF — Design System
   Clean white design with blue (#2563EB) and gray accents
   ============================================================ */

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

:root {
    /* Brand Colors */
    --blue-50: #EFF6FF;
    --blue-100: #DBEAFE;
    --blue-200: #BFDBFE;
    --blue-300: #93C5FD;
    --blue-400: #60A5FA;
    --blue-500: #3B82F6;
    --blue-600: #2563EB;
    --blue-700: #1D4ED8;
    --blue-800: #1E40AF;
    --blue-900: #1E3A8A;

    /* Gray Palette */
    --gray-25: #FCFCFD;
    --gray-50: #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-400: #9CA3AF;
    --gray-500: #6B7280;
    --gray-600: #4B5563;
    --gray-700: #374151;
    --gray-800: #1F2937;
    --gray-900: #111827;

    /* Semantic */
    --success: #10B981;
    --warning: #F59E0B;
    --error: #EF4444;

    /* Surfaces */
    --bg-primary: #FFFFFF;
    --bg-secondary: var(--gray-50);
    --bg-page: #F0F4F8;

    /* Typography */
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.06), 0 2px 4px -2px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.06), 0 4px 6px -4px rgba(0,0,0,0.04);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.06), 0 8px 10px -6px rgba(0,0,0,0.04);
    --shadow-blue: 0 4px 14px rgba(37, 99, 235, 0.25);

    /* Borders */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --border: 1px solid var(--gray-200);

    /* Transition */
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font);
    background: var(--bg-page);
    color: var(--gray-800);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* --- Header --- */
.header {
    background: var(--bg-primary);
    border-bottom: var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
    background: rgba(255,255,255,0.92);
}

.header-inner {
    max-width: 900px;
    margin: 0 auto;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo-link {
    display: flex;
    align-items: center;
    gap: 14px;
    text-decoration: none;
    color: inherit;
}

.logo-img {
    height: 24px;
    width: auto;
    object-fit: contain;
}

.logo-text {
    display: flex;
    flex-direction: column;
}

.logo-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--gray-800);
    letter-spacing: -0.3px;
}

.highlight {
    color: var(--blue-600);
}

.header-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 500;
    color: var(--blue-700);
    background: var(--blue-50);
    border: 1px solid var(--blue-100);
    border-radius: 100px;
}

.header-badge svg {
    color: var(--success);
}

/* --- Layout Global com Anúncios --- */
.site-layout {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 24px;
    max-width: 1350px; /* 900 (Main) + 320 (Sidebars) + margins */
    margin: 0 auto;
    padding: 0 24px;
    width: 100%;
    flex: 1;
}

/* Painéis Laterais */
.ad-sidebar {
    width: 160px;
    flex-shrink: 0;
    position: sticky;
    top: 100px;
    height: 600px;
    margin-top: 32px;
}

/* Espaço reservado para visualização */
.ad-placeholder {
    width: 100%;
    height: 100%;
    background: var(--gray-100);
    border: 1px dashed var(--gray-300);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-400);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-align: center;
}

/* Painel Mobile (Oculto no Desktop) */
.ad-mobile-wrapper {
    display: none;
    width: 100%;
    height: 100px;
    margin-bottom: 24px;
}

/* --- Main Central --- */
.main {
    flex: 1;
    max-width: 900px;
    padding: 32px 0 48px;
    width: 100%;
}

.container {
    width: 100%;
}

/* --- Hero --- */
.hero {
    text-align: center;
    margin-bottom: 32px;
    animation: fadeInUp 0.6s var(--ease) both;
}

.hero-title {
    font-size: 32px;
    font-weight: 800;
    color: var(--gray-900);
    line-height: 1.2;
    letter-spacing: -0.5px;
    margin-bottom: 12px;
}

.hero-subtitle {
    font-size: 16px;
    color: var(--gray-500);
    max-width: 560px;
    margin: 0 auto;
    line-height: 1.6;
}

/* --- Card --- */
.card {
    background: var(--bg-primary);
    border: var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.3s var(--ease);
    animation: fadeInUp 0.6s var(--ease) both;
}

.card:nth-child(2) { animation-delay: 0.1s; }
.card:nth-child(3) { animation-delay: 0.2s; }

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 24px;
    border-bottom: var(--border);
}

.card-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--blue-50);
    border-radius: var(--radius-sm);
    color: var(--blue-600);
    flex-shrink: 0;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-800);
    flex: 1;
}

.card-actions {
    display: flex;
    gap: 8px;
}

/* --- Action Buttons --- */
.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-600);
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s var(--ease);
    font-family: var(--font);
}

.action-btn:hover {
    background: var(--gray-100);
    color: var(--gray-800);
    border-color: var(--gray-300);
}

.action-btn.primary {
    background: var(--blue-600);
    color: white;
    border-color: var(--blue-600);
}

.action-btn.primary:hover {
    background: var(--blue-700);
    border-color: var(--blue-700);
}

/* --- Preset Grid --- */
.config-body {
    padding: 24px;
}

.config-group {
    margin-bottom: 24px;
}

.config-group:last-child {
    margin-bottom: 0;
}

.config-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 12px;
}

.preset-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.preset-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 18px 12px;
    background: var(--bg-primary);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.25s var(--ease);
    font-family: var(--font);
    text-align: center;
}

.preset-btn:hover {
    border-color: var(--blue-300);
    background: var(--blue-50);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.preset-btn.active {
    border-color: var(--blue-600);
    background: var(--blue-50);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.preset-btn.active .preset-icon {
    color: var(--blue-600);
}

.preset-icon {
    color: var(--gray-400);
    transition: color 0.2s var(--ease);
}

.preset-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700);
}

.preset-size {
    font-size: 12px;
    font-weight: 500;
    color: var(--gray-400);
}

.preset-btn.active .preset-name {
    color: var(--blue-700);
}

.preset-btn.active .preset-size {
    color: var(--blue-500);
}

/* --- Custom Dimensions --- */
.custom-dims {
    animation: fadeInDown 0.3s var(--ease) both;
}

.dims-row {
    display: flex;
    align-items: flex-end;
    gap: 16px;
}

.dim-field {
    flex: 1;
}

.dim-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-500);
    margin-bottom: 8px;
}

.input-with-unit {
    position: relative;
}

.dim-input {
    width: 100%;
    padding: 12px 48px 12px 16px;
    font-size: 16px;
    font-weight: 600;
    font-family: var(--font);
    color: var(--gray-800);
    background: var(--bg-primary);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-sm);
    outline: none;
    transition: all 0.2s var(--ease);
    -moz-appearance: textfield;
}

.dim-input::-webkit-inner-spin-button,
.dim-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
}

.dim-input:focus {
    border-color: var(--blue-500);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.input-unit {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-400);
    pointer-events: none;
}

.dim-separator {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-300);
    padding-bottom: 8px;
}

/* --- DPI Row --- */
.dpi-row {
    display: flex;
    gap: 10px;
}

.dpi-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 8px;
    background: var(--bg-primary);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: var(--font);
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-600);
    transition: all 0.2s var(--ease);
}

.dpi-btn:hover {
    border-color: var(--blue-300);
    background: var(--blue-50);
}

.dpi-btn.active {
    border-color: var(--blue-600);
    background: var(--blue-50);
    color: var(--blue-700);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.dpi-detail {
    font-size: 11px;
    font-weight: 500;
    color: var(--gray-400);
}

.dpi-btn.active .dpi-detail {
    color: var(--blue-400);
}

/* --- ZPL Card --- */
.zpl-body {
    padding: 24px;
}

.textarea-wrapper {
    position: relative;
}

.zpl-textarea {
    width: 100%;
    min-height: 240px;
    padding: 16px;
    font-size: 14px;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
    line-height: 1.6;
    color: var(--gray-800);
    background: var(--gray-50);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-md);
    outline: none;
    resize: vertical;
    transition: all 0.2s var(--ease);
    tab-size: 4;
}

.zpl-textarea::placeholder {
    color: var(--gray-400);
}

.zpl-textarea:focus {
    border-color: var(--blue-500);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
    background: var(--bg-primary);
}

.textarea-footer {
    display: flex;
    justify-content: space-between;
    padding: 10px 4px 0;
    font-size: 12px;
    color: var(--gray-400);
    font-weight: 500;
}

.label-count {
    color: var(--blue-500);
    font-weight: 600;
}

/* --- Upload Area --- */
.upload-area {
    margin-top: 16px;
    padding: 24px;
    border: 2px dashed var(--gray-200);
    border-radius: var(--radius-md);
    text-align: center;
    transition: all 0.3s var(--ease);
}

.upload-area.drag-over {
    border-color: var(--blue-400);
    background: var(--blue-50);
}

.upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font);
    color: var(--blue-600);
    background: var(--blue-50);
    border: 1px solid var(--blue-200);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s var(--ease);
}

.upload-btn:hover {
    background: var(--blue-100);
    border-color: var(--blue-300);
    transform: translateY(-1px);
}

.upload-hint {
    margin-top: 10px;
    font-size: 13px;
    color: var(--gray-400);
}

/* --- Convert Section --- */
.convert-section {
    text-align: center;
    margin: 28px 0;
    animation: fadeInUp 0.6s var(--ease) 0.3s both;
}

.convert-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 16px 48px;
    font-size: 16px;
    font-weight: 700;
    font-family: var(--font);
    color: white;
    background: linear-gradient(135deg, var(--blue-600) 0%, var(--blue-700) 100%);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.3s var(--ease);
    box-shadow: var(--shadow-blue);
    position: relative;
    overflow: hidden;
}

.convert-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent 0%, rgba(255,255,255,0.1) 100%);
    opacity: 0;
    transition: opacity 0.3s var(--ease);
}

.convert-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(37, 99, 235, 0.35);
}

.convert-btn:hover:not(:disabled)::after {
    opacity: 1;
}

.convert-btn:active:not(:disabled) {
    transform: translateY(0);
}

.convert-btn:disabled {
    background: var(--gray-300);
    box-shadow: none;
    cursor: not-allowed;
    opacity: 0.7;
}

.convert-btn.loading {
    pointer-events: none;
}

.convert-btn.loading .convert-icon,
.convert-btn.loading span {
    opacity: 0.4;
}

.convert-hint {
    margin-top: 12px;
    font-size: 13px;
    color: var(--gray-400);
}

/* Spinner */
.convert-loader {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

/* --- Preview --- */
.preview-card {
    animation: fadeInUp 0.5s var(--ease) both;
}

.preview-body {
    padding: 24px;
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
}

.preview-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.preview-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.preview-img {
    max-width: 100%;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    background: white;
}

/* --- Footer --- */
.footer {
    background: var(--bg-primary);
    border-top: var(--border);
    padding: 24px;
    text-align: center;
}

.footer-inner {
    max-width: 900px;
    margin: 0 auto;
    font-size: 13px;
    color: var(--gray-400);
}

.footer-tech {
    margin-top: 4px;
    font-size: 12px;
}

.footer-tech a {
    color: var(--blue-500);
    text-decoration: none;
}

.footer-tech a:hover {
    text-decoration: underline;
}

/* --- Toast --- */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px;
    background: var(--gray-800);
    color: white;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-xl);
    font-size: 14px;
    font-weight: 500;
    animation: toastIn 0.4s var(--ease) both;
    max-width: 400px;
}

.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--error); }
.toast.warning { border-left: 4px solid var(--warning); }

.toast.removing {
    animation: toastOut 0.3s var(--ease) both;
}

/* --- Animations --- */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

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

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(40px); }
}

/* --- Responsive (Media Queries) --- */

/* Quando a tela ficar menor que 1300px, ocultamos as laterais e mostramos o banner de celular */
@media (max-width: 1300px) {
    .ad-sidebar {
        display: none;
    }
    
    .ad-mobile-wrapper {
        display: block;
    }
    
    .site-layout {
        padding: 0 16px;
    }
}

@media (max-width: 768px) {
    .header-inner {
        padding: 14px 16px;
    }

    .header-badge span {
        display: none;
    }

    .hero-title {
        font-size: 24px;
    }

    .hero-subtitle {
        font-size: 14px;
    }

    .preset-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .dpi-row {
        flex-wrap: wrap;
    }

    .dpi-btn {
        min-width: calc(50% - 8px);
    }

    .convert-btn {
        width: 100%;
        padding: 16px 24px;
    }

    .card-header {
        padding: 16px 18px;
    }

    .config-body, .zpl-body {
        padding: 18px;
    }

    .dims-row {
        flex-direction: column;
        gap: 12px;
    }

    .dim-separator {
        transform: rotate(90deg);
        padding: 0;
    }

    .card-actions {
        flex-wrap: wrap;
    }

    .action-btn span {
        display: none;
    }
}

@media (max-width: 480px) {
    .logo-img {
        height: 20px; 
    }

    .logo-title {
        font-size: 15px;
    }

    .hero-title {
        font-size: 20px;
    }

    .preset-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .preset-btn {
        padding: 14px 8px;
    }

    .toast-container {
        bottom: 16px;
        right: 16px;
        left: 16px;
    }

    .toast {
        max-width: 100%;
    }
}