/* ========================================
   RECIPE APP - COMPLETE STYLES
   Modern CSS with Recipe List & Login Pages
   ======================================== */

:root {
    /* Colors */
    --header-color: #112e6e;
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #3b82f6;
    --secondary-color: #64748b;
    --accent-color: #f59e0b;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --background: #ffffff;
    --surface: #f8fafc;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --error-color: #ef4444;
    --success-color: #10b981;

    --characteristic-color: #2563eb;
    --cuisine-color: #f59e0b;
    --protein-color: #10b981;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

    /* Border Radius */
    --radius: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;

    /* Typography */
    --font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ========================================
   GLOBAL STYLES
   ======================================== */

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

.body {
    font-family: var(--font-family);
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--background);

    /* Login overrides */
    &.login {
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        min-height: 100vh;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* ========================================
       RECIPE APP LAYOUT
       ======================================== */

    & .app {
        min-height: 100vh;
        display: grid;
        grid-template-rows: auto 1fr;
        margin: 0 auto;
    }

    /* Login overrides */
    &.login .app {
        width: 100%;
        max-width: 400px;
        margin: 2rem;
        display: block;
        min-height: auto;
    }
}

/* ========================================
   HEADER STYLES
   ======================================== */

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

header h1 {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--header-color);
    letter-spacing: -0.025em;
}

nav {
    display: flex;
    gap: 0.5rem;
}

nav button {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius);
    background-color: transparent;
    color: var(--text-secondary);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

nav button:hover {
    background-color: var(--primary-color);
    color: white;
    transform: translateY(-1px);
}

nav button:active {
    transform: translateY(0);
}

/* ========================================
   MAIN CONTENT
   ======================================== */

main {
    padding: 2rem;
}

/* ========================================
   HOME CONTENT
   ======================================== */

.recipe-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.home-page h2 {
    font-size: clamp(1.5rem, 4vw, 2rem);
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
}

.reload-button {
    padding: 0.5rem 1rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.reload-button:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.reload-button:active {
    transform: translateY(0);
}

/* ========================================
   SEARCH INPUT AND FILTER CONTROLS
   ======================================== */

.search-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 1.5rem;
}

#recipe-search {
    flex: 1;
    min-width: 200px;
    max-width: 400px;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease;
}

#recipe-search:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgb(37 99 235 / 0.1);
}

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

