/**
 * Dalfred CSS Styles
 * Modern chat interface for AI assistant
 */

/* Dalfred branding palette — overridden inline by BrandingService::getCssVariables() */
:root {
    --dalfred-primary: #4CAF50;
    --dalfred-secondary: #45a049;
    --dalfred-primary-shadow: rgba(76, 175, 80, 0.3);
    --dalfred-primary-shadow-hover: rgba(76, 175, 80, 0.4);
}

/* Lucide icons inline alignment — SVG default baseline pushes them off-line */
svg.lucide {
    vertical-align: middle;
    width: 1em;
    height: 1em;
}
svg.lucide.dalfred-icon-lg {
    width: 1.4em;
    height: 1.4em;
}
svg.lucide.dalfred-icon-md {
    width: 1.2em;
    height: 1.2em;
}
svg.dalfred-icon-missing {
    vertical-align: middle;
    width: 1em;
    height: 1em;
}

/* Branded logo rendered as <img>. Caps the size so an oversized uploaded
   asset cannot break the layout. Size classes (dalfred-icon-md, -lg) match
   the matching SVG variants so the brand image follows the surrounding
   text scale when used inline. */
img.dalfred-agent-logo {
    max-width: 48px;
    max-height: 48px;
    object-fit: contain;
    vertical-align: middle;
}
img.dalfred-agent-logo.dalfred-icon-md {
    width: 1.2em;
    height: 1.2em;
}
img.dalfred-agent-logo.dalfred-icon-lg {
    width: 1.4em;
    height: 1.4em;
}

/* Brand icon for the top-right login_block entry. Uses the uploaded brand
   logo as a background-image when present, otherwise wraps the Lucide bot
   SVG fallback rendered server-side. Sized to match the neighboring
   Font Awesome toolbar icons (~15-16px glyphs; the Lucide grid has more
   internal padding so 18px is the optical equivalent). */
.dalfred-brand-icon {
    display: inline-block;
    width: 18px;
    height: 18px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    vertical-align: middle;
}
.dalfred-brand-icon > svg.lucide {
    width: 100%;
    height: 100%;
    vertical-align: top;
}

/* Chat Widget Toggle Button */
.dalfred-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10000;
    background: linear-gradient(135deg, var(--dalfred-primary), var(--dalfred-secondary));
    color: white;
    border: none;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    font-size: 24px;
    cursor: grab;
    box-shadow: 0 4px 20px var(--dalfred-primary-shadow);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-user-drag: none;
    user-drag: none;
}

.dalfred-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px var(--dalfred-primary-shadow-hover);
}

.dalfred-toggle.dalfred-dragging {
    cursor: grabbing;
    transition: none;
    transform: none;
    box-shadow: 0 6px 25px var(--dalfred-primary-shadow-hover);
}

