/* ================== THEME VARIABLES (Light default) ================== */
/*Primary = Indigo 600 (#4f46e5)  | Accent = Emerald (#10b981)  | Install CTA = Tangerine (#f97316)*/
/*Cool, modern light palette with clear header contrast and tinted cards.*/
:root {
    --bg: #f6f8fb;              /* cool canvas */
    --fg: #0f172a;              /* slate-900 */
    --muted: #64748b;           /* slate-500 */
    --border: #e5e7eb;          /* neutral border */
    --card-bg: #f3f6fb;         /* tinted card surface (indigo-50/azure mix) */
    --shadow: rgba(2, 6, 23, .08);

    --primary: #4f46e5;         /* Indigo 600 */
    --primary-hover: #4338ca;   /* Indigo 700 */
    --primary-dark: var(--primary-hover);
    --accent: #10b981;          /* Emerald 500 */
    --text: var(--fg);

    --topbar-bg: #eef2ff;       /* indigo-50 header for stronger separation */
    --input-bg: #ffffff;        /* crisp inputs on cool canvas */
    --input-text: var(--fg);

    --bot: #f1f5f9;             /* chat bot bubbles (slate-50) */
    --bot-text: #1f2937;
    --user: #4f46e5;            /* chat send/CTA aligned with primary */
    --user-text: #ffffff;

    --link: #2563eb;            /* accessible blue link */
    --install: #f97316;         /* tangerine CTA */

    /* Subtle cool gradient (no apricot) */
    --bg-gradient: linear-gradient(180deg, #f7f9fc 0%, #eef2f7 100%);
    --elev-card-shadow: 0 10px 24px rgba(2, 6, 23, .06);

    --radius-lg: 16px;
    --radius-xl: 18px;
    --max-app-width: 1200px;
    --max-chat-width: 820px;
    --t-bg: background .6s ease, color .4s ease;
    --t-card: background .3s, box-shadow .3s, border-color .2s, transform .2s;
}

/* Auto dark when no data-theme override */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        --bg: #0f1720; /* slate-900 */
        --fg: #e5e7eb; /* gray-200 */
        --muted: #9ca3af; /* gray-400 */
        --border: #1f2937; /* gray-800 */
        --card-bg: #111827; /* gray-900 */
        --shadow: rgba(0, 0, 0, .35);

        --topbar-bg: #0b1220; /* inky topbar */
        --input-bg: #0a1018;
        --input-text: var(--fg);

        --bot: #0f1720;
        --bot-text: #e5e7eb;
        --link: #93c5fd; /* blue-300 */
        --bg-gradient: linear-gradient(180deg, #0f1720 0%, #111827 100%);
        --elev-card-shadow: 0 8px 24px rgba(2, 8, 23, .5);
    }
}

