/* Floating Interaction Panel - Phase 2 (Compact Layout) */

/* Trigger Button */
.interaction-trigger-btn {
    position: fixed;
    bottom: 50px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #007bff, #0056b3);
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.4);
    transition: all 0.3s ease;
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
}

.interaction-trigger-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 123, 255, 0.5);
}

.interaction-trigger-btn.hidden {
    display: none;
}

/* Main Panel */
.interaction-panel {
    position: fixed;
    bottom: 120px;
    right: 20px;
    width: 380px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    z-index: 9999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 13px;
}

.interaction-panel.visible {
    display: flex;
}

/* Panel Header */
.interaction-panel-header {
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: white;
    padding: 10px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: move;
    user-select: none;
}

.interaction-panel-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.interaction-panel-header-actions {
    display: flex;
    gap: 6px;
}

.interaction-panel-header-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.interaction-panel-header-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Panel Body */
.interaction-panel-body {
    padding: 12px;
    max-height: 60vh;
    overflow-y: auto;
}

/* Compact Row Layout */
.ip-row {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    gap: 8px;
}

.ip-row.hidden {
    display: none;
}

.ip-label {
    width: 60px;
    font-size: 12px;
    font-weight: 600;
    color: #555;
    flex-shrink: 0;
}

/* Type Options - Icon + Text */
.ip-type-options {
    display: flex;
    gap: 4px;
    flex: 1;
    flex-wrap: wrap;
}

.ip-type-opt {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    background: #f5f5f5;
    border: 2px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
    font-size: 12px;
}

.ip-type-opt:hover {
    background: #e8e8e8;
    border-color: #bbb;
}

.ip-type-opt.selected {
    background: #e3f2fd;
    border-color: #007bff;
}

.ip-type-opt input[type="radio"] {
    display: none;
}

.ip-type-icon {
    font-size: 14px;
}

.ip-type-text {
    font-weight: 500;
    color: #333;
}

.ip-type-opt.selected .ip-type-text {
    color: #007bff;
}

/* Direction Options - Compact */
.ip-direction-options {
    display: flex;
    gap: 6px;
    flex: 1;
}

.ip-dir-opt {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px 16px;
    background: #f5f5f5;
    border: 2px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.15s;
}

.ip-dir-opt:hover {
    background: #e8e8e8;
    border-color: #bbb;
}

.ip-dir-opt.selected {
    background: #e3f2fd;
    border-color: #007bff;
    color: #007bff;
}

.ip-dir-opt input[type="radio"] {
    display: none;
}

/* Section Divider */
.ip-divider {
    height: 1px;
    background: #e0e0e0;
    margin: 8px 0;
}

/* Dropdown Wrapper */
.ip-dropdown-wrap {
    flex: 1;
    position: relative;
}

.ip-dropdown-input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
    box-sizing: border-box;
}

.ip-dropdown-input:focus {
    outline: none;
    border-color: #007bff;
}

.ip-clear-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #999;
    font-size: 16px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.ip-clear-btn:hover {
    color: #dc3545;
}

/* CRA Dashboard Link */
.ip-cra-link {
    position: absolute;
    right: 28px;
    top: 50%;
    transform: translateY(-50%);
    color: #007bff;
    font-size: 14px;
    text-decoration: none;
    padding: 2px 4px;
    line-height: 1;
    z-index: 1;
}

.ip-cra-link:hover {
    color: #0056b3;
}

.ip-cra-link.hidden {
    display: none;
}

.ip-clear-btn.hidden {
    display: none;
}

/* Dropdown List */
.ip-dropdown-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 180px;
    overflow-y: auto;
    background: white;
    border: 1px solid #007bff;
    border-top: none;
    border-radius: 0 0 6px 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 200;
}

.ip-dropdown-list.hidden {
    display: none;
}

.ip-dropdown-item {
    padding: 8px 10px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
}

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

.ip-dropdown-item:hover {
    background: #f0f7ff;
}

.ip-item-main {
    font-size: 13px;
    color: #333;
    display: block;
}

.ip-item-sub {
    font-size: 11px;
    color: #888;
    display: block;
    margin-top: 2px;
}

.ip-item-badge {
    font-size: 10px;
    color: #666;
    background: #f0f0f0;
    padding: 2px 6px;
    border-radius: 10px;
    float: right;
    margin-top: 2px;
}

.ip-dropdown-empty {
    padding: 12px 10px;
    text-align: center;
    color: #888;
    font-size: 12px;
}

.ip-dropdown-header {
    padding: 8px 10px;
    background: #f8f9fa;
    color: #495057;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    border-bottom: 1px solid #e9ecef;
}

