/* ================================================================
   CampSuite Global Styles
   Grandma-first: large text, generous touch targets, high contrast
   ================================================================ */

/* Base font: 16px everywhere — never smaller than the browser default */
html {
    font-size: 16px;
}

@media (min-width: 768px) {
    html {
        font-size: 16px;
    }
}

html {
    position: relative;
    min-height: 100%;
}

body {
    margin-bottom: 60px;
    -webkit-text-size-adjust: 100%;
    /* Brand typeface — large, friendly, highly legible for every age.
       Falls back to the system stack until DM Sans has loaded. */
    font-family: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI",
        Roboto, Helvetica, Arial, sans-serif;
    font-feature-settings: "ss01" on, "cv11" on;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    letter-spacing: -0.003em;
}

/* Headings: slightly tighter tracking reads more "designed" without
   hurting legibility. Weights stay bold so hierarchy is obvious. */
h1, h2, h3, h4 {
    letter-spacing: -0.018em;
}

/* ── Focus styles ── visible, high-contrast ring for keyboard users.
   Brand green so it matches the rest of the UI. */
:focus-visible {
    outline: 3px solid #1f7049;
    outline-offset: 2px;
}

/* ── Form inputs ── bigger touch targets, clearer text */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="url"],
input[type="number"],
input[type="password"],
input[type="date"],
input[type="time"],
input[type="search"],
select,
textarea {
    font-size: 1rem;
    min-height: 48px;
}

@media (min-width: 768px) {
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="url"],
    input[type="number"],
    input[type="password"],
    input[type="date"],
    input[type="time"],
    input[type="search"],
    select,
    textarea {
        min-height: 44px;
    }
}

/* ── Checkboxes & radio buttons ── larger touch targets */
input[type="checkbox"],
input[type="radio"] {
    min-width: 20px;
    min-height: 20px;
}

/* ── Buttons ── generous touch targets (44px minimum on mobile) */
button,
[type="submit"],
a.inline-flex {
    min-height: 44px;
}

/* ── Smooth transitions for interactive elements ── */
input, select, textarea, button, a {
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

/* ── Mobile drawer animation ── */
#cs-mobile {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    -webkit-overflow-scrolling: touch;
}

#cs-mobile.cs-open {
    transform: translateX(0);
}

#cs-overlay {
    opacity: 0;
    transition: opacity 0.25s ease;
}

#cs-overlay.cs-open {
    opacity: 1;
}

/* ── Table responsive helpers ── */
@media (max-width: 767px) {
    .cs-table-desktop {
        display: none !important;
    }
}

@media (min-width: 768px) {
    .cs-table-mobile {
        display: none !important;
    }
}

/* ── Validation messages ── make errors prominent and readable */
.field-validation-error {
    font-size: 0.9375rem;
    font-weight: 500;
}

/* Hide the validation summary container when there are no errors */
.validation-summary-valid {
    display: none;
}

/* ── Contact search results dropdown ── */
.cs-search-results {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    background: #fff;
    border: 1.5px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
    z-index: 110;
    max-height: 220px;
    overflow-y: auto;
    margin-top: 4px;
}

.cs-search-results.cs-visible {
    display: block;
}

.cs-search-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid #f8fafc;
    transition: background 0.1s;
}

.cs-search-item:hover {
    background: #f0fdf4;
}

.cs-search-item:last-child {
    border-bottom: none;
}

.cs-search-item-name {
    font-weight: 600;
    font-size: 0.9375rem;
    color: #0f172a;
}

.cs-search-item-detail {
    font-size: 0.8125rem;
    color: #64748b;
    margin-top: 2px;
}

/* ── Match banner (duplicate detection) ── */
.cs-match-banner {
    display: none;
    padding: 12px 16px;
    border-radius: 12px;
    background: #eff6ff;
    border: 1.5px solid #bfdbfe;
    margin-top: 12px;
    font-size: 0.875rem;
    align-items: center;
    gap: 10px;
}

.cs-match-banner.cs-visible {
    display: flex;
}

.cs-match-banner-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: #2563eb;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9375rem;
    flex-shrink: 0;
}

