/* Team Onsite Summary Widget Styles */

.team-onsite-summary-widget {
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    padding: 14px 20px 20px 20px;
    max-width: 800px;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    position: relative; /* Required for absolute positioning of loading overlay */
}

/* Disabled state shown after user clicks "Find desk" and we open Desk Booking */
.team-onsite-summary-widget.tos-disabled {
    opacity: 0.6;
    pointer-events: none;
}

/* Header (desktop – mobile overrides in @media below) */
.tos-header {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e5e7eb;
}

.tos-title {
    margin: 0;
    padding: 0;
    font-size: 17px;
    font-weight: 600;
    color: #111827;
    line-height: 1.3;
}

/* Override chat message heading margins when widget is inside .message-content (e.g. h3.tos-title) */
.message.assistant .message-content .team-onsite-summary-widget .tos-title {
    margin: 0;
    padding: 0;
}

.tos-close-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: #6b7280;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.tos-close-btn:hover {
    background-color: #f3f4f6;
    color: #111827;
}

/* Filters - collapsible content under header summary */
.tos-filters-section {
    margin-bottom: 10px;
}

.tos-header-filters-toggle {
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
}

.tos-header-filters-main {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    max-width: 100%;
}

.tos-header-filters-summary {
    font-size: 12px;
    line-height: 1.3;
    color: #6b7280;
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
}

.tos-header-filters-chevron {
    color: #9ca3af;
    transition: transform 0.2s ease;
}

.tos-header-filters-toggle[aria-expanded="true"] .tos-header-filters-chevron {
    transform: rotate(180deg);
}

.tos-filters-content {
    padding: 8px 10px 12px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    background-color: #ffffff;
}

.tos-filters-content--collapsed {
    display: none;
}

.tos-filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.tos-select {
    flex: 1;
    min-width: 150px;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    background-color: #ffffff;
    color: #111827;
    cursor: pointer;
    transition: border-color 0.2s;
}

.tos-select:hover {
    border-color: #9ca3af;
}

.tos-select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Tab panel: tabs + content as one bordered unit */
.tos-tab-panel {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 20px;
}

/* Week-level callout */
.tos-week-callout {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 1px solid #fbbf24;
    border-radius: 8px;
    margin-bottom: 12px;
}

.tos-week-callout.hidden {
    display: none;
}

.tos-week-callout-icon {
    flex-shrink: 0;
    color: #d97706;
}

.tos-week-callout-text {
    font-size: 13px;
    color: #92400e;
    line-height: 1.4;
}

.tos-week-callout-text strong {
    font-weight: 600;
    color: #78350f;
}

/* Days Row - tab-style day selector */
.tos-days {
    display: flex;
    gap: 6px;
    margin-bottom: 0;
    padding: 0 8px 0 8px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e5e7eb;
    flex-wrap: wrap;
    align-items: stretch;
    background: transparent;
}

.tos-day-btn {
    flex: 1;
    min-width: 76px;
    /* Keep tab height stable while increasing font sizes */
    padding: 9px 8px 13px;
    border: 1px solid #e5e7eb;
    border-radius: 8px 8px 0 0;
    border-bottom: none;
    background-color: #ffffff;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    position: relative;
    color: #374151;
    font-weight: 500;
}

.tos-day-btn:hover:not(.tos-day-btn--past):not(.active) {
    border-color: #d1d5db;
    background-color: #f9fafb;
}

/* Active tab: solid blue, white text */
.tos-day-btn.active {
    background-color: #3b82f6;
    border-color: #3b82f6;
    color: #ffffff;
    z-index: 1;
    margin-bottom: -1px;
    padding-bottom: 12px;
}

.tos-day-btn.active:hover {
    background-color: #2563eb;
    border-color: #2563eb;
    color: #ffffff;
}

.tos-day-btn.active:hover .tos-day-line1,
.tos-day-btn.active:hover .tos-day-line2,
.tos-day-btn.active:hover .tos-day-count {
    color: #ffffff;
}

