* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: #323130;
    background-color: #faf9f8;
}

.container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding: 16px;
}

/* Header removed - title shown in Outlook add-in chrome */

main {
    flex: 1;
    position: relative;
}

/* Top Controls Container (pop-out button + options menu) */
.top-controls {
    position: absolute;
    top: -4px;
    right: 0;
    display: flex;
    align-items: center;
    gap: 2px;
    z-index: 100;
}

.toolbar-btn {
    background: none;
    border: none;
    font-size: 16px;
    color: #605e5c;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    transition: all 0.15s ease;
    line-height: 1;
}

.toolbar-btn:hover {
    background-color: #f3f2f1;
    color: #323130;
}

.toolbar-btn:active {
    background-color: #edebe9;
}

/* Options Menu (now relative within .top-controls) */
.options-menu {
    position: relative;
}

.options-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: #605e5c;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background-color 0.15s ease;
    line-height: 1;
}

.options-btn:hover {
    background-color: #f3f2f1;
}

.options-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    min-width: 220px;
    background-color: #fff;
    border: 1px solid #8a8886;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    animation: fadeIn 0.2s ease;
    overflow: hidden;
}

.options-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    background: none;
    border: none;
    text-align: left;
    font-size: 13px;
    color: #323130;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.options-item:hover {
    background-color: #f3f2f1;
}

.options-icon {
    font-size: 16px;
}

.email-info {
    margin-bottom: 24px;
}

.field {
    margin-bottom: 16px;
}

.field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #605e5c;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.field .value {
    font-size: 14px;
    color: #323130;
    word-break: break-word;
}

.field .value.mono {
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 11px;
    background-color: #f3f2f1;
    padding: 8px;
    border-radius: 4px;
    overflow-x: auto;
}

.conversation-index {
    background-color: #fff;
    padding: 12px;
    border-radius: 6px;
    border: 1px solid #0078d4;
}

.conversation-index label {
    color: #0078d4;
}

.actions {
    margin-bottom: 16px;
}

.btn-primary {
    width: 100%;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    background-color: #0078d4;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.btn-primary:hover:not(:disabled) {
    background-color: #106ebe;
}

.btn-primary:disabled {
    background-color: #c8c6c4;
    cursor: not-allowed;
}

.btn-primary:active:not(:disabled) {
    background-color: #005a9e;
}

.status-section {
    padding: 12px;
    border-radius: 6px;
    margin-top: 12px;
    position: relative;
}

.status-dismiss {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    font-size: 14px;
    cursor: pointer;
    opacity: 0.5;
    padding: 2px 6px;
    border-radius: 4px;
    transition: opacity 0.15s, background-color 0.15s;
}

.status-dismiss:hover {
    opacity: 1;
    background-color: rgba(0, 0, 0, 0.1);
}

.status-message {
    font-size: 13px;
}

.status-section.success {
    background-color: #dff6dd;
    border: 1px solid #107c10;
}

.status-section.success .status-message {
    color: #107c10;
}

.status-section.error {
    background-color: #fde7e9;
    border: 1px solid #d13438;
}

.status-section.error .status-message {
    color: #d13438;
}

.status-section.info {
    background-color: #f3f2f1;
    border: 1px solid #605e5c;
}

.status-section.info .status-message {
    color: #605e5c;
}

/* Spinner for live status updates */
.status-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid #605e5c;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
}

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

/* Status history for showing previous messages */
.status-history {
    font-size: 11px;
    color: #8a8886;
    margin-bottom: 4px;
    max-height: 60px;
    overflow-y: auto;
}

.status-history-item {
    padding: 2px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
}

.status-history-item:last-child {
    border-bottom: none;
}

.status-history-item .checkmark {
    color: #107c10;
    margin-right: 4px;
}

.status-section.success .status-history {
    color: #0b6a0b;
}

.status-section.error .status-history {
    color: #a4262c;
}

footer {
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid #edebe9;
    text-align: center;
}

.version {
    font-size: 11px;
    color: #a19f9d;
}

