/* Input Section Layout */
.input-section {
    @apply flex-[2] flex flex-col relative; /* Required for file suggestions absolute positioning */
}

.input-wrapper {
    @apply w-full h-full flex flex-col;
    background: var(--bg-primary);
    border-radius: 0;
    box-shadow: none;
    padding: var(--spacing-lg);
}

.header {
    @apply flex justify-between items-center;
    min-height: 24px;
    padding: var(--spacing-sm) var(--spacing-md);
    margin: calc(-1 * var(--spacing-sm)) calc(-1 * var(--spacing-md));
    margin-bottom: var(--spacing-sm);
    border-radius: var(--radius-md);
    transition: background-color 0.2s ease;
}

/* Draggable header state - enables window dragging */
.header.draggable {
    -webkit-app-region: drag;
    cursor: grab;
    background-color: oklch(from var(--color-blue-500) l c h / 0.15);
    border: 1px solid oklch(from var(--color-blue-500) l c h / 0.3);
}

.header.draggable:active {
    cursor: grabbing;
}

/* Drag indicator - shows when window is draggable */
.drag-indicator {
    display: none;
    align-items: center;
    gap: 6px;
    color: oklch(from var(--color-blue-500) l c h / 0.9);
    font-size: var(--font-size-sm);
    animation: fadeInPulse 0.3s ease-out;
}

.header.draggable .drag-indicator {
    display: flex;
}

/* Hide shortcuts when draggable */
.header.draggable .shortcuts {
    display: none;
}

.drag-icon {
    width: 16px;
    height: 16px;
    opacity: 0.8;
}

.drag-text {
    font-weight: 500;
    letter-spacing: 0.02em;
}

