* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 10px 20px;
}

.container {
    display: flex;
    gap: 12px;
    max-width: 1280px;
    min-height: calc(100vh - 20px);
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

/* Panneau de gauche - Paramètres */
.parameters-panel {
    flex: 0 0 525px;
    min-width: 0;
    padding: 12px 20px;
    background: #f8f9fa;
    max-width: 525px;
    overflow: visible;
}

.parameters-panel h1 {
    color: #2c3e50;
    margin-bottom: 16px;
    text-align: center;
    font-size: 1.8em;
    font-weight: 700;
}

.section {
    background: white;
    border-radius: 15px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
    border: 1px solid #e9ecef;
}

[hidden] {
    display: none !important;
}

.ruling-presets {
    display: grid;
    grid-template-columns: repeat(auto-fit, calc(25mm + 12px));
    gap: 8px;
    margin-bottom: 16px;
}

.preset-card {
    position: relative;
    min-width: 0;
}

.preset-btn {
    position: relative;
    display: flex;
    justify-content: center;
    width: 100%;
    padding: 4px;
    border: 2px solid #cbd5e1;
    border-radius: 10px;
    background: white;
    color: #34495e;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.preset-thumbnail {
    display: block;
    width: 25mm;
    height: 25mm;
    background: #fff;
    pointer-events: none;
}

.preset-btn[aria-pressed="true"]::after {
    content: '✓';
    position: absolute;
    top: 5px;
    left: 8px;
    font-size: 20px;
    line-height: 24px;
    width: 24px;
    border-radius: 50%;
    background: #fff;
}

.preset-info-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid #31536b;
    border-radius: 50%;
    background: #fff;
    color: #203b4e;
    font: bold 16px Georgia, serif;
    cursor: pointer;
}

.preset-info-btn:hover {
    background: #eaf3f8;
}

.preset-btn[aria-pressed="true"] {
    border-color: #667eea;
    background: #edf0ff;
    color: #403b88;
}

.preset-btn:hover {
    border-color: #667eea;
}

.preset-btn:focus-visible {
    outline: 3px solid #3498db;
    outline-offset: 3px;
}

.section h2 {
    color: #34495e;
    margin-bottom: 12px;
    font-size: 1.2em;
    font-weight: 600;
    border-bottom: 2px solid #3498db;
    padding-bottom: 10px;
}

/* Sections déroulantes */
.collapsible .collapsible-header button,
.download-options summary {
    cursor: pointer;
    position: relative;
    padding-right: 24px;
    transition: all 0.3s ease;
}

.collapsible .collapsible-header:hover,
.download-options summary:hover {
    color: #3498db;
}

.collapsible .collapsible-header button::after,
.download-options summary::after {
    content: '▼';
    position: absolute;
    right: 0;
    top: 0;
    transition: transform 0.3s ease;
    color: #3498db;
    font-size: 0.8em;
}

.collapsible.collapsed .collapsible-header button::after,
.download-options:not([open]) summary::after {
    transform: rotate(-90deg);
}

.collapsible-content {
    max-height: 2000px;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.collapsible.collapsed .collapsible-content {
    max-height: 0;
}

.collapsible.collapsed .collapsible-header {
    margin-bottom: 0;
}

/* Formulaires */
.form-group input[type="range"] {
    padding: 0;
    border: 0;
    accent-color: #667eea;
    cursor: pointer;
}

.range-limits {
    display: flex;
    justify-content: space-between;
    color: #6c757d;
    font-size: 0.85em;
}

.form-group {
    margin-bottom: 12px;
}

.section .form-group:last-child,
.parameters-panel > .form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #2c3e50;
    font-weight: 500;
    font-size: 0.95em;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s ease;
    background: white;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.form-group input[type="color"] {
    height: 50px;
    padding: 5px;
    cursor: pointer;
}

.settings-group {
    min-width: 0;
    padding: 12px 0;
    border: 0;
    border-top: 1px solid #e2e8f0;
}

.settings-group legend {
    padding-right: 8px;
    color: #34495e;
    font-size: 0.95em;
    font-weight: 600;
}

.form-group.color-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
}

.color-row label {
    flex: 1;
    margin-bottom: 0;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.checkbox-row label {
    margin-bottom: 0;
}

.form-group.checkbox-row input[type="checkbox"].toggle-switch {
    appearance: none;
    flex: 0 0 42px;
    width: 42px;
    height: 24px;
    padding: 2px;
    border: 0;
    border-radius: 20px;
    background: #64748b;
    cursor: pointer;
}

.form-group.checkbox-row input.toggle-switch::before {
    content: '';
    display: block;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    transition: transform 0.2s ease;
}

.form-group.checkbox-row input.toggle-switch:checked {
    background: #4f46e5;
}

.form-group.checkbox-row input.toggle-switch:focus-visible {
    outline: 3px solid #3498db;
    outline-offset: 3px;
}

.form-group.checkbox-row input.toggle-switch:checked::before {
    transform: translateX(18px);
}

.frame-advanced {
    margin-top: 14px;
}

.frame-advanced summary {
    cursor: pointer;
    color: #34495e;
    font-weight: 600;
}

.frame-advanced summary:focus-visible {
    outline: 3px solid #3498db;
    outline-offset: 3px;
}

#dysFrameOptions {
    margin-top: 12px;
}

#dysFrameOptions:disabled {
    opacity: 0.55;
}

