/* ============================================
   HKD GÉOMATIQUE - FICHE DE RÉFÉRENCE GENERATOR
   Version 5.0 - Avec templates et snap grid
   ============================================ */

:root {
    /* Couleurs HKD */
    --hkd-red: #E31E24;
    --hkd-red-dark: #c41a1f;
    --hkd-gray-dark: #6D6E71;
    --hkd-gray-medium: #A7A9AC;
    --hkd-gray-light: #E5E5E5;
    --hkd-white: #FFFFFF;

    /* Couleurs UI */
    --bg-primary: #f8f9fa;
    --bg-secondary: #ffffff;
    --border-color: #dee2e6;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);

    /* Typographie */
    --font-primary: 'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    /* Tailles de typo */
    --title-size: 24px;
    --subtitle-size: 20px;
    --section-title-size: 14px;
    --body-size: 10px;
    --small-size: 9px;

    /* Dimensions A4 */
    --a4-width: 520px;
    --a4-height: 735px;

    /* Snap grid */
    --snap-size: 10px;
}

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

body {
    font-family: var(--font-primary);
    background: var(--bg-primary);
    color: var(--hkd-gray-dark);
    line-height: 1.5;
    min-height: 100vh;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

/* ============================================
   Layout Principal
   ============================================ */

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.app-header {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 12px 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    z-index: 100;
}

.header-logo {
    flex-shrink: 0;
}

.app-header h1 {
    flex: 1;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--hkd-gray-dark);
}

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

/* Boutons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-family: var(--font-primary);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary {
    background: var(--hkd-red);
    color: white;
}

.btn-primary:hover {
    background: var(--hkd-red-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--hkd-gray-light);
    color: var(--hkd-gray-dark);
}

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

.btn-full {
    width: 100%;
}

.btn-row {
    display: flex;
    gap: 8px;
}

.btn .icon {
    font-size: 1rem;
}

/* ============================================
   Main Content Layout
   ============================================ */

.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ============================================
   Panneau Formulaire
   ============================================ */

.form-panel {
    width: 420px;
    min-width: 380px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    padding: 20px;
}

.form-section {
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
}

.form-section:last-child {
    border-bottom: none;
}

.form-section h2 {
    font-size: 0.875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--hkd-red);
    margin-bottom: 16px;
}

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

.form-group.half {
    width: calc(50% - 5px);
}

.form-row {
    display: flex;
    gap: 10px;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--hkd-gray-dark);
    margin-bottom: 6px;
}

.form-group input[type="text"],
.form-group textarea,
.form-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-family: var(--font-primary);
    font-size: 0.9rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input[type="text"]:focus,
.form-group textarea:focus,
.form-select:focus {
    outline: none;
    border-color: var(--hkd-red);
    box-shadow: 0 0 0 3px rgba(227, 30, 36, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-hint {
    font-size: 0.8rem;
    color: var(--hkd-gray-medium);
    margin-bottom: 12px;
}

/* Slider container */
.slider-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.slider-container input[type="range"] {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: var(--hkd-gray-light);
    appearance: none;
    cursor: pointer;
}

.slider-container input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--hkd-red);
    cursor: pointer;
}

.slider-container span {
    font-size: 0.85rem;
    font-weight: 600;
    min-width: 50px;
    text-align: right;
}

/* Checkbox label */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--hkd-red);
}

.gallery-tools {
    margin-bottom: 12px;
    padding: 10px;
    background: var(--hkd-gray-light);
    border-radius: 6px;
}

/* Cover Preview in form */
.cover-preview {
    margin-top: 10px;
    max-height: 150px;
    overflow: hidden;
    border-radius: 6px;
}

.cover-preview img {
    width: 100%;
    height: auto;
    display: block;
}

.photo-input-hidden {
    display: none;
}

/* Gallery Pages Container */
.gallery-pages-container {
    margin-bottom: 16px;
}

.pages-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 10px;
}

.page-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--hkd-gray-light);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.page-item:hover {
    background: #d5d5d5;
}

.page-item.active {
    background: var(--hkd-red);
    color: white;
}

.page-item-info {
    flex: 1;
}

.page-item-title {
    font-weight: 600;
    font-size: 0.85rem;
}

.page-item-photos {
    font-size: 0.75rem;
    opacity: 0.7;
}

.page-item .btn-delete-page {
    width: 24px;
    height: 24px;
    padding: 0;
    background: transparent;
    border: none;
    cursor: pointer;
    opacity: 0.6;
    font-size: 14px;
}

.page-item .btn-delete-page:hover {
    opacity: 1;
}

.page-item.active .btn-delete-page {
    color: white;
}

/* Gallery Edit Section */
.gallery-edit-section {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.gallery-edit-header {
    margin-bottom: 12px;
}

.gallery-edit-header h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--hkd-gray-dark);
}