.filter-button {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: 9999px;
    background-color: var(--background);
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.filter-button:hover {
    background-color: var(--surface);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.filter-button.active {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    font-weight: 600;
}

.filter-button.active:hover {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
}

.recipe-count {
    font-size: 1.125rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-weight: 500;
}

/* ========================================
   RECIPE LIST STYLES
   ======================================== */

.recipe-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.5rem;
}

.recipe-card {
    background-color: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 0;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    & a {
        display: block;
        text-decoration: none;
        color: inherit;
    }

    & a:link,
    & a:visited {
        color: inherit;
        text-decoration: none;
    }

    & a:hover,
    & a:focus {
        color: inherit;
        text-decoration: none;
        outline: none;
    }

    &:focus-visible {
        outline: 2px solid var(--primary-color);
        outline-offset: 2px;
        transform: translateY(-2px);
    }

    &::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        height: 3px;
        background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
        transform: scaleX(0);
        transition: transform 0.3s ease;
    }

    &:hover {
        transform: translateY(-2px);
        box-shadow: var(--shadow-lg);
        border-color: var(--border);
    }

    &:hover::before {
        transform: scaleX(1);
    }

    & .recipe-content {
        flex: 1;
        padding: 1.5rem;
    }

    & .recipe-actions {
        display: flex;
        gap: 0;
        margin-top: auto;
        border-top: 1px solid var(--border-light);
    }

    & .meal-plan-button {
        flex: 1;
        padding: 0.75rem 1rem;
        border: 1px solid var(--border-light);
        border-top: none;
        background-color: var(--surface);
        color: var(--text-secondary);
        font-size: 0.875rem;
        font-weight: 500;
        cursor: pointer;
        transition: all 0.2s ease;

        &:first-child {
            border-right: none;
            border-bottom-left-radius: var(--radius-lg);
        }

        &:last-child {
            border-bottom-right-radius: var(--radius-lg);
        }

        &:hover {
            background-color: rgb(from var(--primary-color) r g b / 25%);
            color: white;
        }

        &.active {
            background-color: var(--primary-color);
            color: white;
            font-weight: 600;
        }
        &.active:hover {
            background-color: rgb(from var(--primary-color) r g b / 75%);
        }

        &:active {
            transform: translateY(1px);
        }
    }

    & .recipe-title {
        font-size: clamp(1.125rem, 2.5vw, 1.25rem);
        font-weight: 600;
        margin-bottom: 1rem;
        color: var(--text-primary);
        line-height: 1.4;
    }

    & .recipe-meta {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
        margin-bottom: 1rem;
    }

    & .recipe-meta-item {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        font-size: 0.875rem;
        color: var(--text-secondary);
    }

    & .recipe-meta-item::before {
        content: attr(data-icon);
        font-size: 1rem;
        color: var(--accent-color);
    }

    & .recipe-details {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }

    & .recipe-detail {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        font-size: 0.875rem;
    }

    & .recipe-detail-label {
        font-weight: 500;
        color: var(--text-secondary);
        min-width: 80px;
    }

    & .recipe-detail-value {
        color: var(--text-primary);
        padding: 0.25rem 0.5rem;
        background-color: var(--background);
        border-radius: calc(var(--radius) * 0.5);
        border: 1px solid var(--border);
        font-size: 0.8125rem;
    }

    & .recipe-tags {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
        margin-top: 1rem;
    }

    & .recipe-tag {
        padding: 0.25rem 0.75rem;
        background-color: var(--primary-color);
        color: white;
        border-radius: 9999px;
        font-size: 0.75rem;
        font-weight: 500;
        text-transform: uppercase;
        letter-spacing: 0.025em;
    }

    & .recipe-tag--characteristic {
        background-color: var(--characteristic-color);
    }

    & .recipe-tag--cuisine {
        background-color: var(--cuisine-color);
    }

    & .recipe-tag--protein {
        background-color: var(--protein-color);
    }
}

/* ========================================
   LOGIN PAGE STYLES
   ======================================== */

.login-container {
    background: var(--background);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    backdrop-filter: blur(10px);
    border: 1px solid rgb(255 255 255 / 0.1);

    & .login-header {
        background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
        color: white;
        padding: 2rem;
        text-align: center;
        position: relative;
        overflow: hidden;
    }

    & .login-header::before {
        content: '';
        position: absolute;
        top: -50%;
        left: -50%;
        width: 200%;
        height: 200%;
        background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
        animation: shimmer 3s ease-in-out;
    }

    & .login-header h1 {
        font-size: 2rem;
        font-weight: 700;
        margin: 0;
        position: relative;
        z-index: 1;
        letter-spacing: -0.025em;
    }

    & .login-header .subtitle {
        font-size: 0.875rem;
        opacity: 0.9;
        margin-top: 0.5rem;
        position: relative;
        z-index: 1;
    }

    & .login-form {
        padding: 2rem;
    }

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

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

    & .form-input {
        width: 100%;
        padding: 0.875rem 1rem;
        border: 2px solid var(--border);
        border-radius: var(--radius);
        font-size: 1rem;
        transition: all 0.2s ease;
        background: var(--surface);
        position: relative;
    }

    & .form-input:focus {
        outline: none;
        border-color: var(--primary-color);
        box-shadow: 0 0 0 3px rgb(37 99 235 / 0.1);
        background: var(--background);
    }

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

    & .input-icon {
        position: relative;
    }

    & .input-icon::before {
        content: '🔑';
        position: absolute;
        left: 0.875rem;
        top: 50%;
        transform: translateY(-50%);
        z-index: 1;
        pointer-events: none;
    }

    & .input-icon .form-input {
        padding-left: 2.5rem;
    }

    & .submit-button {
        width: 100%;
        padding: 0.875rem 1.5rem;
        background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
        border: none;
        border-radius: var(--radius);
        color: white;
        font-size: 1rem;
        font-weight: 600;
        cursor: pointer;
        transition: all 0.3s ease;
        position: relative;
        overflow: hidden;
        text-transform: uppercase;
        letter-spacing: 0.025em;
    }

    & .submit-button::before {
        content: '';
        position: absolute;
        top: 0;
        left: -100%;
        width: 100%;
        height: 100%;
        background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
        transition: left 0.6s ease;
    }

    & .submit-button:hover {
        transform: translateY(-2px);
        box-shadow: var(--shadow-lg);
        background: linear-gradient(135deg, var(--primary-hover) 0%, var(--primary-color) 100%);
    }

    & .submit-button:hover::before {
        left: 100%;
    }

    & .submit-button:active {
        transform: translateY(0);
    }

    & .submit-button:disabled {
        opacity: 0.6;
        cursor: not-allowed;
        transform: none;
    }

    & .login-footer {
        padding: 1.5rem 2rem;
        background: var(--surface);
        border-top: 1px solid var(--border-light);
        text-align: center;
    }

    & .help-text {
        font-size: 0.875rem;
        color: var(--text-muted);
        margin-bottom: 1rem;
    }

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

    & .help-link:hover {
        color: var(--primary-hover);
        text-decoration: underline;
    }

    & .security-notice {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        justify-content: center;
        font-size: 0.75rem;
        color: var(--text-muted);
        margin-top: 1rem;
    }

    & .security-notice::before {
        content: '🔒';
    }
}

