/* Components CSS - Reusable UI components */

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    font-size: 0.9375rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    text-decoration: none;
}

.btn svg {
    width: 18px;
    height: 18px;
}

.btn-primary {
    background-color: var(--accent-primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--accent-primary-hover);
}

.btn-secondary {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: var(--bg-hover);
}

.btn-success {
    background-color: var(--color-success);
    color: white;
}

.btn-success:hover {
    background-color: var(--color-success-hover);
}

.btn-danger {
    background-color: var(--color-danger);
    color: white;
}

.btn-danger:hover {
    background-color: var(--color-danger-hover);
}

.btn-warning {
    background-color: var(--color-warning);
    color: var(--text-dark);
}

.btn-warning:hover {
    background-color: var(--color-warning-hover);
}

.btn-outline {
    background-color: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-outline:hover {
    background-color: var(--bg-hover);
}

.btn-icon {
    padding: 0.5rem;
    min-width: 44px;
    min-height: 44px;
}

.btn-sm {
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
}

.btn-lg {
    padding: 1rem 1.5rem;
    font-size: 1rem;
}

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

/* Cards */
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.card-image {
    width: 100%;
    height: 160px;
    object-fit: cover;
    background-color: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-image svg {
    width: 48px;
    height: 48px;
    color: var(--text-muted);
}

.card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card-body {
    padding: 1rem;
}

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

.card-description {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.card-meta-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.card-meta-item svg {
    width: 14px;
    height: 14px;
}

.card-actions {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-secondary);
}

.card-actions .btn {
    flex: 1;
}

/* Tags/Badges */
.tag {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    background-color: var(--bg-secondary);
    color: var(--text-secondary);
}

.tag-primary {
    background-color: var(--accent-primary-light);
    color: var(--accent-primary);
}

.tag-success {
    background-color: var(--color-success-light);
    color: var(--color-success);
}

.tag-warning {
    background-color: var(--color-warning-light);
    color: var(--color-warning-dark);
}

.tag-danger {
    background-color: var(--color-danger-light);
    color: var(--color-danger);
}

/* Form Elements */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.form-label.required::after {
    content: " *";
    color: var(--color-danger);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 0.9375rem;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-primary-light);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--text-muted);
}

.form-textarea {
    min-height: 100px;
    resize: vertical;
}

.form-select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px;
    padding-right: 2.5rem;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

.form-hint {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.form-error {
    font-size: 0.8125rem;
    color: var(--color-danger);
    margin-top: 0.25rem;
}

/* Checkbox & Radio */
.form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--accent-primary);
}

.form-check-label {
    font-size: 0.9375rem;
    color: var(--text-primary);
    user-select: none;
}

/* Image Upload */
.image-upload {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 1.5rem;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

.image-upload:hover {
    border-color: var(--accent-primary);
    background-color: var(--bg-hover);
}

.image-upload svg {
    width: 48px;
    height: 48px;
    color: var(--text-muted);
}

.image-upload-text {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-align: center;
}

.image-upload input {
    display: none;
}

.image-preview {
    position: relative;
    width: 100%;
    max-width: 200px;
}

.image-preview img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: var(--radius-md);
}

.image-preview-remove {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--color-danger);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
}

.image-preview-remove svg {
    width: 16px;
    height: 16px;
}

/* Modal */
.modal-container {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-container.hidden {
    display: none;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal {
    position: relative;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    background-color: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    animation: modalIn 0.2s ease;
}

.modal-lg {
    max-width: 900px;
}

.modal-xl {
    max-width: 1200px;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: var(--radius-sm);
}

.modal-close:hover {
    color: var(--text-primary);
    background-color: var(--bg-hover);
}

.modal-close svg {
    width: 20px;
    height: 20px;
}

.modal-body {
    padding: 1.25rem;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-secondary);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s ease;
    min-width: 280px;
    max-width: 400px;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.toast-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.toast-message {
    flex: 1;
    font-size: 0.9375rem;
    color: var(--text-primary);
}

.toast-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
}

.toast-close svg {
    width: 16px;
    height: 16px;
}

.toast-success .toast-icon {
    color: var(--color-success);
}

.toast-error .toast-icon {
    color: var(--color-danger);
}

.toast-warning .toast-icon {
    color: var(--color-warning);
}

.toast-info .toast-icon {
    color: var(--accent-primary);
}

/* Cooking Mode */
.cooking-mode {
    position: fixed;
    inset: 0;
    z-index: 1500;
    background-color: var(--bg-primary);
    display: flex;
    flex-direction: column;
}

.cooking-mode.hidden {
    display: none;
}

.cooking-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    background-color: var(--bg-header);
    border-bottom: 1px solid var(--border-color);
}

.cooking-header h2 {
    flex: 1;
    font-size: 1.25rem;
    font-weight: 600;
}

