﻿/* -------------------------------------------------------
   1. GLOBAL THEME VARIABLES (Fluent-ready, user-themeable)
   Light mode = default values below.
------------------------------------------------------- */

:root {
    /* Primary brand color (user-changeable) */
    --color-primary: #4a90e2;
    --color-primary-light: color-mix(in srgb, var(--color-primary) 85%, white);
    --color-primary-dark: color-mix(in srgb, var(--color-primary) 80%, black);
    /* Neutral palette (Light) */
    --color-bg: #f5f5f7;
    --color-surface: rgba(255, 255, 255, 0.82); /* Acrylic T2 */
    --color-border: rgba(0, 0, 0, 0.12);
    --color-text: #1a1a1a;
    --color-muted: #666;
    /* Radii */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    /* Spacing scale */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    /* Fluent Acrylic Shadows (S3-C) */
    --shadow-strong: 0 4px 12px rgba(0,0,0,0.14), 0 16px 32px rgba(0,0,0,0.18);
    /* Backdrop blur */
    --blur: blur(12px);
    /* Font */
    --font: "Segoe UI", Roboto, sans-serif;
}

/* -------------------------------------------------------
   1b. DARK THEME
   Activated via [data-theme="dark"] on <html>.
   Overrides all light-mode palette + derived values.
------------------------------------------------------- */

[data-theme="dark"] {
    /* Core palette */
    --color-bg: #1a1a2e;
    --color-surface: rgba(30, 30, 50, 0.88);
    --color-border: rgba(255, 255, 255, 0.12);
    --color-text: #e8e8ec;
    --color-muted: #9a9ab0;
    --shadow-strong: 0 4px 12px rgba(0,0,0,0.3), 0 16px 32px rgba(0,0,0,0.4);
    /* Brand tints: mix toward dark bg instead of white/black */
    --color-primary-light: color-mix(in srgb, var(--color-primary) 22%, #1a1a2e);
    --color-primary-dark: color-mix(in srgb, var(--color-primary) 85%, white);
}

/* -- Top bar -- */
[data-theme="dark"] h1 {
    background: color-mix(in srgb, var(--color-primary) 80%, #1a1a2e);
}

/* -- Tabs (person-tab, settings-tab) -- */
[data-theme="dark"] .person-tab {
    background: rgba(255, 255, 255, 0.08);
    color: var(--color-text);
}

[data-theme="dark"] .person-tab.active {
    background: var(--color-primary);
    color: white;
}

/* -- Form controls -- */
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="date"],
[data-theme="dark"] input[type="email"],
[data-theme="dark"] input[type="tel"],
[data-theme="dark"] textarea,
[data-theme="dark"] .overview-input,
[data-theme="dark"] select {
    background: rgba(255, 255, 255, 0.06);
    color: var(--color-text);
    border-color: var(--color-border);
}

[data-theme="dark"] select option {
    background: #2a2a42;
    color: var(--color-text);
}

/* Color picker & file inputs */
[data-theme="dark"] input[type="color"] {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--color-border);
}

/* -- Locked / editable field states -- */
[data-theme="dark"] .input-locked {
    background: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .input-editable {
    background: rgba(255, 255, 255, 0.10);
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 30%, transparent);
}

/* -- Birthday "today" highlight -- */
[data-theme="dark"] .today {
    background: rgba(255, 193, 7, 0.15);
    border-left-color: #ffca28;
}

/* -- Nav bar -- */
[data-theme="dark"] #nav-bar {
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.5);
}

/* -- Search inputs (toolbar + mass update) -- */
[data-theme="dark"] .toolbar-search .search-input,
[data-theme="dark"] .mass-search-input {
    color: var(--color-text);
}

/* -- Secondary button -- */
[data-theme="dark"] .secondary-btn {
    color: var(--color-text);
}

/* -- Gift form inputs -- */
[data-theme="dark"] .gift-form input {
    background: rgba(255, 255, 255, 0.06);
    color: var(--color-text);
}

/* -- Gift suggestion image placeholder -- */
[data-theme="dark"] .gift-suggestion-img {
    background: rgba(255, 255, 255, 0.08);
}

/* -- Mass update cells -- */
[data-theme="dark"] .mass-cell-input {
    color: var(--color-text);
}

[data-theme="dark"] .mass-cell-input:focus {
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-primary) 35%, transparent);
}

/* -- Toast: flip to light on dark background -- */
[data-theme="dark"] .toast {
    background: rgba(230, 230, 245, 0.94);
    color: #1a1a2e;
}

/* -- Tag input -- */
[data-theme="dark"] .tag-input {
    color: var(--color-text);
}

/* -- Modal overlay slightly stronger -- */
[data-theme="dark"] .modal {
    background: rgba(0, 0, 0, 0.55);
}

