:root {
    /* --primary: #FF6B6B; */
    /* --secondary: #4ECDC4; */
    /* --accent: #FFD93D; */
    --background: #F7F7FF;
    --text: #333;
    --surface: #FFFFFF;
    --border-radius: 12px;
    --transition: all 0.3s ease;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --primary-gradient: linear-gradient(135deg, #FF6B6B, #4ECDC4);
    --secondary-gradient: linear-gradient(135deg, #FFD93D, #FF6B6B);
    --soft-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
    --playful-radius: 25px;
}

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

body {
    font-family: 'Baloo 2', cursive;
    /* background-color: var(--background); */
    background-image: url(../images/bgapp.png);
    color: var(--text);
    line-height: 1.6;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 100%;
    position: relative;
}

.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(15px);
    border-radius: 50px;
    padding: 8px 15px;
    margin: 15px auto;
    max-width: 95%;
    box-shadow: var(--soft-shadow);
    border: 2px solid rgba(78, 205, 196, 0.1);
    transition: all 0.4s ease;
}

.toolbar:hover {
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
    transform: translateY(-3px);
}

.toolbar-section {
    display: flex;
    align-items: center;
    gap: 15px;
}

.actionbar {
    display: flex;
    align-items: center;
    flex-direction: column;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(15px);
    border-radius: 50px;
    padding: 8px 15px;
    margin: 15px 15px 15px auto;
    max-width: 95%;
    box-shadow: var(--soft-shadow);
    border: 2px solid rgba(78, 205, 196, 0.1);
    transition: all 0.4s ease;
    position: fixed;
    right: 15px;
    top: 35%;
    /* transform: translateY(-50%); */
    z-index: 100;
}

.actionbar:hover {
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
    transform: scale(1.05);
}

.actionbar-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}
.tool-btn {
    position: relative;
    background: transparent;
    border: none;
    color: #333;
    cursor: pointer;
    padding: 10px;
    border-radius: 50%;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    perspective: 500px;
}

.tool-btn i {
    font-size: 18px;
    transition: transform 0.3s ease;
}

.tool-btn:hover i {
    transform: rotate(15deg) scale(1.2);
}

.tool-btn.active {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 4px 15px rgba(78, 205, 196, 0.3);
    transform: scale(1.1) rotate(5deg);
}

.tool-btn.template {
    background-color: #2ecc71;
    color: white;
}

.tool-btn.template:hover {
    background-color: #1d8348;
}

.tool-btn.wipe-all {
    background-color: #FF4136; /* Bright red to indicate destructive action */
    color: white;
    transition: transform 0.3s ease, background-color 0.3s ease;
}

.tool-btn.wipe-all:hover {
    background-color: #FF6F61; /* Lighter red on hover */
    transform: scale(1.1) rotate(5deg);
}

.tool-bubble {
    position: absolute;
    transform: translateX(-50%) scale(0.7);
    background: var(--secondary-gradient);
    color: white;
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    box-shadow: var(--soft-shadow);
    z-index: 10;
}

.toolbar .tool-bubble {
    bottom: -40px;
    left: 50%;
}

.actionbar .tool-bubble {
    right: 50%;
}

.tool-btn:hover .tool-bubble {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) scale(1);
}

.brush-styles {
    display: flex;
    gap: 10px;
    background-color: rgba(0, 0, 0, 0.03);
    border-radius: 30px;
    padding: 5px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
}

.brush-size-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

.size-label {
    font-size: 12px;
    color: #666;
    margin-right: 5px;
}

#brush-size {
    -webkit-appearance: none;
    width: 100px;
    height: 6px;
    background: var(--primary-gradient);
    outline: none;
    opacity: 0.7;
    border-radius: 3px;
    transition: opacity 0.2s;
}

#brush-size::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 15px;
    height: 15px;
    background: white;
    border: 2px solid var(--primary-gradient);
    cursor: pointer;
    border-radius: 50%;
    box-shadow: var(--soft-shadow);
}