/* ========================================
   LOADING PAGE STYLES
   ======================================== */

.loading-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    text-align: center;
}

.loading-page h2 {
    font-size: clamp(1.5rem, 4vw, 2rem);
    color: var(--text-secondary);
    margin: 0 0 2rem 0;
    text-align: center;
}

.loading-spinner {
    width: 3rem;
    height: 3rem;
    border: 3px solid var(--border);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    align-self: center;
    flex-shrink: 0;
}

/* ========================================
   PAGE LAYOUT STYLES
   ======================================== */

.planning-page,
.detail-page {
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

.not-found-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    text-align: center;
    color: var(--text-secondary);
}

/* ========================================
   ANIMATIONS
   ======================================== */

@keyframes shimmer {
    0%,
    25% {
        transform: translateX(-100%) translateY(-100%) rotate(0deg);
    }
    100% {
        transform: translateX(0%) translateY(0%) rotate(180deg);
    }
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}


/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

@media (max-width: 768px) {
    header {
        padding: 1rem;
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    nav {
        width: 100%;
        justify-content: center;
    }

    main {
        padding: 1rem;
    }

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

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

    /* Login page mobile */
    .body.login .app {
        margin: 1rem;
    }

    .login-header {
        padding: 1.5rem;
    }

    .login-header h1 {
        font-size: 1.5rem;
    }

    .login-form {
        padding: 1.5rem;
    }

    .login-footer {
        padding: 1rem 1.5rem;
    }
}

@media (max-width: 480px) {
    .recipe-list {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

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

/* ========================================
   DARK MODE SUPPORT
   ======================================== */

@media (prefers-color-scheme: dark) {
    :root {
        --text-primary: #f1f5f9;
        --text-secondary: #cbd5e1;
        --text-muted: #94a3b8;
        --background: #1e293b;
        --surface: #334155;
        --border: #475569;
        --border-light: #374151;
        --header-color: #f1f5f9;
    }

    .body.login {
        background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    }

    #recipe-search {
        background-color: var(--surface);
        color: var(--text-primary);
    }

    #recipe-search::placeholder {
        color: var(--text-muted);
    }
}

/* ========================================
   MODERN CSS FEATURES
   ======================================== */

@supports (backdrop-filter: blur(10px)) {
    header {
        backdrop-filter: blur(10px);
    }

    .login-container {
        backdrop-filter: blur(10px);
    }
}

/* Container Queries (when supported) */
@supports (container-type: inline-size) {
    .recipe-list {
        container-type: inline-size;
    }
}

@container (max-width: 400px) {
    .recipe-meta {
        grid-template-columns: 1fr;
    }
    
    .recipe-card {
        padding: 1rem;
    }
}

@container (min-width: 600px) {
    .recipe-meta {
        grid-template-columns: 1fr 1fr 1fr;
    }
}

/* Modern color mixing support */
@supports (color-mix: in oklch, white 0%, black 100%)) {
    :root {
        --primary-hover: color-mix(in oklch, var(--primary-color) 90%, black);
        --surface-hover: color-mix(in oklch, var(--surface) 95%, white);
    }
}
