/*
 * Pipali Styles - Confirmation Dialogs & Toasts
 * Includes: confirmation dialogs, toast notifications, badges
 */

/* ========================================
   Confirmation Dialog Styles (compact)
   ======================================== */

.confirmation-container {
    max-width: 800px;
    margin: 0 auto 8px auto;
    padding: 0 24px;
    animation: slide-up 0.15s ease-out;
}

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

.confirmation-dialog {
    background: var(--color-bg);
    border-radius: 10px;
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-md);
    width: 100%;
    overflow: hidden;
}

.confirmation-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-light);
    background: var(--color-bg-elevated);
}

.confirmation-title {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Question badge for agent questions */
.question-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--color-info-bg);
    color: var(--color-info-text);
    flex-shrink: 0;
}

/* Agent question title styling */
.agent-question-title {
    display: flex;
    align-items: center;
    gap: 5px;
    color: var(--color-info-text);
}

.agent-question-title .question-icon {
    flex-shrink: 0;
}

/* Agent question dialog styling */
.confirmation-dialog.agent-question {
    border-color: var(--color-info-border);
}

.confirmation-dialog.agent-question .confirmation-header {
    background: var(--color-info-bg);
    border-bottom-color: var(--color-info-border);
}

/* Toast agent question styling */
.confirmation-toast--question {
    border-color: var(--color-info-border);
}

.confirmation-toast--question .toast-header {
    background: var(--color-info-bg);
}