/* -- Scrollbar styling -- */
[data-theme="dark"] ::-webkit-scrollbar {
    width: 8px;
}

[data-theme="dark"] ::-webkit-scrollbar-track {
    background: var(--color-bg);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* -------------------------------------------------------
   2. BASE STYLES
------------------------------------------------------- */

body {
    margin: 0;
    padding: 0;
    font-family: var(--font);
    background: var(--color-bg);
    color: var(--color-text);
    -webkit-text-size-adjust: 100%;
}

/* Slimmer top bar */
h1 {
    text-align: center;
    padding: 12px 0;
    margin: 0;
    background: var(--color-primary);
    color: white;
    font-weight: 500;
    font-size: 20px;
}

/* -------------------------------------------------------
   3. LAYOUT CONTAINERS
------------------------------------------------------- */

#view-list,
#view-details,
#view-birthdays,
#view-settings {
    max-width: 700px;
    margin: 24px auto;
    background: var(--color-surface);
    backdrop-filter: var(--blur);
    padding: var(--space-4);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-strong);
}

@media (max-width: 600px) {
    #view-list,
    #view-details,
    #view-birthdays,
    #view-settings {
        margin: 8px;
        padding: 14px;
        border-radius: var(--radius-md);
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    }

    #view-massupdate {
        margin: 8px;
        padding: 10px;
    }

    body {
        padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px));
    }
}

/* -------------------------------------------------------
   4. BUTTONS — Modern Fluent Style
------------------------------------------------------- */

button {
    background: var(--color-primary);
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    box-shadow: 0 2px 4px rgba(0,0,0,0.12);
    transition: background 0.2s, transform 0.1s;
}

    button:hover {
        background: var(--color-primary-dark);
    }

    button:active {
        transform: scale(0.97);
    }

    /* Icon-only buttons (gold standard for all list-item actions) */
    .icon-btn {
        background: none;
        border: none;
        font-size: 20px;
        cursor: pointer;
        color: var(--color-muted);
        padding: 4px;
        box-shadow: none;
    }

        .icon-btn:hover {
            color: var(--color-primary);
            background: none;
            box-shadow: none;
        }

    /* -------------------------------------------------------
   5. FORMS
------------------------------------------------------- */

label {
    font-weight: 600;
    display: block;
    margin-bottom: 4px;
}

input[type="text"],
input[type="date"],
input[type="email"],
input[type="tel"],
textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: 15px;
    box-sizing: border-box;
    background: var(--color-surface);
    backdrop-filter: var(--blur);
}

/* Re-usable input style used across overview and modals */
.overview-input {
    padding: 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    box-sizing: border-box;
    width: 100%;
    font-size: 15px;
}

textarea {
    min-height: 80px;
}

/* Field validation error state */
.input-invalid {
    border-color: #d33 !important;
    box-shadow: 0 0 0 3px rgba(211,51,51,0.18) !important;
}

.field-error {
    display: block;
    font-size: 13px;
    color: #d33;
    min-height: 0;
    margin-top: 4px;
}

.field-error:empty {
    display: none;
}

/* Overview tab: locked vs editable */
.input-locked {
    background: transparent;
    border: 1px solid transparent;
    box-shadow: none;
    pointer-events: none;
    opacity: 1;
    transition: all 0.2s ease;
}

.input-editable {
    background: var(--color-surface);
    border: 1px solid var(--color-primary);
    box-shadow: 0 0 0 3px rgba(74,144,226,0.25);
    opacity: 1;
    cursor: text;
    transition: all 0.2s ease;
}


    /* -------------------------------------------------------
   6. DETAIL GROUPS
------------------------------------------------------- */

.detail-group {
    background: var(--color-surface);
    backdrop-filter: var(--blur);
    padding: var(--space-4);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-5);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-strong);
}

    .detail-group h4 {
        margin: 0 0 12px 0;
        font-size: 1rem;
        font-weight: 600;
        color: var(--color-primary-dark);
    }

.detail-section {
    margin-bottom: var(--space-3);
}

    .detail-section:last-child {
        margin-bottom: 0;
    }

    /* -------------------------------------------------------
   7. GENERIC LISTS
------------------------------------------------------- */

ul {
    list-style: none;
    padding: 0;
}

    ul li {
        padding: 12px;
        background: var(--color-surface);
        backdrop-filter: var(--blur);
        margin-bottom: 8px;
        border-radius: var(--radius-md);
        cursor: pointer;
        transition: background 0.2s;
        box-shadow: var(--shadow-strong);
    }

        ul li:hover {
            background: var(--color-primary-light);
        }

    /* -------------------------------------------------------
   8. BIRTHDAY VIEW — Avatar Left
------------------------------------------------------- */

#view-birthdays li {
    padding: 0;
    margin-bottom: 12px;
    border-radius: var(--radius-md);
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
}