.cs-match-banner-info {
    flex: 1;
    min-width: 0;
}

.cs-match-banner-name {
    font-weight: 700;
    color: #1e40af;
}

.cs-match-banner-detail {
    font-size: 0.8125rem;
    color: #3b82f6;
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cs-match-use {
    padding: 6px 14px;
    border-radius: 10px;
    border: none;
    background: #2563eb;
    color: #fff;
    font-size: 0.8125rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    min-height: 36px;
}

.cs-match-use:hover {
    background: #1d4ed8;
}

/* ── Linked guest banner ── */
.cs-linked-guest {
    display: none;
    padding: 12px 16px;
    border-radius: 12px;
    background: #f0fdf4;
    border: 1.5px solid #bbf7d0;
    font-size: 0.875rem;
    align-items: center;
    gap: 10px;
}

.cs-linked-guest.cs-visible {
    display: flex;
}

.cs-linked-guest-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: #059669;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
    flex-shrink: 0;
}

.cs-linked-guest-info {
    flex: 1;
}

.cs-linked-guest-name {
    font-weight: 700;
    color: #065f46;
}

.cs-linked-guest-detail {
    font-size: 0.8125rem;
    color: #059669;
    margin-top: 2px;
}

.cs-linked-clear {
    padding: 6px 14px;
    border-radius: 10px;
    border: 1.5px solid #bbf7d0;
    background: #fff;
    color: #059669;
    font-size: 0.8125rem;
    font-weight: 700;
    cursor: pointer;
    min-height: 36px;
}

.cs-linked-clear:hover {
    background: #f0fdf4;
}

/* ── Stepper (+ / - buttons for party size) ── */
.cs-stepper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    border: 1.5px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
}

.cs-stepper-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: #f8fafc;
    border: none;
    cursor: pointer;
    color: #475569;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}

.cs-stepper-btn:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.cs-stepper-btn:active {
    background: #cbd5e1;
}

.cs-stepper-value {
    width: 48px !important;
    min-height: 48px !important;
    text-align: center;
    font-size: 1.125rem;
    font-weight: 700;
    color: #0f172a;
    border: none !important;
    border-left: 1.5px solid #e2e8f0 !important;
    border-right: 1.5px solid #e2e8f0 !important;
    border-radius: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
    background: #fff;
    -moz-appearance: textfield;
}

.cs-stepper-value::-webkit-inner-spin-button,
.cs-stepper-value::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* ── iOS Safari modal fixes ──
   On iOS, position:fixed + keyboard causes viewport issues.
   Using overflow-y:auto on the overlay with overscroll-contain
   lets the modal scroll naturally when the keyboard opens. */
@supports (-webkit-touch-callout: none) {
    .fixed.overflow-y-auto {
        -webkit-overflow-scrolling: touch;
    }
}

/* ── Pricing table mobile layout ── */
@media (max-width: 767px) {
    .cs-pricing-table {
        display: block;
    }

    .cs-pricing-table thead {
        display: none;
    }

    .cs-pricing-table tbody {
        display: flex;
        flex-direction: column;
        gap: 1rem;
    }

    .cs-pricing-table tr {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 0.5rem;
        padding: 0.75rem;
        border: 1px solid #e2e8f0;
        border-radius: 0.75rem;
        background: #fff;
    }

    .cs-pricing-table td:first-child {
        flex: 0 0 100%;
        padding: 0;
        font-weight: 600;
        font-size: 0.9375rem;
        margin-bottom: 0.25rem;
    }

    .cs-pricing-table td {
        flex: 1 1 0;
        min-width: 0;
        padding: 0;
    }

    .cs-pricing-table td input {
        width: 100% !important;
    }

    .cs-pricing-season-label {
        display: block;
        font-size: 0.75rem;
        font-weight: 500;
        color: #64748b;
        margin-bottom: 2px;
    }
}

@media (min-width: 768px) {
    .cs-pricing-season-label {
        display: none;
    }
}

