/* ===== CSS RESET & VARIABLES ===== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0
}

:root {
    /* Color palette — romantic, warm tones */
    --bg: #0f0e17;
    --bg-card: #1a1929;
    --bg-card-hover: #22213a;
    --surface: #2a2940;
    --border: #3a3858;
    --text: #fffffe;
    --text-muted: #a7a5c6;
    --primary: #e8a0bf;
    --primary-dark: #c77d9e;
    --primary-glow: rgba(232, 160, 191, 0.25);
    --accent: #f2d0a4;
    --accent2: #c4b5fd;
    --danger: #f87171;
    --success: #6ee7b7;
    --warning: #fbbf24;
    --warning-bg: rgba(251, 191, 36, 0.12);
    --radius: 14px;
    --radius-sm: 8px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.4);
    --transition: 0.25s cubic-bezier(.4, 0, .2, 1);
    --font-display: 'Playfair Display', Georgia, serif;
    --font-body: 'Inter', -apple-system, sans-serif;
}

html {
    scroll-behavior: smooth
}

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ===== BACKGROUND DECORATION ===== */
.bg-decoration {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden
}

.bg-circle {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: .18
}

.bg-circle-1 {
    width: 600px;
    height: 600px;
    background: var(--primary);
    top: -200px;
    right: -150px;
    animation: float 20s ease-in-out infinite
}

.bg-circle-2 {
    width: 500px;
    height: 500px;
    background: var(--accent2);
    bottom: -150px;
    left: -100px;
    animation: float 25s ease-in-out infinite reverse
}

.bg-circle-3 {
    width: 350px;
    height: 350px;
    background: var(--accent);
    top: 40%;
    left: 50%;
    animation: float 18s ease-in-out infinite 5s
}

@keyframes float {

    0%,
    100% {
        transform: translate(0, 0)
    }

    50% {
        transform: translate(30px, -40px)
    }
}

/* ===== HEADER ===== */
header {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 2.5rem 1rem 1.5rem;
    background: linear-gradient(180deg, rgba(232, 160, 191, 0.08) 0%, transparent 100%);
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .6rem
}

.logo-icon {
    font-size: 2rem;
    animation: pulse 2s ease-in-out infinite
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1)
    }

    50% {
        transform: scale(1.15)
    }
}

header h1 {
    font-family: var(--font-display);
    font-size: 2.2rem;
    font-weight: 700;
    letter-spacing: .01em;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text
}

.tagline {
    color: var(--text-muted);
    font-size: .95rem;
    margin-top: .3rem;
    font-weight: 300
}

/* ===== MAIN ===== */
main {
    position: relative;
    z-index: 1;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1.25rem 3rem
}

/* ===== TABS ===== */
.tabs {
    display: flex;
    gap: .5rem;
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: .4rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border);
    overflow-x: auto;
}

.tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    padding: .7rem .8rem;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font-body);
    font-size: .85rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.tab:hover {
    background: var(--surface);
    color: var(--text)
}

.tab.active {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: #fff;
    box-shadow: 0 2px 12px var(--primary-glow)
}

.tab-icon {
    font-size: 1.1rem
}

/* ===== TAB CONTENT ===== */
.tab-content {
    display: none;
    animation: fadeIn .35s ease
}

.tab-content.active {
    display: block
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px)
    }

    to {
        opacity: 1;
        transform: translateY(0)
    }
}

/* ===== SECTION HEADERS ===== */
.section-header {
    margin-bottom: 1.5rem
}

.section-header h2 {
    font-family: var(--font-display);
    font-size: 1.6rem;
    font-weight: 600;
    margin-bottom: .3rem
}

.section-header p {
    color: var(--text-muted);
    font-size: .9rem
}

/* ===== CARDS ===== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    transition: var(--transition);
}

.card:hover {
    border-color: rgba(232, 160, 191, 0.25)
}

/* ===== FORMS ===== */
.form-row {
    display: flex;
    gap: .75rem;
    align-items: flex-end;
    flex-wrap: wrap
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: .3rem;
    min-width: 0
}

.form-group.flex-grow {
    flex: 1
}

.form-group label {
    font-size: .78rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em
}

.optional {
    font-weight: 400;
    text-transform: none;
    letter-spacing: normal;
    opacity: .6
}

input,
select {
    font-family: var(--font-body);
    font-size: .9rem;
    padding: .55rem .75rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    outline: none;
    transition: var(--transition);
}

input:focus,
select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow)
}

input::placeholder {
    color: var(--text-muted);
    opacity: .5
}

select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23a7a5c6' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right .6rem center;
    padding-right: 2rem
}

