:root {
    --bg-color: #f0f9ff;
    --text-color: #334155;
    --heading-color: #0f172a;
    --primary-color: #0ea5e9;
    --card-bg: #ffffff;
    --card-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --border-color: #e2e8f0;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #0f172a;
        --text-color: #cbd5e1;
        --heading-color: #f8fafc;
        --primary-color: #38bdf8;
        --card-bg: #1e293b;
        --card-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.3), 0 2px 4px -2px rgb(0 0 0 / 0.3);
        --border-color: #334155;
    }
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

h1, h2, h3, h4, h5, h6 {
    color: var(--heading-color);
}

nav {
    background-color: var(--card-bg);
    padding: 1rem 2rem;
    box-shadow: var(--card-shadow);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
}

nav a {
    color: var(--text-color);
    text-decoration: none;
    margin-right: 1.5rem;
    font-weight: 500;
}

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

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

form {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 8px;
    max-width: 600px;
    box-shadow: var(--card-shadow);
    border: 1px solid var(--border-color);
}

div {
    margin-bottom: 1rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--heading-color);
    font-weight: 500;
}

input, textarea {
    width: 100%;
    padding: 0.75rem;
    box-sizing: border-box;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: inherit;
}

input[type="checkbox"] {
    width: auto;
    padding: 0;
    margin-right: 0.5rem;
}

input:focus, textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.2);
}

button, .button {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background-color: var(--primary-color);
    color: #ffffff; /* Always white for contrast on primary color */
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    text-decoration: none;
    transition: opacity 0.2s;
}

button:hover, .button:hover {
    opacity: 0.9;
}

.button.delete {
    background-color: #ef4444; /* Red-500 from Tailwind palette to match style */
}

.recipes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.recipe-card {
    border: 1px solid var(--border-color);
    padding: 1.5rem;
    border-radius: 8px;
    background-color: var(--card-bg);
    box-shadow: var(--card-shadow);
    transition: transform 0.2s;
}

.recipe-card:hover {
    transform: translateY(-2px);
}

.recipe-card h3 {
    margin-top: 0;
    margin-bottom: 0.5rem;
}

.recipe-card p {
    color: var(--text-color);
    opacity: 0.8;
}

.recipe-card a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    display: inline-block;
    margin-top: 1rem;
}

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

pre {
    background-color: var(--card-bg);
    padding: 1.5rem;
    border-radius: 8px;
    white-space: pre-wrap;
    border: 1px solid var(--border-color);
    color: var(--text-color);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

#message {
    margin-top: 1rem;
    font-weight: 500;
}

.login-container {
    max-width: 400px;
    margin: 4rem auto;
    text-align: center;
}

.login-header {
    margin-bottom: 2rem;
}

.login-header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    color: var(--primary-color);
}

.login-header p {
    color: var(--text-color);
    font-size: 1.1rem;
}

.login-footer {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
    color: var(--text-color);
    font-size: 0.9rem;
}

.social-links {
    margin-top: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
}

.social-links a {
    color: var(--text-color);
    text-decoration: none;
    transition: color 0.2s;
}

.social-links a:hover {
    color: var(--primary-color);
}

.social-links a i {
    margin-right: 5px;
}

.separator {
    color: var(--border-color);
}

.nav-brand {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
}

.nav-tab {
    padding: 0.5rem 1rem;
    border-radius: 6px;
    transition: background-color 0.2s;
}

.nav-tab:hover {
    background-color: var(--bg-color);
}

#user-links, #auth-links {
    gap: 1rem;
    align-items: center;
}

.contact-container {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 200px); /* Adjust based on nav/padding */
    justify-content: space-between;
}

.contact-socials {
    margin-top: auto;
    padding-top: 3rem;
    text-align: center;
}

