/* Trip Itinerary Builder — all styles scoped under .ib so nothing leaks
   into /demos or the site. Vanilla, no framework. */

.ib {
    --bg: #f5f4f1;
    --panel: #ffffff;
    --ink: #1c1b18;
    --muted: #6b6a64;
    --line: #e6e3dc;
    --brand: #0d9488;
    --brand-ink: #0f766e;
    --accent: #4f46e5;
    --ok: #16a34a;
    --warn: #d97706;
    --danger: #dc2626;
    --radius: 12px;
    --shadow: 0 14px 40px -22px rgba(28, 27, 24, .45);
    --shadow-sm: 0 4px 14px -8px rgba(28, 27, 24, .4);

    --c-accommodation: #7c3aed;
    --c-dining: #ea580c;
    --c-attraction: #0d9488;
    --c-transport: #64748b;
    --c-experience: #4f46e5;

    color-scheme: light;
    min-height: calc(100vh - 44px);
    font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
    color: var(--ink);
    background:
        radial-gradient(900px 380px at 92% -8%, rgba(13, 148, 136, .10), transparent),
        radial-gradient(820px 360px at 2% 108%, rgba(79, 70, 229, .10), transparent),
        var(--bg);
}
.ib *, .ib *::before, .ib *::after { box-sizing: border-box; }
.ib [hidden] { display: none !important; }

@media (prefers-color-scheme: dark) {
    .ib {
        --bg: #14130f;
        --panel: #201e19;
        --ink: #f2efe8;
        --muted: #a5a299;
        --line: #34312a;
        --shadow: 0 14px 40px -20px rgba(0, 0, 0, .7);
        color-scheme: dark;
    }
}

/* ── Buttons ─────────────────────────────────────────────────────── */
.ib-btn {
    border: 0; cursor: pointer; border-radius: 10px;
    padding: .55rem .95rem; font: 600 .88rem inherit;
    background: var(--brand); color: #fff; white-space: nowrap;
    transition: transform .1s ease, background .15s, box-shadow .15s, border-color .15s;
}
.ib-btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.ib-btn:active { transform: translateY(0); }
.ib-btn.ghost { background: var(--panel); color: var(--ink); border: 1px solid var(--line); }
.ib-btn.ghost:hover { border-color: var(--brand); color: var(--brand-ink); }
.ib-btn.ghost.danger { color: var(--danger); }
.ib-btn.ghost.danger:hover { border-color: var(--danger); }
.ib-btn.xs { padding: .4rem .7rem; font-size: .8rem; background: rgba(13, 148, 136, .12); color: var(--brand-ink); }
.ib-btn.xs:hover { background: rgba(13, 148, 136, .2); }
.ib-btn.xs.ghost { background: var(--panel); color: var(--ink); border: 1px solid var(--line); }
.ib-btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }

/* ── Top bar ─────────────────────────────────────────────────────── */
.ib-topbar {
    display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
    padding: .85rem 1.4rem; background: var(--panel);
    border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 500;
}
.ib-brand { display: flex; align-items: center; gap: .7rem; min-width: 0; }
.ib-logo { font-size: 1.7rem; }
.ib-brand-txt { min-width: 0; }
.ib-title {
    font: 800 1.15rem inherit; border: 0; background: transparent; color: var(--ink);
    letter-spacing: -.02em; border-bottom: 1.5px dashed transparent; padding: 0 0 1px;
    width: 14rem; max-width: 42vw;
}
.ib-title:focus { outline: 0; border-bottom-color: var(--brand); }
.ib-sub { color: var(--muted); font-size: .82rem; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.ib-dest {
    border: 1px solid var(--line); background: var(--panel); color: var(--ink);
    border-radius: 8px; padding: .2rem .4rem; font: inherit; font-size: .82rem;
}
.ib-stats { display: flex; gap: 1.1rem; margin-left: auto; }
.ib-stat { text-align: center; }
.ib-stat b { display: block; font-size: 1.05rem; letter-spacing: -.02em; }
.ib-stat span { font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.ib-topbar-actions { display: flex; align-items: center; gap: .6rem; }
.ib-saved { font-size: .72rem; color: var(--ok); display: inline-flex; align-items: center; gap: .35rem; }
.ib-saved::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: var(--ok); }
.ib-menu { position: relative; }
.ib-menu-pop {
    position: absolute; right: 0; top: calc(100% + .4rem); z-index: 600;
    background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
    box-shadow: var(--shadow); padding: .3rem; min-width: 13rem;
}
.ib-menu-pop button {
    display: block; width: 100%; text-align: left; border: 0; background: transparent;
    color: var(--ink); font: 500 .85rem inherit; padding: .5rem .6rem; border-radius: 7px; cursor: pointer;
}
.ib-menu-pop button:hover { background: rgba(13, 148, 136, .1); }

/* ── Body layout ─────────────────────────────────────────────────── */
.ib-body {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr) 360px;
    gap: 1rem; padding: 1rem 1.4rem;
    align-items: start;
}
.ib-rail, .ib-side { position: sticky; top: 76px; display: flex; flex-direction: column; gap: 1rem; }