.brush-size-preview {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(45deg, #333, #666);
    box-shadow: var(--soft-shadow);
}

.color-palette {
    display: flex;
    gap: 10px;
    padding: 5px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 25px;
    backdrop-filter: blur(5px);
}

.color-btn {
    width: 35px;
    height: 35px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--soft-shadow);
    position: relative;
    overflow: hidden;
}

.color-btn::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        transparent,
        rgba(255, 255, 255, 0.2),
        transparent
    );
    transform: rotate(45deg) translate(-100%, -100%);
    transition: transform 0.3s ease;
}

.color-btn:hover::after {
    transform: rotate(45deg) translate(0, 0);
}

.color-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.color-btn.active {
    transform: scale(1.1);
    box-shadow: 0 0 0 3px white, 0 6px 12px rgba(0, 0, 0, 0.15);
}

.color-picker-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    margin-left: 10px;
}

.color-picker-label {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--secondary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--soft-shadow);
    overflow: hidden;
}

.color-picker-label:hover {
    transform: scale(1.1) rotate(15deg);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.2);
}

.color-picker-label i {
    color: white;
    font-size: 18px;
    transition: transform 0.3s ease;
}

.color-picker-label:hover i {
    transform: rotate(-15deg);
}

#custom-color-picker {
    position: absolute;
    width: 40px;
    height: 40px;
    top: 0;
    left: 0;
    opacity: 0;
    cursor: pointer;
}

#custom-color-picker::-webkit-color-swatch-wrapper {
    padding: 0;
}

#custom-color-picker::-webkit-color-swatch {
    border: none;
    border-radius: 50%;
}

@keyframes rainbow {
    0% { filter: hue-rotate(0deg); }
    100% { filter: hue-rotate(360deg); }
}

.color-picker-label:active {
    animation: rainbow 1s linear;
}

.color-picker-label::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        transparent,
        rgba(255, 255, 255, 0.2),
        transparent
    );
    transform: rotate(45deg);
    transition: transform 0.3s ease;
}

.color-picker-label:hover::after {
    transform: rotate(45deg) translate(50%, 50%);
}

.main-content {
    height: 800px;
    flex: 2;
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    padding: 20px;
    padding-right: 10%;
    position: relative;

}

.template-preview-container{
    position: relative;
    max-width: 400px;
    height: 600px; margin-right: 48px;
    background: white;
    border-radius: var(--playful-radius);
    box-shadow: var(--soft-shadow);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.canvas-container {
    position: relative;
    flex: 1;
    max-width: 800px;
    height: 600px;
    background: white;
    border-radius: var(--playful-radius);
    box-shadow: var(--soft-shadow);
    overflow: hidden;
}

#canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: crosshair;
}