/* ===== BUTTONS ===== */
.btn {
    font-family: var(--font-body);
    font-size: .85rem;
    font-weight: 600;
    padding: .6rem 1.2rem;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: #fff;
    box-shadow: 0 2px 10px var(--primary-glow)
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 18px var(--primary-glow)
}

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border)
}

.btn-secondary:hover {
    background: var(--bg-card-hover);
    border-color: var(--primary)
}

.btn-danger {
    background: transparent;
    color: var(--danger);
    border: 1px solid rgba(248, 113, 113, 0.3);
    font-size: .78rem;
    padding: .35rem .7rem
}

.btn-danger:hover {
    background: rgba(248, 113, 113, 0.1)
}

.btn-small {
    font-size: .78rem;
    padding: .35rem .7rem
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    padding: .3rem .5rem
}

.btn-ghost:hover {
    color: var(--text);
    background: var(--surface)
}

/* ===== TABLE LIST (Setup) ===== */
.table-list-card {
    padding: 0;
    overflow: hidden
}

.table-list {
    width: 100%;
    border-collapse: collapse;
    font-size: .88rem;
}

.table-list thead th {
    text-align: left;
    padding: .65rem .8rem;
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.table-list tbody tr {
    border-bottom: 1px solid var(--border);
    transition: var(--transition);
}

.table-list tbody tr:hover {
    background: var(--bg-card-hover)
}

.table-list tbody tr:last-child {
    border-bottom: none
}

.table-list td {
    padding: .45rem .8rem;
    vertical-align: middle
}

.col-num {
    width: 3rem;
    text-align: center;
    color: var(--text-muted);
    font-weight: 600;
    font-size: .8rem
}

.col-name {
    min-width: 140px
}

.col-seats {
    width: 5.5rem
}

.col-filled {
    width: 5.5rem;
    text-align: center
}

.col-actions {
    width: 3.5rem;
    text-align: center
}

.inline-input {
    font-family: var(--font-body);
    font-size: .88rem;
    padding: .35rem .55rem;
    border-radius: 6px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text);
    outline: none;
    width: 100%;
    transition: var(--transition);
}

.inline-input:hover {
    border-color: var(--border)
}

.inline-input:focus {
    border-color: var(--primary);
    background: var(--surface);
    box-shadow: 0 0 0 2px var(--primary-glow)
}

.inline-num {
    width: 4rem;
    text-align: center
}

.filled-badge {
    font-size: .78rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Add table footer row */
.table-list tfoot td {
    padding: .55rem .8rem;
    border-top: 1px solid var(--border);
    background: rgba(232, 160, 191, 0.03);
}

.add-row-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: .9rem;
    font-weight: 700;
}

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted)
}

.empty-state.small {
    padding: 1.5rem .5rem
}

.empty-icon {
    font-size: 2.5rem;
    display: block;
    margin-bottom: .6rem
}

.empty-state p {
    font-size: .9rem
}

/* ===== GUESTS TAB ===== */
.guests-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 1rem;
    align-items: start
}

@media(max-width:800px) {
    .guests-layout {
        grid-template-columns: 1fr
    }
}

.guest-controls {
    margin-bottom: 1rem
}

.unseated-panel {
    position: sticky;
    top: 1rem
}

.unseated-panel h3 {
    font-size: .95rem;
    font-weight: 600;
    margin-bottom: .6rem;
    display: flex;
    align-items: center;
    gap: .5rem
}

.badge {
    background: var(--primary);
    color: #fff;
    font-size: .7rem;
    font-weight: 700;
    padding: .1rem .45rem;
    border-radius: 20px;
    min-width: 1.3rem;
    text-align: center;
}

.unseated-list {
    display: flex;
    flex-direction: column;
    gap: .35rem;
    max-height: 50vh;
    overflow-y: auto
}

.unseated-guest {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .45rem .65rem;
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-size: .85rem;
    cursor: grab;
    transition: var(--transition);
}

.unseated-guest:hover {
    background: var(--bg-card-hover);
    border-color: var(--primary)
}

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

.unseated-guest .delete-guest {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: .85rem;
    padding: .15rem .3rem;
    border-radius: 4px;
    transition: var(--transition);
    opacity: .5;
}

.unseated-guest .delete-guest:hover {
    color: var(--danger);
    opacity: 1;
    background: rgba(248, 113, 113, 0.1)
}

/* ===== SEATING VISUAL ===== */
.tables-visual {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem
}

.table-visual {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.2rem;
    transition: var(--transition);
}

.table-visual:hover {
    border-color: var(--primary)
}

.table-visual-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: .75rem
}

.table-visual-name {
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 600
}

.table-visual-count {
    font-size: .78rem;
    color: var(--text-muted)
}

.seats-grid {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem
}