/* ─── Audience toggle (Settings → Extras) ─────────────────────────
   Three big tappable cards for "where should we show this extra".
   Visual checkbox: the native input is hidden but still receives focus,
   and the card lifts + paints emerald when the box is ticked.
   ──────────────────────────────────────────────────────────────── */
.audience-toggle {
    position: relative;
    display: block;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.audience-toggle-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 0;
    height: 0;
}

.audience-toggle-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 16px 14px;
    border-radius: 14px;
    border: 2px solid #e2e8f0;
    background: #ffffff;
    transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease, transform 120ms ease;
    height: 100%;
}

.audience-toggle:hover .audience-toggle-card {
    border-color: #94a3b8;
    background: #f8fafc;
}

.audience-toggle-input:focus-visible + .audience-toggle-card {
    outline: 3px solid #059669;
    outline-offset: 2px;
}

.audience-toggle-input:checked + .audience-toggle-card {
    border-color: #059669;
    background: linear-gradient(180deg, #ecfdf5 0%, #ffffff 100%);
    box-shadow: 0 1px 0 #a7f3d0, 0 6px 16px rgba(5, 150, 105, 0.12);
    transform: translateY(-1px);
}

.audience-toggle-input:checked + .audience-toggle-card::after {
    content: "✓";
    position: absolute;
    top: 10px;
    right: 12px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #059669;
    color: #ffffff;
    font-weight: 800;
    font-size: 14px;
    line-height: 26px;
    text-align: center;
    box-shadow: 0 2px 6px rgba(5, 150, 105, 0.35);
}

.audience-toggle-emoji {
    font-size: 28px;
    line-height: 1;
    margin-bottom: 2px;
}

.audience-toggle-title {
    font-size: 16px;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.25;
}

.audience-toggle-sub {
    font-size: 13px;
    color: #64748b;
    line-height: 1.35;
}

/* ──────────────────────────────────────────────────────────────
   Rich HTML email editor (Quill) — styled to match the Tailwind UI
   ────────────────────────────────────────────────────────────── */
.cs-editor-wrap .ql-toolbar.ql-snow {
    border: 1px solid #cbd5e1;
    border-bottom: none;
    border-radius: 0.75rem 0.75rem 0 0;
    background: #f8fafc;
    padding: 8px;
}

.cs-editor-wrap .ql-container.ql-snow {
    border: 1px solid #cbd5e1;
    border-radius: 0 0 0.75rem 0.75rem;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    font-size: 16px;
    background: #ffffff;
}

.cs-editor-wrap .ql-editor {
    min-height: 240px;
    line-height: 1.6;
    color: #0f172a;
}

.cs-editor-wrap .ql-editor.ql-blank::before {
    color: #94a3b8;
    font-style: normal;
}

/* Green focus ring to match the rest of the app. */
.cs-editor-wrap:focus-within .ql-toolbar.ql-snow,
.cs-editor-wrap:focus-within .ql-container.ql-snow {
    border-color: #10b981;
}

/* Friendly blockquote = the "info card" used in templates. */
.cs-editor-wrap .ql-editor blockquote {
    border-left: 4px solid #2d6a4f;
    background: #f8fafc;
    border-radius: 8px;
    padding: 12px 16px;
    margin: 0 0 12px;
    color: #334155;
}

/* Raw HTML source view. */
.cs-html-source {
    width: 100%;
    min-height: 280px;
    border: 1px solid #cbd5e1;
    border-radius: 0.75rem;
    padding: 12px 14px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
    line-height: 1.55;
    color: #0f172a;
    background: #ffffff;
}

.cs-html-source:focus {
    outline: none;
    border-color: #10b981;
    box-shadow: 0 0 0 1px #10b981;
}

.cs-source-toggle.cs-source-active {
    background: #ecfdf5;
    border-color: #10b981;
    color: #047857;
}

/* Attachment chips (selected files on the send / template forms). */
.cs-attachment-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
    border-radius: 9999px;
    padding: 4px 12px;
    font-size: 13px;
    font-weight: 500;
}