#view-birthdays .birthday-info {
    display: flex;
    flex-direction: column;
}

/* Layout helper: avatar next to text for list items */
.list-item-with-avatar {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
}

/* Birthday list: ensure avatar and info sit in a row and info fills remaining space */
#view-birthdays .list-item-with-avatar {
    width: 100%;
    align-items: center;
}

#view-birthdays .list-item-with-avatar .birthday-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1 1 auto;
}

#view-birthdays .list-item-with-avatar .avatar {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
}

#view-birthdays .birthday-name {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 18px;
    color: var(--color-primary-dark);
}

.birthday-meta {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

/* force meta items on one line when there is space */
@media (min-width: 600px) {
    .birthday-meta {
        flex-wrap: nowrap;
    }
}

.birthday-date, .birthday-days, .birthday-age {
    margin-right: 8px;
}

#view-birthdays li strong {
    font-size: 16px;
    color: var(--color-primary-dark);
}

.birthday-date,
.birthday-age {
    font-size: 14px;
    color: var(--color-muted);
}

.birthday-days {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-primary);
}

/* Birthday action icons (SMS, gift) — desktop only */
.birthday-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
    align-items: center;
}

.birthday-actions .icon-btn {
    font-size: 20px;
    padding: 6px;
    border-radius: 50%;
    transition: background 0.15s, opacity 0.15s;
}

.birthday-actions .icon-btn:disabled {
    opacity: 0.25;
    cursor: default;
}

.birthday-actions .icon-btn:not(:disabled):hover {
    background: var(--color-primary-light);
}

/* Birthday swipe infrastructure */
.birthday-item {
    position: relative;
    overflow: hidden;
    touch-action: pan-y;
}

.birthday-item * {
    touch-action: pan-y;
}

.birthday-inner {
    background: var(--color-surface);
    backdrop-filter: var(--blur);
    padding: 14px 16px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: 12px;
    transition: transform 0.15s ease-out;
    position: relative;
    z-index: 2;
    box-shadow: var(--shadow-strong);
}

/* Swipe backgrounds: hidden by default, enabled only on mobile */
.birthday-swipe-bg {
    display: none;
}

.birthday-swipe-left {
    background: var(--color-primary-light);
    padding-left: 20px;
    justify-content: flex-start;
}

.birthday-swipe-right {
    background: var(--color-primary-light);
    padding-right: 20px;
    justify-content: flex-end;
}

.birthday-swipe-icon {
    font-size: 28px;
    opacity: 0;
    transform: scale(0.5);
    transition: opacity 0.15s ease, transform 0.15s ease;
}

/* Mobile: enable swipe backgrounds, hide desktop icon buttons */
@media (max-width: 600px) {
    .birthday-swipe-bg {
        display: flex;
        position: absolute;
        inset: 0;
        align-items: center;
        visibility: hidden;
        z-index: 1;
        border-radius: var(--radius-md);
    }

    .birthday-actions {
        display: none;
    }
}

.today {
    background: rgba(255, 243, 205, 0.8);
    border-left: 4px solid #ffca28;
}

/* -------------------------------------------------------
   9. BOTTOM NAVIGATION
------------------------------------------------------- */

#nav-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(60px + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--color-surface);
    backdrop-filter: var(--blur);
    box-shadow: 0 -2px 6px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-around;
    align-items: center;
    border-top: 1px solid var(--color-border);
}

    #nav-bar button {
        background: none;
        border: none;
        font-size: 15px;
        color: var(--color-muted);
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        padding: 6px 10px;
        box-shadow: none;
    }

        #nav-bar button.active {
            color: var(--color-primary);
            font-weight: 600;
        }

    .nav-icon {
        font-size: 22px;
    }

    /* ---- Mobile nav: icons only, hide Mass Update ---- */
    @media (max-width: 600px) {
        #nav-bar .nav-desktop-only {
            display: none;
        }

        .nav-label {
            display: none;
        }

        #nav-bar button {
            padding: 10px 16px;
        }

        .nav-icon {
            font-size: 26px;
        }
    }

    /* -------------------------------------------------------
   10. PEOPLE LIST
------------------------------------------------------- */

.personlist-layout {
    display: flex;
    gap: var(--space-3);
    position: relative;
}

.people-list {
    flex: 1;
    padding-bottom: 80px;
}