/* Template Grid */
.template-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
}

.template-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 4px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    background: white;
    cursor: pointer;
    transition: all 0.2s;
}

.template-btn svg {
    width: 32px;
    height: 32px;
    color: var(--hkd-gray-medium);
}

.template-btn span {
    font-size: 0.65rem;
    color: var(--hkd-gray-medium);
}

.template-btn:hover {
    border-color: var(--hkd-red);
}

.template-btn:hover svg {
    color: var(--hkd-red);
}

.template-btn.active {
    border-color: var(--hkd-red);
    background: rgba(227, 30, 36, 0.05);
}

.template-btn.active svg {
    color: var(--hkd-red);
}

.template-btn.active span {
    color: var(--hkd-red);
    font-weight: 600;
}

/* Gallery Options */
.gallery-options {
    margin: 12px 0;
    padding: 8px 10px;
    background: var(--hkd-gray-light);
    border-radius: 6px;
}

/* No photos hint */
.no-photos-hint {
    font-size: 0.8rem;
    color: var(--hkd-gray-medium);
    text-align: center;
    padding: 15px;
    background: var(--hkd-gray-light);
    border-radius: 6px;
}

/* Photos List */
.photos-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.photo-list-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    background: var(--hkd-gray-light);
    border-radius: 6px;
}

.photo-list-thumb {
    width: 50px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
    cursor: pointer;
}

.photo-list-thumb:hover {
    opacity: 0.8;
}

.photo-list-info {
    flex: 1;
    min-width: 0;
}

.photo-list-name {
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.photo-list-size {
    font-size: 0.7rem;
    color: var(--hkd-gray-medium);
}

.photo-list-actions {
    display: flex;
    gap: 4px;
}

.btn-crop-photo,
.btn-remove-photo,
.btn-replace-photo {
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s, transform 0.2s;
}

.btn-crop-photo:hover,
.btn-remove-photo:hover,
.btn-replace-photo:hover {
    transform: scale(1.1);
}

.btn-crop-photo {
    background: var(--hkd-gray-medium);
    color: white;
}

.btn-replace-photo {
    background: #2196F3;
    color: white;
}

.btn-replace-photo:hover {
    background: #1976D2;
}

.btn-remove-photo {
    background: var(--hkd-red);
    color: white;
}

.btn-remove-photo:hover {
    background: var(--hkd-red-dark);
}

/* Auto-layout button */
.btn-auto-layout {
    margin-top: 10px;
    background: linear-gradient(135deg, var(--hkd-red), #ff5252);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

/* ============================================
   Preview Panel
   ============================================ */

.preview-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #e9ecef;
    overflow: hidden;
}

.preview-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.preview-nav {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-nav {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-nav:hover:not(:disabled) {
    border-color: var(--hkd-red);
    color: var(--hkd-red);
}

.btn-nav:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

#page-indicator {
    font-size: 0.9rem;
    font-weight: 600;
    min-width: 100px;
    text-align: center;
}

.preview-zoom {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-zoom {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-zoom:hover {
    border-color: var(--hkd-red);
    color: var(--hkd-red);
}

#zoom-level {
    font-size: 0.8rem;
    font-weight: 600;
    min-width: 50px;
    text-align: center;
}

#zoom-fit {
    width: auto;
    padding: 0 12px;
    font-size: 0.8rem;
}

.preview-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 30px;
    overflow: auto;
}

.pages-wrapper {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* ============================================
   A4 Page Base Styles
   ============================================ */

.a4-page {
    width: var(--a4-width);
    height: var(--a4-height);
    background: white;
    box-shadow: var(--shadow-lg);
    transform-origin: top center;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

/* Filigrane de fond - en arrière-plan sous les images */
.page-watermark {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url('../mediahkd/filigrane_A4_opacite.png');
    background-size: cover;
    background-position: center;
    opacity: 0.3;
    pointer-events: none;
    z-index: 0;
}

.page-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
}

/* ============================================
   PAGE DE GARDE (Cover Page)
   ============================================ */

/* Bande rouge gauche */
.red-band {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 8px;
    background: var(--hkd-red);
    z-index: 5;
}

.cover-content {
    padding: 0;
}

.cover-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 20px 25px 20px 30px;
    position: relative;
    z-index: 2;
}

.logo-cover {
    height: 32px;
    width: auto;
}

.cover-date {
    font-size: 11px;
    font-weight: 400;
    color: var(--hkd-gray-medium);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Zone image de couverture - avec zoom/pan */
.cover-image-zone {
    position: absolute;
    top: 80px;
    left: 25px;
    right: 25px;
    height: 340px;
    background: transparent;
    overflow: hidden;
    z-index: 1;
    cursor: pointer;
}

.cover-image-zone img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.1s ease-out;
}

.cover-image-zone:hover,
.description-image-zone:hover {
    cursor: grab;
}

.cover-image-zone:active,
.description-image-zone:active {
    cursor: grabbing;
}

.cover-image-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--hkd-gray-medium);
    font-size: 11px;
    background: rgba(245, 245, 245, 0.7);
    border: 2px dashed var(--hkd-gray-light);
}

