/* Variables d'accessibilité & palette */
:root {
    --bg-primary: #F7F5F0;
    --text-primary: #1C1B1A;
    --accent-gold: #8B6508;
    --gold-button: #C5A059;
    --action-green: #206E35;
    --btn-disabled: #A8A29E;
    --card-bg: #FFFFFF;
    --border-subtle: #E2DDD5;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    padding-bottom: 40px;
}

/* En-tête */
header {
    padding: 16px;
    background-color: #FFFFFF;
    border-bottom: 2px solid var(--border-subtle);
    text-align: center;
}

header h1 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--accent-gold);
}

main {
    padding: 16px 12px;
    max-width: 480px;
    margin: 0 auto;
}

/* Gestion de l'affichage des 3 vues */
.view {
    display: none;
}

.view.active {
    display: block;
}

/* Boutons massifs (Cibles tactiles >= 64px, pleine largeur 320px) */
.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 64px;
    font-size: 1.25rem;
    font-weight: 700;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    margin-bottom: 16px;
    text-decoration: none;
    padding: 12px 16px;
    text-align: center;
    touch-action: manipulation;
}

.btn-primary {
    background-color: var(--gold-button);
    color: #FFFFFF;
}

.btn-action {
    background-color: var(--action-green);
    color: #FFFFFF;
}

.btn-secondary {
    background-color: #E7E3DC;
    color: var(--text-primary);
    border: 2px solid #C4BEB4;
}

.btn:disabled {
    background-color: var(--btn-disabled);
    cursor: not-allowed;
    opacity: 0.7;
}

/* Écran 1 : Liste du Coffre */
.items-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.card {
    background: var(--card-bg);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-subtle);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    cursor: pointer;
}

.card img {
    width: 100%;
    height: 220px;
    object-fit: cover;
    display: block;
    background: #EBE8E1;
}

.card-content {
    padding: 16px;
}

.card-date {
    font-size: 0.9rem;
    color: #78716C;
    margin-bottom: 6px;
}

.card-text {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Écran 2 : Capture */
.image-preview-container {
    width: 100%;
    min-height: 200px;
    max-height: 280px;
    background: #EBE8E1;
    border-radius: 12px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 2px dashed #C4BEB4;
}

.image-preview-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: none;
}

.image-preview-placeholder {
    font-size: 1.1rem;
    color: #78716C;
    font-weight: 600;
    text-align: center;
    padding: 20px;
}

.story-input {
    width: 100%;
    min-height: 140px;
    font-size: 1.25rem;
    padding: 16px;
    border-radius: 12px;
    border: 2px solid var(--border-subtle);
    background-color: #FFFFFF;
    color: var(--text-primary);
    margin-bottom: 16px;
    resize: vertical;
    font-family: inherit;
}

.story-input:focus {
    outline: 3px solid var(--accent-gold);
}

/* Écran 3 : Fiche détaillée */
.detail-image {
    width: 100%;
    max-height: 320px;
    object-fit: contain;
    background-color: #000000;
    border-radius: 12px;
    margin-bottom: 16px;
}

.detail-date {
    font-size: 1rem;
    color: #78716C;
    margin-bottom: 8px;
}

.detail-story {
    font-size: 1.3rem;
    line-height: 1.6;
    background: #FFFFFF;
    padding: 16px;
    border-radius: 12px;
    border: 1px solid var(--border-subtle);
    margin-bottom: 20px;
    white-space: pre-wrap;
}

/* Messages et alertes */
.status-msg {
    padding: 12px;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    text-align: center;
    margin-bottom: 16px;
    display: none;
}
.status-msg.error {
    display: block;
    background-color: #FEE2E2;
    color: #991B1B;
}
.status-msg.success {
    display: block;
    background-color: #DCFCE7;
    color: #166534;
}

/* Styles pour l'impression A4 */
@media print {
    body {
        background: #FFFFFF !important;
        color: #000000 !important;
        padding: 0 !important;
    }
    header, .btn, .no-print {
        display: none !important;
    }
    .view {
        display: none !important;
    }
    #print-container {
        display: block !important;
    }
    .print-page {
        page-break-after: always;
        padding: 15mm;
    }
    .print-page:last-child {
        page-break-after: avoid;
    }
    .print-item {
        margin-bottom: 20mm;
        break-inside: avoid;
    }
    .print-img {
        max-height: 90mm;
        width: auto;
        max-width: 100%;
        display: block;
        margin: 0 auto 10mm;
    }
    .print-story {
        font-size: 14pt;
        line-height: 1.5;
    }
}

#print-container {
    display: none;
}