/* Attachment list */
.attachment-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.attachment-list li {
    display: flex;
    align-items: center;
    padding: 4px 0;
    font-size: 13px;
}

.attachment-list li::before {
    content: "📎";
    margin-right: 6px;
}

.no-attachments {
    color: #a19f9d;
    font-style: italic;
}

/* Untrack button mode */
.btn-primary.untrack-mode {
    background-color: #d13438;
}

.btn-primary.untrack-mode:hover:not(:disabled) {
    background-color: #a4262c;
}

.btn-primary.untrack-mode:active:not(:disabled) {
    background-color: #8a2025;
}

/* D365 Link */
#d365Link {
    display: block;
    margin-top: 12px;
    padding: 10px 16px;
    text-align: center;
    color: #0078d4;
    text-decoration: none;
    font-weight: 600;
    font-size: 13px;
    border: 1px solid #0078d4;
    border-radius: 6px;
    background-color: #fff;
    transition: background-color 0.2s ease;
}

#d365Link:hover {
    background-color: #f3f2f1;
}

/* Warning Banner */
.warning-banner {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    margin-bottom: 20px;
    background-color: #fff4ce;
    border: 1px solid #fde300;
    border-radius: 6px;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.warning-icon {
    font-size: 20px;
    line-height: 1;
}

.warning-text {
    flex: 1;
}

.warning-text strong {
    display: block;
    font-size: 13px;
    color: #8a5340;
    margin-bottom: 4px;
}

.warning-text p {
    font-size: 12px;
    color: #605e5c;
    margin: 0;
}

/* Regarding Section */
.regarding-section {
    margin-bottom: 20px;
}

.section-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #323130;
    margin-bottom: 8px;
}

.regarding-input-container {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.regarding-input {
    flex: 1;
    padding: 10px 12px;
    font-size: 14px;
    color: #323130;
    background-color: #fff;
    border: 1px solid #8a8886;
    border-radius: 6px;
    transition: all 0.2s ease;
    font-family: inherit;
}

.regarding-input:focus {
    outline: none;
    border-color: #0078d4;
    box-shadow: 0 0 0 1px #0078d4;
}

.regarding-input::placeholder {
    color: #a19f9d;
}

.lookup-btn {
    padding: 10px 14px;
    font-size: 16px;
    background-color: #fff;
    border: 1px solid #8a8886;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lookup-btn:hover {
    background-color: #f3f2f1;
    border-color: #605e5c;
}

.lookup-btn:active {
    background-color: #edebe9;
}

.lookup-btn-small {
    padding: 6px 10px;
    font-size: 14px;
    background-color: #fff;
    border: 1px solid #8a8886;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.lookup-btn-small:hover {
    background-color: #f3f2f1;
}

/* Regarding Results Dropdown */
.regarding-results {
    position: relative;
    max-height: 240px;
    overflow-y: auto;
    background-color: #fff;
    border: 1px solid #8a8886;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    cursor: pointer;
    transition: background-color 0.15s ease;
    border-bottom: 1px solid #f3f2f1;
}

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

.result-item:hover {
    background-color: #f3f2f1;
}

.result-item.inactive {
    opacity: 0.5;
}

.result-icon {
    font-size: 18px;
    line-height: 1;
}

.result-info {
    flex: 1;
    min-width: 0;
}

.result-name {
    font-size: 14px;
    font-weight: 500;
    color: #323130;
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.result-type {
    font-size: 11px;
    color: #605e5c;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.result-meta {
    font-size: 12px;
    color: #8a8886;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.result-status {
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: 500;
}

.result-status.active {
    background-color: #dff6dd;
    color: #107c10;
}

.result-status.inactive {
    background-color: #f3f2f1;
    color: #8a8886;
}

.no-results {
    padding: 16px;
    text-align: center;
    color: #a19f9d;
    font-size: 13px;
}

.results-loading {
    padding: 16px;
    text-align: center;
    color: #605e5c;
    font-size: 13px;
}

/* Selected Regarding Display Row */
.regarding-selected-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

/* Twisty button for expanding/collapsing search */
.twisty-btn {
    padding: 10px 12px;
    font-size: 12px;
    background-color: #fff;
    border: 1px solid #8a8886;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.twisty-btn:hover {
    background-color: #f3f2f1;
    border-color: #605e5c;
}

.twisty-btn:active {
    background-color: #edebe9;
}

.twisty-icon {
    display: inline-block;
    transition: transform 0.2s ease;
    line-height: 1;
    font-size: 18px;
    font-weight: bold;
    pointer-events: none;
}

.twisty-btn.expanded .twisty-icon {
    transform: rotate(90deg);
}

.regarding-link {
    flex: 1;
    padding: 10px 12px;
    background-color: #f3f2f1;
    border: 1px solid #d2d0ce;
    border-radius: 6px;
    color: #0078d4;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.regarding-link:hover {
    text-decoration: underline;
    background-color: #edebe9;
}

/* Entity Type Selector */
.entity-selector {
    position: relative;
    margin-top: 12px;
    padding: 16px;
    background-color: #fff;
    border: 1px solid #8a8886;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    animation: fadeIn 0.2s ease;
}

.entity-selector-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #edebe9;
}

.entity-selector-header span {
    font-size: 13px;
    font-weight: 600;
    color: #323130;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: #605e5c;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.15s ease;
}

.close-btn:hover {
    background-color: #f3f2f1;
}

.entity-selector-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.select-action-btn {
    flex: 1;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    color: #323130;
    background-color: #f3f2f1;
    border: 1px solid #d2d0ce;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.select-action-btn:hover {
    background-color: #edebe9;
}

.select-action-btn:active {
    background-color: #e1dfdd;
}

.entity-type-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

.entity-type-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 10px;
    background-color: #faf9f8;
    border: 2px solid #edebe9;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.entity-type-checkbox:hover {
    background-color: #f3f2f1;
    border-color: #0078d4;
}

