/* Reset and base styles */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary-color: #e67e22;
    --primary-dark: #d35400;
    --secondary-color: #3498db;
    --danger-color: #e74c3c;
    --text-color: #2c3e50;
    --text-light: #7f8c8d;
    --bg-color: #f5f6fa;
    --white: #ffffff;
    --border-color: #dcdde1;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --radius: 8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Container */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Navigation */
.navbar {
    background-color: var(--white);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    max-width: 1200px;
    margin: 0 auto;
}

.nav-brand {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    text-decoration: none;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 1.5rem;
}

.nav-link {
    color: var(--text-color);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.nav-link:hover {
    color: var(--primary-color);
}

/* Hamburger menu */
.hamburger {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
}

.hamburger span {
    width: 25px;
    height: 3px;
    background-color: var(--text-color);
    border-radius: 2px;
    transition: 0.3s;
}

/* Main content */
main {
    flex: 1;
    padding: 2rem 1rem;
}

/* Page header */
.page-header {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 2rem;
    color: var(--text-color);
}

/* Search */
.search-container {
    width: 100%;
    max-width: 400px;
}

.search-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 1rem;
    transition: border-color 0.2s;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Recipe grid */
.recipe-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

/* Recipe card */
.recipe-card {
    background: var(--white);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
}

.recipe-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.recipe-card-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.recipe-image {
    width: 100%;
    height: 200px;
    overflow: hidden;
}

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

.recipe-image-placeholder {
    background: linear-gradient(135deg, var(--border-color), #ecf0f1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-light);
}

.recipe-card-content {
    padding: 1rem;
}

.recipe-title {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

.recipe-meta {
    color: var(--text-light);
    font-size: 0.875rem;
}

.delete-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: rgba(231, 76, 60, 0.9);
    color: white;
    font-size: 1.25rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.recipe-card:hover .delete-btn {
    opacity: 1;
}

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

/* Empty state */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem;
    background: var(--white);
    border-radius: var(--radius);
}

.empty-state p {
    margin-bottom: 1rem;
    color: var(--text-light);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.2s, transform 0.1s;
}

.btn:active {
    transform: scale(0.98);
}

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

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

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

.btn-secondary:hover {
    background-color: #2980b9;
}

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

.btn-danger:hover {
    background-color: #c0392b;
}

.btn-block {
    width: 100%;
}

/* Forms */
.form-container {
    max-width: 500px;
    margin: 0 auto;
    background: var(--white);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.form-container + .form-container {
    margin-top: 1.5rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-help {
    display: block;
    margin-top: 0.5rem;
    color: var(--text-light);
    font-size: 0.875rem;
}

/* Spinner */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.btn-loading {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

/* Alerts */
.alert {
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.alert-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: inherit;
    opacity: 0.5;
}

.alert-close:hover {
    opacity: 1;
}

/* Supported sites */
.supported-sites {
    max-width: 500px;
    margin: 2rem auto 0;
    padding: 1.5rem;
    background: var(--white);
    border-radius: var(--radius);
}

.supported-sites h3 {
    margin-bottom: 0.5rem;
}

.supported-sites p {
    color: var(--text-light);
    margin-bottom: 1rem;
}

.supported-sites ul {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.supported-sites li {
    background: var(--bg-color);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.875rem;
}

/* Recipe detail page */
.recipe-detail {
    max-width: 800px;
    margin: 0 auto;
}

.recipe-header {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.recipe-header h1 {
    font-size: 1.75rem;
}

.recipe-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.recipe-hero {
    margin-bottom: 2rem;
    border-radius: var(--radius);
    overflow: hidden;
}

.recipe-hero img {
    width: 100%;
    max-height: 400px;
    object-fit: cover;
}

.recipe-content {
    display: grid;
    gap: 2rem;
}

.recipe-ingredients,
.recipe-method {
    background: var(--white);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.recipe-ingredients h2,
.recipe-method h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--primary-color);
}

.ingredients-list {
    list-style: none;
}

.ingredients-list li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
}

.ingredients-list li:last-child {
    border-bottom: none;
}

.ingredient-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    cursor: pointer;
}

.ingredient-checkbox {
    margin-top: 0.25rem;
    cursor: pointer;
}

.ingredient-checkbox:checked + span {
    text-decoration: line-through;
    color: var(--text-light);
}

.method-list {
    padding-left: 1.25rem;
}

.method-list li {
    padding: 0.75rem 0;
    padding-left: 0.5rem;
}

.method-list li::marker {
    color: var(--primary-color);
    font-weight: 700;
}

/* Footer */
.footer {
    background: var(--white);
    padding: 1.5rem;
    text-align: center;
    color: var(--text-light);
    margin-top: auto;
}

/* Responsive styles */
@media (min-width: 768px) {
    .page-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }

    .recipe-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .recipe-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: flex-start;
    }

    .recipe-header h1 {
        font-size: 2rem;
    }

    .recipe-content {
        grid-template-columns: 1fr 2fr;
    }
}

@media (min-width: 1024px) {
    .recipe-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 767px) {
    .hamburger {
        display: flex;
    }

    .nav-menu {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--white);
        flex-direction: column;
        padding: 1rem;
        box-shadow: var(--shadow);
        gap: 0;
    }

    .nav-menu.active {
        display: flex;
    }

    .nav-menu li {
        padding: 0.75rem 0;
        border-bottom: 1px solid var(--border-color);
    }

    .nav-menu li:last-child {
        border-bottom: none;
    }

    .hamburger.active span:nth-child(1) {
        transform: rotate(45deg) translate(6px, 6px);
    }

    .hamburger.active span:nth-child(2) {
        opacity: 0;
    }

    .hamburger.active span:nth-child(3) {
        transform: rotate(-45deg) translate(6px, -6px);
    }
}

/* Login page styles */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 200px);
}

