/**
 * Book a Meeting Widget – self-contained styles.
 *
 * Follows the same design language as the Room Finder widget (same spacing
 * system, pill-expand pattern, chip styles) with `bm-` prefix instead of `rf-`.
 * Adds: title input, attendees section, Meet toggle, description row,
 * confirmation banner with links.
 */

/* ── Container ─────────────────────────────────────────────────────────────── */

.bm-widget {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.10);
    padding: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    overflow: hidden;
}

/* ── Header band ───────────────────────────────────────────────────────────── */

.bm-header {
    padding: 1rem 1.25rem;
    background: #f7fafc;
    border-bottom: 1px solid #e2e8f0;
}

/* ── Body ──────────────────────────────────────────────────────────────────── */

.bm-body {
    padding: 1.25rem 1.5rem 1.75rem;
}

/* ── Widget title ──────────────────────────────────────────────────────────── */

.bm-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0;
    letter-spacing: -0.01em;
}

/* ── Meeting title input ───────────────────────────────────────────────────── */

.bm-title-field {
    margin-bottom: 1rem;
}

.bm-title-input {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #cbd5e0;
    border-radius: 8px;
    padding: 0.6rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    font-family: inherit;
    color: #111827;
    background: #ffffff;
    outline: none;
    transition: border-color 0.15s, background 0.15s;
}

.bm-title-input::placeholder {
    color: #6b7280;
    font-weight: 400;
}

.bm-title-input:hover:not(:disabled) {
    border-color: #9ca3af;
    background: #f9fafb;
}

.bm-title-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 1px rgba(102, 126, 234, 0.2);
    background: #ffffff;
}

.bm-widget--disabled .bm-title-input {
    background: #f9fafb;
    color: #9ca3af;
    cursor: not-allowed;
}

/* ── Collapsible sections ──────────────────────────────────────────────────── */

.bm-section {
    margin-bottom: 0.6rem;
}

/* Display pill */
.bm-display-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #ffffff;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    color: #111827;
    box-sizing: border-box;
    transition: border-color 0.15s, background 0.15s;
}

.bm-display-row:hover:not(:disabled) {
    border-color: #9ca3af;
    background: #f9fafb;
}

.bm-display-row--placeholder .bm-display-value {
    color: #6b7280;
    font-weight: 400;
}

/* Accent border while expanded; pill stays clickable (collapses on click) */
.bm-section--expanded .bm-display-row {
    border-color: #667eea;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-bottom-color: #e2e8f0;
}

.bm-section--expanded .bm-display-row:hover {
    border-color: #667eea;
    border-bottom-color: #e2e8f0;
    background: #f9fafb;
}

/* Chevron always visible; rotates to point up when expanded */
.bm-chevron-icon {
    color: #9ca3af;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.bm-section--expanded .bm-chevron-icon {
    transform: rotate(180deg);
}

.bm-display-icon {
    color: #6b7280;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    line-height: 1;
}

.bm-display-value {
    flex: 1;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Editor panel — forms a connected card with the pill above it when expanded */
.bm-editor {
    display: none;
}

.bm-section--expanded .bm-editor {
    display: block;
    border: 1.5px solid #667eea;
    border-top: none;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
    padding: 0.875rem 0.875rem 0.75rem;
    background: #fafafa;
}

/* ── Fields ────────────────────────────────────────────────────────────────── */

.bm-field {
    margin-bottom: 1rem;
}

.bm-label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: #111827;
    margin-bottom: 0.35rem;
}

.bm-select,
.bm-input {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #cbd5e0;
    border-radius: 8px;
    padding: 0.55rem 0.75rem;
    font-size: 0.9rem;
    color: #111827;
    background: #ffffff;
    outline: none;
    appearance: auto;
    transition: border-color 0.15s;
}

.bm-select:focus,
.bm-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 1px rgba(102, 126, 234, 0.2);
}

.bm-select:disabled,
.bm-input:disabled {
    background: #f9fafb;
    color: #9ca3af;
    cursor: not-allowed;
}

.bm-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 0;
}