/* Toolbar */
.personlist-toolbar {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.toolbar-search {
    flex: 1;
    display: flex;
    align-items: center;
    background: var(--color-surface);
    backdrop-filter: var(--blur);
    padding: 8px 12px;
    border-radius: 20px;
    gap: 8px;
    box-shadow: var(--shadow-strong);
    position: relative;
}

    .toolbar-search .search-icon {
        font-size: 20px;
        color: var(--color-muted);
    }

    .toolbar-search .search-input {
        border: none;
        background: transparent;
        flex: 1;
        font-size: 15px;
        outline: none;
    }

    /* Add button */
    .add-btn {
        background: var(--color-primary);
        color: white;
        border: none;
        width: 40px;
        height: 40px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        box-shadow: var(--shadow-strong);
    }

        .add-btn:hover {
            background: var(--color-primary-dark);
        }

    /* Tag suggestions */
    .tag-suggestions {
        position: relative;
        width: calc(100% - 48px);
        margin-top: 4px;
        padding: 6px 4px;
        background: var(--color-surface);
        backdrop-filter: var(--blur);
        border: 1px solid var(--color-border);
        border-radius: var(--radius-md);
        box-shadow: var(--shadow-strong);
        display: none;
    }

    /* Generic suggestions list used under inputs */
    .suggestions {
        margin-top: 6px;
        background: var(--color-surface);
        backdrop-filter: var(--blur);
        border: 1px solid var(--color-border);
        border-radius: var(--radius-md);
        box-shadow: var(--shadow-strong);
        padding: 8px 6px;
        z-index: 2100;
        display: none;
    }

    .suggestion {
        padding: 8px 10px;
        cursor: pointer;
        border-radius: 6px;
    }

    .suggestion:hover {
        background: var(--color-primary-light);
    }

    /* Secondary button variant matching primary style */
    .secondary-btn {
        background: var(--color-primary-light);
        color: white;
        border: none;
        padding: 8px 12px;
        border-radius: var(--radius-md);
        cursor: pointer;
        font-weight: 500;
        box-shadow: 0 2px 4px rgba(0,0,0,0.12);
    }

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 12px;
}

/* Gift form animations */
.gift-form-container {
    overflow: hidden;
    transition: max-height 260ms cubic-bezier(.2,.9,.2,1), opacity 200ms ease;
    max-height: 0;
    opacity: 0;
    padding: 3px 3px 0;
}

.gift-form-container.open {
    max-height: 620px; /* enough to fit the form + price field + suggestions */
    opacity: 1;
}

/* Relationship inline form */
.rel-form-container {
    overflow: hidden;
    transition: max-height 300ms cubic-bezier(.2,.9,.2,1), opacity 220ms ease;
    max-height: 0;
    opacity: 0;
    padding: 3px 3px 0;
}

.rel-form-container.open {
    max-height: 480px;
    opacity: 1;
}

.gift-form input {
    width: 100%;
    padding: 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    margin-bottom: 8px;
}

/* Gift product suggestions dropdown */
.gift-suggestions {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    max-height: 260px;
    overflow-y: auto;
    z-index: 2100;
    margin-top: 4px;
}

.gift-suggestion-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
}

.gift-suggestion-img {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    object-fit: contain;
    flex-shrink: 0;
    background: #f0f0f0;
}

.gift-suggestion-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.gift-suggestion-info {
    flex: 1;
    min-width: 0;
}

.gift-suggestion-title {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gift-suggestion-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 2px;
}

.gift-suggestion-price {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-primary-dark);
}

.gift-suggestion-empty {
    color: var(--color-muted);
    font-style: italic;
    cursor: default;
}

.gift-suggestion-empty:hover {
    background: none;
}

.gift-suggestion-error {
    color: #c0392b;
    font-style: italic;
    cursor: default;
    font-size: 13px;
}

.gift-suggestion-error:hover {
    background: none;
}

/* Gift empty state */
.gift-empty-state {
    text-align: center;
    padding: 36px 16px;
    color: var(--color-muted);
}

.gift-empty-icon {
    font-size: 48px;
    margin-bottom: 8px;
}

.gift-empty-state p {
    margin: 4px 0;
    font-size: 15px;
}

.gift-empty-hint {
    font-size: 13px !important;
    opacity: 0.7;
}

/* Retailer badge */
.gift-retailer-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 8px;
    background: var(--color-primary-light);
    color: var(--color-primary-dark);
    text-transform: capitalize;
}

/* Price on gift cards */
.gift-price {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-primary-dark);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Search spinner inside the title input */
.gift-search-spinner {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: giftSpin 0.6s linear infinite;
}

@keyframes giftSpin {
    to { transform: translateY(-50%) rotate(360deg); }
}

/* Animate new gift card insertion */
.gift-card {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 260ms ease, transform 260ms ease;
}

.gift-card.new {
    opacity: 0;
    transform: translateY(-8px);
}

/* Person item */
.person-item {
    position: relative;
    overflow: hidden;
    touch-action: pan-y;
}

.person-item * {
    touch-action: pan-y;
}

/* Swipe pin confirmation flash */
.swipe-confirm {
    animation: swipeFlash 0.35s ease-out;
}