.ip-dropdown-divider {
    height: 1px;
    background: #e9ecef;
    margin: 4px 0;
}

.ip-add-person-cra-item {
    border-top: 1px solid #e9ecef;
    background: #f0f9ff;
}

.ip-add-person-cra-item:hover {
    background: #e0f0ff !important;
}

.ip-new-lead-item {
    background: #f8f5ff;
    border-top: 1px solid #e0d8f0;
}

.ip-new-lead-item:hover {
    background: #f0e8ff;
}

.ip-new-lead-item .ip-item-main {
    color: #6f42c1;
    font-weight: 500;
}

/* Notes Row */
.ip-notes-row {
    margin-bottom: 8px;
}

.ip-notes-row .ip-label {
    display: block;
    margin-bottom: 4px;
    width: auto;
}

.ip-notes {
    width: 100%;
    min-height: 60px;
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    resize: vertical;
    box-sizing: border-box;
}

.ip-notes:focus {
    outline: none;
    border-color: #007bff;
}

/* Multi-select Row (Who, Entities) */
.ip-row-multi {
    align-items: flex-start;
}

.ip-row-multi .ip-label {
    padding-top: 6px;
}

.ip-multi-wrap {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

/* Pills */
.ip-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.ip-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: #e3f2fd;
    border: 1px solid #90caf9;
    border-radius: 14px;
    font-size: 12px;
    color: #1565c0;
}

.ip-pill-x {
    background: none;
    border: none;
    color: #1565c0;
    font-size: 14px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    opacity: 0.7;
}

.ip-pill-x:hover {
    opacity: 1;
    color: #dc3545;
}

/* Entity Pills (green) */
.ip-pill-entity {
    background: #e8f5e9;
    border-color: #a5d6a7;
    color: #2e7d32;
}

.ip-pill-entity .ip-pill-x {
    color: #2e7d32;
}

/* Entity Toggle Chips */
.ip-entity-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.ip-entity-chip {
    display: inline-block;
    padding: 4px 10px;
    font-size: 11px;
    border-radius: 12px;
    cursor: pointer;
    border: 1px solid #ccc;
    background: #f8f9fa;
    color: #666;
    transition: all 0.15s ease;
    user-select: none;
}

.ip-entity-chip:hover {
    border-color: #2e7d32;
    color: #2e7d32;
}

.ip-entity-chip.selected {
    background: #e8f5e9;
    border-color: #2e7d32;
    color: #2e7d32;
    font-weight: 600;
}

/* Contact Sections */
.ip-client-section,
.ip-lead-section,
.ip-new-lead-section {
    padding: 8px 0;
}

.ip-client-section.hidden,
.ip-lead-section.hidden,
.ip-new-lead-section.hidden {
    display: none;
}

/* Lead Info Display */
.ip-lead-info {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: #fff8e1;
    border: 1px solid #ffe082;
    border-radius: 6px;
}

.ip-lead-badge {
    background: #ff9800;
    color: white;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 3px;
    text-transform: uppercase;
}

.ip-lead-name {
    flex: 1;
    font-weight: 500;
    color: #333;
}

.ip-lead-link {
    font-size: 12px;
    color: #1976d2;
    text-decoration: none;
}

.ip-lead-link:hover {
    text-decoration: underline;
}

/* New Lead Section */
.ip-new-lead-section {
    text-align: center;
    padding: 15px;
}

.ip-btn-new-lead {
    background: #4caf50;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
}

.ip-btn-new-lead:hover {
    background: #43a047;
}

/* Add Button */
.ip-add-wrap {
    position: relative;
}

.ip-add-btn {
    padding: 4px 10px;
    background: #f5f5f5;
    border: 1px dashed #ccc;
    border-radius: 14px;
    font-size: 12px;
    color: #666;
    cursor: pointer;
}

.ip-add-btn:hover {
    background: #e8e8e8;
    border-color: #999;
}

.ip-add-wrap .ip-dropdown-list {
    min-width: 220px;
    left: 0;
    right: auto;
}

/* Standard Input (for time fields, etc.) */
.ip-input {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
    box-sizing: border-box;
}

.ip-input:focus {
    outline: none;
    border-color: #007bff;
}

/* Panel Footer */
.interaction-panel-footer {
    padding: 10px 12px;
    background: #f8f9fa;
    border-top: 1px solid #e0e0e0;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.interaction-panel-footer.hidden {
    display: none;
}

.ip-btn {
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.15s;
}

.ip-btn-cancel {
    background: #f0f0f0;
    color: #555;
}

