/* Reset et base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%);
    min-height: 100vh;
    color: #374151;
    line-height: 1.5;
}

/* Container principal */
.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    text-align: center;
    padding: 40px 20px 20px;
}

.header-icon {
    color: #8b5cf6;
    margin-bottom: 10px;
}

.header-icon svg {
    width: 48px;
    height: 48px;
}

.header h1 {
    font-size: 1.75rem;
    font-weight: 600;
    color: #1f2937;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.header-subtitle {
    color: #6b7280;
    margin-top: 8px;
    font-size: 0.95rem;
}

/* User info */
.user-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 16px;
    font-size: 0.9rem;
}

.user-email {
    color: #6b7280;
}

.logout-link {
    color: #8b5cf6;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 4px;
}

.logout-link:hover {
    text-decoration: underline;
}

/* Carte de connexion */
.auth-card {
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    padding: 40px;
    max-width: 420px;
    margin: 0 auto;
}

.auth-card .header {
    padding: 0 0 24px 0;
}

.auth-card h1 {
    font-size: 1.5rem;
}

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

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 6px;
    color: #374151;
    font-size: 0.9rem;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: #8b5cf6;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.form-input::placeholder {
    color: #9ca3af;
}

/* Checkbox remember me */
.form-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #8b5cf6;
}

.form-checkbox label {
    font-size: 0.9rem;
    color: #6b7280;
    margin-bottom: 0;
}

/* Boutons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    text-decoration: none;
}

.btn-primary {
    background: #8b5cf6;
    color: white;
    width: 100%;
}

.btn-primary:hover {
    background: #7c3aed;
}

.btn-google {
    background: white;
    color: #374151;
    border: 1px solid #d1d5db;
    width: 100%;
}

.btn-google:hover {
    background: #f9fafb;
}

.btn-google svg {
    width: 20px;
    height: 20px;
}

.btn-add {
    background: #8b5cf6;
    color: white;
    padding: 12px 20px;
    white-space: nowrap;
}

.btn-add:hover {
    background: #7c3aed;
}

/* Séparateur */
.divider {
    display: flex;
    align-items: center;
    margin: 24px 0;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid #e5e7eb;
}

.divider span {
    padding: 0 16px;
    color: #9ca3af;
    font-size: 0.85rem;
}

/* Liens */
.auth-links {
    margin-top: 24px;
    text-align: center;
    font-size: 0.9rem;
}

.auth-links a {
    color: #8b5cf6;
    text-decoration: none;
}

.auth-links a:hover {
    text-decoration: underline;
}

/* Messages d'erreur et succès */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 0.9rem;
}