.cover-image-zone.has-image .cover-image-placeholder {
    display: none;
}

.cover-image-zone.drag-over {
    border-color: var(--hkd-blue) !important;
    background: rgba(33, 150, 243, 0.1);
}

.cover-image-zone.drag-over .cover-image-placeholder {
    border-color: var(--hkd-blue);
    background: rgba(33, 150, 243, 0.15);
    color: var(--hkd-blue);
}

/* Cover template grid */
.cover-template-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    margin-bottom: 10px;
}

/* Cover images list in form */
.cover-images-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.cover-images-list .cover-thumb {
    position: relative;
    width: 60px;
    height: 50px;
    border-radius: 4px;
    overflow: hidden;
    border: 2px solid var(--border-color);
}

.cover-images-list .cover-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cover-images-list .cover-thumb .btn-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    background: var(--hkd-red);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}

.cover-images-list .cover-thumb:hover .btn-remove {
    opacity: 1;
}

/* Cover image grid within zone */
.cover-image-grid {
    display: grid;
    width: 100%;
    height: 100%;
    gap: 5px;
}

.cover-image-grid.template-single {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
}

.cover-image-grid.template-duo-h {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr;
}

.cover-image-grid.template-duo-v {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
}

.cover-image-grid.template-trio {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1.5fr 1fr;
}

.cover-image-grid.template-trio .cover-grid-item:first-child {
    grid-column: 1 / -1;
}

.cover-image-grid.template-quad {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
}

.cover-grid-item {
    position: relative;
    overflow: hidden;
    background: transparent;
    cursor: grab;
}

.cover-grid-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.1s ease-out;
}

.cover-grid-item:active {
    cursor: grabbing;
}

.cover-grid-item .placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--hkd-gray-medium);
    font-size: 10px;
    border: 2px dashed var(--hkd-gray-light);
}

/* Bloc titre qui chevauche l'image */
.cover-title-block {
    position: absolute;
    bottom: 90px;
    left: 25px;
    right: 25px;
    background: rgba(255, 255, 255, 0.95);
    padding-top: 20px;
    z-index: 3;
}

.cover-category {
    font-size: var(--subtitle-size);
    font-weight: 300;
    font-style: italic;
    color: var(--hkd-gray-dark);
    margin-bottom: 2px;
    margin-top: -45px;
    background: white;
    display: inline-block;
    padding-right: 15px;
}

.cover-title {
    font-size: var(--title-size);
    font-weight: 700;
    color: var(--hkd-gray-dark);
    text-transform: uppercase;
    margin-bottom: 12px;
    line-height: 1.1;
}

/* Séparateur ligne seule */
.cover-separator {
    margin-bottom: 12px;
}

.separator-line {
    width: 100%;
    height: 1px;
    background: var(--hkd-gray-light);
}

.cover-info {
    padding-top: 0;
}

.cover-author {
    font-size: 11px;
    font-weight: 700;
    color: var(--hkd-gray-dark);
    margin-bottom: 4px;
    text-transform: uppercase;
}

.cover-details {
    font-size: var(--small-size);
    color: var(--hkd-gray-dark);
    margin-bottom: 2px;
    display: flex;
    gap: 5px;
}

.detail-label {
    font-weight: 600;
    text-transform: uppercase;
    color: var(--hkd-gray-medium);
}

.detail-value {
    color: var(--hkd-gray-dark);
}

/* Footer commun */
.page-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px 25px;
    z-index: 4;
}


.footer-image {
    width: 100%;
    height: auto;
    display: block;
}

.page-number {
    position: absolute;
    right: 25px;
    bottom: 6px;
    font-size: 9px;
    color: var(--hkd-gray-medium);
}

/* ============================================
   PAGE DESCRIPTION
   ============================================ */

.description-content {
    padding: 20px 25px 75px;
    display: flex;
    flex-direction: column;
    height: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.page-header {
    margin-bottom: 15px;
}

.logo-page {
    height: 28px;
    width: auto;
}

.description-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.description-section {
    margin-bottom: 15px;
}

.section-title {
    font-size: var(--section-title-size);
    font-weight: 600;
    color: var(--hkd-gray-dark);
    margin-bottom: 6px;
    padding-bottom: 3px;
    border-bottom: 1px solid var(--hkd-gray-light);
}

.section-content {
    font-size: var(--body-size);
    line-height: 1.6;
    color: var(--hkd-gray-dark);
}

.section-content p {
    margin-bottom: 6px;
}

/* Prestations list */
.prestations-list ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.prestations-list li {
    position: relative;
    padding-left: 12px;
    margin-bottom: 3px;
}

.prestations-list li::before {
    content: "—";
    position: absolute;
    left: 0;
    color: var(--hkd-gray-medium);
}

/* Zone image description - auto-fill remaining space */
.description-image-zone {
    flex: 1 1 0;
    min-height: 60px;
    max-height: 100%;
    background: #f5f5f5;
    overflow: hidden;
    cursor: pointer;
    position: relative;
}

/* Plus de redimensionnement manuel - auto-fill */

/* Mode normal: object-fit cover */
.description-image-zone img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform-origin: center center;
    transition: transform 0.1s ease-out;
}