.ip-btn-cancel:hover {
    background: #e0e0e0;
}

.ip-btn-save {
    background: linear-gradient(135deg, #28a745, #218838);
    color: white;
}

.ip-btn-save:hover {
    background: linear-gradient(135deg, #218838, #1e7e34);
}

.ip-btn-save:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Inline Cancel Warning */
.ip-cancel-warning {
    padding: 12px;
    background: #fff8e1;
    border-top: 1px solid #ffe082;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.ip-cancel-warning.hidden {
    display: none;
}

.ip-warning-text {
    font-size: 13px;
    color: #f57c00;
    font-weight: 500;
}

.ip-warning-btns {
    display: flex;
    gap: 10px;
}

.ip-btn-keep {
    background: #f0f0f0;
    color: #555;
}

.ip-btn-keep:hover {
    background: #e0e0e0;
}

.ip-btn-discard {
    background: #dc3545;
    color: white;
}

.ip-btn-discard:hover {
    background: #c82333;
}

/* Minimized Panel */
.interaction-panel-minimized {
    position: fixed;
    bottom: 50px;
    right: 20px;
    background: white;
    border-radius: 25px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    padding: 8px 14px;
    display: none;
    align-items: center;
    gap: 10px;
    z-index: 9999;
    cursor: pointer;
}

.interaction-panel-minimized.visible {
    display: flex;
}

.interaction-panel-minimized:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.ip-min-icon {
    font-size: 16px;
}

.ip-min-timer {
    font-size: 14px;
    font-weight: 700;
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
    color: #333;
}

.ip-min-btn {
    background: #007bff;
    color: white;
    border: none;
    padding: 5px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.ip-min-btn:hover {
    background: #0056b3;
}

/* Inline Lead Form */
.ip-lead-form {
    background: #f8f5ff;
    border: 2px solid #6f42c1;
    border-radius: 8px;
    margin: 8px 0;
    overflow: hidden;
}

.ip-lead-form.hidden {
    display: none;
}

.ip-lead-form-header {
    background: linear-gradient(135deg, #6f42c1, #5a32a3);
    color: white;
    padding: 8px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ip-lead-form-title {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.ip-lead-form-cancel {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 22px;
    height: 22px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.ip-lead-form-cancel:hover {
    background: rgba(255, 255, 255, 0.3);
}

.ip-lead-form-body {
    padding: 10px;
    overflow: hidden;
}

.ip-lead-row {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    gap: 8px;
    overflow: hidden;
}

.ip-lead-row:last-child {
    margin-bottom: 0;
}

.ip-lead-label {
    width: 50px;
    font-size: 11px;
    font-weight: 600;
    color: #555;
    flex-shrink: 0;
}

.ip-lead-name-fields {
    display: flex;
    gap: 4px;
    flex: 1;
    flex-wrap: wrap;
    min-width: 0;
}

.ip-lead-input {
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 12px;
    box-sizing: border-box;
    min-width: 0;
}

.ip-lead-input:focus {
    outline: none;
    border-color: #6f42c1;
}

.ip-lead-prefix,
.ip-lead-suffix {
    width: 48px;
    flex-shrink: 0;
    padding: 6px 4px;
    font-size: 11px;
}

.ip-lead-first,
.ip-lead-last {
    flex: 1 1 70px;
    min-width: 60px;
}

.ip-lead-full {
    flex: 1;
    width: 100%;
    max-width: 100%;
}

.ip-lead-form-footer {
    padding: 8px 10px;
    background: #f0ebf8;
    border-top: 1px solid #e0d8f0;
    display: flex;
    justify-content: flex-end;
}

.ip-btn-create-lead {
    background: linear-gradient(135deg, #6f42c1, #5a32a3);
    color: white;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.ip-btn-create-lead:hover {
    background: linear-gradient(135deg, #5a32a3, #4a2793);
}

.ip-btn-create-lead:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Lead form validation error state */
.ip-lead-input.error {
    border-color: #dc3545;
    background: #fff5f5;
}

/* Responsive */
@media (max-width: 420px) {
    .interaction-panel {
        width: calc(100vw - 40px);
        right: 20px;
        bottom: 80px;
    }

    .ip-type-options {
        gap: 3px;
    }

    .ip-type-opt {
        padding: 4px 8px;
        font-size: 11px;
    }

    .ip-lead-name-fields {
        flex-wrap: wrap;
    }

    .ip-lead-prefix,
    .ip-lead-suffix {
        width: 48px;
    }

    .ip-lead-first,
    .ip-lead-last {
        flex-basis: calc(50% - 28px);
    }
}