.seat {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: calc(50% - .2rem);
    padding: .45rem .55rem;
    border-radius: var(--radius-sm);
    font-size: .8rem;
    transition: var(--transition);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.seat.empty {
    background: var(--surface);
    border: 1.5px dashed var(--border);
    color: var(--text-muted);
}

.seat.empty:hover {
    border-color: var(--primary);
    background: rgba(232, 160, 191, 0.06);
    color: var(--text)
}

.seat.occupied {
    background: linear-gradient(135deg, rgba(232, 160, 191, 0.12), rgba(196, 181, 253, 0.1));
    border: 1.5px solid rgba(232, 160, 191, 0.3);
    color: var(--text);
}

.seat.occupied:hover {
    border-color: var(--primary);
    background: linear-gradient(135deg, rgba(232, 160, 191, 0.2), rgba(196, 181, 253, 0.15))
}

.seat.warning {
    border-color: var(--warning) !important;
    box-shadow: 0 0 8px rgba(251, 191, 36, 0.2)
}



/* ===== LINKS TAB ===== */
.link-form-card {
    margin-bottom: 1rem
}

.link-form-card .form-row {
    align-items: center
}

.link-heart {
    font-size: 1.5rem;
    padding-bottom: .0rem
}

.links-list {
    display: flex;
    flex-direction: column;
    gap: .6rem
}

.link-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .8rem 1rem;
    transition: var(--transition);
}

.link-card:hover {
    border-color: var(--primary)
}

.link-card-info {
    display: flex;
    align-items: center;
    gap: .6rem;
    font-size: .9rem
}

.link-card-info .heart {
    color: var(--primary);
    font-size: 1.1rem
}

.link-status {
    font-size: .75rem;
    padding: .2rem .5rem;
    border-radius: 20px;
    font-weight: 500
}

.link-status.ok {
    background: rgba(110, 231, 183, 0.12);
    color: var(--success)
}

.link-status.warn {
    background: var(--warning-bg);
    color: var(--warning)
}

.link-status.unassigned {
    background: rgba(167, 165, 198, 0.12);
    color: var(--text-muted)
}

/* ===== WARNINGS ===== */
.warning-banner {
    background: var(--warning-bg);
    border: 1px solid rgba(251, 191, 36, 0.3);
    border-radius: var(--radius);
    padding: .8rem 1rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: flex-start;
    gap: .6rem;
    font-size: .85rem;
    color: var(--warning);
    animation: fadeIn .3s ease;
}

.warning-banner .warn-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
    margin-top: .1rem
}

/* ===== EXPORT TAB ===== */
.export-actions {
    display: flex;
    gap: .6rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap
}

.export-preview {
    white-space: pre-wrap;
    font-size: .85rem;
    line-height: 1.7;
    color: var(--text-muted);
    max-height: 60vh;
    overflow-y: auto
}

.export-preview h3 {
    color: var(--text);
    font-family: var(--font-display);
    font-size: 1.1rem;
    margin: 1rem 0 .4rem
}

.export-preview h3:first-child {
    margin-top: 0
}

.export-preview .guest-line {
    color: var(--text);
    padding: .15rem 0
}

.export-preview .empty-line {
    color: var(--text-muted);
    font-style: italic
}

.export-preview .couple-icon {
    color: var(--primary)
}

/* ===== MODAL ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn .2s ease;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0;
    width: 90%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
    animation: slideUp .25s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0
    }

    to {
        transform: translateY(0);
        opacity: 1
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-family: var(--font-display);
    font-size: 1.1rem
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    padding: .2rem
}

.modal-close:hover {
    color: var(--text)
}

.modal-body {
    padding: 1rem 1.25rem;
    max-height: 50vh;
    overflow-y: auto
}

.modal-body .modal-guest {
    padding: .5rem .65rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    font-size: .88rem;
    margin-bottom: .3rem;
}

.modal-body .modal-guest:hover {
    background: var(--surface);
    color: var(--primary)
}

/* ===== TOAST ===== */
#toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: .4rem
}

.toast {
    padding: .65rem 1rem;
    border-radius: var(--radius-sm);
    font-size: .83rem;
    font-weight: 500;
    box-shadow: var(--shadow);
    animation: toastIn .3s ease;
    max-width: 320px;
}

@keyframes toastIn {
    from {
        transform: translateX(40px);
        opacity: 0
    }

    to {
        transform: translateX(0);
        opacity: 1
    }
}

.toast.success {
    background: #065f46;
    color: var(--success);
    border: 1px solid rgba(110, 231, 183, 0.3)
}

.toast.error {
    background: #7f1d1d;
    color: var(--danger);
    border: 1px solid rgba(248, 113, 113, 0.3)
}

.toast.info {
    background: #1e1b4b;
    color: var(--accent2);
    border: 1px solid rgba(196, 181, 253, 0.3)
}