@keyframes swipeFlash {
    0%   { background: var(--color-primary-light); }
    50%  { background: rgba(251, 192, 45, 0.35); }
    100% { background: var(--color-primary-light); }
}

/* Avatar */
.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--color-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 16px;
    flex-shrink: 0;
    box-shadow: var(--shadow-strong);
}

.person-inner {
    background: var(--color-surface);
    backdrop-filter: var(--blur);
    padding: 12px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: 12px;
    transition: transform 0.15s ease-out;
    position: relative;
    z-index: 2;
    box-shadow: var(--shadow-strong);
}

.person-name {
    flex: 1;
}

/* Swipe */
.swipe-bg {
    position: absolute;
    inset: 0;
    background: var(--color-primary-light);
    display: flex;
    align-items: center;
    padding-left: 16px;
    visibility: hidden;
    z-index: 1;
}

.swipe-star {
    font-size: 26px;
    opacity: 0;
    transform: scale(0.5);
    transition: opacity 0.15s ease, transform 0.15s ease;
    color: var(--color-primary);
}

/* Letter sidebar */
.letter-sidebar {
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: sticky;
    top: 80px;
    height: fit-content;
    padding-left: 8px;
}

.letter-btn {
    background: none;
    border: none;
    padding: 4px;
    font-size: 14px;
    color: var(--color-muted);
    cursor: pointer;
}

    .letter-btn:hover {
        color: var(--color-primary);
        font-weight: 600;
    }

    /* -------------------------------------------------------
   11. TAGS
------------------------------------------------------- */

.tag-chip-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

.tag-chip {
    background: var(--color-primary);
    color: white;
    padding: 6px 10px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s;
}

    .tag-chip:hover {
        background: var(--color-primary-dark);
    }

.tag-input {
    width: 100%;
    padding: 10px;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    font-size: 15px;
    background: var(--color-surface);
    backdrop-filter: var(--blur);
}

/* -------------------------------------------------------
   12. NOTES
------------------------------------------------------- */

.notes-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.note-card {
    background: var(--color-surface);
    backdrop-filter: var(--blur);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 12px;
    box-shadow: var(--shadow-strong);
}

/* Notes form hidden toggle (similar to gifts) */
.note-form-container {
    overflow: hidden;
    transition: max-height 260ms cubic-bezier(.2,.9,.2,1), opacity 200ms ease;
    max-height: 0;
    opacity: 0;
    padding: 3px 3px 0;
}

.note-form-container.open {
    max-height: 320px;
    opacity: 1;
}

/* Animate new note insertion */
.note-card {
    transition: opacity 260ms ease, transform 260ms ease;
}

.note-card.new {
    opacity: 0;
    transform: translateY(-8px);
}

.notes-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.note-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.note-date {
    font-size: 13px;
    color: var(--color-muted);
}

.note-text {
    white-space: pre-wrap;
    font-size: 15px;
}

/* -------------------------------------------------------
   13. GIFTS — Hidden form + add icon
------------------------------------------------------- */

.add-gift-btn {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--color-primary);
    margin-bottom: 12px;
}

    .add-gift-btn:hover {
        color: var(--color-primary-dark);
    }

.gift-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    backdrop-filter: var(--blur);
    box-shadow: var(--shadow-strong);
    margin-bottom: 20px;
}

    .gift-card img {
        width: 100%;
        max-width: 150px;
        border-radius: var(--radius-md);
        align-self: center;
    }

.gift-card-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.gift-title {
    font-weight: 600;
    font-size: 1.1rem;
}

.gift-link {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 500;
}

    .gift-link:hover {
        text-decoration: underline;
    }

    /* -------------------------------------------------------
   14. RELATIONSHIPS
------------------------------------------------------- */

.relationship-group {
    margin-bottom: 20px;
}

.relationship-group-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-muted);
    padding-bottom: 6px;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--color-border);
}

.relationship-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius-md);
    background: var(--color-surface);
    backdrop-filter: var(--blur);
    border: 1px solid var(--color-border);
    margin-bottom: 10px;
    box-shadow: var(--shadow-strong);
}

.relationship-icon {
    font-size: 24px;
}

.relationship-type {
    font-size: 13px;
    color: var(--color-muted);
}

.relationship-info {
    flex: 1;
}

/* Inference suggestion modal */
.inference-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 320px;
    overflow-y: auto;
    margin-bottom: 16px;
}

.inference-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    cursor: pointer;
    transition: background 0.15s;
    margin-bottom: 0;
    font-weight: normal;
}

.inference-row:hover {
    background: var(--color-primary-light);
}

.inference-row input[type="checkbox"] {
    width: auto;
    min-height: auto;
    margin: 0;
    flex-shrink: 0;
}

.inference-icon {
    font-size: 20px;
    flex-shrink: 0;
}

