/* --- STYLE GLOBAL COMPATIBLE TOUS APPAREILS --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: #f3f4f6;
    color: #1f2937;
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

/* En-tête premium */
header {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: white;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
    position: sticky;
    top: 0;
    z-index: 10;
    flex-shrink: 0;
}

.header-title {
    font-size: 1.25rem;
    font-weight: 800;
    flex-grow: 1;
    text-align: center;
    letter-spacing: -0.5px;
}

.btn-back {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.btn-back:active {
    background: rgba(255, 255, 255, 0.3);
}

.hidden {
    display: none !important;
}

.header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    min-width: 40px;
}

.header-icon-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: background 0.2s;
}

.header-icon-btn:active {
    background: rgba(255, 255, 255, 0.3);
}

/* Contenu principal : occupe toute la largeur pour que le scroll fonctionne
   depuis n'importe quel point de l'écran (pas seulement au-dessus de la
   colonne de contenu centrée, cf. .view-section ci-dessous). */
main {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px;
    padding-bottom: 120px;
}

/* Vues */
.view-section {
    display: none;
    max-width: 500px;
    margin: 0 auto;
}

.view-section.active {
    display: block;
    animation: fadeIn 0.25s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Accueil */
.home-menu {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 24px;
}

.btn-home {
    background: white;
    border: 2px solid;
    padding: 24px;
    border-radius: 20px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.02);
    transition: transform 0.15s, box-shadow 0.15s;
    text-decoration: none;
}

.btn-home:active {
    transform: scale(0.97);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.btn-home-course {
    border-color: #3b82f6;
    color: #2563eb;
}

.btn-home-editor {
    border-color: #10b981;
    color: #059669;
}

.btn-home-portal {
    border-color: #8b5cf6;
    color: #7c3aed;
}

.btn-home span {
    font-size: 1.25rem;
    font-weight: 700;
}

/* Icônes */
.icon {
    width: 44px;
    height: 44px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

.icon-sm {
    width: 20px;
    height: 20px;
}

/* Éditeur & Cartes de Plats */
.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.text-muted {
    color: #6b7280;
    font-size: 0.875rem;
}

.section-title {
    font-size: 1.1rem;
    font-weight: 800;
    margin: 20px 0 10px 0;
    color: #1f2937;
}

.btn-primary {
    background-color: #059669;
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 4px 6px rgba(5, 150, 105, 0.2);
}

.btn-primary:active {
    transform: scale(0.97);
}

.btn-share-editor {
    background-color: #4f46e5;
    color: white;
    border: none;
    padding: 10px 14px;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 4px 6px rgba(79, 70, 229, 0.2);
    font-size: 0.85rem;
}

.btn-share-editor:active {
    transform: scale(0.97);
}

.category-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    margin-bottom: 16px;
}

.category-tab {
    flex-shrink: 0;
    background: white;
    border: 1.5px solid #e5e7eb;
    color: #4b5563;
    font-weight: 700;
    font-size: 0.85rem;
    padding: 8px 14px;
    border-radius: 999px;
    cursor: pointer;
    white-space: nowrap;
}

.category-tab.active {
    background-color: #2563eb;
    border-color: #2563eb;
    color: white;
}

.category-tab-add,
.category-tab-manage {
    color: #2563eb;
    border-style: dashed;
}

.dish-card {
    background: white;
    border: 1px solid #e5e7eb;
    padding: 16px;
    border-radius: 16px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.dish-info {
    flex-grow: 1;
    padding-right: 12px;
}

.dish-info h3 {
    font-size: 1.1rem;
    color: #1f2937;
    margin-bottom: 4px;
    font-weight: 700;
}

.dish-info p {
    font-size: 0.85rem;
    color: #6b7280;
    line-height: 1.3;
}

.dish-actions {
    display: flex;
    gap: 8px;
}

.btn-action {
    background: #f3f4f6;
    border: none;
    color: #4b5563;
    cursor: pointer;
    padding: 8px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.btn-action.delete {
    color: #ef4444;
    background: #fef2f2;
}

.btn-action:active {
    transform: scale(0.9);
}

/* Formulaire */
.form-container {
    background: white;
    padding: 20px;
    border-radius: 20px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.02);
}

.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-weight: 700;
    font-size: 0.875rem;
    color: #4b5563;
    margin-bottom: 8px;
}

.form-input {
    width: 100%;
    padding: 14px;
    border: 1.5px solid #e5e7eb;
    border-radius: 12px;
    font-size: 1rem;
    outline: none;
    background: #f9fafb;
    transition: border-color 0.2s, background 0.2s;
}

.form-input:focus {
    border-color: #2563eb;
    background: white;
}

.ingredient-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    align-items: center;
}