@keyframes fadeInPulse {
    0% {
        opacity: 0;
        transform: scale(0.95);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.app-name {
    @apply font-medium;
    font-size: var(--font-size-md);
    color: oklch(from var(--color-white) l c h / 0.5);
}

.shortcuts {
    font-size: var(--font-size-base);
    color: var(--text-tertiary);
}

/* Text input container for highlight backdrop */
.text-input-container {
    @apply flex-1 relative flex w-full;
    /* Prevent layout thrashing when inserting long text */
    contain: content;
}

/* Highlight backdrop - mirrors textarea content with highlights */
.highlight-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: oklch(from var(--color-white) l c h / 0.08);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    /* Add extra right padding to match textarea scrollbar width (8px) */
    padding-right: calc(var(--spacing-md) + 8px);
    pointer-events: none;
    /* Use hidden overflow - we'll use transform for scroll sync */
    overflow: hidden;

    /* Font metrics - must match textarea exactly */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 15px;
    font-weight: 400;
    font-style: normal;
    font-variant: normal;
    line-height: 1.5;
    letter-spacing: 0;
    word-spacing: 0;

    /* Text wrapping control - must match textarea exactly */
    white-space: break-spaces;
    /* 'anywhere' allows breaking long paths/URLs that have no spaces */
    overflow-wrap: anywhere;
    word-break: normal;

    /* Tab size - must match textarea */
    tab-size: 4;
    -moz-tab-size: 4;

    /* Box model - must match textarea */
    box-sizing: border-box;

    /* Text rendering optimization */
    text-rendering: geometricPrecision;
    -webkit-font-smoothing: antialiased;

    /* Make text invisible, only show highlights */
    color: transparent;
}

/* Inner content wrapper for transform-based scroll sync */
.highlight-backdrop-content {
    will-change: transform;
}

.highlight-backdrop .at-path-highlight {
    background: oklch(from var(--color-blue-500) l c h / 0.4);
    border-radius: 4px;
    color: transparent;

    /* Expand highlight area by 1px in all directions */
    padding: 1px;
    margin: -1px;

    /* Use box-decoration-break for multi-line highlights */
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
}

/* Default agent skill highlight (gray for unknown source or duplicate skills) */
.highlight-backdrop .agent-skill-highlight {
    background: oklch(from var(--color-neutral-500) l c h / 0.25);
    border-radius: 4px;
    color: transparent;

    /* Expand highlight area by 1px in all directions */
    padding: 1px;
    margin: -1px;

    /* Use box-decoration-break for multi-line highlights */
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
}

/* Source-specific agent skill highlight colors */
.highlight-backdrop .agent-skill-highlight.agent-skill-source-claude {
    background: oklch(from var(--color-amber-300) l c h / 0.25);
}

.highlight-backdrop .agent-skill-highlight.agent-skill-source-codex {
    background: oklch(from var(--color-teal-300) l c h / 0.25);
}

.highlight-backdrop .agent-skill-highlight.agent-skill-source-gemini {
    background: oklch(from var(--color-blue-300) l c h / 0.25);
}

.highlight-backdrop .agent-skill-highlight.agent-skill-source-custom {
    background: oklch(from var(--color-teal-400) l c h / 0.25);
}

/* Color based highlights (takes priority over source) */
.highlight-backdrop .agent-skill-highlight.agent-skill-color-grey,
.highlight-backdrop .agent-skill-highlight.agent-skill-color-gray {
    background: oklch(from var(--color-neutral-400) l c h / 0.25);
}

.highlight-backdrop .agent-skill-highlight.agent-skill-color-darkGrey,
.highlight-backdrop .agent-skill-highlight.agent-skill-color-slate,
.highlight-backdrop .agent-skill-highlight.agent-skill-color-stone {
    background: oklch(from var(--color-stone-400) l c h / 0.25);
}

.highlight-backdrop .agent-skill-highlight.agent-skill-color-red {
    background: oklch(from var(--color-red-400) l c h / 0.25);
}

.highlight-backdrop .agent-skill-highlight.agent-skill-color-rose {
    background: oklch(from var(--color-rose-400) l c h / 0.25);
}

.highlight-backdrop .agent-skill-highlight.agent-skill-color-orange {
    background: oklch(from var(--color-orange-400) l c h / 0.25);
}

.highlight-backdrop .agent-skill-highlight.agent-skill-color-amber {
    background: oklch(from var(--color-amber-400) l c h / 0.25);
}

.highlight-backdrop .agent-skill-highlight.agent-skill-color-yellow {
    background: oklch(from var(--color-yellow-300) l c h / 0.25);
}

.highlight-backdrop .agent-skill-highlight.agent-skill-color-lime {
    background: oklch(from var(--color-lime-400) l c h / 0.25);
}

.highlight-backdrop .agent-skill-highlight.agent-skill-color-green {
    background: oklch(from var(--color-green-400) l c h / 0.25);
}

.highlight-backdrop .agent-skill-highlight.agent-skill-color-emerald {
    background: oklch(from var(--color-emerald-400) l c h / 0.25);
}

.highlight-backdrop .agent-skill-highlight.agent-skill-color-teal {
    background: oklch(from var(--color-teal-400) l c h / 0.25);
}

.highlight-backdrop .agent-skill-highlight.agent-skill-color-cyan {
    background: oklch(from var(--color-cyan-400) l c h / 0.25);
}

.highlight-backdrop .agent-skill-highlight.agent-skill-color-sky {
    background: oklch(from var(--color-sky-400) l c h / 0.25);
}

.highlight-backdrop .agent-skill-highlight.agent-skill-color-blue {
    background: oklch(from var(--color-blue-400) l c h / 0.25);
}

.highlight-backdrop .agent-skill-highlight.agent-skill-color-indigo {
    background: oklch(from var(--color-indigo-400) l c h / 0.25);
}

.highlight-backdrop .agent-skill-highlight.agent-skill-color-violet {
    background: oklch(from var(--color-violet-400) l c h / 0.25);
}

.highlight-backdrop .agent-skill-highlight.agent-skill-color-purple {
    background: oklch(from var(--color-purple-400) l c h / 0.25);
}

.highlight-backdrop .agent-skill-highlight.agent-skill-color-fuchsia {
    background: oklch(from var(--color-fuchsia-400) l c h / 0.25);
}

.highlight-backdrop .agent-skill-highlight.agent-skill-color-pink {
    background: oklch(from var(--color-pink-400) l c h / 0.25);
}

/* Agent skill with link style (Cmd+hover or cursor over agent skill) */
.highlight-backdrop .agent-skill-highlight.file-path-link {
    text-decoration: underline;
    text-decoration-color: oklch(from var(--color-white) l c h / 0.4);
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
    cursor: pointer;
}

/* File path link style for Cmd+hover or cursor position */
.highlight-backdrop .file-path-link {
    /* Override the transparent color to make link visible */
    color: var(--text-primary) !important;
    text-decoration: underline;
    text-decoration-color: oklch(from var(--color-white) l c h / 0.4);
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
    cursor: pointer;
}

/* @path with link style (Cmd+hover or cursor over @path) */
.highlight-backdrop .at-path-highlight.file-path-link {
    /* Override the transparent color to make link visible */
    color: var(--text-primary) !important;
    text-decoration: underline;
    text-decoration-color: oklch(from var(--color-white) l c h / 0.4);
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
    /* Underline only, no background highlight */
}

/* Cursor-position underline for absolute file paths */
.highlight-backdrop .file-path-cursor-highlight {
    /* Solid underline for linkable file paths */
    color: transparent;
    text-decoration: underline;
    text-decoration-color: oklch(from var(--color-white) l c h / 0.3);
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
    cursor: pointer;
}

#textInput {
    @apply flex-1 w-full bg-transparent outline-none resize-none relative;
    border: 1px solid oklch(from var(--color-white) l c h / 0.15);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    color: var(--text-primary);
    transition: border-color var(--animation-normal) ease, box-shadow var(--animation-normal) ease;
    z-index: 1;

    /* Font metrics - must match backdrop exactly */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 15px;
    font-weight: 400;
    font-style: normal;
    font-variant: normal;
    line-height: 1.5;
    letter-spacing: 0;
    word-spacing: 0;

    /* Text wrapping control - must match backdrop */
    white-space: break-spaces;
    /* 'anywhere' allows breaking long paths/URLs that have no spaces */
    overflow-wrap: anywhere;
    word-break: normal;

    /* Tab size - must match backdrop */
    tab-size: 4;
    -moz-tab-size: 4;

    /* Box model - must match backdrop */
    box-sizing: border-box;

    /* Text rendering optimization */
    text-rendering: geometricPrecision;
    -webkit-font-smoothing: antialiased;

    /* Always reserve scrollbar space to prevent layout shift */
    overflow-y: scroll;
    /* Hide horizontal overflow to prevent flicker when inserting long file paths */
    overflow-x: hidden;
}

