/* ================================
   Base
================================ */

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    min-height: 100%;
}

body {
    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        Helvetica,
        Arial,
        sans-serif;

    background: #f6f7f8;
    color: #222;

    -webkit-font-smoothing: antialiased;
}


/* ================================
   Page
================================ */

.page {
    width: min(100%, 820px);
    min-height: 100vh;
    margin: 0 auto;
    display: block;
    padding: 24px 16px 60px;
}


/* ================================
   Login Card
================================ */

.login-card {
    width: 100%;
    max-width: 420px;

    background: #ffffff;

    border: 1px solid #e5e7eb;
    border-radius: 12px;

    padding: 32px;

    box-shadow:
        0 2px 6px rgba(0, 0, 0, 0.03),
        0 10px 30px rgba(0, 0, 0, 0.04);
}


/* ================================
   Loading
================================ */

.loading {
    min-height: 300px;

    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;

    color: #666;
    font-size: 14px;
}


/* ================================
   Spinner
================================ */

.spinner {
    width: 18px;
    height: 18px;

    border: 2px solid #e5e7eb;
    border-top-color: #002c07;

    border-radius: 50%;

    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}


/* ================================
   Clerk Container
================================ */

#clerk-sign-in {
    width: 100%;
}

#clerk-sign-in > div {
    width: 100%;
}


/* ================================
   Footer
================================ */

.footer {
    margin-top: 24px;

    color: #8a8f98;

    font-size: 12px;
    font-weight: 400;

    text-align: center;

    user-select: none;
}
/* ================================
   Mobile
================================ */

@media (max-width: 480px) {

    .page {
        padding: 20px 16px;
    }

    .login-card {
        padding: 24px 20px;

        border-radius: 10px;
    }

    .footer {
        margin-top: 20px;
    }
}

/* ================================
   Dashboard
================================ */

.dashboard-page {
    min-height: 100vh;

    width: 100%;
    max-width: 1100px;

    margin: 0 auto;

    padding: 24px 24px 40px;
}


/* ================================
   Dashboard Header
================================ */

.dashboard-header {
    width: 100%;

    display: flex;
    align-items: center;
    justify-content: space-between;

    margin-bottom: 42px;
}

.dashboard-brand {
    display: inline-flex;
    align-items: center;

    text-decoration: none;
}

.dashboard-brand img {
    width: 190px;
    height: auto;

    display: block;
}

.dashboard-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}


/* ================================
   Icon Button
================================ */

.icon-button {
    width: 42px;
    height: 42px;

    display: flex;
    align-items: center;
    justify-content: center;

    background: #ffffff;

    border: 1px solid #e5e7eb;
    border-radius: 10px;

    color: #333;

    text-decoration: none;

    font-size: 20px;

    transition:
        background 0.15s ease,
        border-color 0.15s ease,
        transform 0.15s ease;
}

.icon-button:hover {
    background: #f8f9fa;
    border-color: #d7dbe0;

    transform: translateY(-1px);
}


/* ================================
   Clerk User Button
================================ */

.user-button {
    display: flex;
    align-items: center;
    justify-content: center;
}


/* ================================
   Dashboard Heading
================================ */

.dashboard-heading {
    margin-bottom: 28px;
}

.dashboard-heading h1 {
    margin: 0;

    color: #222;

    font-size: 28px;
    font-weight: 650;
    letter-spacing: -0.4px;
}

.dashboard-heading p {
    margin: 6px 0 0;

    color: #777;

    font-size: 14px;
}


/* ================================
   Features Grid
================================ */

.features-grid {
    display: grid;

    grid-template-columns:
        repeat(2, minmax(0, 1fr));

    gap: 18px;

    margin-bottom: 28px;
}


/* ================================
   Feature Card
================================ */

.feature-card {
    min-height: 170px;

    display: flex;
    flex-direction: column;
    justify-content: space-between;

    padding: 24px;

    background: #ffffff;

    border: 1px solid #e5e7eb;
    border-radius: 12px;

    box-shadow:
        0 2px 6px rgba(0, 0, 0, 0.03),
        0 10px 30px rgba(0, 0, 0, 0.04);

    color: #222;

    text-decoration: none;

    transition:
        transform 0.15s ease,
        box-shadow 0.15s ease,
        border-color 0.15s ease;
}