.entity-type-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    flex-shrink: 0;
}

.entity-type-checkbox input[type="checkbox"]:checked {
    accent-color: #0078d4;
}

.checkbox-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex: 1;
}

.entity-icon {
    font-size: 24px;
    line-height: 1;
}

.entity-label {
    font-size: 12px;
    font-weight: 500;
    color: #323130;
}

.entity-selector-footer {
    padding-top: 12px;
    border-top: 1px solid #edebe9;
}

.apply-filter-btn {
    width: 100%;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    background-color: #0078d4;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.apply-filter-btn:hover {
    background-color: #106ebe;
}

.apply-filter-btn:active {
    background-color: #005a9e;
}

.apply-filter-btn:disabled {
    background-color: #c8c6c4;
    cursor: not-allowed;
}

/* Secondary Button */
.btn-secondary {
    width: 100%;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 600;
    color: #323130;
    background-color: #fff;
    border: 1px solid #8a8886;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-secondary:hover:not(:disabled) {
    background-color: #f3f2f1;
    border-color: #605e5c;
}

.btn-secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary:active:not(:disabled) {
    background-color: #edebe9;
}

.btn-icon {
    font-size: 16px;
    line-height: 1;
}

/* D365 Status Button */
.btn-d365-status {
    width: 100%;
    padding: 12px 20px;
    margin-bottom: 12px;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    background-color: #0078d4;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-d365-status:hover:not(:disabled) {
    background-color: #106ebe;
}

.btn-d365-status:disabled {
    background-color: #c8c6c4;
    color: #605e5c;
    cursor: not-allowed;
}

.btn-d365-status:active:not(:disabled) {
    background-color: #005a9e;
}