/* Modals */
.modal {
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.4s cubic-bezier(0.25, 0.1, 0.25, 1),
                visibility 0.4s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.modal.show {
    display: flex;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.modal-content {
    position: relative;
    background: white;
    border-radius: 25px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    box-shadow: 
        0 15px 35px rgba(0, 0, 0, 0.1), 
        0 5px 15px rgba(0, 0, 0, 0.05);
    transform: scale(0.7) translateY(50px);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.modal.show .modal-content {
    transform: scale(1) translateY(0);
    opacity: 1;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h2 {
    margin: 0;
    color: var(--text);
    font-size: 1.5rem;
}

.close-modal {
    font-size: 24px;
    color: var(--text);
    cursor: pointer;
    transition: all 0.3s ease;
}

.close-modal:hover {
    color: var(--primary);
    transform: rotate(90deg);
}

.save-format-options {
    display: flex;
    justify-content: space-around;
    gap: 20px;
    position: relative;
    z-index: 2;
}

.save-format-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(255, 255, 255, 0.8);
    border: 2px solid transparent;
    border-radius: 15px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.4s ease;
    position: relative;
    overflow: hidden;
    box-shadow: 
        0 4px 6px rgba(0, 0, 0, 0.1),
        inset 0 0 0 1px rgba(78, 205, 196, 0.2);
}

.save-format-btn::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg, 
        transparent, 
        rgba(78, 205, 196, 0.1), 
        transparent
    );
    transform: rotate(45deg);
    transition: transform 0.4s ease;
    opacity: 0;
}

.save-format-btn:hover::before {
    transform: rotate(45deg) translate(50%, 50%);
    opacity: 1;
}

.save-format-btn:hover {
    transform: scale(1.05) translateY(-5px);
    border-color: var(--secondary);
    box-shadow: 
        0 10px 20px rgba(0, 0, 0, 0.1),
        0 0 0 3px var(--secondary);
}

.save-format-btn i {
    font-size: 2.5rem;
    margin-bottom: 10px;
    color: var(--secondary);
    transition: all 0.3s ease;
}

.save-format-btn span {
    font-family: 'Baloo 2', cursive;
    font-weight: 600;
    color: var(--text);
    transition: color 0.3s ease;
}

.save-format-btn:hover i {
    transform: scale(1.2) rotate(15deg);
    color: var(--secondary-dark, #3aa8a4);
}

.save-format-btn:hover span {
    color: var(--secondary-dark, #3aa8a4);
}

/* Animation de la modal */
@keyframes modalEnter {
    0% {
        opacity: 0;
        transform: scale(0.7) translateY(50px);
    }
    70% {
        opacity: 0.8;
        transform: scale(1.05) translateY(-10px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .toolbar {
        flex-wrap: wrap;
        justify-content: center;
        padding: 10px;
    }

    .toolbar-section {
        margin: 5px 0;
    }

    .canvas-container {
        width: 100%;
        height: 0;
        padding-bottom: 75%; /* 4:3 aspect ratio */
    }
}

.upload-image-container {
    border: 2px dashed #4ECDC4;
    border-radius: 20px;
    padding: 20px;
    text-align: center;
    transition: all 0.3s ease;
}

.upload-image-container.highlight {
    border-color: #FF6B6B;
    background-color: rgba(78, 205, 196, 0.1);
    transform: scale(1.02);
}

.upload-image-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 20px;
    transition: all 0.3s ease;
}

.upload-image-label i {
    font-size: 50px;
    color: #4ECDC4;
    margin-bottom: 15px;
    transition: transform 0.3s ease;
}

.upload-image-container.highlight .upload-image-label i {
    transform: scale(1.2) rotate(15deg);
    color: #FF6B6B;
}

#image-upload-input {
    display: none;
}

.image-preview-container {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

#image-preview {
    max-width: 100%;
    max-height: 300px;
    object-fit: contain;
    border-radius: 10px;
}

#use-uploaded-image-btn {
    padding: 10px 20px;
    background-color: var(--accent);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
}

#use-uploaded-image-btn:hover {
    transform: scale(1.08);
}

/* Template Modal Styles */
#template-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.5);
}

#template-modal .modal-content {
    background-color: #fefefe;
    margin: 10% auto;
    padding: 20px;
    border-radius: 10px;
    width: 80%;
    max-width: 900px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    padding: 20px;
    max-height: 70vh;
    overflow-y: auto;
}

.template-item {
    position: relative;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
    cursor: pointer;
    background: white;
}

.template-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.2);
}

.template-item img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.template-item:hover img {
    transform: scale(1.1);
}

#template-modal .modal-content {
    max-width: 900px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 30px;
    background: white;
}
/************************************************************************************************************
/* Styles précédents... */

@media (max-width: 1200px) {
    .template-preview-container {
        width: 100%; /* Pleine largeur */
        max-width: 100%; /* S'assurer qu'il ne dépasse pas le conteneur */
        height: auto; /* Hauteur adaptative */
        max-height: 500px; /* Limiter la hauteur */
        margin: 0 0 20px 0; /* Espacer du canvas */
    }
}

@media (max-width: 768px) {
    .actionbar {
        flex-wrap: wrap;
        justify-content: center;
        align-items: center;
        padding: 10px;
        position: absolute;
        right: 0;
        flex-direction: row; 
    }
    .template-preview-container {
        height: 350px; /* Réduire la hauteur pour les écrans plus petits */
        margin-bottom: 15px;
    }

    .template-preview-container.d-none {
        display: none !important; /* Gérer la visibilité */
    }
}

