:root {
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --radius: 12px;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    
    --meter-good: #22c55e;
    --meter-warn: #eab308;
    --meter-bad: #ef4444;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    padding: 2rem;
}

header {
    text-align: center;
    margin-bottom: 2rem;
}

header h1 {
    font-size: 2.5rem;
    color: var(--text-main);
    margin-bottom: 0.5rem;
}

header p {
    color: var(--text-muted);
    font-size: 1.1rem;
}

.app-container {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.controls-panel, .preview-panel {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.control-group {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.control-group:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
}

label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

input[type="text"], 
textarea, 
select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

/* CORRECTIF NOMS DE FICHIERS LONGS */
input[type="file"] {
    width: 100%;
    font-size: 0.85rem;
    white-space: normal;
    word-wrap: break-word;
    word-break: break-all;
    overflow: hidden;
}

input[type="text"]:focus, 
textarea:focus, 
select:focus {
    border-color: var(--primary);
}

.color-picker-wrapper {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

input[type="color"] {
    -webkit-appearance: none;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    padding: 0;
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

input[type="color"]::-webkit-color-swatch {
    border: 1px solid var(--border);
    border-radius: 8px;
}

input[type="range"] {
    width: 100%;
    margin-top: 0.5rem;
}

.slider-val {
    display: block;
    text-align: right;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

.slider-wrapper {
    margin: 1rem 0;
}

.tooltip {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 16px;
    height: 16px;
    background: var(--text-muted);
    color: white;
    border-radius: 50%;
    font-size: 11px;
    cursor: help;
    margin-left: 0.5rem;
}

button {
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: background 0.2s, transform 0.1s;
}

button:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--primary);
    color: white;
    width: 100%;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--bg-color);
    color: var(--text-main);
    border: 1px solid var(--border);
    width: 100%;
    margin-top: 0.5rem;
}

.btn-secondary:hover {
    background: #e2e8f0;
}

.preview-card h2 {
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    text-align: center;
}

#qr-canvas {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 300px;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    margin-bottom: 2rem;
    padding: 0; /* Plus de padding caché pour simuler une bordure ! */
    overflow: hidden;

    /* Damier de transparence comme dans Photoshop */
    background-color: #f8fafc;
    background-image: 
        linear-gradient(45deg, #e2e8f0 25%, transparent 25%),
        linear-gradient(-45deg, #e2e8f0 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #e2e8f0 75%),
        linear-gradient(-45deg, transparent 75%, #e2e8f0 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

.meter-container {
    background: var(--bg-color);
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 2rem;
}

.meter-header {
    display: flex;
    justify-content: space-between;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.meter-bar-bg {
    width: 100%;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.meter-bar-fill {
    height: 100%;
    transition: width 0.4s ease, background-color 0.4s ease;
}

.meter-hint {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

@media (max-width: 900px) {
    .app-container {
        grid-template-columns: 1fr;
    }
    .grid-3 {
        grid-template-columns: 1fr;
    }
}