/* ── Cards / fields ──────────────────────────────────────────────── */
.ib-card {
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 1rem; box-shadow: var(--shadow-sm);
}
.ib-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .7rem; }
.ib-card-head h3 { margin: 0; font-size: .92rem; letter-spacing: -.01em; }
.ib-field { display: flex; flex-direction: column; gap: .3rem; font-size: .78rem; color: var(--muted); margin-bottom: .7rem; }
.ib-field:last-child { margin-bottom: 0; }
.ib-field span { font-weight: 600; }
.ib-field input, .ib-field select, .ib-field textarea {
    border: 1px solid var(--line); border-radius: 8px; padding: .5rem .55rem;
    font: inherit; font-size: .88rem; color: var(--ink); background: var(--panel);
}
.ib-field input:focus, .ib-field select:focus, .ib-field textarea:focus { outline: 2px solid rgba(13, 148, 136, .4); outline-offset: 1px; }
.ib-field-row { display: flex; gap: .6rem; }
.ib-field-row .ib-field { flex: 1; }
.ib-field-sm { max-width: 6rem; }
.ib-inline { display: flex; gap: .4rem; }
.ib-inline input { flex: 1; min-width: 0; }
.ib-chip {
    font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
    padding: .2rem .5rem; border-radius: 999px; background: rgba(13, 148, 136, .14); color: var(--brand-ink);
}
.ib-chip.warn { background: rgba(217, 119, 6, .16); color: var(--warn); }
.ib-chip.danger { background: rgba(220, 38, 38, .16); color: var(--danger); }

