:root { 
    --blue: #1a4fdb; 
    --green: #2d7a4a; 
    --border: #e2e8f0; 
    --bg: #f4f7f9; 
}

* { box-sizing: border-box; }

body { 
    margin: 0; 
    font-family: 'Segoe UI', sans-serif; 
    background: var(--bg); 
    height: 100vh; 
    overflow: hidden; 
}

.app-layout { 
    display: flex; 
    height: 100vh; 
    width: 100vw; 
}

.form-panel { 
    flex: 0 0 60%; 
    padding: 25px; 
    overflow-y: auto; 
    background: var(--bg); 
}

.preview-panel { 
    flex: 0 0 40%; 
    background: var(--blue); 
    padding: 20px; 
    display: flex; 
    flex-direction: column; 
    border: none; 
}

.sku-header {
    background: rgba(255,255,255,0.15); 
    color: white; 
    padding: 20px; 
    border-radius: 10px; 
    margin-bottom: 15px; 
    font-size: 28px; 
    font-weight: 900; 
    font-family: monospace; 
    border: 1px solid rgba(255,255,255,0.2);
    text-align: center;
}

.card { 
    background: white; 
    padding: 20px; 
    border-radius: 12px; 
    box-shadow: 0 2px 8px rgba(0,0,0,0.05); 
}

.grid-3 { 
    display: grid; 
    grid-template-columns: repeat(3, 1fr); 
    gap: 10px; 
}

.grid-5 { 
    display: grid; 
    grid-template-columns: repeat(5, 1fr); 
    gap: 10px; 
}

.grid-2 { 
    display: grid; 
    grid-template-columns: 1fr 1fr; 
    gap: 15px; 
}

label { 
    font-size: 11px; 
    font-weight: 700; 
    color: #64748b; 
    text-transform: uppercase; 
    margin-bottom: 5px; 
    display: block; 
}

input, select, .mini-editor { 
    width: 100%; 
    padding: 12px; 
    border: 1px solid var(--border); 
    border-radius: 8px; 
    outline: none; 
    font-family: inherit;
    transition: border-color 0.2s;
}

input:focus, select:focus, .mini-editor:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(26, 79, 219, 0.1);
}

.mini-editor { 
    min-height: 160px; 
    background: transparent; 
    overflow-y: auto;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 12px;
    z-index: 2;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.mini-editor:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(26, 79, 219, 0.1);
    background: white;
}

/* Placeholder sempre visibile sotto il campo */
.note-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 12px;
    color: #64748b;
    font-size: 13px;
    line-height: 1.6;
    pointer-events: none;
    z-index: 1;
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    display: block;
}

.note-placeholder strong {
    color: #475569;
    font-weight: 700;
}

.dropdown-list { 
    background: white; 
    border: 1px solid var(--border); 
    position: absolute; 
    width: 400px; 
    z-index: 1000; 
    border-radius: 8px; 
    box-shadow: 0 10px 15px rgba(0,0,0,0.1); 
    max-height: 300px;
    overflow-y: auto;
    display: none;
}

.dropdown-list:not(:empty) {
    display: block;
}

.item { 
    padding: 12px; 
    cursor: pointer; 
    color: black; 
    border-bottom: 1px solid #f1f5f9; 
}

.item:last-child {
    border-bottom: none;
}

.item:hover { 
    background: #f1f5f9; 
    color: var(--blue); 
}

.btn-primary { 
    width: 100%; 
    padding: 20px; 
    background: var(--green); 
    color: white; 
    border: none; 
    border-radius: 10px; 
    font-weight: bold; 
    cursor: pointer; 
    font-size: 18px; 
    margin-top: 10px; 
    transition: all 0.3s;
}

.btn-primary:hover:not(:disabled) {
    background: #236139;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(45, 122, 74, 0.3);
}

.btn-primary:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.btn-secondary {
    width: 100%; 
    padding: 15px; 
    background: #64748b; 
    color: white; 
    border: none; 
    border-radius: 10px; 
    font-weight: bold; 
    cursor: pointer; 
    font-size: 16px; 
    transition: all 0.3s;
}

.btn-secondary:hover {
    background: #475569;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(100, 116, 139, 0.3);
}

.preview-scroll-container { 
    flex-grow: 1; 
    background: white; 
    border-radius: 10px; 
    overflow: auto; 
    position: relative; 
}

#html_live_preview { 
    width: 850px; 
    transform-origin: top left; 
    margin: 0; 
    position: absolute; 
    background: white; 
}

.readonly-input {
    background: #f8fafc !important;
    cursor: default;
}

/* Animazioni feedback */
@keyframes slideIn {
    from { 
        transform: translateX(100%); 
        opacity: 0; 
    }
    to { 
        transform: translateX(0); 
        opacity: 1; 
    }
}

@keyframes slideOut {
    from { 
        transform: translateX(0); 
        opacity: 1; 
    }
    to { 
        transform: translateX(100%); 
        opacity: 0; 
    }
}

/* Responsive per tablet */
@media (max-width: 1200px) {
    .app-layout {
        flex-direction: column;
    }
    
    .form-panel, .preview-panel {
        flex: none;
        width: 100%;
    }
    
    .preview-panel {
        max-height: 50vh;
    }
}

/* ✅ RESPONSIVE PER MOBILE - FIX CHECKBOX TAGLIATE */
@media (max-width: 768px) {
    /* Abilita scroll su body */
    body {
        overflow: auto;
        height: auto;
    }
    
    /* Form panel deve scorrere */
    .form-panel {
        overflow-y: auto;
        height: auto;
        min-height: 100vh;
    }
    
    /* Tutte le grid diventano 1 colonna */
    .grid-3, .grid-5 {
        grid-template-columns: 1fr !important;
    }
    
    .grid-2 {
        grid-template-columns: 1fr !important;
    }
    
    /* Riduci font size su mobile */
    input, select {
        font-size: 16px !important; /* Previene zoom iOS */
        padding: 10px !important;
    }
    
    label {
        font-size: 11px !important;
    }
    
    /* Dropdown più stretta su mobile */
    .dropdown-list {
        width: 100% !important;
        max-width: 100%;
    }
    
    /* Riduci padding card */
    .card {
        padding: 15px !important;
    }
    
    /* Nascondi preview panel su mobile */
    .preview-panel {
        display: none !important;
    }
    
    /* App layout verticale */
    .app-layout {
        display: block;
        height: auto;
        overflow: visible;
    }
}

/* Loading animations */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.loading {
    animation: pulse 2s ease-in-out infinite;
}

/* Checklist salvataggio */
.checklist-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    margin-bottom: 8px;
    border-radius: 8px;
    transition: all 0.3s;
    border-left: 4px solid transparent;
}

.checklist-item.pending {
    background: #f8fafc;
    border-left-color: #cbd5e1;
}

.checklist-item.progress {
    background: #dbeafe;
    border-left-color: #3b82f6;
    animation: pulse 1.5s ease-in-out infinite;
}

.checklist-item.done {
    background: #d1fae5;
    border-left-color: #10b981;
}

.checklist-item.error {
    background: #fee2e2;
    border-left-color: #ef4444;
}

.checklist-icon {
    font-size: 20px;
    min-width: 24px;
}

.checklist-text {
    font-size: 13px;
    color: #334155;
    flex: 1;
    line-height: 1.4;
}

.checklist-item.done .checklist-text,
.checklist-item.error .checklist-text {
    font-weight: 600;
}