/* ==================== */
/* Persistent Copilot Coworker */
/* ==================== */
.copilot-container {
    position: fixed;
    top: 60px;
    right: 12px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

/* When near bottom, flip chat panel above avatar */
.copilot-container.flipped {
    flex-direction: column-reverse;
}

.copilot-container.flipped .copilot-expanded {
    margin-top: 0;
    margin-bottom: 8px;
}

/* Context menu flip-up when near bottom */
.copilot-context-menu.flip-up {
    bottom: auto;
    top: 0;
    transform: translateY(calc(-100% - 4px));
}

/* Resize handle (bottom-left corner of avatar image) */
.copilot-resize-handle {
    position: absolute;
    bottom: 24px;
    left: 0;
    width: 28px;
    height: 28px;
    cursor: nesw-resize;
    pointer-events: auto;
    z-index: 10;
    display: none;
    background: var(--color-bg);
    border-radius: 0 6px 0 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.12);
}

.copilot-resize-handle::after {
    content: '⤢';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 16px;
    color: var(--color-primary-light);
    line-height: 1;
}

.copilot-container.resize-mode .copilot-avatar {
    outline: 2px dashed var(--color-primary-light);
    outline-offset: 2px;
}

/* iOS-style jiggle mode — continuous wobble until user taps elsewhere */
.copilot-container.jiggle-mode .copilot-avatar-wrap {
    animation: iosJiggle 0.25s ease-in-out infinite alternate;
    cursor: grab;
}

.copilot-container.jiggle-mode .copilot-avatar {
    box-shadow:
        0 8px 28px rgba(0, 0, 0, 0.18),
        0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Suppress chat panel while in jiggle mode */
.copilot-container.jiggle-mode .copilot-expanded {
    max-height: 0 !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

@keyframes iosJiggle {
    0% { transform: rotate(-1.5deg); }
    100% { transform: rotate(1.5deg); }
}

/* Actively dragging within jiggle mode */
.copilot-container.dragging .copilot-avatar-wrap {
    animation: none;
    cursor: grabbing;
}

.copilot-container.dragging {
    opacity: 0.9;
}

/* Context menu (options popover) */
.copilot-context-menu {
    position: absolute;
    bottom: 0;
    left: 12px;
    transform: translateY(calc(100% + 4px));
    background: var(--color-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl), 0 0 0 1px var(--color-border);
    padding: 4px;
    min-width: 160px;
    z-index: 10001;
    pointer-events: auto;
}

.copilot-context-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 14px;
    border: none;
    background: transparent;
    color: var(--color-text);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius-md);
    white-space: nowrap;
    transition: background 0.15s ease;
}

.copilot-context-menu-item:hover {
    background: var(--color-bg-muted);
}

.copilot-context-menu-icon {
    font-size: 16px;
    opacity: 0.7;
}

.copilot-avatar-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    position: relative;
    pointer-events: auto;
}

.copilot-avatar {
    width: 112px;
    height: 138px;
    border-radius: 18px;
    object-fit: cover;
    background: var(--color-bg);
    border: 2.5px solid rgba(255, 255, 255, 0.9);
    box-shadow:
        0 4px 20px rgba(0, 0, 0, 0.1),
        0 1px 4px rgba(0, 0, 0, 0.06);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.copilot-avatar-wrap:hover .copilot-avatar {
    border-color: rgba(79, 70, 229, 0.35);
    box-shadow:
        0 6px 28px rgba(79, 70, 229, 0.15),
        0 2px 8px rgba(0, 0, 0, 0.08);
}

.copilot-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text-muted);
    line-height: 1;
    margin-top: 6px;
    transition: color 0.2s ease;
}

.copilot-avatar-wrap:hover .copilot-name {
    color: #4f46e5;
}

/* ··· more options button (inside chat panel) */
.copilot-more-btn {
    background: #fafafa;
    border: none;
    color: var(--color-primary-light);
    font-size: 20px;
    letter-spacing: 3px;
    cursor: pointer;
    padding: 3px 24px;
    line-height: 1;
    text-align: left;
    display: block;
    width: 100%;
    border-radius: 0 0 14px 14px;
    transition: color 0.2s ease;
}

.copilot-more-btn:hover {
    color: var(--color-primary);
}

/* Hide ··· button during jiggle mode */
.copilot-container.jiggle-mode .copilot-more-btn {
    display: none;
}