@media (max-width: 480px) {
    .actionbar {
        flex-wrap: wrap;
        justify-content: center;
        align-items: center;
        padding: 10px;
        position: absolute;
        right: 0;
        flex-direction: row; 
    }
    .template-preview-container {
        height: 250px; /* Encore plus petit sur mobile */
        padding: 10px;
    }

    .template-preview-container img {
        max-height: 100%;
        max-width: 100%;
        object-fit: contain; /* Garder les proportions */
    }
}

/* Ajouts pour améliorer la flexibilité */
.template-preview-container {
    transition: all 0.3s ease; /* Animation douce */
    overflow: hidden; /* Masquer ce qui dépasse */
    display: flex; /* Utiliser flexbox */
    justify-content: center;
    align-items: center;
}

/* Responsive behaviour for main content */
.main-content {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: stretch;
    gap: 20px;
}

.templates-modal {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
}

.templates-modal .modal-content {
    position: relative;
    width: 95%;
    max-width: 1200px;
    max-height: 90vh;
    background: linear-gradient(
        135deg, 
        rgba(255, 255, 255, 0.9), 
        rgba(230, 240, 255, 0.95)
    );
    border-radius: 40px;
    box-shadow: 
        0 30px 60px rgba(0, 0, 0, 0.2),
        0 0 0 20px rgba(255, 255, 255, 0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: modal-enter 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    transform-origin: center;
    padding: 0;
}

@keyframes modal-enter {
    0% {
        opacity: 0;
        transform: scale(0.7) rotate(-15deg);
    }
    70% {
        opacity: 0.8;
        transform: scale(1.05) rotate(5deg);
    }
    100% {
        opacity: 1;
        transform: scale(1) rotate(0);
    }
}

.templates-modal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    background: linear-gradient(
        135deg, 
        var(--primary), 
        var(--secondary)
    );
    color: white;
    position: relative;
    overflow: hidden;
}

.templates-modal .modal-header::before {
    content: '🎨';
    position: absolute;
    font-size: 150px;
    opacity: 0.1;
    top: -50px;
    right: -50px;
    transform: rotate(25deg);
}

.templates-modal .modal-header h2 {
    font-size: 2.5rem;
    font-weight: 700;
    text-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    margin: 0;
    z-index: 2;
}

.templates-modal .close-modal {
    font-size: 2.5rem;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    opacity: 0.8;
    z-index: 2;
}

.templates-modal .close-modal:hover {
    transform: scale(1.2) rotate(90deg);
    opacity: 1;
}

.templates-modal .modal-body {
    flex-grow: 1;
    overflow-y: auto;
    padding: 20px;
    background: rgba(255, 255, 255, 0.05);
}

.app-templates-grid {
    display: flex;
    flex-direction: column;
    gap: 35px;
    padding: 20px;
    justify-content: center;
}

.template-item {
    position: relative;
    background: white;
    border-radius: 25px;
    overflow: hidden;
    box-shadow: 
        0 15px 30px rgba(0, 0, 0, 0.1),
        0 0 0 5px rgba(0, 128, 128, 0.1);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    cursor: pointer;
    perspective: 1000px;
    transform-style: preserve-3d;
}

.template-item:hover {
    transform: 
        translateY(-15px) 
        rotateX(5deg) 
        scale(1.05);
    box-shadow: 
        0 25px 50px rgba(0, 0, 0, 0.15),
        0 0 0 5px var(--primary);
}

.template-item img {
    width: 100%;
    height: 300px;
    object-fit: contain;
    transition: transform 0.4s ease;
    background: linear-gradient(
        135deg, 
        #f5f7fa 0%, 
        #c3cfe2 100%
    );
    padding: 20px;
}

.template-item:hover img {
    transform: scale(1.1) rotate(3deg);
}