/* ════════════════════════════════════════════════════════════════
   CampSuite Design System — reusable components
   ----------------------------------------------------------------
   The single source of truth for buttons, inputs, cards, page
   headers and the Save/action bar. Use these class names on new and
   updated screens so every page looks and behaves the same way.
   See DESIGN.md for the full pattern guide.
   ════════════════════════════════════════════════════════════════ */

/* ── Buttons ─────────────────────────────────────────────────────
   .cs-btn is the base; add a variant. Big tap targets, clear focus. */
.cs-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 48px;
    padding: 0.75rem 1.5rem;
    border-radius: 0.875rem;            /* 14px — soft, modern */
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.2;
    border: 1.5px solid transparent;
    cursor: pointer;
    text-align: center;
    transition: background-color .15s ease, border-color .15s ease,
                box-shadow .15s ease, transform .08s ease;
    -webkit-tap-highlight-color: transparent;
}

.cs-btn:active { transform: translateY(1px); }

.cs-btn:focus-visible {
    outline: 3px solid #1f7049;
    outline-offset: 2px;
}

/* Primary = the main "do it" action (Save, Confirm). Warm espresso-black,
   pairs with the forest-green brand and reads as premium + decisive. */
.cs-btn-primary {
    background: #1b1813;
    color: #fff;
    box-shadow: 0 1px 2px rgba(28, 26, 22, .12);
}
.cs-btn-primary:hover { background: #2a2722; }

/* Brand = positive / booking-led CTAs in the forest green. */
.cs-btn-brand {
    background: #1f7049;
    color: #fff;
    box-shadow: 0 1px 2px rgba(20, 59, 42, .18);
}
.cs-btn-brand:hover { background: #1a5a3c; }

/* Secondary = cancel / back / low-emphasis. */
.cs-btn-secondary {
    background: #fff;
    color: #423d35;
    border-color: #d6d0c4;
    box-shadow: 0 1px 2px rgba(28, 26, 22, .04);
}
.cs-btn-secondary:hover { background: #faf9f6; border-color: #a8a092; }

/* Danger = destructive (Delete). Quiet until hovered. */
.cs-btn-danger {
    background: #fff;
    color: #b42318;
    border-color: #f4c9c4;
}
.cs-btn-danger:hover { background: #fef3f2; border-color: #e8a59d; }

.cs-btn-block { width: 100%; }

/* ── Form fields ─────────────────────────────────────────────────
   .cs-input works for input / select / textarea. */
.cs-input {
    width: 100%;
    border-radius: 0.875rem;
    border: 1.5px solid #d6d0c4;
    background: #fff;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    color: #1b1813;
    box-shadow: 0 1px 2px rgba(28, 26, 22, .04);
    transition: border-color .15s ease, box-shadow .15s ease;
}
.cs-input::placeholder { color: #a8a092; }
.cs-input:focus {
    outline: none;
    border-color: #1f7049;
    box-shadow: 0 0 0 4px rgba(31, 112, 73, .15);
}

.cs-label {
    display: block;
    font-size: 1rem;
    font-weight: 600;
    color: #2a2722;
    margin-bottom: 0.375rem;
}
.cs-hint { font-size: 0.875rem; color: #797163; margin-top: 0.375rem; }

/* ── Cards ───────────────────────────────────────────────────────
   The standard container for content & form sections. */
.cs-card {
    border-radius: 1rem;                /* 16px */
    border: 1px solid #e8e4db;
    background: #fff;
    box-shadow: 0 1px 3px rgba(28, 26, 22, .05);
    overflow: hidden;
}
.cs-card-header {
    border-bottom: 1px solid #f3f1ec;
    background: linear-gradient(180deg, #faf9f6 0%, #fff 100%);
    padding: 1rem 1.25rem;
}
.cs-card-title { font-size: 1.125rem; font-weight: 700; color: #1b1813; }
.cs-card-sub   { font-size: 0.9375rem; color: #797163; margin-top: 0.125rem; }
.cs-card-body  { padding: 1.25rem; }

/* Interactive cards (list rows that link somewhere) lift on hover. */
.cs-card-link { transition: border-color .15s ease, box-shadow .15s ease, transform .12s ease; }
.cs-card-link:hover {
    border-color: #d6d0c4;
    box-shadow: 0 10px 24px -10px rgba(28, 26, 22, .18);
    transform: translateY(-1px);
}

/* ── Page header ─────────────────────────────────────────────────
   Consistent title block at the top of every screen. */
.cs-page-header {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}
@media (min-width: 640px) {
    .cs-page-header {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
}
.cs-page-title { font-size: 1.75rem; font-weight: 700; color: #1b1813; line-height: 1.15; }
.cs-page-sub   { margin-top: 0.25rem; color: #575147; }

/* ── Action bar ──────────────────────────────────────────────────
   THE home for Save / Cancel on every form.
   Desktop: right-aligned footer (primary on the right).
   Mobile : sticks to the bottom of the screen so Save is always
            reachable with a thumb — no hunting, grandma-proof. */
.cs-actionbar {
    display: flex;
    flex-direction: column-reverse;
    gap: 0.75rem;
    margin-top: 1.5rem;
}
.cs-actionbar .cs-btn { width: 100%; }

@media (min-width: 640px) {
    .cs-actionbar {
        flex-direction: row;
        align-items: center;
        justify-content: flex-end;
        gap: 0.75rem;
    }
    .cs-actionbar .cs-btn { width: auto; }
    /* When there's a destructive action it sits far left, away from Save. */
    .cs-actionbar .cs-actionbar-spacer { margin-right: auto; }
}

/* On small screens, pin the action bar to the bottom so the primary
   action is always one thumb-tap away. Opt in with .cs-actionbar-sticky. */
@media (max-width: 639px) {
    .cs-actionbar-sticky {
        position: sticky;
        bottom: 0;
        z-index: 20;
        margin-top: 1.5rem;
        margin-left: -1rem;
        margin-right: -1rem;
        padding: 0.875rem 1rem calc(0.875rem + env(safe-area-inset-bottom));
        background: rgba(250, 249, 246, .92);
        backdrop-filter: blur(8px);
        border-top: 1px solid #e8e4db;
    }
}

/* ── Status pills / badges ───────────────────────────────────────── */
.cs-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1.2;
}
.cs-badge-brand   { background: #eef7f1; color: #1a5a3c; }
.cs-badge-neutral { background: #f3f1ec; color: #575147; }
.cs-badge-amber   { background: #fef3c7; color: #92600a; }
.cs-badge-rose    { background: #fee2e2; color: #b42318; }

/* ════════════════════════════════════════════════════════════════
   App chrome polish — sidebar, header, nav
   ════════════════════════════════════════════════════════════════ */

/* Warm, subtle paper backdrop behind the whole app. */
body.cs-app {
    background:
        radial-gradient(1200px 600px at 100% -5%, rgba(31, 112, 73, .05), transparent 60%),
        #f6f4ef;
}

/* Sidebar gets a hairline brand edge + soft depth so it feels intentional. */
.cs-sidebar {
    background: #fff;
    border-right: 1px solid #e8e4db;
    box-shadow: 1px 0 0 rgba(28, 26, 22, .02);
}

/* Sticky header lifts a touch once you scroll. */
.cs-header {
    background: rgba(255, 255, 255, .85);
    backdrop-filter: saturate(160%) blur(10px);
    border-bottom: 1px solid #e8e4db;
}

/* Active nav item: brand tint + a left accent bar so the current
   section is unmistakable (helps non-tech users stay oriented). */
.cs-nav-link {
    position: relative;
    transition: background-color .15s ease, color .15s ease;
}
.cs-nav-link-active::before {
    content: "";
    position: absolute;
    left: -0.75rem;
    top: 0.5rem;
    bottom: 0.5rem;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: #1f7049;
}

/* ── Print: strip the app chrome so reports & invoices print clean ── */
@media print {
    aside,
    header,
    #cs-overlay,
    #cs-mobile,
    .no-print {
        display: none !important;
    }

    body { background: #ffffff !important; }
    main, #main { padding: 0 !important; }
    .print-full { max-width: none !important; }
    a[href]:after { content: ""; } /* don't append URLs */
}
