/* ================================================
   Custom Checkbox – Reusable across all templates
   Usage: <label class="custom-checkbox">
            <input type="checkbox" ...>
            <span class="checkmark"></span>
          </label>
   ================================================ */
.custom-checkbox {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

.custom-checkbox input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
    background: transparent;
    -webkit-appearance: none;
    appearance: none;
}

.custom-checkbox .checkmark {
    position: relative;
    height: 18px;
    width: 18px;
    background-color: #f9fafb;
    border: 2px solid #d1d5db;
    border-radius: 5px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.custom-checkbox .checkmark:hover {
    border-color: #93c5fd;
}

.dark .custom-checkbox .checkmark {
    background-color: transparent;
    border-color: #6b7280;
}

.dark .custom-checkbox .checkmark:hover {
    border-color: #60a5fa;
}

/* Checkmark tick */
.custom-checkbox .checkmark::after {
    content: '';
    width: 5px;
    height: 9px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg) scale(0);
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    margin-top: -1px;
}

/* Checked state */
.custom-checkbox input:checked ~ .checkmark {
    background-color: #2563eb;
    border-color: #2563eb;
}

.dark .custom-checkbox input:checked ~ .checkmark {
    background-color: #3b82f6;
    border-color: #3b82f6;
}

.custom-checkbox input:checked ~ .checkmark::after {
    transform: rotate(45deg) scale(1);
}

/* Indeterminate state (select-all partial) */
.custom-checkbox input:indeterminate ~ .checkmark {
    background-color: #2563eb;
    border-color: #2563eb;
}

.dark .custom-checkbox input:indeterminate ~ .checkmark {
    background-color: #3b82f6;
    border-color: #3b82f6;
}

.custom-checkbox input:indeterminate ~ .checkmark::after {
    width: 8px;
    height: 0;
    border-width: 0 0 2px 0;
    transform: rotate(0deg) scale(1);
    margin-top: 0;
}

@media (prefers-color-scheme: dark) {
    .custom-checkbox .checkmark {
        background-color: #374151;
        border-color: #4b5563;
    }
}

/* Larger touch target variant for mobile */
.custom-checkbox-lg .checkmark {
    height: 22px;
    width: 22px;
    border-radius: 6px;
}

.custom-checkbox-lg .checkmark::after {
    width: 6px;
    height: 11px;
}

.custom-checkbox-lg input:indeterminate ~ .checkmark::after {
    width: 10px;
}

/* Legacy alias – keeps existing invitations working */
.inv-custom-checkbox {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

.inv-custom-checkbox input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
    background: transparent;
    -webkit-appearance: none;
    appearance: none;
}

.inv-custom-checkbox .inv-checkmark {
    position: relative;
    height: 18px;
    width: 18px;
    background-color: #f9fafb;
    border: 2px solid #d1d5db;
    border-radius: 5px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.inv-custom-checkbox .inv-checkmark:hover {
    border-color: #93c5fd;
}

.dark .inv-custom-checkbox .inv-checkmark {
    background-color: transparent;
    border-color: #6b7280;
}

.dark .inv-custom-checkbox .inv-checkmark:hover {
    border-color: #60a5fa;
}

.inv-custom-checkbox .inv-checkmark::after {
    content: '';
    width: 5px;
    height: 9px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg) scale(0);
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    margin-top: -1px;
}

.inv-custom-checkbox input:checked ~ .inv-checkmark {
    background-color: #2563eb;
    border-color: #2563eb;
}

.dark .inv-custom-checkbox input:checked ~ .inv-checkmark {
    background-color: #3b82f6;
    border-color: #3b82f6;
}

.inv-custom-checkbox input:checked ~ .inv-checkmark::after {
    transform: rotate(45deg) scale(1);
}

.inv-custom-checkbox input:indeterminate ~ .inv-checkmark {
    background-color: #2563eb;
    border-color: #2563eb;
}

.dark .inv-custom-checkbox input:indeterminate ~ .inv-checkmark {
    background-color: #3b82f6;
    border-color: #3b82f6;
}

.inv-custom-checkbox input:indeterminate ~ .inv-checkmark::after {
    width: 8px;
    height: 0;
    border-width: 0 0 2px 0;
    transform: rotate(0deg) scale(1);
    margin-top: 0;
}

@media (prefers-color-scheme: dark) {
    .inv-custom-checkbox .inv-checkmark {
        background-color: #374151;
        border-color: #4b5563;
    }
}