/* D365 Status Row - contains status button and refresh button */
.d365-status-row {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.d365-status-row .btn-d365-status {
    flex: 1;
    margin-bottom: 0;
}

/* Refresh Button */
.refresh-btn {
    width: 44px;
    height: 44px;
    padding: 0;
    background-color: #f3f2f1;
    border: 1px solid #8a8886;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.refresh-btn:hover:not(:disabled) {
    background-color: #e1dfdd;
    border-color: #605e5c;
}

.refresh-btn:active:not(:disabled) {
    background-color: #c8c6c4;
}

.refresh-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.refresh-icon {
    font-size: 18px;
    color: #323130;
    transition: transform 0.3s ease;
}

.refresh-btn.refreshing .refresh-icon {
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ============================================================================
   Multi-Select Mode Styles
   ============================================================================ */

/* Error Banner */
.error-banner {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    margin-bottom: 20px;
    background-color: #fde7e9;
    border: 1px solid #d13438;
    border-radius: 6px;
}

.error-icon {
    font-size: 24px;
    line-height: 1;
}

.error-text {
    flex: 1;
}

.error-text strong {
    display: block;
    font-size: 14px;
    color: #a4262c;
    margin-bottom: 4px;
}

.error-text p {
    font-size: 13px;
    color: #605e5c;
    margin: 0;
}

/* Multi-Select Section */
.multi-select-section {
    margin-bottom: 20px;
}

.multi-select-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    background-color: #f3f2f1;
    border-radius: 6px 6px 0 0;
    border: 1px solid #d2d0ce;
    border-bottom: none;
}

.multi-select-icon {
    font-size: 18px;
}

#multiSelectCount {
    font-size: 14px;
    font-weight: 600;
    color: #323130;
}

/* Email List */
.email-list {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #d2d0ce;
    border-radius: 0 0 6px 6px;
    background-color: #fff;
}

/* Simple centered loading spinner for initial load */
.loading-spinner-container {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 12px;
}

.loading-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid #d2d0ce;
    border-top-color: #0078d4;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.email-list-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 12px;
    font-size: 13px;
    color: #605e5c;
}

.email-list-loading::before {
    content: "";
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-right: 8px;
    border: 2px solid #d2d0ce;
    border-top-color: #0078d4;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.email-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid #f3f2f1;
    transition: background-color 0.15s ease;
}

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

.email-item:hover {
    background-color: #faf9f8;
}

.email-item.tracked {
    background-color: #f0fdf4;
}