/* Expanded chat panel — click to open */
.copilot-expanded {
    position: relative;
    width: 340px;
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    background: var(--color-bg);
    border-radius: 14px;
    box-shadow:
        0 8px 40px rgba(0, 0, 0, 0.12),
        0 2px 8px rgba(0, 0, 0, 0.06);
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.25s ease;
    pointer-events: none;
}

.copilot-container.expanded .copilot-expanded {
    max-height: 380px;
    opacity: 1;
    pointer-events: auto;
    overflow: visible;
}

/* Suppress chat panel while dragging */
.copilot-container.dragging .copilot-expanded,
.copilot-container.drag-ready .copilot-expanded {
    max-height: 0 !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

.copilot-chat-messages {
    overflow-y: auto;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 280px;
}

.copilot-chat-messages:not(:empty) {
    flex: 1;
    padding: 14px 16px;
}

.copilot-msg {
    font-size: 13px;
    line-height: 1.5;
    max-width: 90%;
    padding: 10px 14px;
    border-radius: 14px;
}

.copilot-msg p {
    margin-bottom: 6px;
}

.copilot-msg p:last-child {
    margin-bottom: 0;
}

.copilot-msg-assistant {
    background: var(--color-bg-muted);
    color: var(--color-text);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.copilot-msg-user {
    background: var(--color-primary);
    color: #ffffff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

/* Copilot Tooltip (contextual discovery bubble) */
.copilot-tooltip {
    position: fixed;
    background: var(--color-bg);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    padding-right: 28px;
    box-shadow: var(--shadow-lg);
    max-width: 280px;
    z-index: 10001;
    pointer-events: auto;
    font-size: 13px;
    line-height: 1.5;
    animation: tooltipFadeIn 0.25s ease-out;
}

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

.copilot-tooltip-message {
    color: var(--color-text-secondary);
    margin-bottom: 10px;
}

.copilot-tooltip-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.copilot-tooltip-followup {
    background: var(--color-primary-bg);
    border: 1px solid var(--color-primary-border);
    border-radius: 20px;
    padding: 5px 14px;
    font-size: 12px;
    font-weight: 500;
    color: var(--color-primary);
    cursor: pointer;
    transition: all var(--ease-default);
    font-family: inherit;
}

.copilot-tooltip-followup:hover {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

.copilot-tooltip-dismiss {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    font-size: 16px;
    color: var(--color-text-faint);
    cursor: pointer;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    transition: color var(--ease-default);
}

.copilot-tooltip-dismiss:hover {
    color: var(--color-text);
}

/* Copilot Typing Indicator */
.copilot-typing {
    padding: 8px 14px !important;
}

.typing-dots {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 4px 0;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    background: var(--color-text-faint);
    border-radius: var(--radius-full);
    animation: typingBounce 1.4s ease-in-out infinite;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-5px); opacity: 1; }
}

/* Chat Message Fade-In (universal) */
.copilot-msg,
.claude-message,
.or-chat-msg,
.cg-chat-msg,
.ad-writer-msg,
.studio-chat-msg {
    animation: msgFadeIn 0.3s ease-out;
}

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

.copilot-input-area {
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, #f6f7f8 0%, #eff0f2 100%);
    border-radius: 24px;
    padding: 14px 18px 10px 18px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow:
        inset 0 1px 2px rgba(0, 0, 0, 0.04),
        0 1px 0 rgba(255, 255, 255, 0.8);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    margin: 0 12px 12px;
}

.copilot-input-area:focus-within {
    border-color: rgba(79, 70, 229, 0.3);
    box-shadow:
        inset 0 1px 2px rgba(0, 0, 0, 0.04),
        0 0 0 3px rgba(79, 70, 229, 0.1);
}

.copilot-input {
    width: 100%;
    border: none;
    background: transparent;
    padding: 0 0 8px 0;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    box-shadow: none;
    -webkit-appearance: none;
    color: var(--color-text);
    resize: none;
    max-height: 120px;
    line-height: 1.5;
}

.copilot-input:focus {
    outline: none;
    border: none;
    box-shadow: none;
}

.copilot-input::placeholder {
    color: #6b6b6b;
}

.copilot-send {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: #1a1a1a;
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
    align-self: flex-end;
}

.copilot-send:hover {
    background: #333333;
    transform: scale(1.05);
}

.copilot-send:active {
    transform: scale(0.95);
}

.copilot-send:disabled {
    background: #d1d5db;
    cursor: not-allowed;
}

/* Tab Content */
.tab-content {
    flex: 1;
    overflow: hidden;
    background: var(--color-bg-canvas);
}

.tab-panel {
    display: none;
    height: 100%;
}

.tab-panel.active {
    display: block;
}