.input-qty {
    width: 100px;
    flex-shrink: 0;
}

.btn-qty-toggle {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #2563eb;
    font-weight: 700;
    font-size: 0.85rem;
    padding: 12px 10px;
    border-radius: 12px;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
}

.btn-qty-toggle:active {
    background: #dbeafe;
}

.btn-remove-ing {
    background: #fef2f2;
    border: none;
    color: #ef4444;
    cursor: pointer;
    padding: 12px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Sélection de courses */
.selection-item-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 16px;
    cursor: pointer;
    user-select: none;
    transition: border-color 0.2s, background-color 0.2s;
    flex: 1;
}

.checkbox-label.selected {
    background-color: #eff6ff;
    border-color: #3b82f6;
}

.checkbox-input {
    width: 22px;
    height: 22px;
    accent-color: #2563eb;
    border-radius: 6px;
}

/* Contrôles de quantité (+ / -) */
.qty-controls {
    display: flex;
    align-items: center;
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 16px;
    overflow: hidden;
    height: 56px;
}

.qty-btn {
    background: #f9fafb;
    border: none;
    width: 40px;
    height: 100%;
    font-size: 1.2rem;
    font-weight: bold;
    color: #4b5563;
    cursor: pointer;
}

.qty-btn:active {
    background: #e5e7eb;
}

.qty-val {
    width: 36px;
    text-align: center;
    font-weight: 700;
    font-size: 1rem;
    color: #1f2937;
}

.fixed-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 16px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    justify-content: center;
    z-index: 5;
}

.btn-continue,
.btn-save-full {
    max-width: 500px;
    width: 100%;
    background-color: #2563eb;
    color: white;
    border: none;
    padding: 16px;
    font-size: 1rem;
    font-weight: bold;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
    transition: background-color 0.2s, transform 0.1s;
}

.btn-save-full {
    background-color: #059669;
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.2);
    margin-top: 20px;
}

.btn-continue:active,
.btn-save-full:active {
    transform: scale(0.98);
}

.btn-continue:disabled {
    background-color: #9ca3af;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-link {
    background: none;
    border: none;
    color: #2563eb;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 12px;
    padding: 6px 0;
}

/* Liste finale */
.shopping-list {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    list-style: none;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.02);
}

.shopping-item {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    border-bottom: 1px solid #f3f4f6;
    transition: background-color 0.15s;
}

.shopping-item:last-child {
    border-bottom: none;
}

.circle-check {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2px solid #d1d5db;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.shopping-item.checked .circle-check {
    background-color: #10b981;
    border-color: #10b981;
}

.checkmark {
    color: white;
    font-size: 14px;
    font-weight: bold;
}

.shopping-item-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-grow: 1;
}

.ing-header-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    width: 100%;
}

.ing-name-title {
    font-weight: 700;
    font-size: 1rem;
    color: #1f2937;
}

.shopping-item.checked .ing-name-title {
    text-decoration: line-through;
    color: #9ca3af;
}

.ing-qty-badge {
    background-color: #ecfdf5;
    color: #059669;
    font-size: 0.8rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 8px;
    border: 1px solid #a7f3d0;
}

.ing-counter {
    background-color: #e0e7ff;
    color: #4338ca;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 6px;
    margin-left: auto;
}

.ing-origin-text {
    font-size: 0.8rem;
    color: #6b7280;
    font-weight: 500;
}

.shopping-item.checked .ing-origin-text {
    color: #d1d5db;
}

.no-data {
    text-align: center;
    color: #9ca3af;
    padding: 40px 20px;
    font-style: italic;
}

/* Modales */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    animation: fadeIn 0.15s ease-out;
}

.modal-content {
    background: white;
    padding: 24px;
    border-radius: 20px;
    max-width: 340px;
    width: 100%;
    text-align: center;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.modal-title {
    font-size: 1.15rem;
    font-weight: bold;
    margin-bottom: 12px;
    color: #1f2937;
}

.modal-body {
    color: #4b5563;
    font-size: 0.95rem;
    margin-bottom: 24px;
    line-height: 1.4;
}

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

.btn-modal {
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: bold;
    cursor: pointer;
    border: none;
    flex: 1;
}

.btn-modal-confirm {
    background-color: #ef4444;
    color: white;
}

.btn-modal-cancel {
    background-color: #f3f4f6;
    color: #4b5563;
}