/* Badges container */
.confirmation-badges {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

/* Operation type pill styles */
.operation-type-pill {
    display: inline-block;
    width: fit-content;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 3px;
    text-transform: lowercase;
    letter-spacing: 0.3px;
    font-family: var(--font-mono);
}

.operation-type-pill.read-only,
.operation-type-pill.safe {
    background: var(--color-info-bg);
    color: var(--color-info-text);
}

.operation-type-pill.write-only {
    background: var(--color-warning-bg);
    color: var(--color-warning-text);
}

.operation-type-pill.read-write,
.operation-type-pill.unsafe {
    background: #fce7f3;
    color: #9d174d;
}

.confirmation-body {
    padding: 10px 12px;
    max-height: 40vh;
    overflow-y: auto;
}

.confirmation-message {
    color: var(--color-text-secondary);
    font-size: 13px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.confirmation-message p {
    margin: 0 0 8px 0;
}

.confirmation-message p:last-child {
    margin-bottom: 0;
}

.confirmation-message strong {
    color: var(--color-text);
    font-weight: 600;
    word-break: break-all;
}

/* Command execution confirmation styles */
.command-confirmation {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.command-section {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.command-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.command-section-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.workdir-pill {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--color-text-secondary);
    background: var(--color-bg-elevated);
    padding: 2px 6px;
    border-radius: 10px;
    border: 1px solid var(--border-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 250px;
}

.command-section-content {
    margin: 0;
}

.reason-content {
    font-size: 13px;
    line-height: 1.4;
    color: var(--color-text-secondary);
    padding: 6px 10px;
    border-left: 2px solid var(--color-success-text, #22c55e);
    background: var(--color-bg-elevated);
    border-radius: 0 4px 4px 0;
}

.command-content {
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.4;
    color: var(--color-text);
    padding: 8px 10px;
    background: var(--color-bg-elevated);
    border-radius: 6px;
    border: 1px solid var(--border-light);
    max-height: 150px;
    overflow-y: auto;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0;
}

.command-content code {
    font-family: inherit;
    background: none;
    padding: 0;
}

/* MCP Tool confirmation styles */
.mcp-tool-confirmation {
    display: flex;
    flex-direction: column;
}

.mcp-args-list {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 8px 10px;
    background: var(--color-bg-elevated);
    border-radius: 6px;
    border: 1px solid var(--border-light);
}

.mcp-arg-row {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    font-size: 12px;
}

.mcp-arg-key {
    font-family: var(--font-mono);
    font-weight: 500;
    color: var(--color-text-secondary);
    flex-shrink: 0;
}

.mcp-arg-separator {
    color: var(--text-muted);
    flex-shrink: 0;
}

/* Argument value styling */
.arg-value {
    font-family: var(--font-mono);
    word-break: break-word;
}

.arg-value.null {
    color: var(--text-muted);
    font-style: italic;
}

.arg-value.boolean {
    font-weight: 500;
}

.arg-value.boolean.true {
    color: #22c55e;
}

.arg-value.boolean.false {
    color: #ef4444;
}

.arg-value.number {
    color: #3b82f6;
}

.arg-value.string {
    color: var(--color-text);
    background: var(--color-bg-muted);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 11px;
}

.arg-value.object {
    margin: 2px 0 0 0;
    padding: 6px;
    background: var(--color-bg-muted);
    border-radius: 4px;
    font-size: 10px;
    line-height: 1.4;
    overflow-x: auto;
    max-height: 80px;
    overflow-y: auto;
}

.arg-value.object code {
    font-family: inherit;
    background: none;
    padding: 0;
}

.confirmation-files {
    margin-top: 8px;
    padding: 8px 10px;
    background: var(--color-bg-elevated);
    border-radius: 6px;
}

.files-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.files-list {
    margin: 4px 0 0 0;
    padding: 0;
    list-style: none;
}

.file-item {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--color-text);
    padding: 2px 0;
    word-break: break-all;
}

.confirmation-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 12px;
    border-top: 1px solid var(--border-light);
    background: var(--color-bg-elevated);
    overflow-x: auto;
}

.confirmation-btn {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    border: 1px solid transparent;
    white-space: nowrap;
}

.confirmation-btn.primary {
    background: var(--color-accent);
    color: var(--color-bg);
    border-color: var(--color-accent);
}

.confirmation-btn.primary:hover {
    background: var(--color-accent-hover);
    border-color: var(--color-accent-hover);
}

.confirmation-btn.secondary {
    background: var(--color-bg);
    color: var(--color-text-secondary);
    border-color: var(--color-border);
}

.confirmation-btn.secondary:hover {
    background: var(--color-bg-muted);
    color: var(--color-text);
}

.confirmation-btn.danger {
    background: var(--color-error-bg);
    color: var(--color-error-text);
    border-color: var(--color-error-border);
}

.confirmation-btn.danger:hover {
    background: var(--color-error-border);
}

.confirmation-btn.warning {
    background: var(--color-warning-bg);
    color: var(--color-warning-text);
    border-color: #fde68a;
}

.confirmation-btn.warning:hover {
    background: #fde68a;
}

/* Keyboard shortcut badges */
.btn-shortcut {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    margin-right: 4px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
}

.confirmation-btn.primary .btn-shortcut {
    background: rgba(255, 255, 255, 0.2);
}

.confirmation-btn.danger .btn-shortcut {
    background: rgba(153, 27, 27, 0.15);
}

/* Diff display styles */
.diff-container {
    border: 1px solid var(--color-border);
    border-radius: 6px;
    overflow: hidden;
    font-family: var(--font-mono);
    font-size: 12px;
}

.diff-file-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: var(--color-bg-muted);
    border-bottom: 1px solid var(--color-border);
    font-size: 11px;
    font-weight: 500;
    color: var(--color-text);
}

.diff-file-path {
    word-break: break-all;
}

.diff-inline {
    padding: 0;
    margin: 0;
    overflow-y: auto;
    /* height managed by parent .confirmation-body max-height: 40vh */
}

.diff-line {
    display: flex;
    padding: 1px 10px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.diff-line.context {
    background: var(--color-bg-elevated);
    color: var(--color-text-secondary);
}

.diff-line.removed {
    background: var(--color-error-bg);
    color: var(--color-error-text);
}

.diff-line.added {
    background: var(--color-success-bg);
    color: var(--color-success-text);
}

.diff-line-indicator {
    flex-shrink: 0;
    width: 16px;
    font-weight: 600;
    user-select: none;
}

.diff-line-content {
    flex: 1;
    min-width: 0;
}

.diff-meta {
    padding: 4px 10px;
    font-size: 10px;
    color: var(--color-text-muted);
    background: var(--color-bg-muted);
    border-top: 1px solid var(--color-border);
}

@media (max-width: 480px) {
    .confirmation-container {
        padding: 0 12px;
    }

    .confirmation-actions {
        flex-wrap: wrap;
        gap: 6px;
        justify-content: space-around;
    }

    .confirmation-btn {
        width: auto;
        padding: 10px 12px;
        font-size: 14px;
    }
}

/* ========================================
   Toast Notification Styles
   ======================================== */

.toast-container {
    position: fixed;
    bottom: 100px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 1000;
    max-width: 400px;
    pointer-events: none;
}

.toast-container > * {
    pointer-events: auto;
}

.confirmation-toast {
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    animation: toast-slide-in 0.2s ease-out;
}

@keyframes toast-slide-in {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 14px;
    background: var(--color-bg-muted);
    border-bottom: 1px solid var(--color-border);
}

.toast-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.toast-info-clickable {
    cursor: pointer;
    border-radius: var(--radius-sm);
    padding: 4px;
    margin: -4px;
    transition: background var(--transition);
}

.toast-info-clickable:hover {
    background: var(--bg-hover, rgba(0, 0, 0, 0.05));
}

.toast-conversation {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.toast-conversation-clickable {
    cursor: pointer;
    border-radius: var(--radius-sm);
    padding: 2px 4px;
    margin: -2px -4px;
    transition: background var(--transition);
}

.toast-conversation-clickable:hover {
    background: var(--bg-hover, rgba(0, 0, 0, 0.05));
}

.toast-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.toast-title {
    font-size: 11px;
    color: var(--color-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.toast-preview {
    font-size: 12px;
    color: var(--color-text-secondary);
    line-height: 1.4;
    margin-top: 2px;
    /* Allow up to 3 lines */
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    white-space: normal;
}

.toast-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

.toast-expand-btn,
.toast-close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--color-text-muted);
    cursor: pointer;
    transition: all var(--transition);
}

.toast-expand-btn:hover,
.toast-close-btn:hover {
    background: var(--color-bg-elevated);
    color: var(--color-text);
}

.toast-body {
    padding: 12px 14px;
    max-height: 200px;
    overflow-y: auto;
    border-bottom: 1px solid var(--color-border);
}

.toast-message {
    font-size: 13px;
    color: var(--color-text-secondary);
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Toast command section (for bash command confirmations) */
.toast-command-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.toast-command-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toast-command-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.toast-workdir {
    font-size: 10px;
    color: var(--color-text-muted);
    background: var(--color-bg-muted);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
}

.toast-command-code {
    margin: 0;
    padding: 8px 10px;
    background: var(--color-bg-muted);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 11px;
    line-height: 1.4;
    color: var(--color-text);
    max-height: 150px;
    overflow-y: auto;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

.toast-command-code code {
    font-family: inherit;
}

/* Toast reason section (for bash command confirmations) */
.toast-reason-section {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
}

.toast-reason-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.toast-reason-content {
    font-size: 13px;
    color: var(--color-text-secondary);
    line-height: 1.4;
}

.toast-actions {
    display: flex;
    gap: 8px;
    padding: 10px 14px;
    overflow-x: auto;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
}

.toast-actions::-webkit-scrollbar {
    height: 3px;
}

.toast-actions::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 2px;
}

.toast-btn {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 7px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    border: 1px solid transparent;
    white-space: nowrap;
}

.toast-btn .btn-shortcut {
    width: 16px;
    height: 16px;
    font-size: 10px;
    margin-right: 4px;
}

.toast-btn.primary {
    background: var(--color-accent);
    color: var(--color-bg);
    border-color: var(--color-accent);
}

.toast-btn.primary:hover {
    background: var(--color-accent-hover);
    border-color: var(--color-accent-hover);
}

.toast-btn.secondary {
    background: var(--color-bg-muted);
    color: var(--color-text-secondary);
    border-color: var(--color-border);
}

.toast-btn.secondary:hover {
    background: var(--color-border);
    color: var(--color-text);
}

.toast-btn.danger {
    background: var(--color-error-bg);
    color: var(--color-error-text);
    border-color: var(--color-error-border);
}

.toast-btn.danger:hover {
    background: var(--color-error-border);
}

/* Responsive toast positioning */
@media (max-width: 480px) {
    .toast-container {
        left: 16px;
        right: 16px;
        bottom: 120px;
        max-width: none;
    }

    .toast-actions {
        flex-wrap: wrap;
        gap: 6px;
    }

    .toast-btn {
        padding: 10px 12px;
        font-size: 14px;
    }
}

/* Guidance input in confirmation section */
.guidance-input-section {
    padding: 12px 20px 16px;
    border-top: 1px solid var(--border-light);
}

/* Toast - guidance input row with send button */
.toast-guidance-row {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 8px 14px 12px;
    border-top: 1px solid var(--color-border);
}

.toast-guidance-input {
    flex: 1;
    min-width: 0;
    padding: 6px 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-bg);
    color: var(--color-text);
    font-size: 12px;
    font-family: inherit;
    height: 32px;
    box-sizing: border-box;
}

.toast-guidance-input:focus {
    outline: none;
    border-color: var(--color-accent);
}

.toast-guidance-input::placeholder {
    color: var(--text-muted);
}

.toast-guidance-send {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    padding: 0;
    background: var(--color-accent);
    color: var(--color-bg);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
}

.toast-guidance-send:hover:not(:disabled) {
    background: var(--color-accent-hover);
}

.toast-guidance-send:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* Automation confirmation toast variant */
.confirmation-toast--automation {
    border-left: 3px solid #f59e0b;
}

.confirmation-toast--automation .automation-source {
    display: flex;
    align-items: center;
    gap: 4px;
    color: #b45309;
}

.toast-expiry {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--color-text-muted);
    padding: 2px 6px;
    background: var(--color-bg-muted);
    border-radius: var(--radius-sm);
}

/* Toast guidance section */
.toast-guidance-section {
    padding: 8px 14px 10px;
    border-top: 1px solid var(--border-light);
}

.toast-guidance-input-row {
    display: flex;
    gap: 6px;
    align-items: center;
}

.toast-guidance-actions {
    display: flex;
    gap: var(--space-2);
    justify-content: flex-end;
}