.contact-socials h3 {
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.pantry-container {
    max-width: 600px;
    margin: 0 auto;
}

.pantry-form {
    margin-bottom: 2rem;
    max-width: 100%; /* Override default form max-width */
}

.pantry-list {
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: var(--card-shadow);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

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

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

.pantry-item span {
    font-size: 1.1rem;
    color: var(--text-color);
}

.delete-icon {
    color: #ef4444;
    cursor: pointer;
    padding: 5px;
    transition: opacity 0.2s;
}

.delete-icon:hover {
    opacity: 0.7;
}

.tag-filter {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.tag-filter:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.tag-filter.active {
    background-color: var(--primary-color);
    color: #ffffff;
    border-color: var(--primary-color);
}

.back-link {
    text-decoration: none;
    color: var(--text-color);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    transition: color 0.2s;
}

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

/* Toast Notifications */
#toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background-color: var(--card-bg);
    color: var(--text-color);
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-left: 4px solid var(--primary-color);
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 250px;
    animation: slideIn 0.3s ease-out forwards;
    opacity: 0;
    transform: translateX(100%);
}

.toast.success {
    border-left-color: #10b981;
}

.toast.error {
    border-left-color: #ef4444;
}

.toast.info {
    border-left-color: #3b82f6;
}

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

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

/* Mobile Menu Button (Hidden on Desktop) */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-color);
    cursor: pointer;
    padding: 0.5rem;
}

.nav-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: auto;
}

#nav-content {
    display: flex;
    align-items: center;
    width: 100%;
    justify-content: flex-end;
}

/* Search Container & Filters */
.search-container {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: center;
    background: var(--card-bg);
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.filter-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    margin-bottom: 0;
    white-space: nowrap;
}

#search-input {
    flex: 1;
    min-width: 200px;
}

/* Mobile Responsiveness */
@media (max-width: 1024px) {
    nav {
        flex-direction: column;
        padding: 1rem;
        align-items: stretch; /* Full width */
    }

    .nav-header {
        width: 100%;
    }

    .mobile-menu-btn {
        display: block; /* Show hamburger on mobile/tablet */
    }

    #nav-content {
        display: none; /* Hide links by default */
        flex-direction: column;
        width: 100%;
        margin-top: 1rem;
        border-top: 1px solid var(--border-color);
        padding-top: 1rem;
    }

    #nav-content.active {
        display: flex; /* Show when active */
    }

    .nav-brand {
        margin-bottom: 0;
    }

    #user-links, #auth-links {
        display: flex;
        flex-direction: column;
        width: 100%;
        gap: 0.5rem;
        text-align: center;
    }

    nav a {
        margin-right: 0;
        padding: 0.75rem;
        display: block;
        background-color: rgba(0,0,0,0.03);
        border-radius: 6px;
        width: 100%;
        box-sizing: border-box;
    }

    nav a:hover {
        background-color: rgba(0,0,0,0.06);
    }

    .container {
        padding: 1rem;
    }

    .recipes-grid {
        grid-template-columns: 1fr; /* Force single column on mobile */
        gap: 1rem;
    }

    form {
        padding: 1.5rem;
    }
    
    /* Adjust search bar layout on mobile */
    .search-container {
        flex-direction: column;
        align-items: stretch !important;
        width: 100%;
        box-sizing: border-box; /* Ensure padding doesn't add to width */
    }
    
    .filter-label {
        white-space: normal; /* Allow wrapping on mobile */
        margin-top: 0.5rem;
        width: 100%; /* Ensure label stays within container */
    }
    
    #search-input {
        width: 100%;
        min-width: 0 !important;
        box-sizing: border-box; /* Ensure padding doesn't add to width */
    }
    
    /* Social links on mobile */
    .social-links {
        flex-wrap: wrap;
    }
    
    .social-links .separator {
        display: none; /* Hide separators on mobile if we stack or wrap tightly */
    }

    .social-links a {
        margin: 0.25rem;
        padding: 0.25rem 0.5rem;
        background: rgba(0,0,0,0.03);
        border-radius: 4px;
    }
}