/* Selected tab indicator: pill bar at bottom (clear, modern) */
.tos-day-btn.active::after {
    content: '';
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: 6px;
    width: 28px;
    height: 3px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 2px;
}

.tos-day-btn.active:hover::after {
    background: rgba(255, 255, 255, 0.95);
}

/* Tab label: line 1 = day + short date, line 2 = count + you */
.tos-day-line1 {
    font-size: 13px;
    font-weight: 600;
    color: inherit;
    line-height: 1.1;
    white-space: nowrap;
}

/* De-emphasize label on inactive tabs so metric stands out */
.tos-day-btn:not(.active) .tos-day-line1 {
    color: #6b7280;
    font-weight: 500;
}

.tos-day-line2 {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    line-height: 1.1;
}

.tos-day-btn.active .tos-day-line2 {
    color: rgba(255, 255, 255, 0.95);
}

.tos-day-count {
    font-size: 13px;
    font-weight: 700;
    color: inherit;
}

.tos-day-person-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: inherit;
}

.tos-day-person-icon-svg {
    display: block;
    width: 13px;
    height: 13px;
}

.tos-day-btn:not(.active) .tos-day-person-icon {
    color: #6b7280;
}

.tos-day-btn.active .tos-day-person-icon {
    color: rgba(255, 255, 255, 0.9);
}

.tos-day-you-part {
    font-size: 10px;
    font-weight: 500;
    color: inherit;
    margin-left: 0;
}

.tos-day-btn:not(.active) .tos-day-you-part {
    color: #6b7280;
}

.tos-day-btn.active .tos-day-you-part {
    color: rgba(255, 255, 255, 0.95);
}

.tos-day-line2--past {
    font-size: 10px;
    font-style: italic;
    color: #9ca3af;
}

/* Past days: greyed out */
.tos-day-btn--past {
    background-color: #f3f4f6;
    border-color: #e5e7eb;
    color: #9ca3af;
    cursor: not-allowed;
    opacity: 0.85;
}

.tos-day-btn--past .tos-day-line1 {
    color: #9ca3af;
}

.tos-day-btn--past:hover {
    border-color: #e5e7eb;
    background-color: #f3f4f6;
}

.tos-day-btn--past:disabled {
    cursor: not-allowed;
}

/* Colleagues Section - tab content (no separate box) */
.tos-colleagues-section {
    margin: 0;
    padding: 0;
    background: #ffffff;
}

/* User's current booking info - distinct card style above heading */
.tos-user-booking {
    padding: 12px 16px;
    background: #ffffff;
}

.tos-user-booking.hidden {
    display: none;
}