.cooking-timer {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background-color: var(--bg-secondary);
    border-radius: var(--radius-md);
    font-size: 1.25rem;
    font-weight: 600;
    font-family: 'Courier New', monospace;
}

.cooking-timer svg {
    width: 24px;
    height: 24px;
    color: var(--accent-primary);
}

.cooking-content {
    display: grid;
    grid-template-columns: 1fr 2fr;
    flex: 1;
    overflow: hidden;
}

.cooking-ingredients,
.cooking-steps {
    padding: 1.5rem;
    overflow-y: auto;
}

.cooking-ingredients {
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
}

.cooking-ingredients h3,
.cooking-steps h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

/* Cooking Ingredient Item */
.cooking-ingredient-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background-color: var(--bg-card);
    border-radius: var(--radius-md);
    margin-bottom: 0.5rem;
}

.cooking-ingredient-qty {
    font-weight: 600;
    color: var(--accent-primary);
    min-width: 80px;
}

.cooking-ingredient-name {
    flex: 1;
}

/* Cooking Step Item */
.cooking-step-item {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 0.75rem;
    transition: opacity 0.2s ease;
}

.cooking-step-item.completed {
    opacity: 0.5;
}

.cooking-step-item.completed .cooking-step-title,
.cooking-step-item.completed .cooking-step-description {
    text-decoration: line-through;
}

.cooking-step-check {
    flex-shrink: 0;
}

.cooking-step-check input {
    width: 24px;
    height: 24px;
    cursor: pointer;
    accent-color: var(--color-success);
}

.cooking-step-content {
    flex: 1;
}

.cooking-step-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background-color: var(--accent-primary);
    color: white;
    border-radius: 50%;
    font-size: 0.875rem;
    font-weight: 600;
    margin-right: 0.5rem;
}

.cooking-step-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.cooking-step-description {
    font-size: 0.9375rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.cooking-step-timer {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background-color: var(--bg-secondary);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

.cooking-step-timer svg {
    width: 16px;
    height: 16px;
    color: var(--accent-primary);
}

.cooking-step-timer-btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    background-color: var(--accent-primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
}

/* Drag and Drop */
.draggable {
    cursor: grab;
}

.draggable:active {
    cursor: grabbing;
}

.drag-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    color: var(--text-muted);
    cursor: grab;
}

.drag-handle:active {
    cursor: grabbing;
}

.drag-handle svg {
    width: 16px;
    height: 16px;
}

.drag-over {
    border: 2px dashed var(--accent-primary) !important;
    background-color: var(--accent-primary-light) !important;
}

/* List Items */
.list-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 0.5rem;
}

.list-item-content {
    flex: 1;
    min-width: 0;
}

.list-item-title {
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-item-subtitle {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.list-item-actions {
    display: flex;
    gap: 0.25rem;
}

.list-item-actions .btn {
    padding: 0.375rem;
}

.list-item-actions .btn svg {
    width: 16px;
    height: 16px;
}

/* Autocomplete */
.autocomplete-container {
    position: relative;
}

.autocomplete-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 200px;
    overflow-y: auto;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    box-shadow: var(--shadow-md);
    z-index: 100;
}

.autocomplete-results.hidden {
    display: none;
}

.autocomplete-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: background-color 0.1s ease;
}

.autocomplete-item:hover,
.autocomplete-item.active {
    background-color: var(--bg-hover);
}

.autocomplete-item-title {
    font-weight: 500;
    color: var(--text-primary);
}

.autocomplete-item-subtitle {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

/* Progress Bar */
.progress-bar {
    width: 100%;
    height: 8px;
    background-color: var(--bg-secondary);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background-color: var(--accent-primary);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.progress-bar-fill.success {
    background-color: var(--color-success);
}

/* Preparation Item */
.preparation-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: box-shadow 0.2s ease;
}

.preparation-item:hover {
    box-shadow: var(--shadow-sm);
}

.preparation-item-info {
    flex: 1;
    min-width: 0;
}

.preparation-item-name {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.preparation-item-time {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.preparation-item-progress {
    width: 120px;
}

.preparation-item-actions {
    display: flex;
    gap: 0.5rem;
}

/* Responsive for Cooking Mode */
@media (max-width: 768px) {
    .cooking-content {
        grid-template-columns: 1fr;
    }
    
    .cooking-ingredients {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        max-height: 30vh;
    }
}

/* Detail Views */
.detail-image {
    width: 100%;
    height: 200px;
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: 1rem;
}

.detail-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Ingredients and Steps Lists in Forms */
.ingredients-list,
.steps-list,
.recipes-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 300px;
    overflow-y: auto;
    padding: 0.5rem;
    background-color: var(--bg-secondary);
    border-radius: var(--radius-md);
}

.ingredients-list:empty::before,
.steps-list:empty::before,
.recipes-list:empty::before {
    content: 'Aucun élément ajouté';
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
    padding: 1rem;
}

/* Checkbox Grid */
.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.5rem;
}