/* -------------------------------------------------------
   SPLASH SCREEN
------------------------------------------------------- */
#splash {
    position: fixed;
    inset: 0;
    background: var(--color-bg, #0d1117);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
}

#splash img {
    width: 120px;
    height: 120px;
    object-fit: contain;
    pointer-events: none;
    animation: splash-pop 0.5s cubic-bezier(.2,.9,.2,1) both;
}

@keyframes splash-pop {
    0%   { opacity: 0; transform: scale(0.7); }
    100% { opacity: 1; transform: scale(1); }
}

.inference-detail {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.inference-type {
    font-size: 13px;
    color: var(--color-primary);
    font-weight: 500;
}

.inference-reason {
    font-size: 12px;
    color: var(--color-muted);
    font-style: italic;
}

/* -------------------------------------------------------
   15. PERSON DETAILS
------------------------------------------------------- */

.person-details-layout {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.person-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 8px;
}

.person-tab {
    padding: 8px 14px;
    border-radius: 20px;
    background: #eee;
    color: #181818;
    cursor: pointer;
    white-space: nowrap;
    font-weight: 500;
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.person-tab .tab-icon {
    display: none;
    font-size: 22px;
    line-height: 1;
}

    .person-tab.active {
        background: var(--color-primary);
        color: white;
    }

#personTabContent {
    padding-bottom: 120px;
    flex: 1;
}

/* Animations for switching between persons */
.animate-out {
    animation: fadeOut 220ms ease forwards;
}

.animate-in {
    animation: fadeIn 260ms cubic-bezier(.2,.9,.2,1) forwards;
}

@keyframes fadeOut {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(-8px); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

/* quick highlight when clicking a relationship */
.relationship-card:active {
    transform: scale(0.995);
}

/* Pin / Favorite star buttons — consistent with .icon-btn */
.pin-btn,
.favorite-star {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 24px;
    padding: 4px;
    box-shadow: none;
}

    .pin-btn:hover,
    .favorite-star:hover {
        background: none;
        box-shadow: none;
    }

    /* Desktop layout */
    @media (min-width: 800px) {
    .person-details-layout {
        flex-direction: row;
        align-items: flex-start;
    }

    .person-tabs {
        flex-direction: column;
        width: 200px;
        background: var(--color-surface);
        backdrop-filter: var(--blur);
        padding: 16px;
        border-radius: var(--radius-lg);
        height: fit-content;
        box-shadow: var(--shadow-strong);
    }

    .person-tab {
        width: 100%;
        text-align: left;
    }

    .person-tab .tab-icon {
        display: inline;
        font-size: 18px;
    }
}

/* -------------------------------------------------------
   16. MODALS
------------------------------------------------------- */

.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    backdrop-filter: blur(6px);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 80px;
    overflow-y: auto;
    z-index: 2000;
}

    .modal.hidden {
        display: none !important;
    }

    /* Generic utility to hide elements via the "hidden" class used throughout the UI */
    .hidden {
        display: none !important;
    }

.modal-content {
    background: var(--color-surface);
    backdrop-filter: var(--blur);
    width: 420px;
    max-width: 92%;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    padding: 24px 28px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-strong);
    display: flex;
    flex-direction: column;
    animation: modalFadeIn 0.18s;
}

/* Contact picker items inside modal */
.contact-pick-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background 0.15s;
}

.contact-pick-item:hover {
    background: var(--color-primary-light);
}

/* Multi-select contact picker */
.contact-multi-selectall {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 4px;
}

.contact-multi-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    margin: 0 -4px;
    padding: 0 4px;
}

.contact-multi-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background 0.15s;
    font-weight: normal;
    margin-bottom: 0;
}

.contact-multi-row:hover {
    background: var(--color-primary-light);
}

.contact-multi-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.contact-multi-icons {
    display: flex;
    gap: 4px;
    font-size: 14px;
    flex-shrink: 0;
}

/* Toast notifications */
.toast {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: 24px;
    background: rgba(20,20,20,0.9);
    color: white;
    padding: 10px 16px;
    border-radius: 10px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.2);
    font-weight: 600;
    opacity: 0;
    pointer-events: none;
    transition: opacity 220ms ease, transform 220ms ease;
    z-index: 3000;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(-6px);
}

/* Settings tabs: wider sidebar on desktop to fit longer labels */
@media (min-width: 800px) {
    .settings-tabs {
        width: 220px;
    }
}

/* import card dragover visual */
.detail-group.dragover {
    outline: 2px dashed var(--color-primary);
}

.card {
    animation: fadeIn 260ms ease;
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity:1; transform: none; } }

/* -------------------------------------------------------
   17. IMPORT REVIEW DIALOG
------------------------------------------------------- */

.import-picker-modal {
    width: 600px;
}