.bm-row-2 .bm-field {
    margin-bottom: 0;
}

@media (max-width: 400px) {
    .bm-row-2 { grid-template-columns: 1fr; }
}

/* ── Date field ─────────────────────────────────────────────────────────────── */

.bm-date-wrapper {
    position: relative;
}

.bm-date-display {
    display: block;
    cursor: pointer;
    user-select: none;
}

.bm-date-display:hover {
    border-color: #6b7280;
}

.bm-date-native {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
    overflow: hidden;
    border: none;
    padding: 0;
    margin: 0;
}

.bm-widget--disabled .bm-date-display {
    color: #9ca3af;
    cursor: not-allowed;
}

/* ── Custom time dropdown ───────────────────────────────────────────────────── */

.bm-time-select {
    position: relative;
}

.bm-time-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.35rem;
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #cbd5e0;
    border-radius: 8px;
    padding: 0.55rem 0.75rem;
    font-size: 0.9rem;
    font-family: inherit;
    font-weight: 400;
    color: #111827;
    background: #ffffff;
    cursor: pointer;
    text-align: left;
    transition: border-color 0.15s;
}

.bm-time-btn:hover:not(:disabled) { border-color: #9ca3af; }
.bm-time-btn:focus  { outline: none; border-color: #667eea; box-shadow: 0 0 0 1px rgba(102, 126, 234, 0.2); }
.bm-time-btn--placeholder { color: #9ca3af; }

.bm-time-btn:disabled {
    background: #f9fafb;
    color: #9ca3af;
    cursor: not-allowed;
}

.bm-drop-chevron {
    color: #9ca3af;
    flex-shrink: 0;
    transition: transform 0.15s ease;
}

.bm-time-btn[aria-expanded="true"] .bm-drop-chevron {
    transform: rotate(180deg);
}

.bm-time-list {
    display: none;
    position: absolute;
    top: calc(100% + 3px);
    left: 0;
    right: 0;
    z-index: 200;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.10);
    max-height: 196px;
    overflow-y: auto;
    list-style: none;
    margin: 0;
    padding: 0.25rem 0;
    scrollbar-width: thin;
    scrollbar-color: #d1d5db transparent;
}

.bm-time-list::-webkit-scrollbar        { width: 5px; }
.bm-time-list::-webkit-scrollbar-track  { background: transparent; }
.bm-time-list::-webkit-scrollbar-thumb  { background: #d1d5db; border-radius: 99px; }
.bm-time-list--open { display: block; }

.bm-time-option {
    padding: 0.45rem 0.875rem;
    font-size: 0.875rem;
    color: #374151;
    cursor: pointer;
    user-select: none;
}

.bm-time-option:hover       { background: #f3f4f6; }
.bm-time-option--active     { background: #f3f4f6; color: #111827; font-weight: 600; }
.bm-editor-time-row         { margin-bottom: 0; }

/* Last child field in any editor has no trailing bottom margin */
.bm-editor .bm-field:last-child,
.bm-editor .bm-row-2:last-child {
    margin-bottom: 0;
}

/* ── Attendees chips (inside editor) ────────────────────────────────────────── */

.bm-attendees-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.6rem;
    min-height: 0;
}

.bm-attendees-chips:empty {
    display: none;
}

.bm-attendee-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.25rem 0.5rem 0.25rem 0.65rem;
    background: #f3f4f6;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    font-size: 0.8rem;
    color: #374151;
    white-space: nowrap;
}

.bm-attendee-name {
    font-weight: 500;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bm-attendee-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: none;
    background: none;
    font-size: 0.9rem;
    line-height: 1;
    color: #9ca3af;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    transition: background 0.12s, color 0.12s;
}

.bm-attendee-remove:hover {
    background: #e5e7eb;
    color: #374151;
}

/* ── People search (autocomplete) ───────────────────────────────────────────── */

.bm-search-wrap {
    position: relative;
}

.bm-search-input {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #cbd5e0;
    border-radius: 8px;
    padding: 0.55rem 0.75rem;
    font-size: 0.9rem;
    font-family: inherit;
    color: #111827;
    background: #ffffff;
    outline: none;
    transition: border-color 0.15s;
}

.bm-search-input:focus    { border-color: #667eea; box-shadow: 0 0 0 1px rgba(102, 126, 234, 0.2); }
.bm-search-input:disabled { background: #f9fafb; color: #9ca3af; cursor: not-allowed; }

.bm-search-results {
    display: none;
    position: absolute;
    top: calc(100% + 3px);
    left: 0;
    right: 0;
    z-index: 200;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.10);
    max-height: 200px;
    overflow-y: auto;
    list-style: none;
    margin: 0;
    padding: 0.25rem 0;
    scrollbar-width: thin;
    scrollbar-color: #d1d5db transparent;
}

.bm-search-results--open { display: block; }

.bm-search-result {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    padding: 0.5rem 0.875rem;
    cursor: pointer;
    user-select: none;
}

.bm-search-result:hover { background: #f3f4f6; }

.bm-result-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: #111827;
    line-height: 1.3;
}

.bm-result-email {
    font-size: 0.775rem;
    color: #6b7280;
}

/* ── Chips (capacity + feature) ────────────────────────────────────────────── */

.bm-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.bm-chip {
    padding: 0.3rem 0.7rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: #4a5568;
    background: #f3f4f6;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
    white-space: nowrap;
    font-family: inherit;
}

.bm-chip:hover:not(:disabled):not(.bm-chip--active) {
    background: #e5e7eb;
    border-color: #d1d5db;
}

.bm-chip--active {
    background: #667eea;
    border-color: #667eea;
    color: #ffffff;
}

.bm-chip:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ── Room list ─────────────────────────────────────────────────────────────── */

.bm-rooms-header {
    font-size: 0.9rem;
    font-weight: 700;
    color: #111827;
    margin: 1rem 0 0.6rem;
}

.bm-room-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

@media (max-width: 560px) {
    .bm-room-list { grid-template-columns: 1fr; }
}

.bm-room-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.625rem 0.75rem;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    background: #ffffff;
}

.bm-room-item:hover:not(.bm-room-item--unavailable):not(.bm-room-item--disabled) {
    border-color: #667eea;
    background: #f8fafc;
    box-shadow: 0 2px 4px rgba(102, 126, 234, 0.1);
}

.bm-room-item--selected    { border-color: #667eea; background: #edf2f7; }
.bm-room-item--unavailable { opacity: 0.42; cursor: not-allowed; pointer-events: none; }
.bm-room-item--disabled    { pointer-events: none; }

.bm-radio {
    width: 16px;
    height: 16px;
    min-width: 16px;
    border-radius: 50%;
    border: 2px solid #cbd5e0;
    flex-shrink: 0;
    margin-top: 2px;
    box-sizing: border-box;
    transition: border-color 0.15s;
}

.bm-room-item:hover:not(.bm-room-item--unavailable):not(.bm-room-item--disabled) .bm-radio {
    border-color: #6b7280;
}

.bm-radio--selected {
    border-color: #667eea;
    background: radial-gradient(circle, #667eea 42%, transparent 43%);
}

.bm-room-details { flex: 1; min-width: 0; }

.bm-room-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: #111827;
    margin: 0 0 0.15rem;
    line-height: 1.3;
}

.bm-room-meta  { font-size: 0.8rem; color: #6b7280; line-height: 1.6; }
.bm-room-avail { font-size: 0.8rem; color: #6b7280; margin-top: 0.05rem; }
.bm-room-avail--available { color: #374151; }
.bm-room-avail--busy      { color: #dc2626; }

/* ── Status line ───────────────────────────────────────────────────────────── */

.bm-status {
    font-size: 0.82rem;
    color: #6b7280;
    margin: 0.5rem 0 0;
    min-height: 1.1em;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.bm-status:empty          { margin: 0; min-height: 0; }
.bm-status--loading       { color: #4b5563; }
.bm-status--error         { color: #dc2626; }
.bm-status--hint          { color: #667eea; font-style: italic; }

/* Required field that still needs user action — amber to stand out from grey optional rows */
.bm-display-row--action-needed .bm-display-value {
    color: #b45309;
    font-weight: 500;
}

.bm-submit-status {
    margin: 0.75rem 0 0;
}

.bm-spinner {
    width: 14px;
    height: 14px;
    border-radius: 999px;
    border: 2px solid #d1d5db;
    border-top-color: #667eea;
    animation: bm-spin 0.7s linear infinite;
    flex-shrink: 0;
}

@keyframes bm-spin { to { transform: rotate(360deg); } }

/* ── Google Meet toggle row ────────────────────────────────────────────────── */

.bm-toggle-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.75rem;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 0.6rem;
    cursor: pointer;
}

.bm-toggle-icon {
    color: #6b7280;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.bm-toggle-label {
    flex: 1;
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
    user-select: none;
}

/* Toggle switch */
.bm-toggle {
    position: relative;
    width: 36px;
    height: 20px;
    border-radius: 999px;
    border: none;
    background: #d1d5db;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    transition: background 0.2s;
}

.bm-toggle--on { background: #667eea; }

.bm-toggle-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    transition: transform 0.2s;
}

.bm-toggle--on .bm-toggle-thumb {
    transform: translateX(16px);
}

.bm-widget--disabled .bm-toggle-row { pointer-events: none; opacity: 0.6; }

/* ── Description textarea ──────────────────────────────────────────────────── */

.bm-textarea {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #cbd5e0;
    border-radius: 8px;
    padding: 0.55rem 0.75rem;
    font-size: 0.9rem;
    font-family: inherit;
    color: #111827;
    background: #ffffff;
    outline: none;
    resize: vertical;
    min-height: 72px;
    transition: border-color 0.15s;
}

.bm-textarea:focus    { border-color: #667eea; box-shadow: 0 0 0 1px rgba(102, 126, 234, 0.2); }
.bm-textarea:disabled { background: #f9fafb; color: #9ca3af; cursor: not-allowed; }

/* ── Submit row ────────────────────────────────────────────────────────────── */

.bm-submit-row {
    display: flex;
    justify-content: flex-end;
    margin-top: 1.25rem;
}

.bm-submit-btn {
    padding: 0.55rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    color: #ffffff;
    background: #667eea;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.bm-submit-btn:hover:not(:disabled) { background: #5a67d8; }
.bm-submit-btn:disabled { background: #d1d5db; cursor: not-allowed; }

/* ── Confirmation banner ───────────────────────────────────────────────────── */

.bm-confirmed {
    padding: 0.875rem 1rem;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 8px;
    margin-top: 1rem;
}

.bm-confirmed-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}

.bm-confirmed-icon  { color: #16a34a; flex-shrink: 0; }
.bm-confirmed-title { font-size: 0.9rem; font-weight: 700; color: #14532d; }

.bm-confirmed-detail {
    font-size: 0.875rem;
    color: #14532d;
    line-height: 1.5;
    margin-bottom: 0.5rem;
}

.bm-confirmed-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.4rem;
}

.bm-confirmed-link {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.7rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: #14532d;
    background: #dcfce7;
    border: 1px solid #86efac;
    border-radius: 6px;
    text-decoration: none;
    transition: background 0.12s;
}

.bm-confirmed-link:hover { background: #bbf7d0; }

.bm-confirmed-link--meet {
    color: #1d4ed8;
    background: #eff6ff;
    border-color: #bfdbfe;
}

.bm-confirmed-link--meet:hover { background: #dbeafe; }

/* ── Disabled overall ──────────────────────────────────────────────────────── */

.bm-widget--disabled .bm-select,
.bm-widget--disabled .bm-input,
.bm-widget--disabled .bm-textarea {
    background: #f9fafb;
    color: #9ca3af;
    cursor: not-allowed;
}

.bm-widget--disabled .bm-display-row,
.bm-widget--disabled .bm-time-btn {
    pointer-events: none;
    opacity: 0.65;
}

.bm-widget--disabled .bm-attendee-remove {
    pointer-events: none;
    opacity: 0.5;
}
