@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Newsreader:opsz,wght@6..72,500;6..72,650;6..72,800&display=swap");

:root {
    --primary-color: #2f7d58;
    --primary-dark: #20583d;
    --secondary-color: #e9b949;
    --accent-color: #151713;
    --neutral-color: #f5faf7;
    --light-bg: #f5faf7;
    --surface-color: #ffffff;
    --border-color: #dfe8e2;
    --text-dark: #151713;
    --text-light: #64685f;
    --danger-color: #d84a33;
    --warning-color: #e9b949;
    --shadow-soft: 0 18px 48px rgba(21, 23, 19, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    letter-spacing: 0;
}

body {
    min-height: 100vh;
    background: linear-gradient(180deg, var(--surface-color) 0%, var(--light-bg) 54%, #f8fbff 100%);
    color: var(--text-dark);
    font-family: "Inter", "Segoe UI", Arial, sans-serif;
}

h1,
h2,
h3,
.sidebar-header h2 {
    font-family: "Newsreader", Georgia, serif;
    font-weight: 650;
}

.d-flex {
    display: flex;
}

.sidebar {
    width: 280px;
    background:
        linear-gradient(180deg, rgba(21, 23, 19, 0.94), rgba(32, 88, 61, 0.9)),
        url("../../images/recipe2.jpg") center/cover;
    background-blend-mode: multiply;
    color: #fffdf8;
    height: 100vh;
    overflow-y: auto;
    position: fixed;
    left: 0;
    top: 0;
    box-shadow: 10px 0 34px rgba(21, 23, 19, 0.18);
    z-index: 1000;
}

.sidebar-header {
    padding: 2rem 1.5rem;
    border-bottom: 1px solid rgba(255, 253, 248, 0.18);
}

.sidebar-header h2 {
    margin: 0;
    font-size: 1.7rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-header i {
    color: #ffd36c;
}

.nav {
    padding: 1rem 0;
}

.nav-link {
    color: rgba(255, 253, 248, 0.78);
    padding: 0.95rem 1rem;
    margin: 0.25rem 0.85rem;
    border: 1px solid transparent;
    border-radius: 8px;
    transition: background 180ms ease, color 180ms ease, border-color 180ms ease;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
}

.nav-link i {
    width: 20px;
    text-align: center;
    color: #ffd36c;
}

.nav-link:hover,
.nav-link.active {
    background: rgba(255, 253, 248, 0.12);
    border-color: rgba(255, 253, 248, 0.18);
    color: #fffdf8;
}

.nav-link.active {
    font-weight: 800;
    box-shadow: inset 4px 0 0 var(--secondary-color);
}

.main-content {
    margin-left: 280px;
    width: calc(100% - 280px);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.top-bar {
    position: sticky;
    top: 0;
    z-index: 900;
    background: rgba(255, 255, 255, 0.92);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 10px 28px rgba(21, 23, 19, 0.06);
    backdrop-filter: blur(16px);
    padding: 1.15rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.top-bar-left,
.top-bar-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.top-bar-left h1 {
    margin: 0;
    color: var(--accent-color);
    font-size: clamp(1.55rem, 3vw, 2.25rem);
    font-weight: 800;
}

.toggle-sidebar {
    display: none;
    width: 42px;
    height: 42px;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--accent-color);
    cursor: pointer;
}

.username {
    color: var(--text-light);
    font-weight: 700;
}

.btn-logout,
.btn-site,
.btn,
.input-group button,
.btn-submit,
.btn-cancel,
.ingredients-input button,
.ingredient-item button {
    border-radius: 8px !important;
    border: 1px solid transparent !important;
    cursor: pointer;
    font-weight: 800;
    transition: background 180ms ease, border-color 180ms ease, color 180ms ease, transform 180ms ease, box-shadow 180ms ease;
}

.btn-logout {
    min-width: 44px;
    min-height: 42px;
    padding: 0.6rem 0.85rem;
    background: var(--accent-color);
    color: #fffdf8;
}

.btn-site {
    min-height: 42px;
    padding: 0.6rem 0.85rem;
    background: var(--surface-color);
    border: 1px solid var(--border-color) !important;
    color: var(--accent-color);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-site:hover {
    background: var(--neutral-color);
    color: var(--primary-dark);
    transform: translateY(-2px);
}

.btn-logout:hover,
.btn-secondary:hover {
    background: var(--primary-dark);
    color: #fffdf8;
    transform: translateY(-2px);
}

.content {
    padding: clamp(1rem, 3vw, 2rem);
    padding-bottom: calc(5rem + env(safe-area-inset-bottom));
    flex: 1;
    overflow-y: auto;
}

.section {
    margin-bottom: 2rem;
}

.section h2 {
    margin-bottom: 1.25rem;
    color: var(--accent-color);
    font-size: clamp(1.6rem, 3vw, 2.35rem);
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.section h2 i,
.form-section h3 i {
    color: var(--primary-color);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card,
.quick-actions,
.recipes-table,
.categories-list,
.add-category-form,
.form-card,
.login-container {
    background: var(--surface-color) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 8px !important;
    box-shadow: var(--shadow-soft) !important;
}

.stat-card {
    padding: 1.35rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: transform 180ms ease, box-shadow 180ms ease;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 24px 58px rgba(54, 43, 28, 0.16) !important;
}

.stat-icon {
    width: 58px;
    height: 58px;
    background: rgba(47, 107, 79, 0.1);
    border: 1px solid rgba(47, 107, 79, 0.18);
    border-radius: 8px;
    display: grid;
    place-items: center;
    color: var(--primary-color);
    font-size: 1.35rem;
}

.stat-content h3 {
    margin: 0;
    color: var(--text-light);
    font-family: "Inter", "Segoe UI", Arial, sans-serif;
    font-size: 0.82rem;
    font-weight: 800;
    text-transform: uppercase;
}

.stat-value {
    margin: 0.25rem 0 0;
    color: var(--accent-color);
    font-size: 2.2rem;
    font-weight: 800;
}

.quick-actions,
.categories-list,
.add-category-form,
.form-card {
    padding: clamp(1rem, 2.5vw, 2rem) !important;
}

.quick-actions h3,
.add-category-form h3,
.form-section h3 {
    color: var(--accent-color) !important;
    font-weight: 800;
}

.quick-actions a,
.quick-actions button {
    margin-right: 0.75rem;
    margin-bottom: 0.75rem;
}

.recipes-table {
    overflow-x: auto;
}

.table {
    margin: 0;
    min-width: 720px;
}

.table thead {
    background: rgba(47, 107, 79, 0.08);
    border-bottom: 1px solid var(--border-color);
}

.table th,
.table td {
    padding: 1rem 1.25rem;
    border-color: var(--border-color);
    vertical-align: middle;
}

.table th {
    color: var(--accent-color);
    font-weight: 800;
}

.table tbody tr:hover {
    background: rgba(217, 164, 65, 0.08);
}

.badge,
.bg-primary {
    padding: 0.52rem 0.75rem;
    border-radius: 8px;
    background: var(--danger-color) !important;
    color: #fffdf8 !important;
    font-weight: 800;
}

.category-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
}

.input-group,
.ingredients-input,
.form-actions {
    display: flex;
    gap: 0.85rem;
}

.profile-actions {
    align-items: center;
    flex-wrap: wrap;
}

.profile-actions .btn {
    min-height: 46px;
    padding: 0.72rem 1.05rem;
}

.form-group {
    margin-bottom: 1.35rem !important;
}

.form-label {
    display: block;
    margin-bottom: 0.45rem;
    color: var(--accent-color) !important;
    font-weight: 800 !important;
}

.form-control,
.input-group .form-control {
    background: rgba(255, 255, 255, 0.96) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 8px !important;
    color: var(--text-dark) !important;
    padding: 0.78rem 0.85rem !important;
    font-size: 1rem;
    transition: border-color 180ms ease, box-shadow 180ms ease;
}

.form-control:focus,
.input-group .form-control:focus {
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 0 4px rgba(47, 125, 88, 0.13) !important;
    outline: none;
}

textarea.form-control {
    min-height: 120px !important;
    resize: vertical;
}

.form-section {
    margin-bottom: 2rem !important;
    padding-bottom: 1.75rem !important;
    border-bottom: 1px solid var(--border-color) !important;
}

.form-section:last-child {
    margin-bottom: 0 !important;
    padding-bottom: 0 !important;
    border-bottom: 0 !important;
}

.image-preview img {
    border-radius: 8px !important;
    border: 1px solid var(--border-color);
    box-shadow: 0 14px 34px rgba(21, 23, 19, 0.07) !important;
}

.ingredient-item {
    background: rgba(47, 125, 88, 0.08) !important;
    border: 1px solid rgba(47, 125, 88, 0.14);
    border-radius: 8px !important;
    color: var(--text-dark);
}

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

.btn-primary,
.btn-submit,
.input-group button,
.ingredients-input button {
    background: var(--primary-color) !important;
    color: #fffdf8 !important;
}

.btn-primary:hover,
.btn-submit:hover,
.input-group button:hover,
.ingredients-input button:hover {
    background: var(--primary-dark) !important;
    color: #fffdf8 !important;
    transform: translateY(-2px);
}

.btn-secondary,
.btn-cancel {
    background: var(--accent-color) !important;
    color: #fffdf8 !important;
}

.btn-warning {
    background: var(--warning-color) !important;
    color: var(--accent-color) !important;
}

.btn-warning:hover {
    background: #e3b752 !important;
    color: var(--accent-color) !important;
}

.btn-danger,
.delete-button,
.ingredient-item button {
    background: var(--danger-color) !important;
    color: #fffdf8 !important;
}

.btn-danger:hover,
.delete-button:hover,
.ingredient-item button:hover {
    background: #9f3725 !important;
    color: #fffdf8 !important;
}

.btn-sm {
    padding: 0.45rem 0.7rem;
    font-size: 0.85rem;
}

.btn-submit:disabled {
    background: #b8b1a5 !important;
    cursor: not-allowed;
    transform: none;
}

.alert {
    border: 1px solid var(--border-color) !important;
    border-radius: 8px !important;
}

.login-container {
    max-width: 500px;
    width: min(500px, calc(100vw - 2rem));
    overflow: hidden;
}

.login-header {
    background:
        linear-gradient(90deg, rgba(21, 23, 19, 0.86), rgba(32, 88, 61, 0.72)),
        url("../../images/recipe3.jpg") center/cover !important;
    color: #fffdf8 !important;
}

.login-header i {
    color: #ffd36c !important;
}

.login-form,
.login-footer {
    background: var(--surface-color);
}

.error-message {
    color: var(--danger-color) !important;
}

button,
a,
select,
input[type="button"],
input[type="submit"] {
    cursor: pointer;
}

:focus-visible {
    outline: 3px solid rgba(47, 107, 79, 0.34);
    outline-offset: 3px;
}

@media (max-width: 768px) {
    body.admin-menu-open {
        overflow: hidden;
    }

    .d-flex {
        display: block;
    }

    .sidebar {
        width: min(82vw, 320px);
        height: 100vh;
        position: fixed;
        left: 0;
        top: 0;
        transform: translateX(-105%);
        transition: transform 220ms ease;
        z-index: 1200;
        border-right: 1px solid rgba(255, 253, 248, 0.18);
        border-bottom: 0;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
        width: 100%;
    }

    .top-bar {
        align-items: center;
        flex-direction: row;
        gap: 0.75rem;
        padding: 0.85rem 1rem;
    }

    .toggle-sidebar {
        display: inline-grid;
        place-items: center;
        flex: 0 0 auto;
    }

    .top-bar-left {
        min-width: 0;
        flex: 1 1 auto;
    }

    .top-bar-left h1 {
        font-size: 1.28rem;
        overflow-wrap: anywhere;
    }

    .top-bar-right {
        flex: 0 0 auto;
        gap: 0.6rem;
    }

    .btn-site {
        width: 42px;
        min-width: 42px;
        padding: 0;
        justify-content: center;
    }

    .btn-site .site-link-text {
        display: none;
    }

    .username {
        max-width: 72px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    body.admin-menu-open::before {
        content: "";
        position: fixed;
        inset: 0;
        background: rgba(31, 42, 36, 0.46);
        z-index: 1100;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .input-group,
    .ingredients-input,
    .form-actions {
        flex-direction: column;
    }

    .input-group .form-control,
    .input-group button,
    .ingredients-input button,
    .btn-submit,
    .btn-cancel {
        width: 100%;
    }

    .content {
        padding-bottom: calc(7rem + env(safe-area-inset-bottom));
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}