.description-image-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--hkd-gray-medium);
    font-size: 10px;
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 10px,
        rgba(0,0,0,0.02) 10px,
        rgba(0,0,0,0.02) 20px
    );
}

.description-image-zone.has-image .description-image-placeholder {
    display: none;
}

/* Mode édition pour les zones d'image */
.cover-image-zone.edit-mode,
.description-image-zone.edit-mode {
    outline: 3px solid #2196F3;
    outline-offset: -3px;
    cursor: grab;
}

.cover-image-zone.edit-mode:active,
.description-image-zone.edit-mode:active {
    cursor: grabbing;
}

/* En mode édition: contain pour voir toute l'image */
.cover-image-zone.edit-mode img,
.description-image-zone.edit-mode img {
    object-fit: contain !important;
    transition: none;
}

/* Indicateur de zoom en mode édition */
.image-zoom-indicator {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(33, 150, 243, 0.9);
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    z-index: 20;
    pointer-events: none;
}

/* Bouton reset en mode édition */
.image-reset-btn {
    position: absolute;
    bottom: 10px;
    left: 10px;
    width: 32px;
    height: 32px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 16px;
    cursor: pointer;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.image-reset-btn:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.1);
}

/* Bouton valider en mode édition */
.image-validate-btn {
    position: absolute;
    bottom: 10px;
    right: 10px;
    padding: 8px 16px;
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    z-index: 20;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    transition: all 0.2s;
}

.image-validate-btn:hover {
    background: #45a049;
    transform: scale(1.05);
}

/* Info mode édition */
.edit-mode-info {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(33, 150, 243, 0.9);
    color: white;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 10px;
    z-index: 10;
    white-space: nowrap;
}

/* ============================================
   PAGES GALERIE
   ============================================ */

.gallery-page .page-content {
    padding: 20px 25px 75px;
}

.gallery-page .page-header {
    margin-bottom: 12px;
}

.gallery-photos-zone {
    flex: 1;
    position: relative;
    min-height: 480px;
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 10px,
        rgba(0,0,0,0.01) 10px,
        rgba(0,0,0,0.01) 20px
    );
}

/* Snap Grid visual */
.gallery-photos-zone.show-grid {
    background-image:
        linear-gradient(rgba(0,0,0,0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0,0,0,0.05) 1px, transparent 1px);
    background-size: var(--snap-size) var(--snap-size);
}

/* Guide lines for alignment */
.snap-guide {
    position: absolute;
    background: var(--hkd-red);
    opacity: 0.5;
    pointer-events: none;
    z-index: 100;
}

.snap-guide-h {
    height: 1px;
    left: 0;
    right: 0;
}

.snap-guide-v {
    width: 1px;
    top: 0;
    bottom: 0;
}

.photos-drop-hint {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--hkd-gray-medium);
    font-size: 10px;
    text-align: center;
    pointer-events: none;
}

.gallery-photos-zone.has-photos .photos-drop-hint {
    display: none;
}

/* Photo redimensionnable */
.resizable-photo {
    position: absolute;
    background: transparent;
    overflow: hidden;
    cursor: move;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    touch-action: none;
    user-select: none;
    transition: box-shadow 0.2s;
}

/* Mode normal: object-fit cover */
.resizable-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform-origin: center center;
    pointer-events: none;
}

.resizable-photo:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

.resizable-photo.selected {
    outline: 2px solid var(--hkd-red);
    outline-offset: 2px;
}

.resizable-photo.snapping {
    outline: 2px solid #4CAF50;
    outline-offset: 2px;
}

/* Mode édition inline (double-clic) */
.resizable-photo.edit-mode {
    outline: 3px solid #2196F3;
    outline-offset: 2px;
    z-index: 100;
    cursor: grab !important;
}

.resizable-photo.edit-mode:active {
    cursor: grabbing !important;
}

/* En mode édition: contain pour voir toute l'image, puis zoom/pan */
.resizable-photo.edit-mode img {
    object-fit: contain !important;
    pointer-events: auto;
    cursor: grab;
    transition: none;
}

.resizable-photo.edit-mode .edit-mode-hint {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #2196F3;
    color: white;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 10px;
    white-space: nowrap;
    margin-bottom: 4px;
}