.alert-error {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.alert-success {
    background: #f0fdf4;
    color: #16a34a;
    border: 1px solid #bbf7d0;
}

/* Zone d'ajout d'article */
.add-item-form {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
}

.add-item-form .form-input {
    flex: 1;
}

/* Liste de courses */
.shopping-list {
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.shopping-item {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #f3f4f6;
    transition: background 0.2s;
}

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

.shopping-item:hover {
    background: #f9fafb;
}

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

/* Checkbox circulaire */
.item-checkbox {
    width: 24px;
    height: 24px;
    border: 2px solid #d1d5db;
    border-radius: 50%;
    margin-right: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.item-checkbox:hover {
    border-color: #8b5cf6;
}

.item-checkbox.checked {
    background: #8b5cf6;
    border-color: #8b5cf6;
}

.item-checkbox.checked::after {
    content: '✓';
    color: white;
    font-size: 14px;
}

.item-name {
    flex: 1;
    font-size: 1rem;
    color: #374151;
}

.item-quantity {
    color: #6b7280;
    font-size: 0.9rem;
    margin-right: 16px;
}

.item-delete {
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    padding: 4px;
    transition: color 0.2s;
}

.item-delete:hover {
    color: #ef4444;
}

.item-delete svg {
    width: 20px;
    height: 20px;
}

/* Groupe de recette */
.recipe-group {
    margin-bottom: 24px;
}

.recipe-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    color: white;
    border-radius: 12px 12px 0 0;
    cursor: pointer;
}

.recipe-group-header h3 {
    font-size: 1rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.recipe-group-actions button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
}

.recipe-group-actions button:hover {
    background: rgba(255, 255, 255, 0.3);
}

.recipe-group .shopping-list {
    border-radius: 0 0 12px 12px;
}

/* Modal recette */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: white;
    border-radius: 16px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    transform: scale(0.9);
    transition: transform 0.3s;
}

.modal-overlay.active .modal {
    transform: scale(1);
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h2 {
    font-size: 1.25rem;
    color: #1f2937;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #6b7280;
    cursor: pointer;
}

.modal-body {
    padding: 20px;
}

.modal-body h3 {
    font-size: 1rem;
    color: #374151;
    margin-bottom: 12px;
}

.recipe-description {
    white-space: pre-wrap;
    line-height: 1.8;
    color: #4b5563;
}

/* Formulaire ajout recette */
.add-recipe-section {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid #e5e7eb;
}

.add-recipe-section h3 {
    font-size: 1rem;
    color: #374151;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.add-recipe-form {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.add-recipe-form .form-input {
    flex: 1;
    min-width: 200px;
}

.add-recipe-form .servings-input {
    width: 120px;
    flex: none;
}

/* Liste vide */
.empty-list {
    text-align: center;
    padding: 48px 20px;
    color: #6b7280;
}

.empty-list svg {
    width: 64px;
    height: 64px;
    color: #d1d5db;
    margin-bottom: 16px;
}

.empty-list p {
    font-size: 1rem;
}

/* Footer */
.footer {
    text-align: center;
    padding: 24px;
    color: #9ca3af;
    font-size: 0.85rem;
}

.footer a {
    color: #8b5cf6;
    text-decoration: none;
}

/* Responsive */
@media (max-width: 640px) {
    .container {
        padding: 16px;
    }

    .auth-card {
        padding: 24px;
    }

    .add-item-form {
        flex-direction: column;
    }

    .add-recipe-form {
        flex-direction: column;
    }

    .add-recipe-form .servings-input {
        width: 100%;
    }

    .user-info {
        flex-direction: column;
        gap: 8px;
    }
}

/* Loading spinner */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #8b5cf6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Tabs pour basculer entre liste simple et recettes */
.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
}

.tab {
    padding: 10px 20px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    color: #6b7280;
    transition: all 0.2s;
}

.tab.active {
    background: #8b5cf6;
    color: white;
    border-color: #8b5cf6;
}

.tab:hover:not(.active) {
    background: #f9fafb;
}

/* Boutons d'action recette */
.btn-recipe-action {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.btn-recipe-action:hover {
    background: rgba(255, 255, 255, 0.3);
}

.btn-recipe-action.btn-danger:hover {
    background: rgba(239, 68, 68, 0.8);
}

/* Compteur d'ingrédients */
.recipe-item-count {
    font-weight: 400;
    opacity: 0.8;
    font-size: 0.85rem;
}

/* Nombre de convives */
.recipe-servings {
    font-weight: 400;
    font-size: 0.85rem;
    opacity: 0.9;
    font-style: italic;
}

/* Hint pour la recette */
.recipe-hint {
    color: #6b7280;
    font-size: 0.85rem;
    margin-bottom: 12px;
}

/* Bouton avec loading */
.btn-add.loading svg,
.btn-add.loading .btn-icon {
    display: none !important;
}

.btn-add.loading .btn-text {
    display: none !important;
}

.btn-add.loading .loading-spinner {
    display: inline-block !important;
}

.loading-spinner {
    display: none;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.btn-add:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Responsive header recette */
@media (max-width: 640px) {
    .recipe-group-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .recipe-group-header h3 {
        flex-wrap: wrap;
    }

    .recipe-group-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .btn-recipe-action {
        padding: 6px 10px;
        font-size: 0.8rem;
    }
}