.tos-user-booking-card {
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.tos-user-booking-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.tos-user-booking-label {
    font-size: 14px;
    font-weight: 600;
    color: #1e40af;
    line-height: 1.2;
}

.tos-user-booking-location {
    font-size: 13px;
    color: #3b82f6;
    line-height: 1.3;
}

.tos-user-booking-cancel-btn {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    color: #93c5fd;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}

.tos-user-booking-cancel-btn:hover {
    background-color: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: #ef4444;
}

.tos-colleagues-heading {
    padding: 14px 16px 6px;
    font-size: 13px;
    font-weight: 600;
    color: #111827;
    background: #ffffff;
}

.tos-colleagues-list {
    /* Fixed viewport so widget height doesn't change per-day */
    --tos-colleague-row-min-height: 66px;
    height: calc((3 * var(--tos-colleague-row-min-height)) + (2 * 8px) + 24px);
    overflow-y: auto;
    padding: 12px 16px 12px;
    background: #ffffff;
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px 12px;
    align-content: start;
}

@media (min-width: 640px) {
    .tos-colleagues-list {
        grid-template-columns: 1fr 1fr;
    }
}

.tos-action {
    padding: 12px 16px 16px;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tos-action.hidden {
    display: none;
}

.tos-action-summary {
    font-size: 13px;
    font-weight: 500;
    color: #111827;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* When summary is empty (no selections), don't take vertical space */
.tos-action-summary:empty {
    display: none;
}

.tos-colleague-row {
    display: flex;
    align-items: flex-start;
    padding: 12px;
    border-radius: 4px;
    transition: background-color 0.2s;
    min-height: var(--tos-colleague-row-min-height);
    box-sizing: border-box;
}

.tos-colleague-row:hover {
    background-color: #f9fafb;
}

.tos-colleague-row input[type="checkbox"] {
    margin-right: 12px;
    margin-top: 2px;
    cursor: pointer;
    width: 18px;
    height: 18px;
}

/* Spacer for "You" row so label aligns with colleague rows (same as checkbox + margin) */
.tos-colleague-row-spacer {
    width: 30px;
    min-width: 30px;
    flex-shrink: 0;
}

.tos-colleague-row--you {
    background-color: #f0f9ff;
    grid-column: 1 / -1;
}

.tos-colleague-row--you .tos-colleague-label {
    cursor: default;
}

.tos-colleague-label {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    cursor: pointer;
}

.tos-colleague-name {
    font-size: 14px;
    font-weight: 500;
    color: #111827;
}

.tos-colleague-location {
    font-size: 12px;
    color: #6b7280;
}

.tos-empty-state {
    padding: 40px 20px;
    text-align: center;
    color: #6b7280;
    font-size: 14px;
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.tos-empty-state-icon {
    color: #9ca3af;
    margin-bottom: 4px;
}

.tos-empty-state-icon svg {
    display: block;
}

.tos-empty-state-primary {
    font-size: 15px;
    font-weight: 500;
    color: #374151;
}

.tos-empty-state-secondary {
    font-size: 13px;
    color: #6b7280;
    max-width: 320px;
}


/* Footer */
.tos-footer {
    display: flex;
    justify-content: center;
    padding-top: 20px;
    border-top: 1px solid #e5e7eb;
}

.tos-cta-btn {
    padding: 12px 24px;
    background-color: #3b82f6;
    color: #ffffff;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    box-shadow: 0 1px 1px rgba(15, 23, 42, 0.04);
    transition: background-color 0.2s, box-shadow 0.2s, border-color 0.2s;
    align-self: center;        /* Avoid full-width bar look */
    min-width: 160px;          /* Make it feel like a button */
    max-width: 260px;
}

.tos-cta-btn:not(:disabled) {
    border-color: #1d4ed8;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.18), 0 0 0 1px rgba(37, 99, 235, 0.5);
}

.tos-cta-btn:hover:not(:disabled) {
    background-color: #2563eb;
}

.tos-cta-btn:disabled {
    background-color: #d1d5db;
    color: #9ca3af;
    cursor: not-allowed;
}

/* Error Container */
.tos-error {
    padding: 12px 16px;
    background-color: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 6px;
    color: #991b1b;
    font-size: 14px;
    margin-bottom: 16px;
}

.tos-error.hidden {
    display: none;
}

/* Loading Indicator - Full Widget Overlay */
.tos-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(3px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    border-radius: 8px;
    pointer-events: all; /* Block all interactions when loading */
}

.tos-loading.hidden {
    display: none;
    pointer-events: none;
}

.tos-loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e5e7eb;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: tos-spin 0.8s linear infinite;
    margin-bottom: 12px;
}

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

.tos-loading-text {
    color: #6b7280;
    font-size: 14px;
    font-weight: 500;
}

/* Modal */
.tos-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.tos-modal {
    background: #ffffff;
    border-radius: 8px;
    padding: 24px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.tos-modal p {
    margin: 0 0 20px 0;
    font-size: 14px;
    color: #111827;
}

.tos-modal-buttons {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.tos-modal-btn {
    padding: 8px 16px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    background-color: #ffffff;
    color: #111827;
    transition: all 0.2s;
}

.tos-modal-btn:hover {
    background-color: #f9fafb;
}

.tos-modal-btn--primary {
    background-color: #3b82f6;
    color: #ffffff;
    border-color: #3b82f6;
}

.tos-modal-btn--primary:hover {
    background-color: #2563eb;
}

.tos-modal-btn--danger {
    background-color: #ef4444;
    color: #ffffff;
    border-color: #ef4444;
}

.tos-modal-btn--danger:hover {
    background-color: #dc2626;
}

/* Scrollbar styling for colleagues list */
.tos-colleagues-list::-webkit-scrollbar {
    width: 8px;
}

.tos-colleagues-list::-webkit-scrollbar-track {
    background: #f9fafb;
    border-radius: 4px;
}

.tos-colleagues-list::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 4px;
}

.tos-colleagues-list::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Accordion (mobile only – hidden on desktop) */
.tos-accordion {
    display: none;
}

/* Mobile-friendly styles */
@media (max-width: 640px) {
    .team-onsite-summary-widget {
        padding: 0.5rem 10px 16px 10px;
        max-width: 100%;
        margin: 0;
    }

    .tos-header {
        margin-bottom: 6px;
        padding: 0.5rem 0 0.375rem 0;
        gap: 0.2rem;
    }

    .tos-title {
        margin: 0;
        padding: 0;
        font-size: 1.125rem;
        font-weight: 600;
    }

    .tos-header-filters-toggle {
        min-height: 40px;
        padding: 0.125rem 0;
    }

    .tos-header-filters-summary {
        font-size: 0.8125rem;
    }

    .tos-filters-content {
        padding: 10px 0 12px;
        border-left: none;
        border-right: none;
        border-radius: 0;
        margin: 0 -2px;
    }

    .tos-filters {
        flex-direction: column;
        gap: 10px;
    }

    .tos-select {
        min-width: 0;
        width: 100%;
        padding: 10px 12px;
        font-size: 16px; /* Prevents zoom on focus in iOS */
    }

    /* Hide tab panel on mobile – replaced by accordion */
    .tos-tab-panel {
        display: none;
    }

    /* Show accordion on mobile */
    .tos-accordion {
        display: flex;
        flex-direction: column;
        gap: 6px;
        margin-bottom: 16px;
    }

    .tos-accordion-item {
        border: 1px solid #e5e7eb;
        border-radius: 10px;
        overflow: hidden;
        transition: border-color 0.15s ease, box-shadow 0.15s ease;
    }

    .tos-accordion-item--active {
        border-color: #3b82f6;
        box-shadow: 0 0 0 1px #3b82f6;
    }

    .tos-accordion-header {
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 14px 14px;
        background: #ffffff;
        border: none;
        cursor: pointer;
        text-align: left;
        transition: background-color 0.15s ease;
        min-height: 56px;
        gap: 8px;
    }

    .tos-accordion-header:active {
        background: #f3f4f6;
    }

    .tos-accordion-item--past .tos-accordion-header {
        cursor: default;
        opacity: 0.5;
    }

    .tos-accordion-item--active > .tos-accordion-header {
        background: #3b82f6;
        color: #ffffff;
    }

    .tos-accordion-header-left {
        display: flex;
        flex-direction: column;
        gap: 2px;
        flex: 1;
        min-width: 0;
    }

    .tos-accordion-day-name {
        font-size: 15px;
        font-weight: 600;
        color: inherit;
        line-height: 1.2;
    }

    .tos-accordion-day-date {
        font-size: 12px;
        color: #6b7280;
        line-height: 1.2;
    }

    .tos-accordion-item--active .tos-accordion-day-date {
        color: rgba(255, 255, 255, 0.8);
    }

    .tos-accordion-header-right {
        display: flex;
        align-items: center;
        gap: 8px;
        flex-shrink: 0;
    }

    .tos-accordion-count {
        display: inline-flex;
        align-items: center;
        gap: 4px;
        font-size: 13px;
        font-weight: 600;
        color: #374151;
        background: #f3f4f6;
        padding: 3px 8px;
        border-radius: 999px;
    }

    .tos-accordion-item--active .tos-accordion-count {
        background: rgba(255, 255, 255, 0.2);
        color: #ffffff;
    }

    .tos-accordion-you {
        font-weight: 500;
        font-size: 12px;
    }

    .tos-accordion-past-label {
        font-size: 12px;
        color: #9ca3af;
    }

    .tos-accordion-chevron {
        color: #9ca3af;
        transition: transform 0.2s ease;
        display: flex;
        align-items: center;
    }

    .tos-accordion-item--active .tos-accordion-chevron {
        transform: rotate(180deg);
        color: rgba(255, 255, 255, 0.9);
    }

    .tos-accordion-body {
        display: none;
    }

    .tos-accordion-item--active > .tos-accordion-body {
        display: block;
        border-top: 1px solid #bfdbfe;
    }

    /* Colleagues section inside accordion body */
    .tos-accordion-body .tos-colleagues-section {
        padding: 0;
    }

    .tos-accordion-body .tos-user-booking-card {
        padding: 10px 14px;
        border-radius: 0;
        border-left: none;
        border-right: none;
        border-top: none;
    }

    .tos-accordion-body .tos-colleagues-heading {
        padding: 12px 14px 6px;
        font-size: 12px;
    }

    .tos-accordion-body .tos-colleagues-list {
        padding: 6px 14px 12px;
        height: calc((3 * var(--tos-colleague-row-min-height)) + (2 * 8px) + 20px);
    }

    .tos-accordion-body .tos-colleague-row {
        padding: 12px 4px;
        min-height: 52px;
    }

    .tos-accordion-body .tos-action {
        padding: 12px 14px 16px;
        gap: 12px;
    }

    .tos-accordion-body .tos-cta-btn {
        width: 100%;
        max-width: none;
        min-width: 0;
        padding: 14px 20px;
        font-size: 16px;
        min-height: 48px;
    }

    .tos-day-line1,
    .tos-day-line2 {
        font-size: 12px;
    }

    .tos-day-count {
        font-size: 12px;
    }

    .tos-colleagues-section {
        padding: 0;
    }

    .tos-user-booking-card {
        padding: 10px 12px;
    }

    .tos-user-booking-label {
        font-size: 13px;
    }

    .tos-colleagues-heading {
        padding: 12px 8px 6px;
        font-size: 12px;
    }

    .tos-colleagues-list {
        padding: 10px 8px 12px;
        height: calc((3 * var(--tos-colleague-row-min-height)) + (2 * 8px) + 20px);
    }

    .tos-colleague-row {
        padding: 12px 8px;
        min-height: 52px;
    }

    .tos-colleague-row input[type="checkbox"] {
        width: 20px;
        height: 20px;
        margin-right: 10px;
    }

    .tos-action {
        padding: 12px 8px 16px;
        gap: 12px;
    }

    .tos-action-summary {
        white-space: normal;
        overflow: visible;
        text-overflow: unset;
        font-size: 12px;
    }

    .tos-cta-btn {
        width: 100%;
        max-width: none;
        min-width: 0;
        padding: 14px 20px;
        font-size: 16px;
        min-height: 48px;
    }

    .tos-footer {
        padding-top: 16px;
    }

    .tos-modal {
        width: calc(100% - 20px);
        max-width: none;
        margin: 10px;
        padding: 20px 12px;
    }

    .tos-modal-buttons {
        flex-wrap: wrap;
    }

    .tos-modal-btn {
        flex: 1;
        min-width: 100px;
    }

    .tos-error {
        padding: 10px 8px;
        font-size: 13px;
    }
}