.resizable-photo.edit-mode .resize-handle,
.resizable-photo.edit-mode .photo-delete-btn,
.resizable-photo.edit-mode .photo-crop-btn,
.resizable-photo.edit-mode .photo-replace-btn {
    display: none !important;
}

/* ============================================
   Editor Toolbar (nouveau système d'édition)
   ============================================ */

.editor-toolbar {
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(33, 150, 243, 0.95);
    padding: 6px 10px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 1000;
    white-space: nowrap;
}

.editor-btn {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 4px;
    background: rgba(255,255,255,0.2);
    color: white;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.2s;
}

.editor-btn:hover {
    background: rgba(255,255,255,0.35);
    transform: scale(1.1);
}

.editor-btn:active {
    transform: scale(0.95);
}

.editor-btn-validate {
    background: #4CAF50;
}

.editor-btn-validate:hover {
    background: #45a049;
}

.editor-btn-cancel {
    background: #f44336;
}

.editor-btn-cancel:hover {
    background: #da190b;
}

.editor-btn-reset {
    background: #ff9800;
}

.editor-btn-reset:hover {
    background: #e68a00;
}

.editor-zoom-level {
    font-size: 11px;
    font-weight: 600;
    color: white;
    min-width: 40px;
    text-align: center;
}

/* Les zones cover/description utilisent le même positionnement de toolbar */

/* Notification styles */
.hkd-notification {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 10000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    animation: slideUp 0.3s ease;
    max-width: calc(100vw - 40px);
    text-align: center;
}

.hkd-notification.fade-out {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
    transition: all 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* Poignées de redimensionnement */
.resize-handle {
    position: absolute;
    background: var(--hkd-red);
    border-radius: 2px;
    opacity: 0;
    transition: opacity 0.2s;
}

.resizable-photo:hover .resize-handle,
.resizable-photo.selected .resize-handle {
    opacity: 1;
}

.resize-handle-se {
    width: 14px;
    height: 14px;
    right: -5px;
    bottom: -5px;
    cursor: se-resize;
}

.resize-handle-sw {
    width: 14px;
    height: 14px;
    left: -5px;
    bottom: -5px;
    cursor: sw-resize;
}

.resize-handle-ne {
    width: 14px;
    height: 14px;
    right: -5px;
    top: -5px;
    cursor: ne-resize;
}

.resize-handle-nw {
    width: 14px;
    height: 14px;
    left: -5px;
    top: -5px;
    cursor: nw-resize;
}

/* Boutons sur photo */
.photo-delete-btn,
.photo-crop-btn,
.photo-replace-btn {
    position: absolute;
    width: 24px;
    height: 24px;
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 12px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.photo-delete-btn:hover,
.photo-crop-btn:hover,
.photo-replace-btn:hover {
    transform: scale(1.15);
}

.photo-delete-btn {
    top: 4px;
    right: 4px;
    background: var(--hkd-red);
}

.photo-delete-btn:hover {
    background: var(--hkd-red-dark);
}

.photo-crop-btn {
    top: 4px;
    right: 32px;
    background: var(--hkd-gray-dark);
}

.photo-crop-btn:hover {
    background: #555;
}

.photo-replace-btn {
    top: 4px;
    right: 60px;
    background: #2196F3;
}

.photo-replace-btn:hover {
    background: #1976D2;
}

.resizable-photo:hover .photo-delete-btn,
.resizable-photo:hover .photo-crop-btn,
.resizable-photo:hover .photo-replace-btn {
    opacity: 1;
}

/* ============================================
   Templates de galerie
   ============================================ */

/* Grille 2x2 */
.gallery-template-grid-2x2 .resizable-photo {
    width: calc(50% - 5px) !important;
    height: calc(50% - 5px) !important;
}

.gallery-template-grid-2x2 .resizable-photo:nth-child(1) {
    left: 0 !important;
    top: 0 !important;
}

.gallery-template-grid-2x2 .resizable-photo:nth-child(2) {
    left: calc(50% + 5px) !important;
    top: 0 !important;
}

.gallery-template-grid-2x2 .resizable-photo:nth-child(3) {
    left: 0 !important;
    top: calc(50% + 5px) !important;
}

.gallery-template-grid-2x2 .resizable-photo:nth-child(4) {
    left: calc(50% + 5px) !important;
    top: calc(50% + 5px) !important;
}

/* 1 grande + 2 petites */
.gallery-template-grid-1-2 .resizable-photo:nth-child(1) {
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    height: 60% !important;
}

.gallery-template-grid-1-2 .resizable-photo:nth-child(2) {
    left: 0 !important;
    top: calc(60% + 10px) !important;
    width: calc(50% - 5px) !important;
    height: calc(40% - 10px) !important;
}

.gallery-template-grid-1-2 .resizable-photo:nth-child(3) {
    left: calc(50% + 5px) !important;
    top: calc(60% + 10px) !important;
    width: calc(50% - 5px) !important;
    height: calc(40% - 10px) !important;
}

/* 2 petites + 1 grande */
.gallery-template-grid-2-1 .resizable-photo:nth-child(1) {
    left: 0 !important;
    top: 0 !important;
    width: calc(50% - 5px) !important;
    height: calc(40% - 5px) !important;
}

.gallery-template-grid-2-1 .resizable-photo:nth-child(2) {
    left: calc(50% + 5px) !important;
    top: 0 !important;
    width: calc(50% - 5px) !important;
    height: calc(40% - 5px) !important;
}

.gallery-template-grid-2-1 .resizable-photo:nth-child(3) {
    left: 0 !important;
    top: calc(40% + 5px) !important;
    width: 100% !important;
    height: calc(60% - 5px) !important;
}

/* 1 photo pleine page */
.gallery-template-full .resizable-photo:nth-child(1) {
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    height: 100% !important;
}

/* ============================================
   Modals
   ============================================ */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 12px;
    padding: 24px;
    min-width: 400px;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-content.modal-large {
    min-width: 600px;
    max-width: 800px;
}

.modal-content h2 {
    font-size: 1.25rem;
    color: var(--hkd-gray-dark);
    margin-bottom: 20px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

/* Crop Container */
.crop-container {
    width: 100%;
    height: 400px;
    background: #1a1a1a;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.crop-container img {
    max-width: 100%;
    max-height: 100%;
    cursor: grab;
    user-select: none;
}

.crop-container img:active {
    cursor: grabbing;
}

.crop-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 15px;
}

#crop-zoom-level {
    min-width: 60px;
    text-align: center;
    font-weight: 600;
}

/* ============================================
   Image Edit Modal (nouveau système)
   ============================================ */

.image-edit-modal-content {
    max-width: 700px;
    width: 95%;
}

.image-edit-container {
    background: #1a1a1a;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 15px;
}

.image-edit-preview {
    position: relative;
    width: 100%;
    height: 350px;
    overflow: hidden;
    cursor: grab;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-edit-preview:active {
    cursor: grabbing;
}

.image-edit-preview img {
    max-width: none;
    max-height: none;
    user-select: none;
    pointer-events: none;
    transform-origin: center center;
    transition: none;
}

.image-edit-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 15px;
}

.zoom-control {
    display: flex;
    align-items: center;
    gap: 12px;
}

.zoom-control label {
    font-weight: 600;
    color: var(--hkd-gray-dark);
    min-width: 50px;
}

.zoom-slider-container {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.zoom-slider {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--hkd-gray-light);
    border-radius: 3px;
    outline: none;
}

.zoom-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--hkd-red);
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.zoom-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--hkd-red);
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.zoom-btn {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: white;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--hkd-gray-dark);
    transition: all 0.2s;
}