/* ── Tabs (left rail) ────────────────────────────────────────────── */
.ib-tabs { display: flex; gap: .25rem; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: .25rem; flex-wrap: wrap; }
.ib-tab { flex: 1; border: 0; background: transparent; color: var(--muted); font: 600 .78rem inherit; padding: .45rem .3rem; border-radius: 7px; cursor: pointer; }
.ib-tab.is-active { background: var(--brand); color: #fff; }
.ib-pane { display: flex; flex-direction: column; gap: 1rem; }

/* ── Budget bits ─────────────────────────────────────────────────── */
.ib-budget-bar { height: 10px; border-radius: 999px; background: var(--line); overflow: hidden; }
.ib-budget-bar i { display: block; height: 100%; width: 0; background: var(--brand); transition: width .3s ease, background .3s; }
.ib-budget-bar i.over { background: var(--danger); }
.ib-budget-nums { display: flex; justify-content: space-between; font-size: .78rem; color: var(--muted); margin: .45rem 0 .2rem; }
.ib-donut { width: 120px; height: 120px; display: block; margin: .4rem auto 0; }
.ib-donut-legend { display: flex; flex-direction: column; gap: .25rem; font-size: .76rem; margin-top: .4rem; }
.ib-donut-legend span { display: flex; align-items: center; gap: .45rem; }
.ib-donut-legend i { width: .7rem; height: .7rem; border-radius: 3px; flex: none; }
.ib-donut-legend b { margin-left: auto; color: var(--ink); }

.ib-budget-cats > div, .ib-budget-days > div { display: flex; align-items: center; gap: .55rem; font-size: .8rem; margin-bottom: .55rem; }
.ib-bar { flex: 1; height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; }
.ib-bar i { display: block; height: 100%; }

/* ── Templates list ─────────────────────────────────────────────── */
.ib-templates { display: flex; flex-direction: column; gap: .4rem; }
.ib-template { text-align: left; border: 1px solid var(--line); background: var(--panel); border-radius: 9px; padding: .55rem .65rem; cursor: pointer; font: inherit; color: var(--ink); }
.ib-template:hover { border-color: var(--brand); }
.ib-template b { display: block; font-size: .85rem; }
.ib-template small { color: var(--muted); font-size: .74rem; }

/* ── Day tabs (centre) ──────────────────────────────────────────── */
.ib-days-tabs { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .4rem; }
.ib-day-tab {
    flex: none; border: 1px solid var(--line); background: var(--panel); color: var(--ink);
    border-radius: 10px; padding: .45rem .7rem; cursor: pointer; font: 600 .8rem inherit; text-align: center; min-width: 6.5rem;
}
.ib-day-tab.is-active { border-color: var(--brand); background: rgba(13, 148, 136, .1); color: var(--brand-ink); }
.ib-day-tab small { display: block; font-weight: 500; color: var(--muted); font-size: .7rem; }
.ib-day-tab.is-active small { color: var(--brand-ink); }

.ib-day-toolbar { display: flex; align-items: center; justify-content: space-between; gap: .6rem; flex-wrap: wrap; margin: .5rem 0; }
.ib-day-summary { font-size: .82rem; color: var(--muted); }
.ib-day-tools { display: flex; gap: .4rem; flex-wrap: wrap; }

/* ── Conflict banner ────────────────────────────────────────────── */
.ib-conflict {
    border: 1px solid rgba(217, 119, 6, .4); background: rgba(217, 119, 6, .1); color: var(--warn);
    border-radius: 10px; padding: .6rem .8rem; font-size: .82rem; margin-bottom: .6rem;
    display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
}
.ib-conflict button { margin-left: auto; }

/* ── Add bar ────────────────────────────────────────────────────── */
.ib-addbar { position: relative; display: flex; align-items: center; gap: .5rem; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: .5rem .7rem; margin-bottom: .7rem; }
.ib-addbar input { flex: 1; border: 0; background: transparent; font: inherit; font-size: .9rem; color: var(--ink); }
.ib-addbar input:focus { outline: 0; }
.ib-suggest-pop, .ib-search-pop {
    position: absolute; left: 0; right: 0; top: calc(100% + .35rem); z-index: 400;
    background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow);
    max-height: 16rem; overflow-y: auto; padding: .3rem;
}
.ib-suggest-pop button {
    display: flex; width: 100%; gap: .5rem; align-items: center; text-align: left;
    border: 0; background: transparent; color: var(--ink); font: 500 .84rem inherit; padding: .5rem .55rem; border-radius: 7px; cursor: pointer;
}
.ib-suggest-pop button:hover { background: rgba(13, 148, 136, .1); }
.ib-suggest-pop small { color: var(--muted); margin-left: auto; font-size: .74rem; }