/* ================================================
   Stepper Form – Multi-step wizard for modals
   ================================================ */

/* Blur backdrop for modals */
.modal-blur-backdrop {
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    background: rgba(15, 23, 42, 0.4);
}

/* Step indicator */
.stepper-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 0 0.5rem;
}

.stepper-step {
    display: flex;
    align-items: center;
    gap: 0;
}

.stepper-dot {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 600;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 1;
    flex-shrink: 0;
}

.stepper-dot.inactive {
    background: #f1f5f9;
    color: #94a3b8;
    border: 2px solid #e2e8f0;
}

.stepper-dot.active {
    background: linear-gradient(135deg, #3b82f6, #60a5fa);
    color: white;
    border: 2px solid transparent;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15), 0 4px 12px rgba(59, 130, 246, 0.25);
    transform: scale(1.1);
}

.stepper-dot.completed {
    background: linear-gradient(135deg, #10b981, #34d399);
    color: white;
    border: 2px solid transparent;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.2);
}

.stepper-line {
    width: 40px;
    height: 2px;
    background: #e2e8f0;
    transition: background 0.35s ease;
    flex-shrink: 0;
}

.stepper-line.completed {
    background: linear-gradient(90deg, #10b981, #34d399);
}

.stepper-label {
    display: none;
}

@media (min-width: 640px) {
    .stepper-dot {
        width: 36px;
        height: 36px;
        font-size: 0.8rem;
    }
    .stepper-line {
        width: 56px;
    }
    .stepper-label {
        display: block;
        position: absolute;
        top: calc(100% + 6px);
        left: 50%;
        transform: translateX(-50%);
        font-size: 0.65rem;
        font-weight: 500;
        white-space: nowrap;
        color: #94a3b8;
        transition: color 0.3s ease;
    }
    .stepper-dot.active .stepper-label {
        color: #3b82f6;
        font-weight: 600;
    }
    .stepper-dot.completed .stepper-label {
        color: #10b981;
    }
}

/* Step content panels */
.stepper-panel {
    display: none;
    opacity: 0;
    transform: translateX(12px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.stepper-panel.active {
    display: block;
    opacity: 1;
    transform: translateX(0);
}

/* Soft input styling */
.soft-input {
    background: #f8fafc;
    border: 1.5px solid #e2e8f0;
    border-radius: 0.75rem;
    padding: 0.5rem 0.875rem;
    font-size: 0.875rem;
    color: #1e293b;
    transition: all 0.25s ease;
    outline: none;
    width: 100%;
}

.soft-input:focus {
    border-color: #93c5fd;
    background: white;
    box-shadow: 0 0 0 3px rgba(147, 197, 253, 0.25);
}

.soft-input::placeholder {
    color: #94a3b8;
}

textarea.soft-input {
    resize: none;
}

select.soft-input {
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.5rem;
}

select[multiple].soft-input {
    background-image: none;
    padding-right: 0.75rem;
}

/* Soft label */
.soft-label {
    display: block;
    margin-bottom: 0.375rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #475569;
}

.soft-label .optional {
    color: #94a3b8;
    font-weight: 400;
    font-size: 0.75rem;
}

/* Soft section heading */
.soft-section-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: #334155;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.soft-section-title .icon {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Step navigation buttons */
.stepper-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 1.25rem;
    font-size: 0.8125rem;
    font-weight: 500;
    border-radius: 0.75rem;
    transition: all 0.25s ease;
    cursor: pointer;
    border: none;
}

.stepper-btn-back {
    background: #f1f5f9;
    color: #64748b;
}

.stepper-btn-back:hover {
    background: #e2e8f0;
    color: #475569;
}

.stepper-btn-next {
    background: linear-gradient(135deg, #3b82f6, #60a5fa);
    color: white;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.stepper-btn-next:hover {
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.4);
    transform: translateY(-1px);
}

.stepper-btn-submit {
    background: linear-gradient(135deg, #10b981, #34d399);
    color: white;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.stepper-btn-submit:hover {
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.4);
    transform: translateY(-1px);
}

/* Personalization toggle chips */
.toggle-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.875rem;
    border-radius: 9999px;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s ease;
    border: 1.5px solid #e2e8f0;
    background: #f8fafc;
    color: #64748b;
    user-select: none;
}

.toggle-chip:hover {
    border-color: #93c5fd;
    background: #eff6ff;
}

.toggle-chip.checked {
    background: linear-gradient(135deg, #eff6ff, #dbeafe);
    border-color: #93c5fd;
    color: #1d4ed8;
}

.toggle-chip input[type="checkbox"] {
    display: none;
}

/* Preview card */
.preview-bubble {
    background: linear-gradient(135deg, #f0fdf4, #ecfdf5);
    border: 1px solid #bbf7d0;
    border-radius: 1rem;
    padding: 1rem;
    position: relative;
}

.preview-bubble::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 1.5rem;
    width: 12px;
    height: 12px;
    background: #f0fdf4;
    border-left: 1px solid #bbf7d0;
    border-top: 1px solid #bbf7d0;
    transform: rotate(45deg);
}

/* Reminder card enhanced */
.reminder-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 1rem;
    padding: 1.125rem 1.25rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
    border-left: 3px solid transparent;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.reminder-card:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.07), 0 2px 8px rgba(0, 0, 0, 0.04);
    border-color: #cbd5e1;
    border-left-color: #3b82f6;
    transform: translateY(-1px);
    z-index: 2;
}

.reminder-card.has-open-menu {
    z-index: 30;
}

.reminder-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: #64748b;
    background: #f8fafc;
    padding: 0.3125rem 0.75rem;
    border-radius: 2rem;
    border: 1px solid #e2e8f0;
    transition: all 0.2s ease;
}

.reminder-tag svg {
    width: 14px;
    height: 14px;
    color: #94a3b8;
}

.reminder-tag.sent {
    background: linear-gradient(135deg, #f0fdf4, #ecfdf5);
    border-color: #bbf7d0;
    color: #16a34a;
}

/* ---- Dark mode support for stepper ---- */

.dark .stepper-dot.inactive {
    background: #1e293b;
    color: #64748b;
    border-color: #334155;
}

.dark .stepper-line {
    background: #334155;
}

.dark .stepper-dot.active .stepper-label {
    color: #60a5fa;
}

.dark .stepper-dot.completed .stepper-label {
    color: #34d399;
}

.dark .stepper-label {
    color: #64748b;
}

.dark .soft-input {
    background-color: #1e293b;
    border-color: #334155;
    color: #e2e8f0;
}

.dark .soft-input:focus {
    border-color: #60a5fa;
    background-color: #0f172a;
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.15);
}

.dark .soft-input::placeholder {
    color: #475569;
}

.dark select.soft-input {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
}

.dark .soft-label {
    color: #94a3b8;
}

.dark .soft-label .optional {
    color: #475569;
}

.dark .soft-section-title {
    color: #e2e8f0;
}

.dark .stepper-btn-back {
    background: #1e293b;
    color: #94a3b8;
}

.dark .stepper-btn-back:hover {
    background: #334155;
    color: #cbd5e1;
}

.dark .toggle-chip {
    border-color: #334155;
    background: #1e293b;
    color: #94a3b8;
}

.dark .toggle-chip:hover {
    border-color: #60a5fa;
    background: rgba(59, 130, 246, 0.1);
}

.dark .toggle-chip.checked {
    background: rgba(59, 130, 246, 0.15);
    border-color: #3b82f6;
    color: #93c5fd;
}

.dark .preview-bubble {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.08), rgba(52, 211, 153, 0.06));
    border-color: rgba(52, 211, 153, 0.2);
}