.import-picker-toolbar {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
}

.import-picker-search {
    flex: 1;
}

.import-picker-sort {
    display: flex;
    gap: 4px;
}

.import-picker-sort-btn {
    padding: 6px 10px;
    font-size: 13px;
    white-space: nowrap;
}

.import-picker-sort-btn.active {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

.import-picker-count {
    margin-left: auto;
    font-size: 13px;
    color: var(--color-muted);
    font-weight: 400;
}

.import-picker-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    margin: 0 -4px;
    padding: 0 4px;
    max-height: 50vh;
}

.import-picker-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background 0.15s;
    font-weight: normal;
    margin-bottom: 0;
    flex-wrap: wrap;
}

.import-picker-row:hover {
    background: var(--color-primary-light);
}

.import-picker-name {
    flex: 1;
    min-width: 100px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

.import-picker-icons {
    display: flex;
    gap: 4px;
    font-size: 14px;
    flex-shrink: 0;
}

.import-picker-dupe {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--color-muted);
    flex-shrink: 0;
}

.import-picker-match-name {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.import-picker-action {
    flex-shrink: 0;
}

.import-picker-select {
    padding: 4px 8px;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    font-size: 13px;
    cursor: pointer;
}

@media (max-width: 600px) {
    .import-picker-modal {
        width: 100%;
    }
    .import-picker-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .import-picker-row {
        padding: 8px 8px;
        gap: 6px;
    }
    .import-picker-dupe {
        width: 100%;
        padding-left: 28px;
    }
}

.import-review-modal {
    width: 540px;
}

.import-review-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    margin: 0 -4px;
    padding: 0 4px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.import-review-row {
    padding: 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    backdrop-filter: var(--blur);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.import-review-names {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.import-review-contact {
    font-weight: 600;
    font-size: 15px;
}

.import-review-match {
    font-size: 14px;
    color: var(--color-muted);
}

.import-review-badge {
    display: inline-block;
    background: var(--color-primary);
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 4px;
    vertical-align: middle;
}

.import-review-nomatch {
    font-size: 13px;
    color: var(--color-muted);
    font-style: italic;
}

.import-review-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.import-review-option {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    margin-bottom: 0;
}

.import-review-option input[type="radio"]:disabled + * {
    opacity: 0.4;
}

.import-review-option input[type="radio"]:disabled {
    cursor: not-allowed;
}

/* -------------------------------------------------------
   18. MASS UPDATE TABLE
------------------------------------------------------- */

.mass-update-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: var(--space-4);
    flex-wrap: wrap;
}

.mass-update-count {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-primary);
}

.mass-update-save {
    background: var(--color-primary);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(0,0,0,0.12);
    transition: background 0.2s, opacity 0.2s;
}

.mass-update-save:disabled {
    opacity: 0.45;
    cursor: default;
}

.mass-update-save:not(:disabled):hover {
    background: var(--color-primary-dark);
}

.mass-update-scroll {
    overflow-x: auto;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    backdrop-filter: var(--blur);
    box-shadow: var(--shadow-strong);
}

.mass-update-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1200px;
}

.mass-update-table thead th {
    position: sticky;
    top: 0;
    background: var(--color-primary-dark);
    color: white;
    text-align: left;
    padding: 10px 8px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    z-index: 2;
}

.mass-update-table tbody tr {
    border-bottom: 1px solid var(--color-border);
    transition: background 0.15s;
}

.mass-update-table tbody tr:hover {
    background: var(--color-primary-light);
}

.mass-cell {
    padding: 4px;
}

.mass-cell-input {
    width: 100%;
    min-width: 110px;
    padding: 8px 10px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    font-size: 14px;
    font-family: var(--font);
    box-sizing: border-box;
    transition: border-color 0.15s, background 0.15s;
}

.mass-cell-input:focus {
    outline: none;
    border-color: var(--color-primary);
    background: var(--color-surface);
    box-shadow: 0 0 0 2px rgba(74,144,226,0.2);
}

/* Wider columns for names and email */
.mass-update-table th:nth-child(1) .mass-cell-input,
.mass-update-table td:nth-child(1) .mass-cell-input,
.mass-update-table th:nth-child(2) .mass-cell-input,
.mass-update-table td:nth-child(2) .mass-cell-input { min-width: 130px; }

.mass-update-table th:nth-child(4) .mass-cell-input,
.mass-update-table td:nth-child(4) .mass-cell-input,
.mass-update-table th:nth-child(6) .mass-cell-input,
.mass-update-table td:nth-child(6) .mass-cell-input { min-width: 160px; }

/* Dirty row highlight */
.mass-row-dirty {
    background: rgba(74,144,226,0.08);
    box-shadow: inset 4px 0 0 var(--color-primary);
}

