/* Global Styles */
body {
    margin: 0;
    padding: 0;
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
    position: relative;
}

/* Contenedor principal (superficie sólida, sin glass) */
.glass-container {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    padding: 0;
    width: 90%;
    max-width: 1400px;
    height: 90vh;
    border-radius: 10px;
    display: flex;
    /* Sidebar | Content */
    overflow: hidden;
    z-index: 10;
    box-shadow: var(--shadow-sm);
}

/* --- New Dashboard Styles --- */

header {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 40px;
    padding-top: 20px;
}

.header-left h1 {
    font-size: 1.8rem;
    font-weight: 600;
    letter-spacing: -0.5px;
    margin: 0;
    color: var(--text-primary);
}

/* Back Navigation */
.back-nav {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 100;
}

.back-nav a {
    color: var(--text-secondary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.back-nav a:hover {
    color: var(--accent-color);
    transform: translateX(3px);
}

.back-nav a svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
}

.printer-status-inline {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 5px;
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #64748b;
    /* Offline */
}

.status-indicator.connected {
    background: #22c55e;
    box-shadow: none;
}

.section-title {
    font-size: 1.5rem;
    margin-bottom: 30px;
    color: var(--text-primary);
    font-weight: 300;
    text-align: center;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 30px;
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
}

.label-card {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-lg, 20px);
    padding: var(--padding-lg, 20px);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    gap: 20px;
    position: relative;
    overflow: hidden;
}

.label-card:hover {
    background: var(--card-bg-hover);
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
    border-color: var(--accent-color);
}

.label-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.05), transparent);
    transform: translateX(-100%);
    transition: 0.5s;
}

.label-card:hover::before {
    transform: translateX(100%);
}