.dark .preview-bubble::before {
    background: rgba(16, 185, 129, 0.08);
    border-left-color: rgba(52, 211, 153, 0.2);
    border-top-color: rgba(52, 211, 153, 0.2);
}

.dark .reminder-card {
    background: #1e293b;
    border-color: #334155;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.dark .reminder-card:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3), 0 2px 8px rgba(0, 0, 0, 0.15);
    border-color: #475569;
    border-left-color: #3b82f6;
    transform: translateY(-1px);
    z-index: 2;
}

.dark .reminder-tag {
    background: #0f172a;
    border-color: #334155;
    color: #94a3b8;
    border-radius: 2rem;
}

.dark .reminder-tag svg {
    color: #64748b;
}

.dark .reminder-tag.sent {
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(52, 211, 153, 0.2);
    color: #34d399;
}

/* ---- Tag Editor (contenteditable message area) ---- */
.tag-editor {
    min-height: 6.5rem;
    max-height: 14rem;
    overflow-y: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    line-height: 1.7;
}

.tag-editor:empty::before {
    content: attr(data-placeholder);
    color: #94a3b8;
    pointer-events: none;
}

/* Tag pill inside editor */
.msg-tag {
    display: inline-flex;
    align-items: center;
    background: #dbeafe;
    color: #1d4ed8;
    border-radius: 0.375rem;
    padding: 0.0625rem 0.4375rem;
    font-size: 0.8125rem;
    font-weight: 500;
    font-family: inherit;
    white-space: nowrap;
    user-select: all;
    margin: 0 1px;
    vertical-align: baseline;
}