/* ===== PRINT — Romantic & Fancy ===== */
@media print {

    /* Reset everything */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important
    }

    body {
        background: #fff !important;
        color: #3d2b1f !important;
        font-family: 'Playfair Display', Georgia, 'Times New Roman', serif !important;
        font-size: 11pt;
        line-height: 1.7;
    }

    /* Hide app chrome */
    .tabs,
    .guest-controls,
    .add-form,
    .export-actions,
    .unseated-panel,
    .bg-decoration,
    #toast-container,
    .modal-overlay,
    .section-header {
        display: none !important;
    }

    .tab-content {
        display: none !important
    }

    #content-export {
        display: block !important
    }

    /* Print header — show a romantic title */
    header {
        display: block !important;
        background: none !important;
        padding: 0.5cm 0 0.3cm !important;
        border-bottom: none !important;
        text-align: center;
    }

    .logo-icon {
        animation: none !important;
        font-size: 2.2rem
    }

    header h1 {
        font-family: 'Playfair Display', Georgia, serif !important;
        font-size: 28pt !important;
        font-weight: 700 !important;
        color: #8b4062 !important;
        -webkit-text-fill-color: #8b4062 !important;
        background: none !important;
        letter-spacing: .05em;
    }

    .tagline {
        color: #a06070 !important;
        font-family: 'Playfair Display', Georgia, serif !important;
        font-size: 11pt !important;
        font-style: italic;
        margin-top: .1cm;
    }

    /* Decorative line under header */
    header::after {
        content: '~ ✿ ❤ ✿ ~';
        display: block;
        text-align: center;
        font-size: 14pt;
        color: #d4a0b0;
        margin-top: .25cm;
        letter-spacing: .4em;
    }

    /* Main container */
    main {
        max-width: none !important;
        padding: 0 1cm !important;
    }

    /* Export preview card */
    .export-preview {
        color: #3d2b1f !important;
        max-height: none !important;
        border: none !important;
        box-shadow: none !important;
        background: none !important;
        padding: 0 !important;
        columns: 2;
        column-gap: 1cm;
    }

    /* Each table block — fancy card */
    .export-preview h3 {
        color: #8b4062 !important;
        font-family: 'Playfair Display', Georgia, serif !important;
        font-size: 13pt !important;
        font-weight: 600;
        margin: 0 0 .15cm 0 !important;
        padding: .25cm .4cm .15cm;
        border-top: 2px solid #d4a0b0;
        border-bottom: 1px solid #e8c8d4;
        break-inside: avoid;
        break-after: avoid;
        position: relative;
        text-align: center;
        letter-spacing: .03em;
    }

    /* Ornamental flourish before table name */
    .export-preview h3::before {
        content: '❦ ';
        color: #d4a0b0;
    }

    .export-preview h3::after {
        content: ' ❦';
        color: #d4a0b0;
    }

    /* Guest lines */
    .export-preview .guest-line {
        color: #3d2b1f !important;
        padding: .06cm .4cm !important;
        font-size: 10pt;
        border-bottom: 1px dotted #e0d0d8;
        break-inside: avoid;
        font-family: 'Inter', 'Segoe UI', sans-serif;
    }

    .export-preview .guest-line:last-of-type {
        margin-bottom: .4cm;
    }

    .export-preview .empty-line {
        color: #b8a0a8 !important;
        padding: .06cm .4cm !important;
        font-size: 9.5pt;
        font-style: italic;
        border-bottom: 1px dotted #ece0e4;
        break-inside: avoid;
        font-family: 'Inter', 'Segoe UI', sans-serif;
    }

    .export-preview .couple-icon {
        color: #c4607e !important;
    }

    /* Footer flourish on printed page */
    main::after {
        content: '~ With Love ~  ❤';
        display: block;
        text-align: center;
        font-family: 'Playfair Display', Georgia, serif;
        font-size: 12pt;
        font-style: italic;
        color: #b8889a;
        margin-top: .6cm;
        padding-top: .4cm;
        border-top: 1px solid #e0d0d8;
        letter-spacing: .08em;
    }

    /* Page margins */
    @page {
        size: A4;
        margin: 1.5cm 1cm;
    }
}

/* ===== RESPONSIVE ===== */
@media(max-width:600px) {
    header h1 {
        font-size: 1.6rem
    }

    .tab-label {
        font-size: .75rem
    }

    .form-row {
        flex-direction: column;
        align-items: stretch
    }

    .form-row .btn {
        width: 100%;
        justify-content: center
    }

    .tables-grid {
        grid-template-columns: 1fr
    }

    .tables-visual {
        grid-template-columns: 1fr
    }

    .link-form-card .form-row {
        flex-direction: column
    }

    .link-heart {
        align-self: center
    }
}