.email-item-content {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.email-subject {
    font-size: 13px;
    color: #323130;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attachment-indicator {
    font-size: 12px;
    flex-shrink: 0;
}

.email-status {
    flex-shrink: 0;
}

.tracked-badge {
    display: inline-block;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    color: #107c10;
    background-color: #dff6dd;
    border-radius: 10px;
}

/* Batch Progress */
.batch-progress {
    margin-top: 12px;
    padding: 12px;
    background-color: #f3f2f1;
    border-radius: 6px;
}

.progress-bar {
    height: 8px;
    background-color: #d2d0ce;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background-color: #0078d4;
    border-radius: 4px;
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 12px;
    color: #605e5c;
    text-align: center;
}

/* Batch Results */
.batch-results {
    margin-top: 12px;
    padding: 12px;
    border-radius: 6px;
    animation: fadeIn 0.3s ease;
}

.results-summary {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.result-success {
    font-size: 13px;
    color: #107c10;
    font-weight: 500;
}

.result-error {
    font-size: 13px;
    color: #d13438;
    font-weight: 500;
}

.result-details {
    margin-top: 8px;
    padding: 8px;
    background-color: #fde7e9;
    border-radius: 4px;
}

.result-detail-item {
    font-size: 12px;
    color: #605e5c;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.result-detail-item:last-child {
    margin-bottom: 0;
}

/* Multi-Select Actions */
.multi-select-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.btn-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-danger {
    color: #d13438;
    border-color: #d13438;
}

.btn-danger:hover:not(:disabled) {
    background-color: #fde7e9;
    color: #a4262c;
}

.btn-danger:active:not(:disabled) {
    background-color: #fdd9db;
}

/* ============================================================================
   Confirmation Dialog Styles
   ============================================================================ */

.confirm-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

.confirm-dialog {
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    max-width: 320px;
    width: 90%;
    animation: slideUp 0.2s ease;
}

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

.confirm-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border-bottom: 1px solid #edebe9;
}

.confirm-icon {
    font-size: 24px;
    line-height: 1;
}

.confirm-title {
    font-size: 16px;
    font-weight: 600;
    color: #323130;
}

.confirm-body {
    padding: 16px;
    font-size: 14px;
    color: #605e5c;
    line-height: 1.5;
}

.confirm-footer {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid #edebe9;
    justify-content: flex-end;
}

.confirm-btn {
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.confirm-btn-cancel {
    background-color: #fff;
    border: 1px solid #8a8886;
    color: #323130;
}

.confirm-btn-cancel:hover {
    background-color: #f3f2f1;
}

.confirm-btn-primary {
    background-color: #0078d4;
    border: 1px solid #0078d4;
    color: #fff;
}

.confirm-btn-primary:hover {
    background-color: #106ebe;
}

.confirm-btn-danger {
    background-color: #d13438;
    border: 1px solid #d13438;
    color: #fff;
}

.confirm-btn-danger:hover {
    background-color: #a4262c;
}

/* ============================================================================
   Create Case Form Styles
   ============================================================================ */

.create-case-section {
    margin-top: 16px;
    padding: 16px;
    background-color: #fff;
    border: 1px solid #d2d0ce;
    border-radius: 8px;
    animation: slideDown 0.3s ease;
}

.case-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.case-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.case-field label {
    font-size: 13px;
    font-weight: 600;
    color: #323130;
}

.case-input,
.case-textarea,
.case-select {
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
    color: #323130;
    background-color: #fff;
    border: 1px solid #8a8886;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.case-input:focus,
.case-textarea:focus,
.case-select:focus {
    outline: none;
    border-color: #0078d4;
    box-shadow: 0 0 0 1px #0078d4;
}

.case-input::placeholder,
.case-textarea::placeholder {
    color: #a19f9d;
}

.case-textarea {
    resize: vertical;
    min-height: 100px;
}

.case-select {
    cursor: pointer;
}

.case-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 8px;
}

.case-actions .btn-primary,
.case-actions .btn-secondary {
    width: 100%;
}

.case-status {
    margin-top: 12px;
    padding: 12px;
    border-radius: 6px;
    font-size: 13px;
}

.case-status.loading {
    background-color: #f3f2f1;
    color: #605e5c;
    display: flex;
    align-items: center;
    gap: 8px;
}

.case-status.loading::before {
    content: "";
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #d2d0ce;
    border-top-color: #0078d4;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.case-status.success {
    background-color: #dff6dd;
    border: 1px solid #107c10;
    color: #107c10;
}

.case-status.error {
    background-color: #fde7e9;
    border: 1px solid #d13438;
    color: #d13438;
}

.case-status a {
    color: inherit;
    font-weight: 600;
}

/* Loading placeholder animation for input fields */
.case-input.loading,
.case-textarea.loading {
    background: linear-gradient(90deg, #f3f2f1 25%, #e8e6e4 50%, #f3f2f1 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    color: transparent;
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* ============================================================================
   AI Chat Section Styles
   ============================================================================ */

.chat-section {
    margin-top: 20px;
    border: 1px solid #d2d0ce;
    border-radius: 8px;
    background-color: #fff;
    overflow: hidden;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background-color: #f3f2f1;
    border-bottom: 1px solid #d2d0ce;
    cursor: pointer;
    user-select: none;
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-icon {
    font-size: 18px;
    line-height: 1;
}

.chat-title {
    font-size: 14px;
    font-weight: 600;
    color: #323130;
}

.chat-header-right {
    display: flex;
    align-items: center;
    gap: 4px;
}

.chat-header-btn,
.chat-settings-btn,
.chat-toggle-btn {
    background: none;
    border: none;
    font-size: 14px;
    color: #605e5c;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background-color 0.15s ease;
    line-height: 1;
}

.chat-header-btn:hover,
.chat-settings-btn:hover,
.chat-toggle-btn:hover {
    background-color: #e1dfdd;
}

#newChatBtn span {
    font-size: 18px;
    font-weight: 700;
}

.chat-toggle-icon {
    display: inline-block;
    transition: transform 0.2s ease;
}

.chat-section.collapsed .chat-toggle-icon {
    transform: rotate(-90deg);
}

.chat-section.collapsed .chat-body {
    display: none;
}

/* Settings Dropdown */
.chat-settings-dropdown {
    padding: 8px 12px;
    background-color: #faf9f8;
    border-bottom: 1px solid #edebe9;
}

.chat-setting-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #323130;
    cursor: pointer;
}

.chat-setting-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #0078d4;
}

/* Chat Body */
.chat-body {
    display: flex;
    flex-direction: column;
    height: 300px;
}

/* Messages Container */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Welcome Message */
.chat-welcome {
    padding: 12px;
    background-color: #f3f2f1;
    border-radius: 8px;
    font-size: 13px;
    color: #605e5c;
}

.chat-welcome p {
    margin-bottom: 8px;
}

.chat-welcome ul {
    margin: 0;
    padding-left: 20px;
}

.chat-welcome li {
    margin-bottom: 4px;
}

/* Chat Message Bubbles */
.chat-message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
}

.chat-message.user {
    align-self: flex-end;
}

.chat-message.assistant {
    align-self: flex-start;
}

.chat-bubble {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.chat-message.user .chat-bubble {
    background-color: #0078d4;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-message.assistant .chat-bubble {
    background-color: #f3f2f1;
    color: #323130;
    border-bottom-left-radius: 4px;
}

.chat-message-time {
    font-size: 11px;
    color: #8a8886;
    margin-top: 4px;
    padding: 0 4px;
}

.chat-message.user .chat-message-time {
    text-align: right;
}

/* Streaming indicator */
.chat-bubble.streaming::after {
    content: "▋";
    animation: blink 1s infinite;
    margin-left: 2px;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* Thinking state - shown while waiting for AI response */
.chat-bubble.thinking {
    color: #605e5c;
    font-style: italic;
}

.chat-bubble.thinking::after {
    content: "";
    animation: none;
}

/* Activity Log (Dev Mode) */
.chat-activity-log {
    margin-top: 8px;
    padding: 8px 10px;
    background-color: #faf9f8;
    border: 1px solid #edebe9;
    border-radius: 6px;
    font-size: 11px;
    font-family: 'Consolas', 'Monaco', monospace;
}

.chat-activity-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #605e5c;
    cursor: pointer;
    user-select: none;
}

.chat-activity-header:hover {
    color: #323130;
}

.chat-activity-toggle {
    font-size: 10px;
    transition: transform 0.2s ease;
}

.chat-activity-log.collapsed .chat-activity-toggle {
    transform: rotate(-90deg);
}

.chat-activity-log.collapsed .chat-activity-items {
    display: none;
}

.chat-activity-items {
    margin-top: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-activity-item {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    padding: 4px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.chat-activity-item:last-child {
    border-bottom: none;
}

.activity-icon {
    flex-shrink: 0;
    font-size: 12px;
}

.activity-text {
    flex: 1;
    color: #605e5c;
    word-break: break-word;
}

.activity-duration {
    flex-shrink: 0;
    color: #8a8886;
    font-size: 10px;
}

/* Activity item states */
.chat-activity-item.thinking .activity-icon::before {
    content: "💭";
}

.chat-activity-item.tool-call .activity-icon::before {
    content: "🔧";
}

.chat-activity-item.tool-result.success .activity-icon::before {
    content: "✓";
    color: #107c10;
}

.chat-activity-item.tool-result.error .activity-icon::before {
    content: "✗";
    color: #d13438;
}

.chat-activity-item.agent .activity-icon::before {
    content: "🤖";
}

.chat-activity-item.skill .activity-icon::before {
    content: "⚡";
}

/* In-progress spinner for activity */
.chat-activity-item.in-progress .activity-icon {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid #d2d0ce;
    border-top-color: #0078d4;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.chat-activity-item.in-progress .activity-icon::before {
    content: none;
}

/* Chat Input Area */
.chat-input-area {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid #edebe9;
    background-color: #faf9f8;
}

/* Wrapper clips the scrollbar */
.chat-input-wrapper {
    flex: 1;
    position: relative;
    overflow: hidden;
    border: 1px solid #8a8886;
    border-radius: 20px;
    background-color: #fff;
    transition: border-color 0.2s ease;
}

.chat-input-wrapper:focus-within {
    border-color: #0078d4;
}

.chat-input {
    width: calc(100% + 20px); /* Push scrollbar outside visible area */
    padding: 8px 12px 5px 12px;
    padding-right: 32px; /* Compensate for extra width */
    font-size: 14px;
    line-height: 1.4;
    font-family: inherit;
    color: #323130;
    background-color: transparent;
    border: none;
    resize: none;
    min-height: unset;
    max-height: 120px;
    overflow-y: auto;
    overflow-x: hidden;
    box-sizing: border-box;
}

.chat-input:focus {
    outline: none;
}

.chat-input::placeholder {
    color: #a19f9d;
}

.chat-send-btn {
    width: 40px;
    height: 40px;
    padding: 0;
    font-size: 16px;
    color: #fff;
    background-color: #0078d4;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: background-color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-send-btn:hover:not(:disabled) {
    background-color: #106ebe;
}

.chat-send-btn:disabled {
    background-color: #c8c6c4;
    cursor: not-allowed;
}

.chat-send-btn:active:not(:disabled) {
    background-color: #005a9e;
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    background-color: #f3f2f1;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background-color: #8a8886;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) { animation-delay: 0s; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-4px); }
}

/* ============================================================================
   Pop-Out Window Styles
   ============================================================================ */

.popout-context {
    background-color: #f0f6ff;
    border: 1px solid #b4d6fa;
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 12px;
}

.popout-context .context-label {
    font-size: 11px;
    color: #605e5c;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.popout-context .context-subject {
    font-size: 14px;
    font-weight: 600;
    color: #323130;
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.popout-context .context-from {
    font-size: 12px;
    color: #605e5c;
}

/* Multi-select mode context in pop-out */
.popout-context-multi {
    background-color: #fff9e6;
    border-color: #ffb900;
}

.popout-context-multi .context-count {
    font-size: 14px;
    font-weight: 600;
    color: #323130;
    margin-bottom: 4px;
}

.popout-context-multi .context-tracked {
    font-size: 12px;
    color: #107c10;
}

.multi-select-note {
    font-size: 12px;
    color: #605e5c;
    font-style: italic;
    margin-top: 8px;
    text-align: center;
}

/* System messages in chat (email changed, etc.) */
.chat-system-message {
    display: flex;
    justify-content: center;
    padding: 8px 12px;
    margin: 12px 0;
}

.chat-system-message .system-message-content {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background-color: #fff4ce;
    border: 1px solid #ffb900;
    border-radius: 16px;
    font-size: 12px;
    color: #323130;
}

.chat-system-message .system-icon {
    font-size: 14px;
}

.chat-system-message strong {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
    vertical-align: bottom;
}

/* Popped-out state */
.chat-section.popped-out {
    flex: none;
}

.popped-out-status {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    background: linear-gradient(135deg, #f0f6ff 0%, #e8f4f8 100%);
    border-top: 1px solid #d2d0ce;
    text-align: center;
    gap: 12px;
}

.popped-out-icon {
    font-size: 32px;
    margin-bottom: 4px;
}

.popped-out-text {
    color: #323130;
}

.popped-out-text strong {
    display: block;
    font-size: 14px;
    margin-bottom: 4px;
}

.popped-out-text p {
    font-size: 12px;
    color: #605e5c;
    margin: 0;
}

.focus-popout-btn {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    color: #0078d4;
    background-color: #fff;
    border: 1px solid #0078d4;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.focus-popout-btn:hover {
    background-color: #0078d4;
    color: #fff;
}

.popped-out-buttons {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

.pull-back-btn {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    color: #323130;
    background-color: #fff;
    border: 1px solid #8a8886;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.pull-back-btn:hover {
    background-color: #f3f2f1;
    border-color: #605e5c;
}