.dalfred-toggle.active {
    background: linear-gradient(135deg, #ff5722, #f44336);
}

/* Chat Container */
.dalfred-chat {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 380px;
    height: 520px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    z-index: 9999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #e0e0e0;
}

.dalfred-chat.active {
    display: flex;
    animation: dalfredSlideUp 0.3s ease-out;
}

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

/* Chat Header */
.dalfred-header {
    background: linear-gradient(135deg, var(--dalfred-primary), var(--dalfred-secondary));
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dalfred-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.dalfred-header-actions {
    display: flex;
    gap: 8px;
}

.dalfred-header-actions button {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

/* Header action buttons: SVG icons should fill nicely */
.dalfred-header-actions button svg.lucide {
    width: 16px;
    height: 16px;
}

/* Send button: SVG larger and tilted forward like a paper plane */
.dalfred-send svg.lucide {
    width: 18px;
    height: 18px;
}

/* Error icon: aligned with text */
.dalfred-error-icon {
    color: #c62828;
    margin-right: 4px;
}

.dalfred-header-actions button:hover {
    background: rgba(255,255,255,0.3);
}

.dalfred-status {
    font-size: 11px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
}

.dalfred-status-dot {
    width: 8px;
    height: 8px;
    background: #90EE90;
    border-radius: 50%;
    animation: dalfredPulse 2s infinite;
}

@keyframes dalfredPulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* Chat Messages */
.dalfred-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #fafafa;
}

.dalfred-message {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
}

.dalfred-message.user {
    align-items: flex-end;
}

.dalfred-message.assistant {
    align-items: flex-start;
}

.dalfred-message-content {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.dalfred-message.user .dalfred-message-content {
    background: linear-gradient(135deg, #2196F3, #1976D2);
    color: white;
    border-bottom-right-radius: 5px;
}

.dalfred-message.assistant .dalfred-message-content {
    background: white;
    color: #333;
    border: 1px solid #e0e0e0;
    border-bottom-left-radius: 5px;
}

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

/* Links in messages */
.dalfred-link {
    color: #2196F3;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: all 0.2s;
}

.dalfred-link:hover {
    color: #1976d2;
    border-bottom-color: #1976d2;
}

.dalfred-message.user .dalfred-link {
    color: #ffffff;
    border-bottom-color: rgba(255, 255, 255, 0.5);
}

.dalfred-message.user .dalfred-link:hover {
    border-bottom-color: #ffffff;
}

/* Typing Indicator */
.dalfred-typing {
    display: none;
    padding: 12px 16px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 18px;
    border-bottom-left-radius: 5px;
    margin-bottom: 15px;
    max-width: 80px;
}

.dalfred-typing.active {
    display: flex;
    align-items: center;
    gap: 4px;
}

.dalfred-typing-dot {
    width: 6px;
    height: 6px;
    background: #999;
    border-radius: 50%;
    animation: dalfredTyping 1.4s infinite ease-in-out;
}

.dalfred-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.dalfred-typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes dalfredTyping {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Chat Input — outer "send area" (same shape as fullscreen):
 * [errors] [preview chips] [row of controls]
 * The actual flex row of textarea + buttons lives in .dalfred-input-row. */
.dalfred-input-container {
    padding: 12px 15px;
    background: white;
    border-top: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
}
.dalfred-input-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.dalfred-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 10px 15px;
    font-size: 14px;
    resize: none;
    min-height: 20px;
    max-height: 80px;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
}

.dalfred-input:focus {
    border-color: var(--dalfred-primary);
}

.dalfred-send {
    background: linear-gradient(135deg, var(--dalfred-primary), var(--dalfred-secondary));
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.dalfred-send:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 2px 10px var(--dalfred-primary-shadow);
}

.dalfred-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Error Messages */
.dalfred-error {
    background: #ffebee;
    border: 1px solid #ffcdd2;
    color: #c62828;
    padding: 12px 16px;
    border-radius: 18px;
    border-bottom-left-radius: 5px;
    font-size: 14px;
    max-width: 85%;
}

/* Welcome Message */
.dalfred-welcome {
    background: #e8f5e9;
    border: 1px solid #c8e6c9;
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 15px;
    font-size: 13px;
}

.dalfred-welcome h4 {
    margin: 0 0 10px 0;
    color: #2e7d32;
    font-size: 14px;
}

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

.dalfred-welcome li {
    margin-bottom: 5px;
    color: #1b5e20;
}

/* ====================================
   FULLSCREEN MODAL MODE (widget expand)
   ==================================== */

.dalfred-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    animation: dalfredFadeIn 0.2s ease-out;
}

@keyframes dalfredFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.dalfred-chat.dalfred-fullscreen-mode {
    position: fixed;
    top: 20px;
    left: 20px;
    right: 20px;
    bottom: 20px;
    width: auto;
    height: auto;
    border-radius: 12px;
    z-index: 10001;
    animation: dalfredScaleIn 0.25s ease-out;
}

@keyframes dalfredScaleIn {
    from {
        opacity: 0.8;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.dalfred-chat.dalfred-fullscreen-mode .dalfred-messages {
    padding: 25px 40px;
}

.dalfred-chat.dalfred-fullscreen-mode .dalfred-message-content {
    max-width: 70%;
}

.dalfred-chat.dalfred-fullscreen-mode .dalfred-input-container {
    padding: 15px 40px;
}

.dalfred-chat.dalfred-fullscreen-mode .dalfred-input {
    font-size: 15px;
    padding: 12px 18px;
}

/* Responsive Design */
@media (max-width: 480px) {
    .dalfred-chat {
        width: calc(100vw - 40px);
        height: calc(100vh - 120px);
        right: 20px;
        left: 20px;
        bottom: 90px;
    }

    .dalfred-toggle {
        bottom: 15px;
        right: 15px;
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
}

@media (max-width: 480px) {
    .dalfred-chat.dalfred-fullscreen-mode {
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        border-radius: 0;
    }

    .dalfred-chat.dalfred-fullscreen-mode .dalfred-messages {
        padding: 15px;
    }

    .dalfred-chat.dalfred-fullscreen-mode .dalfred-input-container {
        padding: 10px 15px;
    }
}

/* ====================================
   FULLSCREEN CHAT PAGE STYLES
   ==================================== */

.dalfred-fullscreen-container {
    background: #f5f7fa;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 220px);
    margin: 0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    /* Positioning context for the drop overlay (.dalfred-drop-active::before).
     * The floating widget already has position:fixed and doesn't need this. */
    position: relative;
}

.dalfred-fullscreen-header {
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.dalfred-fullscreen-header h1 {
    margin: 0;
    font-size: 22px;
    color: #333;
    display: flex;
    align-items: center;
    gap: 10px;
}

.dalfred-fullscreen-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.dalfred-fullscreen-body {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.dalfred-fullscreen-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #fff;
    margin: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    overflow: hidden;
}

.dalfred-fullscreen-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #fafbfc;
}

.dalfred-fullscreen-message {
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.dalfred-fullscreen-message.user {
    flex-direction: row-reverse;
}

.dalfred-fullscreen-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.dalfred-fullscreen-message.assistant .dalfred-fullscreen-avatar {
    background: var(--dalfred-primary);
    color: white;
}

.dalfred-fullscreen-message.user .dalfred-fullscreen-avatar {
    background: #2196F3;
    color: white;
}

.dalfred-fullscreen-content {
    max-width: 70%;
    background: white;
    padding: 12px 16px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    line-height: 1.5;
}

.dalfred-fullscreen-message.user .dalfred-fullscreen-content {
    background: #2196F3;
    color: white;
}

.dalfred-fullscreen-time {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
}

.dalfred-fullscreen-typing {
    display: none;
    padding: 20px;
    align-items: center;
    gap: 8px;
}

.dalfred-fullscreen-typing.active {
    display: flex;
}

.dalfred-fullscreen-input-area {
    background: white;
    border-top: 1px solid #e0e0e0;
    padding: 16px 20px;
}

/* Spacing between the attachment chip strip and the textarea row when files
 * are queued for sending. The chip strip itself adds no bottom margin so the
 * gap is owned by this wrapper, keeping the layout tight when no chip shows. */
.dalfred-fullscreen-input-area .dalfred-attach-preview {
    padding: 0 4px 10px;
}
.dalfred-fullscreen-input-area .dalfred-attach-errors {
    padding: 0 4px 8px;
}

.dalfred-fullscreen-input-wrapper {
    display: flex;
    gap: 10px;
    /* flex-end keeps the round send button anchored to the bottom of the
     * textarea when the user types multiple lines. The paperclip below uses
     * a fixed height that matches the one-line textarea, so on a single line
     * the three controls (paperclip, textarea, send) are visually aligned. */
    align-items: flex-end;
}

/* Paperclip on fullscreen: scale up to match the round 48×48 send button.
 * The base .dalfred-attach-btn rule already gives it the round transparent
 * shape — we only override the size here. */
.dalfred-fullscreen-input-wrapper .dalfred-attach-btn {
    width: 46px;
    height: 46px;
}
.dalfred-fullscreen-input-wrapper .dalfred-attach-btn svg.lucide {
    width: 20px;
    height: 20px;
}

.dalfred-fullscreen-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 24px;
    padding: 12px 20px;
    font-size: 15px;
    resize: none;
    max-height: 120px;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
}

.dalfred-fullscreen-input:focus {
    border-color: var(--dalfred-primary);
}

.dalfred-fullscreen-send {
    background: linear-gradient(135deg, var(--dalfred-primary), var(--dalfred-secondary));
    color: white;
    border: none;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 18px;
}

.dalfred-fullscreen-send:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 15px var(--dalfred-primary-shadow);
}

.dalfred-fullscreen-send:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

/* Welcome screen */
.dalfred-welcome-screen {
    text-align: center;
    padding: 40px;
    color: #666;
}

.dalfred-welcome-screen h2 {
    color: #333;
    margin-bottom: 20px;
}

.dalfred-suggestions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 30px;
}

.dalfred-suggestion {
    background: white;
    border: 1px solid #ddd;
    padding: 10px 20px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
}

.dalfred-suggestion:hover {
    background: #f5f5f5;
    border-color: var(--dalfred-primary);
    color: var(--dalfred-primary);
}

/* Action buttons */
.dalfred-btn {
    padding: 8px 16px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    text-decoration: none;
    color: #333;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.dalfred-btn:hover {
    background: #f5f5f5;
    border-color: #999;
}

.dalfred-btn-primary {
    background: linear-gradient(135deg, var(--dalfred-primary), var(--dalfred-secondary));
    color: white;
    border-color: var(--dalfred-primary);
}

.dalfred-btn-primary:hover {
    box-shadow: 0 2px 10px var(--dalfred-primary-shadow);
}

/* Responsive fullscreen */
@media (max-width: 768px) {
    .dalfred-fullscreen-container {
        height: calc(100vh - 150px);
    }

    .dalfred-fullscreen-main {
        margin: 10px;
    }

    .dalfred-fullscreen-content {
        max-width: 85%;
    }

    .dalfred-suggestions {
        flex-direction: column;
        align-items: center;
    }

    .dalfred-fullscreen-header h1 {
        font-size: 18px;
    }
}

/* ====================================
   MARKDOWN CONTENT STYLES
   Styles for rich content rendered by
   marked.js inside chat messages
   ==================================== */

/* Base content reset inside message bubbles */
.dalfred-message-content p,
.dalfred-fullscreen-content p {
    margin: 0 0 8px 0;
}

.dalfred-message-content p:last-child,
.dalfred-fullscreen-content p:last-child {
    margin-bottom: 0;
}

/* Headings in messages */
.dalfred-message-content h1,
.dalfred-message-content h2,
.dalfred-message-content h3,
.dalfred-message-content h4,
.dalfred-fullscreen-content h1,
.dalfred-fullscreen-content h2,
.dalfred-fullscreen-content h3,
.dalfred-fullscreen-content h4 {
    margin: 12px 0 6px 0;
    font-weight: 600;
    line-height: 1.3;
}

.dalfred-message-content h1:first-child,
.dalfred-message-content h2:first-child,
.dalfred-message-content h3:first-child,
.dalfred-fullscreen-content h1:first-child,
.dalfred-fullscreen-content h2:first-child,
.dalfred-fullscreen-content h3:first-child {
    margin-top: 0;
}

.dalfred-message-content h1,
.dalfred-fullscreen-content h1 { font-size: 1.3em; }
.dalfred-message-content h2,
.dalfred-fullscreen-content h2 { font-size: 1.15em; }
.dalfred-message-content h3,
.dalfred-fullscreen-content h3 { font-size: 1.05em; }
.dalfred-message-content h4,
.dalfred-fullscreen-content h4 { font-size: 1em; }

/* Lists */
.dalfred-message-content ul,
.dalfred-message-content ol,
.dalfred-fullscreen-content ul,
.dalfred-fullscreen-content ol {
    margin: 6px 0;
    padding-left: 20px;
}

.dalfred-message-content li,
.dalfred-fullscreen-content li {
    margin-bottom: 3px;
    line-height: 1.5;
}

.dalfred-message-content li p,
.dalfred-fullscreen-content li p {
    margin: 0;
}

/* Tables */
.dalfred-table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0;
    font-size: 13px;
}

.dalfred-table th,
.dalfred-table td {
    padding: 6px 10px;
    border: 1px solid #ddd;
    text-align: left;
    white-space: nowrap;
}

.dalfred-table th {
    background: #f5f5f5;
    font-weight: 600;
    color: #333;
}

.dalfred-table tbody tr:nth-child(even) {
    background: #fafafa;
}

.dalfred-table tbody tr:hover {
    background: #f0f7ff;
}

/* Make tables scrollable in narrow containers */
.dalfred-message-content,
.dalfred-fullscreen-content {
    overflow-x: auto;
}

/* Code blocks */
.dalfred-code-block {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 12px 16px;
    border-radius: 8px;
    margin: 10px 0;
    overflow-x: auto;
    font-size: 13px;
    line-height: 1.5;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

.dalfred-code-block code {
    background: none;
    padding: 0;
    color: inherit;
    font-size: inherit;
}

/* Inline code */
.dalfred-code-inline {
    background: #f0f0f0;
    color: #c7254e;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

/* Inline code in user messages (light text) */
.dalfred-message.user .dalfred-code-inline,
.dalfred-fullscreen-message.user .dalfred-code-inline {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

/* Blockquotes */
.dalfred-message-content blockquote,
.dalfred-fullscreen-content blockquote {
    border-left: 3px solid var(--dalfred-primary);
    margin: 8px 0;
    padding: 6px 12px;
    color: #555;
    background: #f9f9f9;
    border-radius: 0 4px 4px 0;
}

.dalfred-message-content blockquote p,
.dalfred-fullscreen-content blockquote p {
    margin: 0;
}

/* Horizontal rules */
.dalfred-message-content hr,
.dalfred-fullscreen-content hr {
    border: none;
    border-top: 1px solid #e0e0e0;
    margin: 12px 0;
}

/* Strong/Bold */
.dalfred-message-content strong,
.dalfred-fullscreen-content strong {
    font-weight: 600;
}

/* Images (if AI ever sends image links) */
.dalfred-message-content img,
.dalfred-fullscreen-content img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    margin: 6px 0;
}

/* Strikethrough */
.dalfred-message-content del,
.dalfred-fullscreen-content del {
    text-decoration: line-through;
    opacity: 0.7;
}

/* === Attachments === */

/* Paperclip button — unified shape for both the floating widget and the
 * fullscreen page so the input row reads as [📎] [textarea] [➤] with three
 * round controls of comparable size. Sized to match .dalfred-send (40×40
 * in the widget, 48×48 in fullscreen — see scale override below). */
.dalfred-attach-btn {
    background: transparent;
    border: none;
    color: #666;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    flex-shrink: 0;
    border-radius: 50%;
    transition: background 0.15s, color 0.15s;
}
.dalfred-attach-btn:hover {
    background: rgba(0, 0, 0, 0.06);
    color: var(--dalfred-primary);
}
.dalfred-attach-btn svg.lucide {
    width: 18px;
    height: 18px;
}

.dalfred-attach-preview {
    display: none;
    flex-wrap: wrap;
    gap: 6px;
    /* When chips are present, pad the bottom so they don't touch the input
     * row below (the container itself owns the top/side padding). */
    padding: 0 4px 10px;
}
.dalfred-attach-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 16px;
    padding: 4px 8px 4px 6px;
    font-size: 12px;
    max-width: 240px;
}
.dalfred-attach-chip .dalfred-attach-thumb {
    width: 28px;
    height: 28px;
    object-fit: cover;
    border-radius: 4px;
}
.dalfred-attach-chip .dalfred-attach-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    /* Lucide outlines inherit from currentColor; without this the icon ends
     * up almost invisible against the chip's pale background. Pin to a
     * dark grey so the file-text outline reads at chip size. */
    color: #555;
}
.dalfred-attach-chip .dalfred-attach-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 140px;
}
.dalfred-attach-chip .dalfred-attach-size {
    color: #888;
    font-size: 11px;
    flex-shrink: 0;
}
.dalfred-attach-chip .dalfred-attach-remove {
    background: transparent;
    border: none;
    color: #999;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    padding: 0 0 0 2px;
}
.dalfred-attach-chip .dalfred-attach-remove:hover {
    color: #c62828;
}

.dalfred-attach-errors {
    display: none;
    padding: 4px 10px;
}
.dalfred-attach-error {
    color: #c62828;
    font-size: 12px;
    margin: 2px 0;
}

/* Drop overlay — fades in over the chat zone while a file is hovered.
 * NOTE: do NOT set position:relative here — the floating widget (.dalfred-chat)
 * is position:fixed, and overriding it would snap the widget back to the
 * document flow (visible jump to bottom-left). The ::before overlay below
 * uses position:absolute, which already anchors against the nearest
 * positioned ancestor (the fixed widget itself satisfies that). */
.dalfred-drop-active::before {
    content: attr(data-drop-label);
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(76, 175, 80, 0.08);
    border: 2px dashed var(--dalfred-primary);
    border-radius: 8px;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--dalfred-primary);
    font-weight: 600;
    pointer-events: none;
}

/* Attachment chips inside chat bubbles (history rendering).
 * Used by both the widget (.dalfred-message) and the fullscreen page
 * (.dalfred-fullscreen-message), so the rule isn't scoped to either. */
.dalfred-attach-history {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    /* Breathing room between the message bubble and the chip(s) below it. */
    margin-top: 8px;
}
.dalfred-attach-history .dalfred-attach-chip {
    background: rgba(255, 255, 255, 0.92);
    border-color: rgba(0, 0, 0, 0.1);
}
.dalfred-attach-history .dalfred-attach-chip.expired {
    opacity: 0.5;
}
.dalfred-attach-history img.dalfred-attach-thumb {
    width: 80px;
    height: 80px;
    border-radius: 6px;
}

/* Slash-command autocomplete (added in 2.14.0) */
.dalfred-cmd-dropdown {
    /* position:fixed + body-attached so we escape any ancestor overflow:hidden
       (notably .dalfred-chat which clips the floating widget for rounded
       corners). The JS sets top/left/width on every render via
       getBoundingClientRect, plus a translateY(-100%) transform to sit above
       the input. */
    position: fixed;
    max-height: 240px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.08);
    z-index: 100000;
    font-size: 13px;
}
.dalfred-cmd-item {
    padding: 6px 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}
