/* ============================================================
   main.css — Styles principaux, mobile first
   ============================================================ */

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

:root {
    --primary:    #4F46E5;
    --primary-h:  #4338CA;
    --danger:     #EF4444;
    --success:    #22C55E;
    --bg:         #F3F4F6;
    --card-bg:    #FFFFFF;
    --text:       #111827;
    --muted:      #6B7280;
    --border:     #E5E7EB;
    --radius:     12px;
    --shadow:     0 4px 24px rgba(0,0,0,.10);
}

html, body { height: 100%; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }

/* ---- Pages accueil / identification ---- */
.page-accueil {
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 16px;
}

.container { width: 100%; max-width: 440px; }

.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 32px 28px;
}

.logo { font-size: 48px; text-align: center; margin-bottom: 8px; }

h1 {
    font-size: 1.6rem;
    font-weight: 700;
    text-align: center;
    color: var(--text);
    margin-bottom: 8px;
}

.subtitle {
    text-align: center;
    color: var(--muted);
    font-size: .95rem;
    margin-bottom: 24px;
}

.field { margin-bottom: 16px; }

.field label {
    display: block;
    font-size: .85rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.field input {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    color: var(--text);
    outline: none;
    transition: border-color .15s;
}

.field input:focus { border-color: var(--primary); }

.optional { font-weight: 400; color: var(--muted); font-size: .8rem; }

.btn-primary {
    display: block;
    width: 100%;
    padding: 14px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
    margin-top: 8px;
}
.btn-primary:hover  { background: var(--primary-h); }
.btn-primary:disabled { background: #9CA3AF; cursor: not-allowed; }

.btn-secondary {
    padding: 10px 18px;
    background: #fff;
    color: var(--primary);
    border: 1.5px solid var(--primary);
    border-radius: 8px;
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
}
.btn-secondary:hover { background: #EEF2FF; }

.btn-danger {
    padding: 10px 18px;
    background: #fff;
    color: var(--danger);
    border: 1.5px solid var(--danger);
    border-radius: 8px;
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
}

.message-erreur {
    background: #FEE2E2;
    color: #991B1B;
    border-radius: 8px;
    padding: 12px 14px;
    font-size: .9rem;
    margin-top: 12px;
}

.hint { font-size: .8rem; color: var(--muted); margin-top: 6px; }

.text-center { text-align: center; }

/* ---- Page dessin ---- */
.page-dessin {
    background: #1F2937;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

#app-dessin {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Toolbar */
#toolbar {
    background: #111827;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.toolbar-nom { color: #D1D5DB; font-size: .85rem; font-weight: 600; margin-right: 4px; }

.toolbar-tools, .toolbar-options {
    display: flex;
    align-items: center;
    gap: 6px;
}

.tool-btn {
    background: #374151;
    border: 2px solid transparent;
    border-radius: 8px;
    color: #fff;
    font-size: 1.1rem;
    width: 38px;
    height: 38px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .1s, border-color .1s;
}
.tool-btn:hover  { background: #4B5563; }
.tool-btn.active { border-color: var(--primary); background: #312E81; }

#couleur {
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    padding: 2px;
    background: none;
}

#epaisseur { width: 80px; accent-color: var(--primary); }

/* Canvas wrapper */
#canvas-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 8px;
    overflow: hidden;
}

#drawing-canvas {
    background: #fff;
    border-radius: 8px;
    touch-action: none;
    cursor: crosshair;
    box-shadow: 0 0 0 3px rgba(79,70,229,.3);
}

/* Text input overlay */
#text-input-overlay {
    position: fixed;
    z-index: 100;
    background: #fff;
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 10px;
    gap: 6px;
    align-items: center;
}
#text-input {
    border: 1.5px solid var(--border);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: .95rem;
    width: 160px;
    outline: none;
}
#text-confirm {
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 7px 12px;
    cursor: pointer;
    font-size: .85rem;
}
#text-cancel {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font-size: .85rem;
}

/* Footer */
#footer-valider {
    background: #111827;
    padding: 12px 16px;
    text-align: center;
    flex-shrink: 0;
}
#footer-valider .hint { color: #9CA3AF; margin-bottom: 8px; }
#btn-valider { max-width: 320px; margin: 0 auto; }

/* Modals */
#modal-confirm, #modal-succes {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 16px;
}

.modal-box {
    background: #fff;
    border-radius: var(--radius);
    padding: 28px 24px;
    max-width: 360px;
    width: 100%;
    text-align: center;
}
.modal-box h3 { font-size: 1.3rem; margin-bottom: 10px; }
.modal-box p  { color: var(--muted); margin-bottom: 20px; }
.modal-actions { display: flex; gap: 10px; justify-content: center; }
.modal-actions .btn-primary  { flex: 1; max-width: 160px; }
.modal-actions .btn-secondary { flex: 1; max-width: 160px; }