#textInput:focus {
    background: transparent;
    border-color: oklch(from var(--color-white) l c h / 0.25);
    box-shadow: 0 0 0 1px var(--bg-tertiary);
}

/* Update backdrop background on textarea focus */
.text-input-container:focus-within .highlight-backdrop {
    background: var(--bg-tertiary);
}

#textInput::placeholder {
    color: oklch(from var(--color-white) l c h / 0.25);
}

/* Scrollbar styles */
#textInput::-webkit-scrollbar {
    width: 8px;
}

#textInput::-webkit-scrollbar-track {
    background: transparent;
}

#textInput::-webkit-scrollbar-thumb {
    background: oklch(from var(--color-white) l c h / 0.1);
    border-radius: var(--radius-sm);
}

#textInput::-webkit-scrollbar-thumb:hover {
    background: oklch(from var(--color-white) l c h / 0.2);
}

/* Disable IME suggestions */
#textInput::-webkit-input-placeholder {
    color: oklch(from var(--color-white) l c h / 0.25);
}

#textInput::-webkit-textfield-decoration-container {
    display: none !important;
}

/* Hide form autofill */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
textarea:-webkit-autofill,
textarea:-webkit-autofill:hover,
textarea:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0px 1000px transparent inset !important;
    background-color: transparent !important;
}

.footer {
    @apply flex justify-between items-center;
    /*margin-top: var(--spacing-md);*/
    padding-top: var(--spacing-md);
    /*border-top: 1px solid var(--border-primary);*/
}

.hint {
    @apply overflow-hidden text-ellipsis whitespace-nowrap;
    font-size: var(--font-size-sm);
    color: var(--text-tertiary);
    max-width: 80%;
    margin-right: var(--spacing-md);
}

.char-count {
    font-size: var(--font-size-base);
    color: oklch(from var(--color-white) l c h / 0.3);
    font-variant-numeric: tabular-nums;
    transition: color var(--animation-normal) ease;
}

.char-count.warning {
    color: var(--color-orange-500);
}

.char-count.error {
    color: var(--color-red-500);
}

kbd {
    @apply inline-block;
    padding: 2px 6px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-family: inherit;
    margin: 0 2px;
}