.login-box {
    background: var(--white);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 400px;
}

.login-box h1 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--primary-color);
}

.login-form .form-group {
    margin-bottom: 1rem;
}

.login-form .btn-block {
    margin-top: 1rem;
}

/* Nav user styles */
.nav-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.nav-username {
    color: var(--text-light);
    font-size: 0.875rem;
}

/* Admin page styles */
.admin-container {
    max-width: 900px;
    margin: 0 auto;
}

.admin-container h1 {
    margin-bottom: 2rem;
}

.admin-section {
    background: var(--white);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

.admin-section h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--primary-color);
}

.admin-form .form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
}

.admin-form .form-group {
    flex: 1;
    min-width: 150px;
    margin-bottom: 0;
}

.admin-form .form-group-checkbox {
    flex: 0 0 auto;
    min-width: auto;
    display: flex;
    align-items: center;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-weight: 500;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Admin table */
.table-container {
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table th,
.admin-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.admin-table th {
    background: var(--bg-color);
    font-weight: 600;
}

.admin-table tbody tr:hover {
    background: var(--bg-color);
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-admin {
    background: var(--primary-color);
    color: white;
}

.badge-user {
    background: var(--secondary-color);
    color: white;
}

/* Small button variant */
.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

.text-muted {
    color: var(--text-light);
    font-style: italic;
}

/* Category tags in admin */
.category-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
}

.category-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-color);
    padding: 0.5rem 0.75rem;
    border-radius: 20px;
    font-size: 0.875rem;
}

.category-delete-btn {
    background: none;
    border: none;
    color: var(--danger-color);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    opacity: 0.7;
}

.category-delete-btn:hover {
    opacity: 1;
}

/* Recipe meta info */
.recipe-meta-info {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-light);
}

.recipe-category {
    background: var(--primary-color);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
}

.recipe-saved-by {
    font-style: italic;
}

/* Recipe card category tag */
.recipe-card-category {
    display: inline-block;
    background: var(--primary-color);
    color: white;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.7rem;
    margin-top: 0.5rem;
}

/* Search and filter container */
.search-filter-container {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.category-filter {
    min-width: 150px;
    padding: 0.75rem 1rem;
}

/* Add recipe options */
.add-recipe-options {
    text-align: center;
    margin-bottom: 1.5rem;
}

/* Manual recipe form */
.manual-recipe-form {
    max-width: 600px;
}

.ingredient-row,
.method-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    align-items: flex-start;
}

.ingredient-qty {
    flex: 0 0 120px;
}

.ingredient-name {
    flex: 1;
}

.method-row {
    align-items: stretch;
}

.step-label {
    flex: 0 0 60px;
    padding: 0.75rem 0;
    font-weight: 500;
    color: var(--primary-color);
}

.method-step {
    flex: 1;
    min-height: 80px;
    resize: vertical;
}

.remove-row-btn {
    flex: 0 0 auto;
    padding: 0.5rem 0.75rem;
}

#add-ingredient-btn,
#add-step-btn {
    margin-top: 0.5rem;
}

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

/* Image upload styles */
.image-upload-container {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    padding: 1rem;
    background: var(--bg-color);
}

.image-preview-wrapper {
    position: relative;
    text-align: center;
}

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

.image-preview-wrapper .remove-image-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
}

.image-upload-input input[type="file"] {
    width: 100%;
    padding: 0.5rem;
    border: none;
    background: none;
}

.image-upload-input .help-text {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-light);
}

/* Recipe icon placeholder */
.recipe-image-icon {
    background: linear-gradient(135deg, #fff5eb, #ffe8d6);
    display: flex;
    align-items: center;
    justify-content: center;
}

.recipe-placeholder-icon {
    width: 80px;
    height: 80px;
    opacity: 0.8;
}

.recipe-hero-icon {
    background: linear-gradient(135deg, #fff5eb, #ffe8d6);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.recipe-hero-placeholder {
    width: 120px;
    height: 120px;
    opacity: 0.8;
}

/* Action buttons in admin table */
.actions-cell {
    min-width: 200px;
}

.action-buttons {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.password-form-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.form-input-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    width: 150px;
}

/* Mobile adjustments for admin */
@media (max-width: 767px) {
    .admin-form .form-row {
        flex-direction: column;
    }

    .admin-form .form-group {
        width: 100%;
    }

    .nav-user {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }

    .nav-username {
        padding-left: 0;
    }

    .action-buttons {
        flex-direction: column;
        align-items: flex-start;
    }

    .password-form-row {
        flex-direction: column;
        align-items: stretch;
    }

    .form-input-sm {
        width: 100%;
    }

    .search-filter-container {
        flex-direction: column;
        width: 100%;
    }

    .search-filter-container .search-container,
    .search-filter-container .category-filter-container,
    .search-filter-container .my-recipes-filter {
        width: 100%;
    }

    .category-filter {
        width: 100%;
    }

    .ingredient-row {
        flex-wrap: wrap;
    }

    .ingredient-qty {
        flex: 0 0 100%;
    }

    .ingredient-name {
        flex: 1;
    }

    .method-row {
        flex-wrap: wrap;
    }

    .step-label {
        flex: 0 0 100%;
        padding: 0.5rem 0 0.25rem;
    }

    .method-step {
        flex: 0 0 calc(100% - 40px);
    }

    .form-actions {
        flex-direction: column;
    }

    .form-actions .btn {
        width: 100%;
    }
}