.feature-card:hover {
    transform: translateY(-2px);

    border-color: #d8dce1;

    box-shadow:
        0 4px 10px rgba(0, 0, 0, 0.04),
        0 14px 34px rgba(0, 0, 0, 0.06);
}

.feature-icon {
    width: 42px;
    height: 42px;

    display: flex;
    align-items: center;
    justify-content: center;

    background: #f1f3f4;

    border-radius: 10px;

    font-size: 20px;
}

.feature-card-content {
    margin-top: 20px;
}

.feature-card h2 {
    margin: 0;

    font-size: 17px;
    font-weight: 600;
}

.feature-card p {
    margin: 6px 0 0;

    color: #777;

    font-size: 13px;
    line-height: 1.45;
}


/* ================================
   Notifications
================================ */

.notifications-card {
    width: 100%;

    background: #ffffff;

    border: 1px solid #e5e7eb;
    border-radius: 12px;

    padding: 24px;

    box-shadow:
        0 2px 6px rgba(0, 0, 0, 0.03),
        0 10px 30px rgba(0, 0, 0, 0.04);
}

.notifications-header {
    padding-bottom: 18px;

    border-bottom: 1px solid #eef0f2;
}

.notifications-header h2 {
    margin: 0;

    font-size: 18px;
    font-weight: 600;
}

.notifications-header p {
    margin: 5px 0 0;

    color: #888;

    font-size: 13px;
}

.notifications-list {
    display: flex;
    flex-direction: column;
}


/* ================================
   Notification
================================ */

.notification-item {
    display: flex;
    align-items: flex-start;

    gap: 14px;

    padding: 17px 0;

    border-bottom: 1px solid #f0f1f2;
}

.notification-item:last-child {
    border-bottom: 0;
}

.notification-icon {
    width: 36px;
    height: 36px;

    flex: 0 0 36px;

    display: flex;
    align-items: center;
    justify-content: center;

    background: #f1f3f4;

    border-radius: 9px;

    font-size: 14px;
}

.notification-content {
    min-width: 0;
}

.notification-content strong {
    display: block;

    font-size: 14px;
    font-weight: 600;
}

.notification-content p {
    margin: 4px 0 0;

    color: #777;

    font-size: 13px;
    line-height: 1.45;
}


/* ================================
   Empty States
================================ */

.notification-empty {
    display: flex;
    align-items: center;

    gap: 14px;

    padding: 22px 0;

    color: #555;
}

.notification-empty-icon {
    width: 36px;
    height: 36px;

    display: flex;
    align-items: center;
    justify-content: center;

    background: #f1f3f4;

    border-radius: 50%;

    color: #555;

    font-size: 14px;
}

.notification-empty strong {
    display: block;

    font-size: 14px;
    font-weight: 600;
}

.notification-empty p {
    margin: 4px 0 0;

    color: #888;

    font-size: 13px;
}

.empty-state {
    grid-column: 1 / -1;

    padding: 50px 20px;

    background: #ffffff;

    border: 1px solid #e5e7eb;
    border-radius: 12px;

    text-align: center;
}

.empty-state h2 {
    margin: 0;

    font-size: 18px;
}

.empty-state p {
    margin: 8px 0 18px;

    color: #777;

    font-size: 14px;
}

.empty-state a {
    color: #002c07;

    font-size: 14px;
    font-weight: 600;
}

.access-denied {
    padding: 32px 20px;
}

.access-denied h2 {
    margin: 0;

    color: #333;
    font-size: 20px;
    font-weight: 600;
}


/* ================================
   Dashboard Loading
================================ */

.dashboard-loading {
    grid-column: 1 / -1;

    min-height: 150px;

    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;

    color: #777;

    font-size: 14px;
}


/* ================================
   Dashboard Footer
================================ */

