* { box-sizing: border-box; }
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    margin: 0;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

a { color: #3498db; text-decoration: none; }
a:hover { text-decoration: underline; }

.header { margin-bottom: 30px; }
.header h1 { color: #2c3e50; margin: 0 0 10px; }

.message { padding: 12px 15px; margin-bottom: 16px; border-radius: 5px; }
.message.error { background-color: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.message.success { background-color: #d4edda; color: #155724; border: 1px solid #c3e6cb; }

.btn {
    padding: 10px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    font-size: 0.95rem;
    display: inline-block;
}

/* Login / migrate / audit cards */
.simple-card {
    max-width: 700px;
    margin: 40px auto;
    background: #fff;
    padding: 24px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.simple-card.narrow { max-width: 420px; }
.simple-card h1 { margin-top: 0; }

.form-group { display: flex; flex-direction: column; margin-bottom: 12px; }
.form-group label { font-weight: bold; margin-bottom: 6px; color: #34495e; }
.form-group input, .form-group textarea, .form-group select {
    padding: 10px;
    border: 1px solid #bdc3c7;
    border-radius: 4px;
    font-size: 1rem;
    font-family: inherit;
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 5px rgba(52, 152, 219, 0.3);
}
.form-group textarea { resize: vertical; min-height: 100px; }
.form-group textarea.large { min-height: 200px; }

.btn-primary { background-color: #27ae60; color: #fff; }
.btn-primary:hover { background-color: #229954; }
.btn-secondary { background-color: #95a5a6; color: #fff; }
.btn-secondary:hover { background-color: #7f8c8d; }
.btn-auth { background-color: #34495e; color: #fff; }
.btn-auth:hover { background-color: #2c3e50; }
.btn-view { background-color: #3498db; color: #fff; }
.btn-view:hover { background-color: #2980b9; }
.btn-edit { background-color: #f39c12; color: #fff; }
.btn-edit:hover { background-color: #e67e22; }
.btn-delete { background-color: #e74c3c; color: #fff; }
.btn-delete:hover { background-color: #c0392b; }

/* Index */
.header.center { text-align: center; margin-bottom: 40px; }
.header.center h1 { font-size: 2.5rem; }
.header.center p { color: #7f8c8d; font-size: 1.1rem; margin: 0; }

.controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    gap: 20px;
    flex-wrap: wrap;
}
.auth-controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.btn-add { background-color: #27ae60; color: #fff; padding: 12px 24px; border-radius: 5px; }
.btn-add:hover { background-color: #229954; text-decoration: none; }
.search-form { display: flex; flex: 1; gap: 8px; align-items: center; min-width: 200px; }
.search-box { flex: 1; min-width: 0; padding: 10px 15px; border: 1px solid #bdc3c7; border-radius: 5px; font-size: 1rem; }

.category-section { margin-bottom: 35px; }
.category-title { color: #2c3e50; margin-bottom: 15px; padding-bottom: 8px; border-bottom: 2px solid #27ae60; }
.recipes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }
.recipe-card { background: #fff; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.1); padding: 20px; transition: transform 0.3s, box-shadow 0.3s; }
.recipe-card:hover { transform: translateY(-5px); box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
.recipe-card h2 { color: #2c3e50; margin: 0 0 10px; font-size: 1.4rem; }
.recipe-card p { color: #7f8c8d; margin-bottom: 8px; font-size: 0.95rem; }
.recipe-category { display: inline-block; margin-bottom: 10px; padding: 4px 10px; border-radius: 999px; background-color: #eaf2ff; color: #2b5fbc; font-size: 0.8rem; font-weight: bold; }
.recipe-meta { display: flex; gap: 15px; margin: 15px 0; flex-wrap: wrap; font-size: 0.9rem; }
.meta-item { display: flex; align-items: center; gap: 5px; }
.meta-label { font-weight: bold; color: #34495e; }
.difficulty { padding: 4px 8px; border-radius: 3px; font-size: 0.85rem; font-weight: bold; }
.difficulty.easy { background-color: #d4edda; color: #155724; }
.difficulty.medium { background-color: #fff3cd; color: #856404; }
.difficulty.hard { background-color: #f8d7da; color: #721c24; }
.recipe-actions { display: flex; gap: 10px; margin-top: 15px; flex-wrap: wrap; }
.no-recipes { text-align: center; padding: 40px; color: #7f8c8d; }
.no-recipes p { font-size: 1.1rem; margin-bottom: 20px; }
.hidden { display: none !important; }

.pagination { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin-top: 24px; }
.pagination a, .pagination span {
    padding: 8px 12px;
    border: 1px solid #d0d7de;
    border-radius: 4px;
    text-decoration: none;
    color: #2c3e50;
    background: #fff;
    font-size: 0.95rem;
}
.pagination .current { background: #27ae60; border-color: #27ae60; color: #fff; }
.pagination .disabled { color: #9aa5b1; background: #f6f8fa; }

/* Add/Edit form */
.form-page { max-width: 800px; }
.back-link { display: inline-block; margin-bottom: 20px; }
.form-card { background: #fff; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.1); padding: 30px; }
.form-section { margin-bottom: 25px; }
.form-section h3 { color: #2c3e50; margin-bottom: 15px; padding-bottom: 10px; border-bottom: 2px solid #ecf0f1; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; margin-bottom: 15px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 25px; }
.help-text { font-size: 0.9rem; color: #7f8c8d; margin-top: 5px; }

/* View page */
.view-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; gap: 15px; flex-wrap: wrap; }
.view-controls { display: flex; gap: 10px; flex-wrap: wrap; }
.recipe-view-card { background: #fff; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.1); padding: 30px; }
.recipe-title { font-size: 2.5rem; color: #2c3e50; margin-bottom: 15px; }
.recipe-description { font-size: 1.1rem; color: #7f8c8d; margin-bottom: 25px; font-style: italic; }
.recipe-meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 20px; margin-bottom: 30px; padding: 20px; background-color: #ecf0f1; border-radius: 6px; }
.meta-center { text-align: center; }
.meta-value { font-size: 1.5rem; font-weight: bold; color: #2c3e50; }
.meta-sub { color: #7f8c8d; font-size: 0.9rem; margin-top: 5px; }
.badge-easy { background-color: #d4edda; padding: 8px 12px; border-radius: 4px; }
.badge-medium { background-color: #fff3cd; padding: 8px 12px; border-radius: 4px; }
.badge-hard { background-color: #f8d7da; padding: 8px 12px; border-radius: 4px; }
.badge-category { background-color: #eaf2ff; padding: 8px 12px; border-radius: 4px; font-size: 1rem; }
.badge-type { background-color: #fef3c7; padding: 8px 12px; border-radius: 4px; font-size: 1rem; }
.badge-type { color: #92400e; margin-left: 6px; }
.section { margin-bottom: 40px; }
.section-title { font-size: 1.5rem; color: #2c3e50; margin-bottom: 15px; padding-bottom: 10px; border-bottom: 3px solid #27ae60; }
.ingredients-list, .instructions-list { margin: 0; padding: 0; list-style: none; }
.ingredients-list li { padding: 10px 0 10px 25px; position: relative; }
.ingredients-list li:before { content: "✓"; position: absolute; left: 0; color: #27ae60; font-weight: bold; }
.instructions-list { counter-reset: step; }
.instructions-list li { padding: 15px 0 15px 50px; position: relative; margin-bottom: 10px; }
.instructions-list li:before {
    content: counter(step);
    counter-increment: step;
    position: absolute;
    left: 0;
    top: 0;
    background-color: #27ae60;
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}
.notes-box { background-color: #fff9e6; border-left: 4px solid #f39c12; padding: 15px; border-radius: 4px; }
.notes-box p { margin: 0 0 10px; }
.notes-box p:last-child { margin-bottom: 0; }

/* Audit table */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { border: 1px solid #ddd; padding: 8px; text-align: left; vertical-align: top; }
th { background: #f4f7fb; }
.top-links { margin-bottom: 14px; }
.top-links a { margin-right: 10px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.detail-box { background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 6px; padding: 12px; }
.detail-box h2 { margin: 0 0 8px; font-size: 1rem; }
.detail-box pre { white-space: pre-wrap; word-break: break-word; font-size: 0.85rem; margin: 0; }

.search-result-count { color: #555; margin-bottom: 20px; font-size: 0.95rem; }
.search-result-count strong { color: #2c3e50; }
.footer-note { text-align: center; margin-top: 40px; color: #7f8c8d; }
.full-width { width: 100%; }

@media print {
    body { background: #fff; }
    .container { padding: 0; }
    .view-header, .view-controls, .btn { display: none !important; }
    .recipe-view-card { box-shadow: none; padding: 0; }
}

@media (max-width: 800px) {
    .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
    .container { padding: 10px; }
    .header.center h1 { font-size: 1.8rem; }
    .controls { flex-direction: column; align-items: stretch; }
    .recipes-grid { grid-template-columns: 1fr; }
    .form-card { padding: 20px; }
    .form-row { grid-template-columns: 1fr; }
    .form-actions { flex-direction: column-reverse; }
    .recipe-view-card { padding: 20px; }
    .recipe-title { font-size: 1.8rem; }
    .recipe-meta-grid { grid-template-columns: 1fr; }
    .view-header { flex-direction: column; align-items: flex-start; }
}
