/* ===== Messages pour Merlin — mobile first ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: linear-gradient(160deg, #4c3a8f 0%, #7b5ec7 100%);
    min-height: 100vh;
    padding: 16px;
    color: #2d2440;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #fff;
    max-width: 480px;
    margin: 0 auto 12px;
}
.link-muted { color: #d9cff5; font-size: 0.85rem; }

.card {
    background: #fff;
    border-radius: 16px;
    padding: 20px;
    max-width: 480px;
    margin: 0 auto;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
}
.login-card { margin-top: 10vh; }

h1 { font-size: 1.4rem; margin-bottom: 8px; }
.subtitle { color: #6b5f85; font-size: 0.95rem; margin-bottom: 16px; }

label { display: block; font-weight: 600; margin: 14px 0 6px; font-size: 0.95rem; }

input[type=text], input[type=password], textarea {
    width: 100%;
    border: 2px solid #d8d2ea;
    border-radius: 10px;
    padding: 12px;
    font-size: 1rem;
    font-family: inherit;
}
input:focus, textarea:focus { outline: none; border-color: #7b5ec7; }
textarea { resize: vertical; }

.char-count { text-align: right; font-size: 0.8rem; color: #9a8fb5; margin-top: 4px; }

.btn {
    display: inline-block;
    border: none;
    border-radius: 10px;
    padding: 12px 16px;
    font-size: 1rem;
    font-family: inherit;
    background: #ece7f8;
    color: #4c3a8f;
    cursor: pointer;
    font-weight: 600;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: #4c3a8f; color: #fff; }
.btn-danger { background: #fdeaea; color: #b3261e; }
.btn-small { padding: 6px 10px; font-size: 0.85rem; }
.btn:disabled { opacity: 0.5; cursor: wait; }

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
}
.actions .btn { flex: 1 1 auto; }

form .btn { width: 100%; margin-top: 20px; }

.image-zone { margin-top: 16px; text-align: center; }
.image-zone img {
    max-width: 100%;
    border: 1px solid #d8d2ea;
    border-radius: 8px;
    image-rendering: pixelated;
}
.image-zone .btn { margin-top: 8px; }

.ai-zone {
    margin-top: 16px;
    background: #f6f3fd;
    border-radius: 12px;
    padding: 14px;
}
.ai-zone .btn { width: 100%; margin-top: 10px; }

.status {
    margin-top: 14px;
    padding: 12px;
    border-radius: 10px;
    font-size: 0.95rem;
    background: #f6f3fd;
    display: flex;
    align-items: center;
    gap: 10px;
}
.status.error { background: #fdeaea; color: #b3261e; }

.spinner {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
    border: 3px solid #d8d2ea;
    border-top-color: #4c3a8f;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
.status.error .spinner { border-color: #f5c6c6; border-top-color: #b3261e; }

@keyframes spin {
    to { transform: rotate(360deg); }
}
.error {
    background: #fdeaea;
    color: #b3261e;
    padding: 10px;
    border-radius: 10px;
    margin-bottom: 8px;
}

.hidden { display: none !important; }

/* ----- Modales ----- */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(30, 20, 60, 0.75);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    overflow-y: auto;
    padding: 24px 12px;
    z-index: 10;
}
.modal-content {
    background: #fff;
    border-radius: 16px;
    padding: 20px;
    max-width: 420px;
    width: 100%;
}
.modal-content.center { text-align: center; }
.modal-title { font-weight: 600; margin-bottom: 14px; }
.big-emoji { font-size: 3rem; margin-bottom: 8px; }

/* ----- Rendu du ticket (fidèle à l'impression 80mm) ----- */
.ticket {
    width: 288px;               /* 576 px imprimante affichés à 50 % */
    margin: 0 auto;
    background: #fffdf5;
    color: #000;
    font-family: "Courier New", Courier, monospace;
    font-size: 12px;
    line-height: 1.35;
    padding: 14px 10px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
    /* bords crantés de ticket */
    -webkit-mask-image: linear-gradient(#000, #000);
}
.ticket-header, .ticket-footer { text-align: center; }
.ticket-title { font-weight: bold; font-size: 13px; letter-spacing: 1px; margin: 4px 0; }
.ticket-stars { letter-spacing: 4px; }
.ticket-meta { font-size: 11px; }
.ticket-sep { margin: 6px 0; overflow: hidden; white-space: nowrap; }
.ticket-body {
    white-space: pre-wrap;
    word-wrap: break-word;
    margin: 8px 0;
}
.ticket-image {
    width: 100%;
    display: block;
    margin: 8px 0;
    image-rendering: pixelated;
}

.modal .actions { margin-top: 16px; }