.dashboard-footer {
    margin-top: 28px;

    color: #8a8f98;

    font-size: 12px;

    text-align: center;
}


/* ================================
   Dashboard Mobile
================================ */

@media (max-width: 700px) {

    .dashboard-page {
        padding:
            18px
            16px
            30px;
    }

    .dashboard-header {
        margin-bottom: 32px;
    }

    .dashboard-brand img {
        width: 155px;
    }

    .dashboard-heading h1 {
        font-size: 24px;
    }

    .features-grid {
        grid-template-columns: 1fr;
    }

    .feature-card {
        min-height: 145px;
    }

    .notifications-card {
        padding: 20px;
    }
}

/* ================================
   Primary Button
================================ */

.primary-button {
    appearance: none;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    min-height: 42px;
    padding: 0 18px;

    background: #002c07;
    color: #ffffff;

    border: 1px solid #002c07;
    border-radius: 8px;

    font-family: inherit;
    font-size: 14px;
    font-weight: 600;

    cursor: pointer;

    transition:
        background 0.15s ease,
        border-color 0.15s ease,
        transform 0.15s ease,
        box-shadow 0.15s ease;
}

.primary-button:hover {
    background: #003d0a;
    border-color: #003d0a;

    transform: translateY(-1px);

    box-shadow:
        0 3px 8px rgba(0, 44, 7, 0.15);
}

.primary-button:active {
    transform: translateY(0);

    box-shadow: none;
}

.primary-button:focus-visible {
    outline: 2px solid #002c07;
    outline-offset: 2px;
}

/* Shared feature shell and preference controls */
.feature-header {
    min-height: 76px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px max(12px, calc((100% - 1100px) / 2));
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
}

.feature-home,
.feature-shortcuts a {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 52px;
    padding: 0 16px;
    color: #222;
    text-decoration: none;
    font-size: 15px;
    font-weight: 600;
    border-radius: 8px;
}