/* Tag insert button bar */
.tag-insert-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.375rem;
    margin-top: 0.5rem;
}

.tag-insert-bar .bar-label {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #94a3b8;
    margin-right: 0.125rem;
}

.tag-insert-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.1875rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1.5px solid #bfdbfe;
    background: #eff6ff;
    color: #2563eb;
}

.tag-insert-btn:hover {
    background: #dbeafe;
    border-color: #93c5fd;
}

/* Dark mode: tag editor */
.dark .tag-editor:empty::before {
    color: #4b5563;
}

.dark .msg-tag {
    background: rgba(59, 130, 246, 0.18);
    color: #93c5fd;
}

.dark .tag-insert-bar .bar-label {
    color: #4b5563;
}

.dark .tag-insert-btn {
    border-color: #1e3a5f;
    background: rgba(59, 130, 246, 0.1);
    color: #60a5fa;
}

.dark .tag-insert-btn:hover {
    background: rgba(59, 130, 246, 0.2);
    border-color: #3b82f6;
}

/* ---- Dates popover ---- */

.dates-trigger {
    position: relative;
    cursor: pointer;
    user-select: none;
}

.dates-trigger:hover {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #3b82f6;
}

.dates-trigger:hover svg {
    color: #3b82f6;
}

.popover-chevron {
    width: 12px !important;
    height: 12px !important;
    margin-left: 0.125rem;
    transition: transform 0.2s ease;
}

.dates-trigger.active .popover-chevron {
    transform: rotate(180deg);
}

.dates-popover {
    display: none;
    position: absolute;
    left: 0;
    top: calc(100% + 8px);
    z-index: 50;
    min-width: 240px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.04);
    padding: 0.625rem;
    font-size: 0.8125rem;
}

.dates-trigger.active .dates-popover {
    display: block;
}

.dates-popover-arrow {
    position: absolute;
    top: -6px;
    left: 16px;
    width: 12px;
    height: 12px;
    background: white;
    border-left: 1px solid #e2e8f0;
    border-top: 1px solid #e2e8f0;
    transform: rotate(45deg);
    border-radius: 2px;
}

.dates-popover-title {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #94a3b8;
    padding: 0.125rem 0.375rem 0.5rem;
    border-bottom: 1px solid #f1f5f9;
    margin-bottom: 0.375rem;
}

.dates-popover-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.375rem;
    border-radius: 0.5rem;
    transition: background 0.15s ease;
}

.dates-popover-row:hover {
    background: #f8fafc;
}

.dates-popover-date,
.dates-popover-time {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.8125rem;
    color: #475569;
}

.dates-popover-date svg,
.dates-popover-time svg {
    width: 13px;
    height: 13px;
    color: #94a3b8;
    flex-shrink: 0;
}

.dates-popover-time {
    font-weight: 500;
    color: #3b82f6;
    font-variant-numeric: tabular-nums;
}

/* Dark mode: dates popover */
.dark .dates-trigger:hover {
    background: rgba(59, 130, 246, 0.12);
    border-color: rgba(59, 130, 246, 0.25);
    color: #60a5fa;
}

.dark .dates-trigger:hover svg {
    color: #60a5fa;
}

.dark .dates-popover {
    background: #1e293b;
    border-color: #334155;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3), 0 2px 8px rgba(0, 0, 0, 0.2);
}

.dark .dates-popover-arrow {
    background: #1e293b;
    border-left-color: #334155;
    border-top-color: #334155;
}

.dark .dates-popover-title {
    color: #64748b;
    border-bottom-color: #334155;
}

.dark .dates-popover-row:hover {
    background: #0f172a;
}

.dark .dates-popover-date {
    color: #cbd5e1;
}

.dark .dates-popover-date svg {
    color: #64748b;
}

.dark .dates-popover-time {
    color: #60a5fa;
}

.dark .dates-popover-time svg {
    color: #475569;
}