.form-group.checkbox-row input[type="checkbox"] {
    flex: 0 0 18px;
    width: 18px;
    height: 18px;
    accent-color: #667eea;
}

.form-group.color-row input[type="checkbox"] {
    flex: 0 0 18px;
    width: 18px;
    height: 18px;
    padding: 0;
    accent-color: #667eea;
    cursor: pointer;
}

.color-row input[type="color"]:disabled {
    opacity: 0.4;
    cursor: default;
}

.form-group.color-row input[type="color"] {
    flex: 0 0 64px;
    width: 64px;
    height: 32px;
    padding: 3px;
}

.collapsible-content {
    max-height: 4000px;
}

.individual-line-options {
    border: 0;
    min-width: 0;
    margin-top: 12px;
}

.individual-line-options:disabled {
    opacity: 0.55;
}

.form-group.line-style-row {
    gap: 6px;
}

.form-group.line-style-row label {
    font-size: 0.85em;
}

.form-group.line-style-row input[type="color"] {
    flex-basis: 40px;
    width: 40px;
}

.line-style-row select {
    flex: 0 0 88px;
    width: 88px;
    padding: 6px 2px;
    font-size: 12px;
}

.form-group input[type="number"] {
    -moz-appearance: textfield;
}

.form-group input[type="number"]::-webkit-outer-spin-button,
.form-group input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.info-text {
    font-size: 0.85em;
    color: #6c757d;
    margin-top: 5px;
    font-style: italic;
}

/* Boutons */
.download-btn {
    width: 100%;
    padding: 15px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 10px;
}

.download-btn {
    background: linear-gradient(135deg, #27ae60, #229954);
    color: white;
}

.download-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #229954, #1e8449);
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(39, 174, 96, 0.3);
}

.download-btn:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Panneau de droite - Aperçu */
.download-options summary {
    color: #34495e;
    font-size: 1.2em;
    font-weight: 600;
    list-style: none;
    border-bottom: 2px solid #3498db;
    padding-bottom: 10px;
}

.download-options summary::-webkit-details-marker {
    display: none;
}

.download-options-content {
    padding-top: 16px;
}

.download-options .download-btn {
    margin-bottom: 0;
}

.download-options .download-btn + .download-btn {
    margin-top: 12px;
}

.download-options .info-text {
    margin: 6px 0 16px;
}

.download-options .info-text:last-child {
    margin-bottom: 0;
}

.download-options summary:focus-visible,
.word-info-btn:focus-visible,
.download-btn:focus-visible {
    outline: 3px solid #3498db;
    outline-offset: 4px;
}

.word-download-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.word-download-row .download-btn {
    flex: 1;
    min-width: 0;
}

.word-info-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 40px;
    height: 44px;
    border: 1px solid #cbdce8;
    border-radius: 8px;
    background: #edf6fc;
    color: #24648f;
    cursor: pointer;
}

.word-info-btn:hover,
.word-info-btn[aria-expanded="true"] {
    background: #d8eefa;
}

.word-export-info {
    margin-top: 10px;
    padding: 12px;
    border-radius: 8px;
    background: #edf6fc;
    color: #34495e;
    font-size: 0.9em;
    line-height: 1.5;
}

.preview-panel {
    flex: 1;
    min-width: 0;
    min-height: 0;
    height: calc(100vh - 20px);
    align-self: flex-start;
    padding: 6px 10px 6px 0;
    background: white;
    display: flex;
    flex-direction: column;
}

.preview-container {
    flex: 1;
    min-height: 0;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    background: white;
    overflow: hidden;
    position: relative;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    cursor: crosshair;
}

.preview-container > canvas {
    display: block;
}

/* Effet de zoom au survol */
.zoom-overlay {
    position: absolute;
    width: 240px;
    height: 240px;
    border: 2px solid #3498db;
    border-radius: 50%;
    background: white;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    pointer-events: none;
    z-index: 1000;
    overflow: hidden;
    display: none;
}

.zoom-overlay canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Responsive */
@media (max-width: 1200px) {
    .container {
        flex-direction: column;
        max-width: 800px;
        height: auto;
    }
    
    .parameters-panel {
        flex: none;
        max-width: none;
        max-height: none;
    }

    .preview-panel {
        align-self: stretch;
        height: auto;
        padding: 6px 12px 12px;
    }
    
    .preview-container {
        flex: none;
        height: 480px;
    }
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .container {
        border-radius: 15px;
    }
    
    .parameters-panel,
    .preview-panel {
        padding: 10px 20px;
    }
    
    .parameters-panel h1 {
        font-size: 1.8em;
    }
    
    .preview-container {
        height: 360px;
    }
}

/* Animation d'apparition */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.section {
    animation: fadeInUp 0.6s ease forwards;
}

.section:nth-child(2) {
    animation-delay: 0.1s;
}

.section:nth-child(3) {
    animation-delay: 0.2s;
}

/* Styles pour l'aperçu de la grille */
.grid-preview {
    position: relative;
    width: 100%;
    height: 100%;
    background: white;
}

.grid-line {
    position: absolute;
    background: #000;
}

.grid-line.horizontal {
    height: 1px;
    width: 100%;
}

.grid-line.vertical {
    width: 1px;
    height: 100%;
}

.grid-line.margin {
    background: #e74c3c;
}

.grid-line.interline {
    background: #3498db;
}

.grid-line.heavy {
    background: #2c3e50;
}

.grid-line.light {
    background: #95a5a6;
}