/* ── Slots (timeline) ───────────────────────────────────────────── */
.ib-slots { display: flex; flex-direction: column; gap: .55rem; min-height: 4rem; }
.ib-slot {
    display: grid; grid-template-columns: 58px 4px 1fr auto; gap: .7rem; align-items: stretch;
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
    padding: .7rem .8rem; box-shadow: var(--shadow-sm); cursor: grab;
}
.ib-slot:active { cursor: grabbing; }
.ib-slot.is-highlight { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(13, 148, 136, .3); }
.ib-slot.sortable-ghost { opacity: .4; }
.ib-slot.sortable-chosen { box-shadow: var(--shadow); }
.ib-slot-time { font-size: .8rem; color: var(--muted); text-align: right; padding-top: .1rem; }
.ib-slot-time b { display: block; color: var(--ink); font-size: .88rem; }
.ib-slot-rail { border-radius: 999px; background: var(--muted); }
.ib-slot-main { min-width: 0; }
.ib-slot-main b { font-size: .92rem; letter-spacing: -.01em; }
.ib-slot-meta { font-size: .76rem; color: var(--muted); display: flex; gap: .7rem; flex-wrap: wrap; margin-top: .2rem; }
.ib-slot-cat { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: .1rem .4rem; border-radius: 999px; color: #fff; }
.ib-slot-actions { display: flex; flex-direction: column; gap: .3rem; justify-content: center; }
.ib-slot-actions button { border: 1px solid var(--line); background: var(--panel); color: var(--muted); border-radius: 7px; width: 1.9rem; height: 1.9rem; cursor: pointer; font-size: .85rem; }
.ib-slot-actions button:hover { border-color: var(--brand); color: var(--brand-ink); }
.ib-gap { font-size: .72rem; color: var(--muted); text-align: center; padding: .1rem 0; }
.ib-gap.warn { color: var(--warn); font-weight: 600; }
.ib-empty { border: 1.5px dashed var(--line); border-radius: var(--radius); padding: 1.6rem 1rem; text-align: center; color: var(--muted); font-size: .86rem; }

/* ── Map + catalog (right) ──────────────────────────────────────── */
.ib-map-card, .ib-catalog { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
.ib-map-head, .ib-catalog-head { display: flex; align-items: center; justify-content: space-between; gap: .6rem; padding: .7rem .85rem; border-bottom: 1px solid var(--line); }
.ib-map-head strong, .ib-catalog-head strong { font-size: .88rem; }
.ib-toggle { display: inline-flex; align-items: center; gap: .35rem; font-size: .76rem; color: var(--muted); cursor: pointer; }
.ib-map { height: 320px; width: 100%; background: #dfe5e3; }
.ib-map.is-fallback { display: flex; align-items: center; justify-content: center; text-align: center; color: var(--muted); font-size: .82rem; padding: 1rem; }
.ib .leaflet-container { font: inherit; background: #dfe5e3; }
.ib-map-pin {
    display: flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
    color: #fff; font-weight: 700; font-size: .8rem; box-shadow: 0 3px 8px rgba(0,0,0,.35); border: 2px solid #fff;
}
.ib-map-pin span { transform: rotate(45deg); }
.ib-legend { display: flex; flex-wrap: wrap; gap: .5rem .9rem; padding: .6rem .85rem; font-size: .74rem; }
.ib-legend span { display: inline-flex; align-items: center; gap: .35rem; color: var(--muted); }
.ib-legend i { width: .7rem; height: .7rem; border-radius: 3px; }

.ib-catalog-head input { border: 1px solid var(--line); border-radius: 8px; padding: .3rem .5rem; font: inherit; font-size: .82rem; background: var(--panel); color: var(--ink); max-width: 9rem; }
.ib-chips { display: flex; flex-wrap: wrap; gap: .35rem; padding: .6rem .85rem 0; }
.ib-chip-btn { border: 1px solid var(--line); background: var(--panel); color: var(--muted); border-radius: 999px; padding: .25rem .6rem; font: 600 .74rem inherit; cursor: pointer; }
.ib-chip-btn.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.ib-catalog-list { max-height: 320px; overflow-y: auto; padding: .6rem .85rem .85rem; display: flex; flex-direction: column; gap: .45rem; }
.ib-cat-item { display: flex; gap: .55rem; align-items: center; border: 1px solid var(--line); border-radius: 9px; padding: .5rem .6rem; font-size: .82rem; }
.ib-cat-item .ib-cat-emoji { font-size: 1.1rem; }
.ib-cat-item .ib-cat-txt { min-width: 0; }
.ib-cat-item .ib-cat-txt b { display: block; font-size: .84rem; }
.ib-cat-item .ib-cat-txt small { color: var(--muted); font-size: .72rem; }
.ib-cat-item .ib-btn { margin-left: auto; }

/* ── Packing / docs / collaborators ─────────────────────────────── */
.ib-packing { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .7rem; }
.ib-packing label { display: flex; align-items: center; gap: .5rem; font-size: .84rem; }
.ib-packing label.done span { text-decoration: line-through; color: var(--muted); }
.ib-packing-add, .ib-collab-invite { display: flex; gap: .4rem; }
.ib-packing-add input, .ib-collab-invite input { flex: 1; border: 1px solid var(--line); border-radius: 8px; padding: .45rem .55rem; font: inherit; font-size: .84rem; background: var(--panel); color: var(--ink); }

.ib-docs { display: flex; flex-direction: column; gap: .5rem; margin-bottom: .7rem; }
.ib-doc { display: flex; align-items: center; gap: .6rem; border: 1px solid var(--line); border-radius: 9px; padding: .55rem .65rem; font-size: .82rem; }
.ib-doc .ib-doc-ic { font-size: 1.2rem; }
.ib-doc .ib-pill { margin-left: auto; font-size: .68rem; font-weight: 700; padding: .15rem .45rem; border-radius: 999px; }
.ib-pill.ok { background: rgba(22, 163, 74, .16); color: var(--ok); }
.ib-pill.warn { background: rgba(217, 119, 6, .16); color: var(--warn); }
.ib-pill.mut { background: var(--line); color: var(--muted); }
.ib-doc svg { flex: none; }

.ib-collab { display: flex; flex-direction: column; gap: .5rem; margin-bottom: .7rem; }
.ib-member { display: flex; align-items: center; gap: .55rem; font-size: .84rem; }
.ib-avatar { width: 1.9rem; height: 1.9rem; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .78rem; color: #fff; flex: none; }
.ib-member select { margin-left: auto; border: 1px solid var(--line); border-radius: 7px; padding: .2rem .35rem; font: inherit; font-size: .76rem; background: var(--panel); color: var(--ink); }
.ib-member .ib-pending { margin-left: auto; font-size: .7rem; color: var(--muted); }
.ib-feed { display: flex; flex-direction: column; gap: .45rem; font-size: .78rem; color: var(--muted); }
.ib-feed div b { color: var(--ink); }

/* ── More features ──────────────────────────────────────────────── */
.ib-more { margin: 0 1.4rem 1.4rem; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.ib-more > summary { cursor: pointer; padding: .8rem 1rem; font-weight: 700; font-size: .9rem; }
.ib-more-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .6rem; padding: 0 1rem 1rem; }
.ib-more-item { display: flex; align-items: center; gap: .6rem; border: 1px solid var(--line); border-radius: 10px; padding: .6rem .7rem; opacity: .8; }
.ib-more-item .ib-more-ic { font-size: 1.25rem; }
.ib-more-item .ib-more-txt { min-width: 0; }
.ib-more-item b { display: block; font-size: .84rem; }
.ib-more-item small { color: var(--muted); font-size: .72rem; }
.ib-more-item .ib-more-state { margin-left: auto; font-size: .66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: .15rem .45rem; border-radius: 999px; background: var(--line); color: var(--muted); }

/* ── Modal ──────────────────────────────────────────────────────── */
.ib-modal-overlay { position: fixed; inset: 0; z-index: 900; background: rgba(20, 19, 15, .5); display: flex; align-items: center; justify-content: center; padding: 1rem; }
.ib-modal-card { background: var(--panel); border-radius: 14px; box-shadow: var(--shadow); width: min(30rem, 100%); padding: 1.3rem; position: relative; }
.ib-modal-card h3 { margin: 0 0 1rem; font-size: 1rem; }
.ib-modal-close { position: absolute; right: .7rem; top: .5rem; border: 0; background: transparent; font-size: 1.4rem; color: var(--muted); cursor: pointer; line-height: 1; }
.ib-modal-actions { display: flex; justify-content: space-between; gap: .6rem; margin-top: .4rem; }

/* ── Toast ──────────────────────────────────────────────────────── */
.ib-toast {
    position: fixed; left: 50%; bottom: 1.4rem; transform: translateX(-50%);
    background: var(--ink); color: var(--bg); font-size: .84rem; font-weight: 600;
    padding: .6rem 1rem; border-radius: 10px; box-shadow: var(--shadow); z-index: 950;
}

/* ── Shimmer (AI generate) ──────────────────────────────────────── */
.ib-shimmer { position: relative; overflow: hidden; }
.ib-shimmer::after {
    content: ""; position: absolute; inset: 0;
    background: linear-gradient(90deg, transparent, rgba(13,148,136,.18), transparent);
    animation: ib-sweep 1.1s linear infinite;
}
@keyframes ib-sweep { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

/* ── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 1080px) {
    .ib-body { grid-template-columns: 280px minmax(0, 1fr); }
    .ib-side { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; position: static; }
    .ib-map-card, .ib-catalog { flex: 1 1 320px; }
}
@media (max-width: 780px) {
    .ib-body { grid-template-columns: 1fr; padding: .8rem; }
    .ib-rail, .ib-side { position: static; }
    .ib-side { flex-direction: column; }
    .ib-stats { width: 100%; margin-left: 0; justify-content: space-between; }
    .ib-title { max-width: 60vw; }
    .ib-map { height: 260px; }
}

/* ── Print ──────────────────────────────────────────────────────── */
@media print {
    .ib-topbar-actions, .ib-day-tools, .ib-addbar, .ib-side, .ib-tabs, .ib-more,
    .ib-slot-actions, .ib-conflict button, .ib-templates { display: none !important; }
    .ib { background: #fff; }
    .ib-body { grid-template-columns: 1fr; display: block; }
    .ib-card, .ib-slot { break-inside: avoid; box-shadow: none; }
    .ib-days-tabs { flex-wrap: wrap; }
}