.feature-shortcuts a:hover { background: #f1f3f4; }
.feature-shortcuts { display: flex; width: 100%; max-width: 900px; overflow-x: auto; justify-content: center; gap: 8px; scrollbar-width: none; }
.feature-shortcuts::-webkit-scrollbar { display: none; }
.feature-shortcuts .material-icons { font-size: 24px; }

.preferences-panel {
    width: min(100% - 32px, 700px);
    margin: 24px auto;
    padding: 24px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,.04);
}
.preferences-panel h2 { margin: 0; font-size: 20px; }
.preferences-panel p { margin: 6px 0 20px; color: #777; font-size: 13px; }
.preferences-panel label { display: block; margin: 14px 0; color: #444; font-size: 13px; font-weight: 600; }
.preferences-panel input, .preferences-panel select { display: block; width: 100%; margin-top: 6px; padding: 11px 12px; border: 1px solid #d7dbe0; border-radius: 7px; font: inherit; }
.preferences-panel fieldset { margin: 20px 0; padding: 14px; border: 1px solid #eef0f2; border-radius: 8px; }
.preferences-panel legend { padding: 0 5px; font-size: 13px; font-weight: 600; }
.preferences-panel legend small { display: block; margin-top: 4px; color: #888; font-weight: 400; }
.shortcut-option { display: flex; align-items: center; gap: 9px; margin: 11px 0; padding: 10px 9px; font-size: 14px; border: 1px solid #e7ebf2; border-radius: 8px; cursor: grab; background: #fff; }
.shortcut-option input { width: auto; margin: 0; }
.shortcut-option:active { cursor: grabbing; }
.shortcut-drag-handle { color: #98a3b5; font-size: 20px !important; }
.shortcut-name { flex: 1; }
.shortcut-order-buttons { display: inline-flex; gap: 4px; }
.shortcut-order-buttons button { width: 32px; height: 32px; padding: 0; border: 0; border-radius: 6px; color: #2457c5; background: #eef3ff; cursor: pointer; }
.shortcut-order-buttons .material-icons { font-size: 17px; }
.preference-status { margin-left: 12px; color: #276749; font-size: 13px; }
.is-dragging { opacity: .45; }

@media (max-width: 600px) {
    .feature-header { justify-content: flex-start; }
    .feature-shortcuts { justify-content: flex-start; }
    .preferences-panel { padding: 18px; }
}

/* ================================
   Product-wide visual language
================================ */

:root {
    --app-bg: #f5f7fb;
    --app-surface: #ffffff;
    --app-surface-muted: #eef3ff;
    --app-ink: #1b2433;
    --app-muted: #687386;
    --app-border: #dce3ef;
    --app-primary: #2457c5;
    --app-primary-hover: #19439d;
    --app-danger: #c84f4f;
    --app-radius: 10px;
    --app-shadow: 0 8px 24px rgba(23, 57, 40, .07);
}

html, body {
    background: var(--app-bg) !important;
    color: var(--app-ink) !important;
    font-family: "DM Sans", "Avenir Next", "Segoe UI", sans-serif !important;
}

body { line-height: 1.45; }
h1, h2, h3, h4, p { color: inherit; }
a { color: var(--app-primary); }
button, input, select, textarea { font-family: inherit !important; }

/* Shared surfaces kept here so every page uses the same light theme. */
header, .card, .panel, .box, .login-card, .notifications, .notifications-card,
.tile, .feature-card, .form-card, .content-card {
    background: var(--app-surface) !important;
    color: var(--app-ink) !important;
    border-color: var(--app-border) !important;
    box-shadow: var(--app-shadow);
}

header { border-bottom-color: var(--app-border) !important; }
.greeting p, .dashboard-heading p, .desc, .muted, .subtitle,
.notifications-header p, .notification-content p { color: var(--app-muted) !important; }
.icon-btn, .icon-button { color: var(--app-ink) !important; background: transparent !important; }
.icon-btn:hover, .icon-button:hover { background: var(--app-surface-muted) !important; border-color: var(--app-border) !important; }
.tile:hover, .feature-card:hover { border-color: var(--app-primary) !important; background: var(--app-surface-muted) !important; }
.tile .material-icons, .feature-icon, .notification-icon { color: var(--app-primary) !important; }
.admin-pill { color: var(--app-primary) !important; border-color: var(--app-primary) !important; }
.primary-button, .btn-primary { background: var(--app-primary) !important; border-color: var(--app-primary) !important; }
.primary-button:hover, .btn-primary:hover { background: var(--app-primary-hover) !important; }

/* Legacy feature pages */
#page-switcher { background: var(--app-surface) !important; border-bottom: 1px solid var(--app-border); box-shadow: 0 2px 10px rgba(23,57,40,.04); }
.menu-item2 { color: var(--app-muted) !important; font-size: .88rem; font-weight: 600; }
.menu-item2:hover, .menu-item2.active { color: var(--app-primary) !important; }
.menu-item2.active { border-bottom-color: var(--app-primary) !important; }
#userInfo { color: var(--app-muted) !important; margin: 22px auto 8px !important; width: min(100% - 32px, 900px); text-align: left !important; }
#userInfo span { color: var(--app-ink); }
.button-container { width: min(100% - 32px, 900px); margin: 18px auto !important; display: flex; align-items: center; gap: 10px; }
#addItemBtn, .add-meal-btn { flex: 1 1 auto; width: auto !important; background: var(--app-primary) !important; border-radius: var(--app-radius) !important; font-size: .95rem !important; font-weight: 700; box-shadow: var(--app-shadow); }
#addItemBtn:hover, .add-meal-btn:hover { background: var(--app-primary-hover) !important; }
#actionsBtn { background: var(--app-surface) !important; color: var(--app-primary) !important; border: 1px solid var(--app-border) !important; border-radius: var(--app-radius) !important; }
body:has(#mealPlan) #addItemBtn { display: none !important; }
.mobile-only { display: none !important; }
ul { margin: 16px auto !important; width: min(100% - 32px, 900px); }
li, .list-item { background: var(--app-surface) !important; color: var(--app-ink) !important; border: 1px solid var(--app-border); border-radius: var(--app-radius) !important; box-shadow: var(--app-shadow) !important; }
li:hover { background: var(--app-surface-muted) !important; }
li.delete-warning { background: var(--app-danger) !important; color: #fff !important; border-color: var(--app-danger) !important; }
.modal-content, .popup-content, .daymodal-content { background: var(--app-surface) !important; color: var(--app-ink) !important; border: 1px solid var(--app-border); border-radius: var(--app-radius) !important; box-shadow: 0 18px 50px rgba(23,57,40,.18); }
.modal input, .modal select, .popup input, .popup select, textarea, #userNameInput,
.preferences-panel input, .preferences-panel select { background: var(--app-surface) !important; color: var(--app-ink) !important; border-color: var(--app-border) !important; border-radius: 7px !important; }
.modal button, .popup button, .quick-aisle-btn { background: var(--app-primary) !important; border-radius: 7px !important; }
.modal button:hover, .popup button:hover, .quick-aisle-btn:hover { background: var(--app-primary-hover) !important; }
#confirmDeleteBtn, #deleteAllItems { background: var(--app-danger) !important; color: #fff !important; }
.modal button.delete-btn, .list-item button.delete-btn { background: transparent !important; border: 0 !important; color: var(--app-danger) !important; box-shadow: none !important; }
.modal button.delete-btn:hover, .list-item button.delete-btn:hover { background: #fff0f0 !important; color: #a83535 !important; }
.modal button.delete-btn .material-icons, .list-item button.delete-btn .material-icons { color: inherit !important; }
.actions-menu { background: var(--app-surface) !important; border: 1px solid var(--app-border); box-shadow: var(--app-shadow); }
.menu-item { background: transparent !important; color: var(--app-ink); }
.menu-item:hover { background: var(--app-surface-muted) !important; }
.loader { border-color: var(--app-border) !important; border-top-color: var(--app-primary) !important; background: var(--app-surface) !important; }
.overlay { background: rgba(23, 36, 29, .46) !important; }

/* Standalone pages */
.wrap, .legal-wrap, .admin-wrap { color: var(--app-ink) !important; }
.wrap .card, .legal-card, .admin-card { background: var(--app-surface) !important; border-color: var(--app-border) !important; box-shadow: var(--app-shadow); }
.wrap .subtitle, .foot, .legal-meta, .admin-card .desc { color: var(--app-muted) !important; }
.glow { display: none !important; }
.admin-toggle { display: inline-flex; align-items: center; gap: 6px; color: var(--app-muted); font-size: 12px; white-space: nowrap; }
.admin-toggle input { width: auto; margin: 0; }
.tile-order { display: inline-flex; gap: 5px; margin-top: 8px; }
.tile-move { width: 30px; height: 30px; padding: 0; border: 1px solid #dce3ef; border-radius: 6px; background: #fff; color: #2457c5; cursor: pointer; }
.tile-move .material-icons { font-size: 16px !important; color: inherit !important; }
.tile-move:hover { background: #eef3ff; }

@media (max-width: 600px) {
    body { overflow-x: hidden; }
    header { padding: 12px 16px !important; }
    main, .dashboard-page { padding: 24px 12px 48px !important; }
    .greeting, .dashboard-heading { margin-bottom: 18px !important; }
    .greeting h1, .dashboard-heading h1 { font-size: 22px !important; }
    .tiles, .features-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 12px !important; }
    .tile, .feature-card { min-height: 128px !important; }
    .notifications, .notifications-card { padding: 18px !important; }
    .button-container { width: calc(100% - 24px); flex-wrap: nowrap; gap: 10px; }
    .button-container #userInfo { margin: 0 !important; width: auto; }
    #addItemBtn { flex: 1 1 auto; width: auto !important; min-height: 48px; margin: 0 !important; color: #fff !important; }
    #actionsBtn { flex: 0 0 48px; width: 48px; height: 48px; margin: 0 !important; padding: 0 !important; }
    .menu-item2 { padding: 9px 10px !important; }
}