.dalfred-cmd-item.active,
.dalfred-cmd-item:hover {
    background: #f0f4ff;
}
.dalfred-cmd-item code {
    font-weight: 600;
    color: #2255aa;
}
.dalfred-cmd-title {
    color: #555;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.dalfred-cmd-badge {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    background: #e6f0ff;
    color: #2255aa;
}
.dalfred-cmd-empty {
    padding: 8px 10px;
    color: #888;
    font-style: italic;
}

/* ============================================================
 * Copyable blocks (:::copy markdown extension)
 * ============================================================ */

.dalfred-copyable {
    position: relative;
    margin: 12px 0;
    padding: 12px 16px;
    border: 1px solid var(--dalfred-border-color, #e0e0e0);
    border-radius: 6px;
    background: var(--dalfred-copyable-bg, rgba(0, 0, 0, 0.02));
}

.dalfred-copyable-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    user-select: none;
}

/* Block without a label: header floats top-right, no margin reserved */
.dalfred-copyable:not([data-label]) .dalfred-copyable-header {
    position: absolute;
    top: 8px;
    right: 8px;
    margin-bottom: 0;
}

.dalfred-copyable-label {
    font-size: 0.85em;
    font-weight: 600;
    color: var(--dalfred-text-secondary, #666);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.dalfred-copyable-btn {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.15s, background 0.15s, border-color 0.15s, color 0.15s;
    font-size: 0.9em;
    line-height: 1;
}

.dalfred-copyable:hover .dalfred-copyable-btn,
.dalfred-copyable-btn:focus-visible,
.dalfred-code-block:hover .dalfred-copyable-btn--code {
    opacity: 1;
    background: var(--dalfred-btn-hover-bg, rgba(0, 0, 0, 0.05));
    border-color: var(--dalfred-border-color, #e0e0e0);
}

.dalfred-copyable-btn.is-copied {
    opacity: 1;
    color: var(--dalfred-success-color, #2e7d32);
    border-color: var(--dalfred-success-color, #2e7d32);
}

.dalfred-copyable-btn.is-failed {
    opacity: 1;
    color: var(--dalfred-error-color, #c62828);
    border-color: var(--dalfred-error-color, #c62828);
}

/* On touch devices, button is always visible (no hover possible) */
@media (hover: none) {
    .dalfred-copyable-btn {
        opacity: 0.8;
    }
}

/* Content inside a copyable block must remain selectable, only the header isn't */
.dalfred-copyable > *:not(.dalfred-copyable-header) {
    user-select: text;
}

.dalfred-copyable .dalfred-copyable-header + p {
    margin-top: 0;
}

/* Fenced code blocks: button positioned in absolute on top-right */
.dalfred-code-block {
    position: relative;
}

.dalfred-copyable-btn--code {
    position: absolute;
    top: 6px;
    right: 6px;
    opacity: 0.4;
}