.difficulty-badge {
    position: absolute;
    top: 15px;
    right: 15px;
    padding: 8px 15px;
    border-radius: 50px;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.8rem;
    color: white;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    z-index: 3;
}

.difficulty-badge.facile {
    background: #4CAF50; /* Green */
}

.difficulty-badge.moyen {
    background: #FF9800; /* Orange */
}

.difficulty-badge.difficile {
    background: #F44336; /* Red */
}

.difficulty-section {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 25px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

.difficulty-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    justify-content: center;
}

@media (max-width: 768px) {
    .app-templates-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 15px;
    }

    .template-item img {
        height: 250px;
    }

    .templates-modal .modal-header h2 {
        font-size: 2rem;
    }
}

.app-templates-grid {
    display: flex;
    flex-direction: column;
    gap: 35px;
    padding: 20px;
    justify-content: center;
}

.difficulty-section {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 25px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

.difficulty-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 0 10px;
}

.difficulty-section-header h3 {
    font-size: 1.8rem;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.difficulty-section-header p {
    color: rgba(0, 0, 0, 0.6);
    margin: 0;
    font-size: 1rem;
}

.difficulty-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    justify-content: center;
}

.difficulty-section.facile {
    background: linear-gradient(135deg, rgba(76, 175, 80, 0.05), rgba(76, 175, 80, 0.1));
    border: 2px solid rgba(76, 175, 80, 0.2);
}

.difficulty-section.moyen {
    background: linear-gradient(135deg, rgba(255, 152, 0, 0.05), rgba(255, 152, 0, 0.1));
    border: 2px solid rgba(255, 152, 0, 0.2);
}

.difficulty-section.difficile {
    background: linear-gradient(135deg, rgba(244, 67, 54, 0.05), rgba(244, 67, 54, 0.1));
    border: 2px solid rgba(244, 67, 54, 0.2);
}

@media (max-width: 768px) {
    .difficulty-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 15px;
    }

    .difficulty-section-header h3 {
        font-size: 1.5rem;
    }

    .difficulty-section-header p {
        font-size: 0.9rem;
    }
}

.custom-confirm-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.custom-confirm-modal.show {
    display: flex;
    opacity: 1;
}

.custom-confirm-content {
    background: white;
    border-radius: var(--border-radius);
    padding: 30px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: var(--soft-shadow);
    transform: scale(0.7);
    transition: transform 0.3s ease;
}

.custom-confirm-modal.show .custom-confirm-content {
    transform: scale(1);
}

.custom-confirm-content h2 {
    margin-bottom: 20px;
    color: var(--text);
    font-size: 1.2rem;
}

.custom-confirm-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 20px;
}

.custom-confirm-btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
}

.custom-confirm-btn.confirm {
    background: var(--primary-gradient);
    color: white;
}

.custom-confirm-btn.cancel {
    background: #f0f0f0;
    color: var(--text);
}

.custom-confirm-btn:hover {
    transform: translateY(-3px);
    box-shadow: var(--soft-shadow);
}

:root {
    /* --primary: #FF6B6B; */
    /* --secondary: #4ECDC4; */
    /* --accent: #FFD93D; */
    /* --background: #F7F7FF; */
    --text: #333;
    --surface: #FFFFFF;
    --border-radius: 12px;
    --transition: all 0.3s ease;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --primary-gradient: linear-gradient(135deg, #FF6B6B, #4ECDC4);
    --secondary-gradient: linear-gradient(135deg, #FFD93D, #FF6B6B);
    --soft-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
    --playful-radius: 25px;
}

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

body {
    font-family: 'Baloo 2', cursive;
    background-color: var(--background);
    color: var(--text);
    line-height: 1.6;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 100%;
    position: relative;
}

.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(15px);
    border-radius: 50px;
    padding: 8px 15px;
    margin: 15px auto;
    max-width: 95%;
    box-shadow: var(--soft-shadow);
    border: 2px solid rgba(78, 205, 196, 0.1);
    transition: all 0.4s ease;
}

.toolbar:hover {
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
    transform: translateY(-3px);
}

.toolbar-section {
    display: flex;
    align-items: center;
    gap: 15px;
}

.actionbar {
    display: flex;
    align-items: center;
    flex-direction: column;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(15px);
    border-radius: 50px;
    padding: 8px 15px;
    margin: 15px 15px 15px auto;
    max-width: 95%;
    box-shadow: var(--soft-shadow);
    border: 2px solid rgba(78, 205, 196, 0.1);
    transition: all 0.4s ease;
    position: fixed;
    right: 15px;
    top: 35%;
    /* transform: translateY(-50%); */
    z-index: 100;
}

.actionbar:hover {
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
    transform: scale(1.05);
}

.actionbar-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}
.tool-btn {
    position: relative;
    background: transparent;
    border: none;
    color: #333;
    cursor: pointer;
    padding: 10px;
    border-radius: 50%;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    perspective: 500px;
}