/* New row highlight + entrance animation */
.mass-row-new {
    background: rgba(74,144,226,0.12);
    box-shadow: inset 4px 0 0 var(--color-primary);
    opacity: 0;
    transform: translateY(-12px);
}

.mass-row-new-enter {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 320ms ease, transform 320ms cubic-bezier(.2,.9,.2,1);
}

.mass-row-new .mass-cell-input {
    border-color: var(--color-primary);
    background: rgba(74,144,226,0.06);
}

.mass-row-new .mass-cell-input::placeholder {
    color: var(--color-muted);
    font-style: italic;
    opacity: 0.7;
}

/* Toolbar: search + column toggle */
.mass-update-toolbar {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
    flex-wrap: wrap;
}

.mass-search-box {
    flex: 1;
    display: flex;
    align-items: center;
    background: var(--color-surface);
    backdrop-filter: var(--blur);
    padding: 8px 12px;
    border-radius: 20px;
    gap: 8px;
    box-shadow: var(--shadow-strong);
    min-width: 200px;
}

.mass-search-icon {
    font-size: 16px;
    color: var(--color-muted);
    flex-shrink: 0;
}

.mass-search-input {
    border: none;
    background: transparent;
    flex: 1;
    font-size: 15px;
    outline: none;
    min-width: 0;
}

.mass-row-count {
    font-size: 13px;
    color: var(--color-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

/* Column visibility dropdown */
.mass-col-toggle-wrap {
    position: relative;
}

.mass-col-toggle-btn {
    background: var(--color-surface);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    padding: 8px 14px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-strong);
    white-space: nowrap;
}

.mass-col-toggle-btn:hover {
    background: var(--color-primary-light);
    color: var(--color-primary-dark);
}

.mass-col-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    background: var(--color-surface);
    backdrop-filter: var(--blur);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-strong);
    padding: 8px 6px;
    z-index: 50;
    min-width: 180px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.mass-col-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    font-size: 14px;
    transition: background 0.15s;
    margin-bottom: 0;
}

.mass-col-option:hover {
    background: var(--color-primary-light);
}

.mass-col-option input[type="checkbox"] {
    width: auto;
    margin: 0;
}

/* Override the generic view container width for the table */
#view-massupdate {
    max-width: 96vw;
    margin: 24px auto;
    background: var(--color-surface);
    backdrop-filter: var(--blur);
    padding: var(--space-4);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-strong);
}

/* Navigate-to-person button in first column */
.mass-nav-cell {
    width: 36px;
    min-width: 36px;
    text-align: center;
    padding: 4px !important;
}

.mass-nav-btn {
    color: var(--color-primary) !important;
    font-size: 18px !important;
}

.mass-nav-btn:hover {
    color: var(--color-primary-dark) !important;
}

/* -------------------------------------------------------
   MOBILE RESPONSIVENESS
------------------------------------------------------- */

@media (max-width: 600px) {
    /* Larger base text */
    body {
        font-size: 16px;
    }

    h1 {
        font-size: 18px;
        padding: 14px 0;
    }

    h2 {
        font-size: 20px;
    }

    h3 {
        font-size: 18px;
    }

    /* Touch-friendly inputs */
    input[type="text"],
    input[type="date"],
    input[type="email"],
    input[type="tel"],
    textarea,
    .overview-input,
    select {
        font-size: 16px;
        padding: 12px;
        min-height: 44px;
    }

    /* Touch-friendly buttons */
    .primary-btn,
    .secondary-btn {
        min-height: 44px;
        font-size: 15px;
        padding: 10px 16px;
    }

    /* Larger add button */
    .add-btn {
        width: 48px;
        height: 48px;
    }

    /* Tabs: icon-only on mobile */
    .person-tab .tab-label {
        display: none;
    }

    .person-tab .tab-icon {
        display: inline-block;
    }

    .person-tab {
        padding: 10px;
        font-size: 14px;
    }

    /* Relationship cards: larger touch target */
    .relationship-card {
        padding: 14px;
    }

    /* Modal: nearly full-width on mobile */
    .modal-content {
        width: 95%;
        max-width: 95%;
        padding: 20px 16px;
    }

    .modal {
        padding-top: 40px;
    }

    /* Gift cards: tighter layout */
    .gift-card {
        padding: 14px;
    }

    /* Search bar */
    .toolbar-search {
        padding: 10px 14px;
    }

    .toolbar-search .search-input {
        font-size: 16px;
    }

    /* Avatar */
    .avatar {
        width: 44px;
        height: 44px;
        font-size: 17px;
    }

    /* Person details header */
    .person-details-header h2 {
        font-size: 20px;
    }

    /* Detail groups */
    .detail-group {
        padding: 14px;
    }

    /* Settings tabs: horizontal scroll */
    .settings-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}