.zoom-btn:hover {
    background: var(--hkd-gray-light);
    border-color: var(--hkd-red);
}

.zoom-btn:active {
    transform: scale(0.95);
}

.zoom-value {
    min-width: 50px;
    text-align: center;
    font-weight: 600;
    font-size: 14px;
    color: var(--hkd-blue);
}

.edit-hint {
    font-size: 12px;
    color: var(--hkd-gray-medium);
    text-align: center;
    margin: 0;
}

/* Saved Projects List */
.saved-projects-list {
    max-height: 300px;
    overflow-y: auto;
}

.no-projects {
    color: var(--hkd-gray-medium);
    text-align: center;
    padding: 30px;
}

.project-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.project-item:hover {
    border-color: var(--hkd-red);
    background: rgba(227, 30, 36, 0.02);
}

.project-info {
    flex: 1;
}

.project-name {
    font-weight: 600;
    color: var(--hkd-gray-dark);
}

.project-date {
    font-size: 0.8rem;
    color: var(--hkd-gray-medium);
}

.btn-delete {
    width: 28px;
    height: 28px;
    border: none;
    background: var(--hkd-gray-light);
    border-radius: 4px;
    cursor: pointer;
    color: var(--hkd-gray-dark);
    transition: all 0.2s;
}

.btn-delete:hover {
    background: var(--hkd-red);
    color: white;
}

/* ============================================
   Print / PDF Styles
   ============================================ */

@media print {
    .app-header,
    .form-panel,
    .preview-controls,
    .modal {
        display: none !important;
    }

    .preview-panel {
        background: white;
    }

    .preview-container {
        padding: 0;
    }

    .a4-page {
        width: 210mm;
        height: 297mm;
        box-shadow: none;
        page-break-after: always;
    }

    .resize-handle,
    .photo-delete-btn,
    .photo-crop-btn,
    .photos-drop-hint,
    .cover-image-placeholder,
    .description-image-placeholder,
    .snap-guide {
        display: none !important;
    }
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 1200px) {
    :root {
        --a4-width: 450px;
        --a4-height: 636px;
    }

    .form-panel {
        width: 360px;
        min-width: 320px;
    }
}