.tool-btn i {
    font-size: 18px;
    transition: transform 0.3s ease;
}

.tool-btn:hover i {
    transform: rotate(15deg) scale(1.2);
}

.tool-btn.active {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 4px 15px rgba(78, 205, 196, 0.3);
    transform: scale(1.1) rotate(5deg);
}

.tool-btn.template {
    background-color: #2ecc71;
    color: white;
}

.tool-btn.template:hover {
    background-color: #1d8348;
}

.tool-btn.wipe-all {
    background-color: #FF4136; /* Bright red to indicate destructive action */
    color: white;
    transition: transform 0.3s ease, background-color 0.3s ease;
}

.tool-btn.wipe-all:hover {
    background-color: #FF6F61; /* Lighter red on hover */
    transform: scale(1.1) rotate(5deg);
}

.tool-bubble {
    position: absolute;
    transform: translateX(-50%) scale(0.7);
    background: var(--secondary-gradient);
    color: white;
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    box-shadow: var(--soft-shadow);
    z-index: 10;
}

.toolbar .tool-bubble {
    bottom: -40px;
    left: 50%;
}

.actionbar .tool-bubble {
    right: 50%;
}

.tool-btn:hover .tool-bubble {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) scale(1);
}

.brush-styles {
    display: flex;
    gap: 10px;
    background-color: rgba(0, 0, 0, 0.03);
    border-radius: 30px;
    padding: 5px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
}

.brush-size-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

.size-label {
    font-size: 12px;
    color: #666;
    margin-right: 5px;
}

#brush-size {
    -webkit-appearance: none;
    width: 100px;
    height: 6px;
    background: var(--primary-gradient);
    outline: none;
    opacity: 0.7;
    border-radius: 3px;
    transition: opacity 0.2s;
}

#brush-size::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 15px;
    height: 15px;
    background: white;
    border: 2px solid var(--primary-gradient);
    cursor: pointer;
    border-radius: 50%;
    box-shadow: var(--soft-shadow);
}

.brush-size-preview {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(45deg, #333, #666);
    box-shadow: var(--soft-shadow);
}

.color-palette {
    display: flex;
    gap: 10px;
    padding: 5px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 25px;
    backdrop-filter: blur(5px);
}

.color-btn {
    width: 35px;
    height: 35px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--soft-shadow);
    position: relative;
    overflow: hidden;
}

.color-btn::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        transparent,
        rgba(255, 255, 255, 0.2),
        transparent
    );
    transform: rotate(45deg) translate(-100%, -100%);
    transition: transform 0.3s ease;
}

.color-btn:hover::after {
    transform: rotate(45deg) translate(0, 0);
}

.color-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.color-btn.active {
    transform: scale(1.1);
    box-shadow: 0 0 0 3px white, 0 6px 12px rgba(0, 0, 0, 0.15);
}

.color-picker-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    margin-left: 10px;
}

.color-picker-label {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--secondary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--soft-shadow);
    overflow: hidden;
}

.color-picker-label:hover {
    transform: scale(1.1) rotate(15deg);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.2);
}