/* Manual overrides */
:root[data-theme="light"] {
    --bg: #f6f8fb;
    --fg: #0f172a;
    --muted: #64748b;
    --border: #e5e7eb;
    --card-bg: #f3f6fb;
    --shadow: rgba(2, 6, 23, .08);

    --topbar-bg: #eef2ff;       /* clearer header contrast */
    --input-bg: #ffffff;
    --input-text: var(--fg);

    --bot: #f1f5f9;
    --bot-text: #1f2937;
    --user: #4f46e5;
    --user-text: #ffffff;

    --link: #2563eb;
    --bg-gradient: linear-gradient(180deg, #f7f9fc 0%, #eef2f7 100%);
    --elev-card-shadow: 0 10px 24px rgba(2, 6, 23, .06);
}

:root[data-theme="dark"] {
    --bg: #0f1720;
    --fg: #e5e7eb;
    --muted: #9ca3af;
    --border: #1f2937;
    --card-bg: #111827;
    --shadow: rgba(0, 0, 0, .35);

    --topbar-bg: #0b1220;
    --input-bg: #0a1018;
    --input-text: var(--fg);

    --bot: #0f1720;
    --bot-text: #e5e7eb;
    --link: #93c5fd;

    --bg-gradient: linear-gradient(180deg, #0f1720 0%, #111827 100%);
    --elev-card-shadow: 0 8px 24px rgba(2, 8, 23, .5);
}

/* ================== BASE ================== */
* { box-sizing: border-box }
html, body { height: 100% }

body {
    margin: 0;
    font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
    color: var(--text);
    background: var(--bg-gradient, var(--bg));
    transition: var(--t-bg);
    -webkit-text-size-adjust: 100%;
}

a { color: var(--link) }

.app { display: flex; flex-direction: column; min-height: 100vh }

/* ================== TOPBAR (shared) ================== */
.topbar {
    background: color-mix(in srgb, var(--topbar-bg) 92%, #ffffff 8%);
    backdrop-filter: saturate(120%) blur(10px);
    border-bottom-color: color-mix(in srgb, var(--border) 75%, #fff 25%);
    border-bottom: 1px solid var(--border);
    padding: 16px 20px;
    padding-top: calc(16px + env(safe-area-inset-top));
    padding-left: calc(20px + env(safe-area-inset-left));
    padding-right: calc(20px + env(safe-area-inset-right));
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    box-shadow: 0 2px 8px var(--shadow);
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 100;
    max-width: 100%;
    margin: 0 auto;
}

.brand { display: flex; gap: 12px; align-items: center }
.icon { width: 48px; height: 48px; border-radius: 12px; object-fit: cover }
.brand h1 { font-size: 20px; font-weight: 700; color: var(--fg) }
.subtitle { font-size: 12px; color: var(--muted); margin-top: 2px }

.theme-toggle, .install, .nav-btn {
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s
}
.theme-toggle {
    background: none;
    border: 1px solid var(--border);
    padding: 8px 12px;
    color: var(--text)
}
.theme-toggle:hover { background: rgba(127, 127, 127, .08) }

.install {
    background: var(--install);
    color: #fff;
    border: none;
    padding: 8px 16px
}
.install:hover { filter: brightness(.95) }

.nav-btn {
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 8px 16px
}
.nav-btn:hover { background: var(--primary-dark) }

/* Content wrapper (below fixed topbar) */
.content {
    flex: 1;
    padding: 40px 20px;
    max-width: var(--max-app-width);
    width: 100%;
    margin: 0 auto;
    margin-top: calc(88px + env(safe-area-inset-top));
}

/* ================== CARDS (shared) ================== */
.cards {
    display: grid;
    grid-template-columns:repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    margin-bottom: 64px
}
.card {
    background: var(--card-bg);                                /* tinted, not pure white */
    border-color: color-mix(in srgb, var(--border) 85%, #fff 15%);
    box-shadow: var(--elev-card-shadow);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 32px 24px;
    text-decoration: none;
    color: var(--fg);
    transition: var(--t-card);
    display: flex;
    flex-direction: column;
    gap: 12px;
    cursor: pointer;
}
.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px var(--shadow);
    border-color: var(--primary)
}
.card-icon { font-size: 48px; margin-bottom: 8px }
.card h3 { font-size: 24px; font-weight: 700; color: var(--fg) }
.card p { font-size: 14px; color: var(--muted); line-height: 1.6; flex: 1 }
.card-action { color: var(--primary); font-weight: 600; font-size: 14px; margin-top: 8px }

/* ================== FOOTER (shared) ================== */
.footer {
    background: var(--card-bg);
    border-top: 1px solid var(--border);
    padding: 20px;
    text-align: center
}
.footer p { font-size: 12px; color: var(--muted) }

/* ================== RESPONSIVE (shared) ================== */
@media (max-width: 768px) {
    .topbar {
        padding: 12px 16px;
        padding-top: calc(12px + env(safe-area-inset-top));
        padding-left: calc(16px + env(safe-area-inset-left));
        padding-right: calc(16px + env(safe-area-inset-right))
    }
    .brand h1 { font-size: 18px }
    .icon { width: 40px; height: 40px }
    .content {
        padding: 24px 16px;
        margin-top: calc(65px + env(safe-area-inset-top))
    }
    .cards { grid-template-columns:1fr; gap: 16px }
}

button, select { cursor: pointer }
select:hover { background: var(--border) !important }
select.just-cleared { outline: 2px solid var(--primary) }

/* Sleek modern dark theme override (balanced contrast, culinary warmth) */
:root[data-theme="dark"] {
    --bg: #0f1720; /* Deep slate background */
    --fg: #e5e7eb; /* Soft gray text */
    --muted: #9ca3af; /* Muted gray */
    --border: #1f2937; /* Border tone */
    --card-bg: #111827; /* Slightly lighter card panels */
    --shadow: rgba(0, 0, 0, .35);
    --topbar-bg: #0b1220; /* Inky header bar */
    --input-bg: #0a1018;
    --input-text: var(--fg);
    --bot: #0f1720;
    --bot-text: #e5e7eb;
    --link: #93c5fd; /* Soft blue for links */
    --primary: #4f46e5; /* Indigo 600 for actions */
    --primary-hover: #4338ca; /* Indigo 700 hover */
    --accent: #10b981; /* Fresh emerald accent */
    --install: #f97316; /* Vibrant orange CTA */
    --bg-gradient: linear-gradient(180deg, #0f1720 0%, #111827 100%);
    --elev-card-shadow: 0 8px 24px rgba(2, 8, 23, .5);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        --bg: #0f1720;
        --fg: #e5e7eb;
        --muted: #9ca3af;
        --border: #1f2937;
        --card-bg: #111827;
        --shadow: rgba(0, 0, 0, .35);
        --topbar-bg: #0b1220;
        --input-bg: #0a1018;
        --input-text: var(--fg);
        --bot: #0f1720;
        --bot-text: #e5e7eb;
        --link: #93c5fd;
        --primary: #4f46e5;
        --primary-hover: #4338ca;
        --accent: #10b981;
        --install: #f97316;
        --bg-gradient: linear-gradient(180deg, #0f1720 0%, #111827 100%);
        --elev-card-shadow: 0 8px 24px rgba(2, 8, 23, .5);
    }
}


/* Social icons in footer */
.footer .social-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.footer .social-links a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}
.footer .social-links a:hover,
.footer .social-links a:focus {
  text-decoration: underline;
}
.social-icon {
  width: 20px;
  height: 20px;
  display: inline-block;
}
/* Screen-reader-only utility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