.card-preview {
    height: 180px;
    background: var(--input-bg);
    border-radius: var(--border-radius-md, 12px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* Mockup Shapes (Pure CSS) */
.preview-mockup {
    background: #fff;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #333;
    font-size: 0.8rem;
    font-family: monospace;
}

/* Mockup Styles: 100x25 EMAFI Style */
.preview-mockup.size-100x25 {
    display: flex;
    flex-direction: column;
    background: #fff;
    width: 360px;
    height: 90px;
    padding: 0;
    overflow: hidden;
    font-family: 'Arial', sans-serif;
    color: #000;
    box-shadow: var(--shadow-lg);
    border-radius: 4px;
    position: relative;
    border: 1px solid #e2e8f0;
}

.label-inner {
    height: 100%;
    width: 100%;
    display: flex;
    flex-direction: column;
}

.label-body {
    flex-grow: 1;
    display: flex;
    padding: 5px 10px;
    align-items: center;
    justify-content: space-between;
}

.label-left {
    display: flex;
    flex-direction: column;
    width: 60%;
}

.label-code {
    font-size: 1.8rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 2px;
}

.label-desc {
    font-size: 0.7rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-transform: uppercase;
}

.label-right {
    width: 40%;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.label-barcode-img {
    height: 30px;
    width: 100%;
    background: repeating-linear-gradient(90deg, #000, #000 1px, #fff 1px, #fff 3px);
}

.label-gtin {
    font-size: 0.65rem;
    margin-top: 1px;
}

.label-origin {
    font-size: 0.5rem;
    font-weight: bold;
}

/* EMAFI Dark Blue Footer */
/* EMAFI Dark Blue Footer */
.label-footer {
    height: 22px;
    background: #2563eb;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    box-sizing: border-box;
    margin-top: auto;
}

.footer-brand {
    display: flex;
    align-items: center;
    gap: 5px;
    color: #fff;
    font-weight: 900;
    font-size: 0.9rem;
    letter-spacing: 0.5px;
    font-style: italic;
}

.footer-icon {
    color: #3b82f6;
    /* Blue chevron */
    font-size: 0.8rem;
}

.footer-web {
    color: #fff;
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 500;
}

/* Modify Dashboard Card to specific style */
.label-card.emafi-style .card-preview {
    background: #e2e8f0;
    /* Light bg to contrast white label */
}

body.light-theme .card-preview {
    background: #e2e8f0;
    /* Contraste con las etiquetas blancas en tema claro */
}

/* Product Search Dropdown */
.search-container {
    position: relative;
    width: 100%;
}

.suggestions-list {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 0 0 8px 8px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    display: none;
    box-shadow: var(--shadow-md);
}

.suggestion-item {
    padding: 10px 15px;
    border-bottom: 1px solid var(--divider);
    cursor: pointer;
    transition: 0.2s;
}

.suggestion-item:hover,
.suggestion-item.selected {
    background: rgba(56, 189, 248, 0.2);
    border-left: 3px solid #38bdf8;
}

.item-code {
    font-weight: bold;
    color: var(--text-primary);
    display: block;
}

.item-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* 100x64 */
.size-100x64 {
    width: 180px;
    height: 115px;
    /* scaled aspect ratio */
    border-radius: 2px;
    padding: 10px;
}

/* 50x25 (2up) */
.size-50x25 {
    width: 160px;
    height: 90px;
    background: transparent;
    box-shadow: none;
    flex-direction: row;
    gap: 10px;
}

.col-2 {
    display: flex;
    gap: 5px;
}

.mini-label {
    width: 70px;
    height: 35px;
    background: #fff;
    border-radius: 2px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.barcode-lines {
    height: 15px;
    width: 80%;
    background: repeating-linear-gradient(90deg,
            #333,
            #333 2px,
            #fff 2px,
            #fff 3px);
    margin-bottom: 5px;
}

.barcode-lines.lg {
    height: 30px;
    width: 90%;
    margin-top: auto;
}

.mock-text-lg {
    font-weight: 900;
    font-size: 1.2rem;
    align-self: flex-start;
}

.card-info {
    text-align: center;
}

.card-info h3 {
    margin: 0 0 5px 0;
    font-size: 1.2rem;
    color: var(--text-primary);
}

.printer-badge {
    background: var(--badge-bg);
    color: var(--text-secondary);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 500;
    border: 1px solid var(--glass-border);
}

/* --- Form View Styles --- */
.hidden {
    display: none !important;
}

.form-view {
    height: 100%;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.form-container {
    max-width: 900px;
    margin: 0 auto;
    height: 90%;
    display: flex;
    flex-direction: column;
}

.form-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--divider);
    padding-bottom: 15px;
}

.form-body {
    display: flex;
    gap: 30px;
    flex-grow: 1;
    overflow-y: auto;
}

.inputs-grid {
    flex: 1.5;
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding-right: 20px;
}

.input-group {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 0;
}

.input-group label {
    font-size: 0.9rem;
    color: var(--text-primary);
    font-weight: 600;
    min-width: 140px;
    /* Consistent alignment */
    text-align: right;
}

.input-group input {
    flex: 1;
    background: var(--input-bg);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 10px 15px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    transition: all 0.2s;
}

.input-group input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.preview-box {
    flex: 1.2;
    background: var(--input-bg);
    border-radius: var(--border-radius-lg, 16px);
    padding: var(--padding-lg, 30px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--glass-border);
}

.action-btn {
    padding: var(--padding-sm, 12px) 30px;
    border-radius: var(--border-radius-md, 12px);
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    letter-spacing: 0.5px;
}

.back-action-btn {
    background: var(--badge-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.back-action-btn:hover {
    background: var(--card-bg-hover);
    border-color: var(--accent-color);
    transform: translateY(-2px);
}

.back-action-btn:active {
    transform: translateY(0);
}

.preview-box h3 {
    margin-top: 0;
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.live-preview-canvas {
    background: #e2e8f0;
    border-radius: 8px;
    width: 100%;
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    box-sizing: border-box;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* Force specific aspect ratio for 100x25 in preview */
.live-preview-canvas .size-100x25 {
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 4 / 1;
    max-width: 500px;
}

.form-footer {
    border-top: 1px solid var(--divider);
    padding-top: 20px;
    margin-top: 20px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 20px;
}

.qty-control {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--input-bg);
    padding: 4px 8px;
    /* Slightly tighter padding */
    border-radius: 8px;
    border: 1px solid var(--glass-border);
}

.qty-btn {
    background: var(--badge-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.qty-btn:hover {
    background: var(--card-bg-hover);
    transform: translateY(-1px);
}

.qty-btn:active {
    transform: translateY(1px);
}

.qty-btn i {
    font-size: 0.7rem;
}

.qty-control input {
    width: 50px;
    background: transparent;
    border: none;
    text-align: center;
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-primary);
    -webkit-appearance: none;
    appearance: none;
    -moz-appearance: textfield;
}

/* Hide arrows in Chrome, Safari, Edge, Opera */
.qty-control input::-webkit-outer-spin-button,
.qty-control input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.print-action-btn {
    padding: var(--padding-md, 15px) 40px;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 1px;
    border-radius: var(--border-radius-md, 12px);
    background: #2563eb;
    border: none;
    color: white;
    box-shadow: var(--shadow-sm);
}

.print-action-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.status-message {
    margin-top: 10px;
    text-align: center;
    font-size: 0.9rem;
    min-height: 20px;
    color: #4ade80;
    /* Default success color, changed via JS */
}