.color-picker-label i {
    color: white;
    font-size: 18px;
    transition: transform 0.3s ease;
}

.color-picker-label:hover i {
    transform: rotate(-15deg);
}

#custom-color-picker {
    position: absolute;
    width: 40px;
    height: 40px;
    top: 0;
    left: 0;
    opacity: 0;
    cursor: pointer;
}

#custom-color-picker::-webkit-color-swatch-wrapper {
    padding: 0;
}

#custom-color-picker::-webkit-color-swatch {
    border: none;
    border-radius: 50%;
}

@keyframes rainbow {
    0% { filter: hue-rotate(0deg); }
    100% { filter: hue-rotate(360deg); }
}

.color-picker-label:active {
    animation: rainbow 1s linear;
}

.color-picker-label::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        transparent,
        rgba(255, 255, 255, 0.2),
        transparent
    );
    transform: rotate(45deg);
    transition: transform 0.3s ease;
}

.color-picker-label:hover::after {
    transform: rotate(45deg) translate(50%, 50%);
}

.main-content {
    height: 800px;
    flex: 2;
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    padding: 20px;
    padding-right: 10%;
    position: relative;

}

.template-preview-container{
    position: relative;
    max-width: 400px;
    height: 600px; margin-right: 48px;
    background: white;
    border-radius: var(--playful-radius);
    box-shadow: var(--soft-shadow);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.canvas-container {
    position: relative;
    flex: 1;
    max-width: 800px;
    height: 600px;
    background: white;
    border-radius: var(--playful-radius);
    box-shadow: var(--soft-shadow);
    overflow: hidden;
}

#canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: crosshair;
}

/* Modals */
.modal {
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.4s cubic-bezier(0.25, 0.1, 0.25, 1),
                visibility 0.4s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.modal.show {
    display: flex;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.modal-content {
    position: relative;
    background: white;
    border-radius: 25px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    box-shadow: 
        0 15px 35px rgba(0, 0, 0, 0.1), 
        0 5px 15px rgba(0, 0, 0, 0.05);
    transform: scale(0.7) translateY(50px);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.modal.show .modal-content {
    transform: scale(1) translateY(0);
    opacity: 1;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h2 {
    margin: 0;
    color: var(--text);
    font-size: 1.5rem;
}

.close-modal {
    font-size: 24px;
    color: var(--text);
    cursor: pointer;
    transition: all 0.3s ease;
}

.close-modal:hover {
    color: var(--primary);
    transform: rotate(90deg);
}

.save-format-options {
    display: flex;
    justify-content: space-around;
    gap: 20px;
    position: relative;
    z-index: 2;
}

.save-format-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(255, 255, 255, 0.8);
    border: 2px solid transparent;
    border-radius: 15px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.4s ease;
    position: relative;
    overflow: hidden;
    box-shadow: 
        0 4px 6px rgba(0, 0, 0, 0.1),
        inset 0 0 0 1px rgba(78, 205, 196, 0.2);
}

.save-format-btn::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg, 
        transparent, 
        rgba(78, 205, 196, 0.1), 
        transparent
    );
    transform: rotate(45deg);
    transition: transform 0.4s ease;
    opacity: 0;
}

.save-format-btn:hover::before {
    transform: rotate(45deg) translate(50%, 50%);
    opacity: 1;
}

.save-format-btn:hover {
    transform: scale(1.05) translateY(-5px);
    border-color: var(--secondary);
    box-shadow: 
        0 10px 20px rgba(0, 0, 0, 0.1),
        0 0 0 3px var(--secondary);
}

.save-format-btn i {
    font-size: 2.5rem;
    margin-bottom: 10px;
    color: var(--secondary);
    transition: all 0.3s ease;
}

.save-format-btn span {
    font-family: 'Baloo 2', cursive;
    font-weight: 600;
    color: var(--text);
    transition: color 0.3s ease;
}

.save-format-btn:hover i {
    transform: scale(1.2) rotate(15deg);
    color: var(--secondary-dark, #3aa8a4);
}

.save-format-btn:hover span {
    color: var(--secondary-dark, #3aa8a4);
}

/* Animation de la modal */
@keyframes modalEnter {
    0% {
        opacity: 0;
        transform: scale(0.7) translateY(50px);
    }
    70% {
        opacity: 0.8;
        transform: scale(1.05) translateY(-10px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .toolbar {
        flex-wrap: wrap;
        justify-content: center;
        padding: 10px;
    }

    .toolbar-section {
        margin: 5px 0;
    }

    .canvas-container {
        width: 100%;
        height: 0;
        padding-bottom: 75%; /* 4:3 aspect ratio */
    }
}

.upload-image-container {
    border: 2px dashed #4ECDC4;
    border-radius: 20px;
    padding: 20px;
    text-align: center;
    transition: all 0.3s ease;
}

.upload-image-container.highlight {
    border-color: #FF6B6B;
    background-color: rgba(78, 205, 196, 0.1);
    transform: scale(1.02);
}

.upload-image-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 20px;
    transition: all 0.3s ease;
}

.upload-image-label i {
    font-size: 50px;
    color: #4ECDC4;
    margin-bottom: 15px;
    transition: transform 0.3s ease;
}

.upload-image-container.highlight .upload-image-label i {
    transform: scale(1.2) rotate(15deg);
    color: #FF6B6B;
}

#image-upload-input {
    display: none;
}

.image-preview-container {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

#image-preview {
    max-width: 100%;
    max-height: 300px;
    object-fit: contain;
    border-radius: 10px;
}

#use-uploaded-image-btn {
    padding: 10px 20px;
    background-color: var(--accent);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
}

#use-uploaded-image-btn:hover {
    transform: scale(1.08);
}

/* Template Modal Styles */
#template-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.5);
}

