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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    min-height: 100vh;
    padding: 20px;
    color: #fff;
}

.container {
    max-width: 800px;
    margin: 0 auto;
}

h1 {
    text-align: center;
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.subtitle {
    text-align: center;
    color: #94a3b8;
    margin-bottom: 30px;
    font-size: 1.1rem;
}

.section {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 25px;
    margin-bottom: 25px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

h2 {
    color: #60a5fa;
    margin-bottom: 20px;
    font-size: 1.4rem;
}

textarea {
    width: 100%;
    height: 120px;
    padding: 15px;
    border: none;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.3);
    color: #fff;
    font-size: 1rem;
    resize: vertical;
    margin-bottom: 15px;
}

textarea::placeholder {
    color: #64748b;
}

textarea:focus {
    outline: 2px solid #60a5fa;
}

.result-box {
    margin-bottom: 15px;
}

.result-box label {
    display: block;
    color: #94a3b8;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.result {
    background: rgba(0, 0, 0, 0.4);
    padding: 15px;
    border-radius: 10px;
    min-height: 50px;
    font-family: 'Courier New', monospace;
    font-size: 1.1rem;
    word-break: break-all;
    color: #4ade80;
}

/* Zone éditable */
.result.editable {
    cursor: text;
    transition: all 0.3s ease;
    outline: none;
    word-break: break-word;
}

.result.editable:hover {
    background: rgba(0, 0, 0, 0.5);
    box-shadow: 0 0 0 2px rgba(236, 72, 153, 0.3);
}

.result.editable:focus {
    background: rgba(0, 0, 0, 0.6);
    box-shadow: 0 0 0 2px #ec4899;
}

.edit-hint {
    font-size: 0.8rem;
    color: #ec4899;
    font-style: italic;
}

/* Mode sécurité jour */
.mode-securite {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.toggle-container {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.toggle-container input {
    display: none;
}

.toggle-slider {
    width: 50px;
    height: 26px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 13px;
    position: relative;
    transition: all 0.3s ease;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 22px;
    height: 22px;
    background: white;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: all 0.3s ease;
}

.toggle-container input:checked + .toggle-slider {
    background: linear-gradient(135deg, #22c55e, #16a34a);
}

.toggle-container input:checked + .toggle-slider::before {
    left: 26px;
}

.toggle-label {
    color: #94a3b8;
    font-size: 0.95rem;
}

.toggle-container input:checked ~ .toggle-label {
    color: #4ade80;
}

.jour-info {
    background: rgba(34, 197, 94, 0.2);
    border: 1px solid rgba(34, 197, 94, 0.4);
    padding: 8px 15px;
    border-radius: 8px;
    color: #4ade80;
    font-size: 0.9rem;
    font-weight: 500;
}

.jour-select {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 8px 15px;
    border-radius: 8px;
    color: #fff;
    font-size: 0.95rem;
    cursor: pointer;
}

.jour-select:focus {
    outline: none;
    border-color: #60a5fa;
}

.buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 15px;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #60a5fa, #3b82f6);
}

.btn-secondary {
    background: linear-gradient(135deg, #8b5cf6, #6d28d9);
    color: white;
}

.btn-secondary:hover {
    background: linear-gradient(135deg, #a78bfa, #8b5cf6);
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
}

.btn-danger:hover {
    background: linear-gradient(135deg, #f87171, #ef4444);
}

.btn-success {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: white;
}

.btn-success:hover {
    background: linear-gradient(135deg, #4ade80, #22c55e);
}

.btn-smart {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
}

.btn-smart:hover {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
}

.btn-shuffle {
    background: linear-gradient(135deg, #ec4899, #be185d);
    color: white;
    margin-top: 10px;
}

.btn-shuffle:hover {
    background: linear-gradient(135deg, #f472b6, #ec4899);
}

/* Cadre mélange des mots */
.melange-box {
    background: rgba(236, 72, 153, 0.1);
    border: 1px dashed rgba(236, 72, 153, 0.5);
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 15px;
}

.melange-result {
    color: #f472b6 !important;
    font-size: 1.2rem;
    word-break: break-word;
}

.reference {
    background: rgba(255, 255, 255, 0.05);
}

.table-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 8px;
}

.table-item {
    background: rgba(0, 0, 0, 0.3);
    padding: 10px;
    border-radius: 8px;
    text-align: center;
    transition: all 0.2s ease;
}

.table-item:hover {
    background: rgba(96, 165, 250, 0.3);
    transform: scale(1.05);
}

.table-item .letter {
    font-size: 1rem;
    color: #94a3b8;
}

.table-item .number {
    font-size: 1.2rem;
    font-weight: bold;
    color: #60a5fa;
}

.table-item-number {
    background: rgba(245, 158, 11, 0.2);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.table-item-number .number {
    color: #fbbf24;
}

/* Animation pour le résultat */
@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.7; }
    100% { opacity: 1; }
}

.result.updated {
    animation: pulse 0.3s ease;
}

/* Message de copie */
.copy-message {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #4ade80;
    color: #000;
    padding: 15px 25px;
    border-radius: 10px;
    font-weight: bold;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Responsive */
@media (max-width: 600px) {
    h1 {
        font-size: 1.8rem;
    }
    
    .buttons {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
        justify-content: center;
    }
    
    .table-grid {
        grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    }
}

/* Coffre-fort */
.coffre-fort {
    position: relative;
}

.coffre-lock {
    text-align: center;
    padding: 30px;
}

.lock-icon {
    font-size: 4rem;
    display: block;
    margin-bottom: 15px;
    animation: shake 0.5s ease-in-out infinite;
}

@keyframes shake {
    0%, 100% { transform: rotate(-5deg); }
    50% { transform: rotate(5deg); }
}

.coffre-lock p {
    color: #94a3b8;
    margin-bottom: 20px;
}

.code-input {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.code-input input {
    padding: 12px 20px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.4);
    color: #fff;
    font-size: 1.2rem;
    text-align: center;
    letter-spacing: 5px;
    width: 180px;
}

.code-input input:focus {
    outline: none;
    border-color: #60a5fa;
}

.erreur-code {
    color: #ef4444 !important;
    margin-top: 15px;
    font-weight: bold;
}

.code-config {
    margin-top: 25px;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.code-config .btn-secondary {
    opacity: 0.8;
    transition: all 0.3s ease;
}

.code-config .btn-secondary:hover {
    opacity: 1;
    background: linear-gradient(135deg, #64748b, #475569);
}

.btn-small {
    padding: 8px 16px;
    font-size: 0.85rem;
}

.table-container {
    position: relative;
}

.table-container.hidden {
    display: none;
}

.table-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.table-container .btn-danger {
    /* Supprimé margin-bottom car géré par .table-controls */
}

/* Animation déverrouillage */
@keyframes unlock {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.5; }
    100% { transform: scale(0); opacity: 0; }
}

.coffre-lock.unlocking {
    animation: unlock 0.5s ease forwards;
}

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

.table-container.visible {
    display: block;
    animation: fadeIn 0.5s ease;
}

/* Bouton Recomposition */
.btn-recomposer {
    background: linear-gradient(135deg, #ec4899, #be185d);
    color: white;
}

.btn-recomposer:hover {
    background: linear-gradient(135deg, #f472b6, #ec4899);
}

/* Modal de recomposition */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border-radius: 20px;
    padding: 30px;
    max-width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

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

.modal-header h3 {
    color: #ec4899;
    font-size: 1.5rem;
    margin: 0;
}

.btn-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 2rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.3s ease;
}

.btn-close:hover {
    color: #ef4444;
}

.modal-instructions {
    color: #94a3b8;
    margin-bottom: 20px;
    text-align: center;
}

/* Onglets */
.tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 20px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    padding: 5px;
}

.tab {
    flex: 1;
    padding: 12px 20px;
    border: none;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.tab:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.tab.active {
    background: linear-gradient(135deg, #ec4899, #be185d);
    color: white;
}

.methode-content.hidden {
    display: none;
}

/* Touches clavier stylisées */
.touche {
    display: inline-block;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 5px;
    padding: 3px 8px;
    font-family: monospace;
    font-size: 0.85rem;
    color: #fff;
}

/* Mode clavier */
.lettres-container.clavier-mode {
    outline: none;
}

.lettre-item.selected {
    background: linear-gradient(135deg, #ec4899, #be185d) !important;
    box-shadow: 0 0 20px rgba(236, 72, 153, 0.6);
    transform: scale(1.15);
    z-index: 10;
}

.lettre-item.selected.number {
    background: linear-gradient(135deg, #ec4899, #be185d) !important;
}

/* Curseur de navigation */
.lettre-item.curseur {
    position: relative;
}

.lettre-item.curseur::before {
    content: '';
    position: absolute;
    left: -4px;
    top: 2px;
    bottom: 2px;
    width: 3px;
    background: #ec4899;
    border-radius: 2px;
    animation: cursorBlink 1s infinite;
}

@keyframes cursorBlink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* Container des lettres draggables */
.lettres-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 20px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 15px;
    min-height: 100px;
    margin-bottom: 20px;
    justify-content: center;
}

.lettre-item {
    width: 45px;
    height: 45px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    border-radius: 8px;
    font-size: 1.4rem;
    font-weight: bold;
    color: white;
    cursor: grab;
    user-select: none;
    transition: all 0.2s ease;
    font-family: 'Courier New', monospace;
}

.lettre-item:hover {
    transform: scale(1.1);
    box-shadow: 0 5px 15px rgba(59, 130, 246, 0.5);
}

.lettre-item:active {
    cursor: grabbing;
}

.lettre-item.dragging {
    opacity: 0.5;
    transform: scale(1.1);
}

.lettre-item.space {
    background: linear-gradient(135deg, #6b7280, #4b5563);
    color: #d1d5db;
    font-size: 0.8rem;
}

.lettre-item.number {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.modal-result {
    margin-bottom: 20px;
}

.modal-result label {
    display: block;
    color: #94a3b8;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.modal-result .result {
    font-size: 1.3rem;
    letter-spacing: 1px;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

/* Animation pour le drop */
@keyframes dropBounce {
    0% { transform: scale(1.2); }
    50% { transform: scale(0.95); }
    100% { transform: scale(1); }
}

.lettre-item.dropped {
    animation: dropBounce 0.3s ease;
}

/* Responsive modal */
@media (max-width: 600px) {
    .modal-content {
        padding: 20px;
        margin: 10px;
    }
    
    .lettre-item {
        width: 38px;
        height: 38px;
        font-size: 1.2rem;
    }
    
    .modal-buttons {
        flex-direction: column;
    }
    
    .modal-buttons .btn {
        width: 100%;
    }
}