@media (max-width: 900px) {
    .main-content {
        flex-direction: column;
    }

    .form-panel {
        width: 100%;
        max-height: 50vh;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .preview-panel {
        flex: 1;
    }
}

/* ============================================
   MOBILE RESPONSIVE (< 768px)
   ============================================ */

@media (max-width: 768px) {
    :root {
        --a4-width: 100%;
        --a4-height: auto;
    }

    /* Header mobile */
    .app-header {
        flex-wrap: wrap;
        padding: 10px 12px;
        gap: 10px;
    }

    .app-header h1 {
        font-size: 1rem;
        order: 1;
        flex: 1;
        min-width: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .header-logo {
        order: 0;
    }

    .header-logo img {
        height: 30px;
    }

    .header-actions {
        order: 2;
        width: 100%;
        justify-content: space-between;
    }

    .header-actions .btn {
        flex: 1;
        padding: 10px 8px;
        font-size: 0.75rem;
    }

    .header-actions .btn .icon {
        display: none;
    }

    /* Main content mobile - tabs style */
    .main-content {
        flex-direction: column;
        height: calc(100vh - 100px);
    }

    .form-panel {
        width: 100%;
        max-height: none;
        height: auto;
        min-height: 0;
        overflow-y: auto;
        padding: 12px;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .form-section {
        margin-bottom: 16px;
        padding-bottom: 16px;
    }

    .form-section h2 {
        font-size: 0.8rem;
        margin-bottom: 12px;
    }

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

    .form-group label {
        font-size: 0.75rem;
    }

    .form-group input[type="text"],
    .form-group textarea,
    .form-select {
        font-size: 16px; /* Prevent zoom on iOS */
        padding: 12px;
    }

    .form-group textarea {
        min-height: 60px;
    }

    /* Template grid mobile */
    .template-grid,
    .cover-template-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 4px;
    }

    .template-btn {
        padding: 6px 2px;
    }

    .template-btn svg {
        width: 24px;
        height: 24px;
    }

    .template-btn span {
        font-size: 0.6rem;
    }

    /* Preview panel mobile */
    .preview-panel {
        flex: 1;
        min-height: 0;
    }

    .preview-controls {
        padding: 8px 12px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .preview-nav {
        order: 0;
        flex: 1;
    }

    .preview-zoom {
        order: 1;
    }

    .btn-nav {
        width: 32px;
        height: 32px;
    }

    .btn-zoom {
        width: 28px;
        height: 28px;
    }

    #zoom-fit {
        padding: 0 8px;
        font-size: 0.7rem;
    }

    #page-indicator {
        font-size: 0.8rem;
        min-width: 80px;
    }

    .preview-container {
        padding: 10px;
        overflow: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* A4 page mobile */
    .a4-page {
        width: 100%;
        max-width: 400px;
        height: auto;
        aspect-ratio: 210 / 297;
        margin: 0 auto;
    }

    .pages-wrapper {
        gap: 20px;
    }

    /* Gallery zone mobile */
    .gallery-photos-zone {
        min-height: 300px;
    }

    /* Photo controls - always visible on mobile */
    .resizable-photo .photo-delete-btn,
    .resizable-photo .photo-crop-btn,
    .resizable-photo .photo-replace-btn {
        opacity: 1;
    }

    .photo-delete-btn,
    .photo-crop-btn,
    .photo-replace-btn {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }

    .resize-handle {
        opacity: 1;
        width: 18px !important;
        height: 18px !important;
    }

    /* Photos list mobile */
    .photos-list {
        gap: 6px;
    }

    .photo-list-item {
        padding: 6px;
    }

    .photo-list-thumb {
        width: 40px;
        height: 32px;
    }

    .photo-list-name {
        font-size: 0.75rem;
    }

    .photo-list-size {
        font-size: 0.65rem;
    }

    .photo-list-actions .btn-crop-photo,
    .photo-list-actions .btn-remove-photo,
    .photo-list-actions .btn-replace-photo {
        width: 28px;
        height: 28px;
    }

    /* Modals mobile */
    .modal-content {
        min-width: auto;
        max-width: calc(100vw - 20px);
        margin: 10px;
        padding: 16px;
    }

    .modal-content.modal-large {
        min-width: auto;
        max-width: calc(100vw - 20px);
    }

    .crop-container {
        height: 300px;
    }

    /* Image edit modal mobile */
    .image-edit-modal-content {
        max-width: calc(100vw - 20px);
        width: 100%;
    }

    .image-edit-preview {
        height: 280px;
    }

    .zoom-control {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .zoom-control label {
        text-align: center;
    }

    .zoom-slider-container {
        justify-content: center;
    }

    .zoom-btn {
        width: 40px;
        height: 40px;
    }

    /* Image edit trigger button mobile */
    .image-edit-trigger {
        padding: 8px 14px !important;
        font-size: 13px !important;
    }

    /* Editor toolbar mobile */
    .editor-toolbar {
        padding: 4px 6px;
        gap: 3px;
        border-radius: 6px;
    }

    .editor-btn {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }

    .editor-zoom-level {
        font-size: 10px;
        min-width: 35px;
    }

    /* En mode édition sur mobile, masquer les boutons normaux */
    .resizable-photo.edit-mode .photo-delete-btn,
    .resizable-photo.edit-mode .photo-crop-btn,
    .resizable-photo.edit-mode .photo-replace-btn,
    .resizable-photo.edit-mode .resize-handle {
        display: none !important;
    }

    /* Gallery edit section mobile */
    .gallery-edit-section {
        padding-top: 12px;
        margin-top: 12px;
    }

    /* Page items mobile */
    .page-item {
        padding: 8px 10px;
    }

    .page-item-title {
        font-size: 0.8rem;
    }

    .page-item-photos {
        font-size: 0.7rem;
    }

    /* Cover images list mobile */
    .cover-images-list .cover-thumb {
        width: 50px;
        height: 42px;
    }

    /* Cover page elements mobile */
    .cover-header {
        padding: 12px 15px 12px 20px;
    }

    .logo-cover {
        height: 24px;
    }

    .cover-date {
        font-size: 9px;
    }

    .cover-image-zone {
        top: 50px;
        left: 15px;
        right: 15px;
        height: 45%;
    }

    .cover-title-block {
        bottom: 60px;
        left: 15px;
        right: 15px;
        padding-top: 12px;
    }

    .cover-category {
        font-size: 14px;
        margin-top: -30px;
    }

    .cover-title {
        font-size: 18px;
        margin-bottom: 8px;
    }

    .cover-author {
        font-size: 9px;
    }

    .cover-details {
        font-size: 8px;
    }

    .page-footer {
        padding: 8px 15px;
    }

    .page-number {
        font-size: 8px;
        bottom: 4px;
        right: 15px;
    }

    /* Description page mobile */
    .description-content {
        padding: 12px 15px 50px;
    }

    .page-header {
        margin-bottom: 10px;
    }

    .logo-page {
        height: 22px;
    }

    .section-title {
        font-size: 11px;
        margin-bottom: 4px;
    }

    .section-content {
        font-size: 9px;
        line-height: 1.5;
    }

    .description-section {
        margin-bottom: 10px;
    }

    .description-image-zone {
        height: 120px;
        min-height: 60px;
    }

    /* Gallery page mobile */
    .gallery-page .page-content {
        padding: 12px 15px 50px;
    }
}

/* ============================================
   SMALL MOBILE (< 480px)
   ============================================ */

@media (max-width: 480px) {
    .app-header h1 {
        font-size: 0.9rem;
    }

    .header-actions .btn {
        padding: 8px 6px;
        font-size: 0.7rem;
    }

    .form-panel {
        padding: 10px;
    }

    .preview-container {
        padding: 8px;
    }

    .a4-page {
        max-width: 100%;
    }

    .template-grid,
    .cover-template-grid {
        grid-template-columns: repeat(5, 1fr);
    }

    .btn-auto-layout {
        font-size: 0.8rem;
        padding: 10px;
    }
}

/* ============================================
   TOUCH DEVICE SPECIFIC
   ============================================ */

@media (hover: none) and (pointer: coarse) {
    /* Touch devices - larger touch targets */
    .btn {
        min-height: 44px;
    }

    .template-btn {
        min-height: 50px;
    }

    .photo-delete-btn,
    .photo-crop-btn,
    .photo-replace-btn {
        width: 32px;
        height: 32px;
        opacity: 1;
    }

    .resize-handle {
        opacity: 1;
        width: 20px !important;
        height: 20px !important;
    }

    /* Always show controls on touch */
    .resizable-photo .resize-handle {
        opacity: 1;
    }

    /* Disable hover effects on touch */
    .btn-primary:hover {
        transform: none;
    }

    .page-item:hover {
        background: var(--hkd-gray-light);
    }

    .page-item.active:hover {
        background: var(--hkd-red);
    }

    /* Editor toolbar on touch - larger buttons */
    .editor-btn {
        width: 36px;
        height: 36px;
        font-size: 18px;
    }

    .editor-zoom-level {
        font-size: 12px;
        min-width: 45px;
    }

    /* En mode édition, masquer les autres contrôles */
    .resizable-photo.edit-mode .resize-handle {
        display: none !important;
    }
}

/* ============================================
   Animations
   ============================================ */

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeOut {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(20px); }
}