#template-modal .modal-content {
    background-color: #fefefe;
    margin: 10% auto;
    padding: 20px;
    border-radius: 10px;
    width: 80%;
    max-width: 900px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    padding: 20px;
    max-height: 70vh;
    overflow-y: auto;
}

.template-item {
    position: relative;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
    cursor: pointer;
    background: white;
}

.template-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.2);
}

.template-item img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.template-item:hover img {
    transform: scale(1.1);
}

#template-modal .modal-content {
    max-width: 900px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 30px;
    background: white;
}
/************************************************************************************************************
/* Styles précédents... */

@media (max-width: 1200px) {
    .template-preview-container {
        width: 100%; /* Pleine largeur */
        max-width: 100%; /* S'assurer qu'il ne dépasse pas le conteneur */
        height: auto; /* Hauteur adaptative */
        max-height: 500px; /* Limiter la hauteur */
        margin: 0 0 20px 0; /* Espacer du canvas */
    }
}

@media (max-width: 768px) {
    .actionbar {
        flex-wrap: wrap;
        justify-content: center;
        align-items: center;
        padding: 10px;
        position: absolute;
        right: 0;
        flex-direction: row; 
    }
    .template-preview-container {
        height: 350px; /* Réduire la hauteur pour les écrans plus petits */
        margin-bottom: 15px;
    }

    .template-preview-container.d-none {
        display: none !important; /* Gérer la visibilité */
    }
}

@media (max-width: 480px) {
    .actionbar {
        flex-wrap: wrap;
        justify-content: center;
        align-items: center;
        padding: 10px;
        position: absolute;
        right: 0;
        flex-direction: row; 
    }
    .template-preview-container {
        height: 250px; /* Encore plus petit sur mobile */
        padding: 10px;
    }

    .template-preview-container img {
        max-height: 100%;
        max-width: 100%;
        object-fit: contain; /* Garder les proportions */
    }
}

/* Ajouts pour améliorer la flexibilité */
.template-preview-container {
    transition: all 0.3s ease; /* Animation douce */
    overflow: hidden; /* Masquer ce qui dépasse */
    display: flex; /* Utiliser flexbox */
    justify-content: center;
    align-items: center;
}

/* Responsive behaviour for main content */
.main-content {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: stretch;
    gap: 20px;
}
