/* Read page specific styles - extends common.css */

/* Body */
.read-body {
    min-height: 100vh;
}

/* Input section - matches batch */
.input-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.upload-area {
    border: 2px dashed var(--border);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--paper);
    padding: 1rem;
}

.upload-area:hover,
.upload-area.drag-over {
    border-color: var(--accent);
    background: #faf8f5;
}

.upload-icon {
    font-size: 1rem;
}

.upload-icon-lucide {
    width: 18px;
    height: 18px;
    stroke: var(--muted);
    stroke-width: 1.5;
}

.upload-text {
    font-size: 0.9rem;
    color: var(--muted);
}

.files-count {
    font-size: 0.8rem;
    color: var(--muted);
    margin-left: auto;
}

.files-count:empty {
    display: none;
}

.formats-hint {
    font-size: 0.75rem;
    color: var(--muted);
    text-align: center;
    margin: 0;
}

/* Action buttons - matches batch */
.action-buttons {
    display: flex;
    gap: 0.5rem;
}

.action-tile {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.5rem 0.75rem;
    background: linear-gradient(180deg, #fdfcfa 0%, #f8f5f0 100%);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    flex: 1;
    box-shadow: 0 1px 2px rgba(61, 46, 36, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.action-tile:hover {
    background: linear-gradient(180deg, #fff 0%, #faf7f2 100%);
    border-color: #c9bfb0;
    box-shadow: 0 3px 8px rgba(61, 46, 36, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.9);
    transform: translateY(-1px);
}

.action-tile:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(61, 46, 36, 0.08), inset 0 1px 3px rgba(61, 46, 36, 0.06);
    background: linear-gradient(180deg, #f5f2ed 0%, #f8f5f0 100%);
}

.action-tile:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.action-tile-muted {
    flex: 0 0 auto;
}

.tile-icon {
    width: 16px;
    height: 16px;
    stroke: var(--ink);
    stroke-width: 1.5;
}

.tile-label {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--ink);
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

/* Results header */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.results-header h2 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--ink);
    margin: 0;
}

.results-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-icon {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    stroke-width: 1.5;
}

/* Middle section for hint + files */
.middle-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 0;
}

/* Files list - middle area (grid of file cards) */
.files-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0.75rem 0;
}

.file-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem;
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: 4px;
    width: 80px;
    position: relative;
}

.file-icon {
    width: 40px;
    height: 40px;
    background: var(--accent);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 500;
    border-radius: 4px;
    text-transform: uppercase;
}

.file-info {
    text-align: center;
    width: 100%;
    overflow: hidden;
}

.file-name {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.6rem;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 70px;
}

.file-size {
    font-size: 0.55rem;
    color: var(--muted);
}

.remove-file {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 18px;
    height: 18px;
    background: #dc2626;
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.remove-file:hover {
    background: #b91c1c;
}

/* Results list */
.results-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.result-details {
    border-bottom: 1px solid var(--border);
    overflow: hidden;
}

.result-details:last-child {
    border-bottom: none;
}

.result-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 0;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
}

.result-summary:hover {
    background: #faf8f5;
}

.result-summary::-webkit-details-marker {
    display: none;
}

/* Chevron indicator - more visible */
.result-summary::before {
    content: '';
    width: 16px;
    height: 16px;
    background: var(--muted);
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2.5'%3E%3Cpath d='M9 18l6-6-6-6'/%3E%3C/svg%3E") center/contain no-repeat;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2.5'%3E%3Cpath d='M9 18l6-6-6-6'/%3E%3C/svg%3E") center/contain no-repeat;
    flex-shrink: 0;
    transition: transform 0.2s;
}

.result-details[open] > .result-summary::before {
    transform: rotate(90deg);
}

.result-title {
    flex: 1;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 100px;
}

.result-date {
    font-size: 0.7rem;
    color: var(--muted);
}

.result-actions {
    display: flex;
    gap: 0.35rem;
    margin-left: auto;
}

.result-actions .action-btn {
    padding: 0.3rem 0.5rem;
    font-size: 0.7rem;
}

.result-content {
    padding: 0;
}

.result-content .markdown-rendered {
    padding: 1rem 1.25rem;
}

.result-content .markdown-textarea {
    width: 100%;
    min-height: 300px;
    border: none;
    border-top: 1px solid var(--border);
}

/* Loading animation */
.loading-dots span {
    animation: blink 1.4s infinite both;
}

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

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

@keyframes blink {
    0%, 80%, 100% { opacity: 0; }
    40% { opacity: 1; }
}

/* Loading state for action tiles */
.action-tile.loading {
    pointer-events: none;
    opacity: 0.7;
}

.action-tile.loading .tile-icon {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Output section */
.output-section {
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.output-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    background: #faf8f5;
}

.output-header h2 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--ink);
    margin: 0;
}

.output-actions {
    display: flex;
    gap: 0.5rem;
}

.output-content {
    max-height: 70vh;
    overflow: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.output-content::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.output-content::-webkit-scrollbar-track {
    background: transparent;
}

.output-content::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

/* Raw markdown output (streaming) */
.markdown-output {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    line-height: 1.6;
    color: var(--ink);
    margin: 0;
    padding: 1rem;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-x: auto;
    background: var(--paper);
}

.markdown-output.streaming::after {
    content: '|';
    animation: cursor 0.8s infinite;
    color: var(--accent);
}

@keyframes cursor {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* Raw markdown textarea (editable) */
.markdown-textarea {
    width: 100%;
    min-height: 400px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    line-height: 1.6;
    color: var(--ink);
    padding: 1rem;
    border: none;
    resize: vertical;
    background: var(--paper);
}

.markdown-textarea:focus {
    outline: none;
}

/* Rendered markdown (GitHub style from gh-markdown.css) */
.markdown-rendered {
    padding: 1rem 1.5rem;
    font-size: 16px;
    line-height: 1.5;
    color: #24292e;
    word-wrap: break-word;
}

.markdown-rendered > :first-child {
    margin-top: 0 !important;
}

.markdown-rendered > :last-child {
    margin-bottom: 0 !important;
}

.markdown-rendered a {
    color: #0366d6;
    text-decoration: none;
}

.markdown-rendered a:hover {
    text-decoration: underline;
}

.markdown-rendered strong {
    font-weight: 600;
}

.markdown-rendered h1,
.markdown-rendered h2,
.markdown-rendered h3,
.markdown-rendered h4,
.markdown-rendered h5,
.markdown-rendered h6 {
    margin-top: 24px;
    margin-bottom: 16px;
    font-weight: 600;
    line-height: 1.25;
}

.markdown-rendered h1 {
    font-size: 2em;
    padding-bottom: 0.3em;
    border-bottom: 1px solid #eaecef;
}

.markdown-rendered h2 {
    font-size: 1.5em;
    padding-bottom: 0.3em;
    border-bottom: 1px solid #eaecef;
}

.markdown-rendered h3 {
    font-size: 1.25em;
}

.markdown-rendered h4 {
    font-size: 1em;
}

.markdown-rendered h5 {
    font-size: 0.875em;
}

.markdown-rendered h6 {
    font-size: 0.85em;
    color: #6a737d;
}

.markdown-rendered p {
    margin-top: 0;
    margin-bottom: 16px;
}

.markdown-rendered blockquote {
    margin: 0 0 16px;
    padding: 0 1em;
    color: #6a737d;
    border-left: 0.25em solid #dfe2e5;
}

.markdown-rendered blockquote > :first-child {
    margin-top: 0;
}

.markdown-rendered blockquote > :last-child {
    margin-bottom: 0;
}

.markdown-rendered ul,
.markdown-rendered ol {
    padding-left: 2em;
    margin-top: 0;
    margin-bottom: 16px;
}

.markdown-rendered ol ol,
.markdown-rendered ul ol {
    list-style-type: lower-roman;
}

.markdown-rendered ol ol ol,
.markdown-rendered ol ul ol,
.markdown-rendered ul ol ol,
.markdown-rendered ul ul ol {
    list-style-type: lower-alpha;
}

.markdown-rendered li {
    word-wrap: break-all;
}

.markdown-rendered li > p {
    margin-top: 16px;
}

.markdown-rendered li + li {
    margin-top: 0.25em;
}

.markdown-rendered hr {
    height: 0.25em;
    padding: 0;
    margin: 24px 0;
    background-color: #e1e4e8;
    border: 0;
}

.markdown-rendered table {
    display: block;
    width: 100%;
    overflow: auto;
    border-spacing: 0;
    border-collapse: collapse;
    margin-bottom: 16px;
}

.markdown-rendered table th {
    font-weight: 600;
}

.markdown-rendered table td,
.markdown-rendered table th {
    padding: 6px 13px;
    border: 1px solid #dfe2e5;
}

.markdown-rendered table tr {
    background-color: #fff;
    border-top: 1px solid #c6cbd1;
}

.markdown-rendered table tr:nth-child(2n) {
    background-color: #f6f8fa;
}

.markdown-rendered img {
    max-width: 100%;
    box-sizing: initial;
    background-color: #fff;
}

.markdown-rendered code,
.markdown-rendered pre {
    font-family: var(--font-mono);
    font-size: 12px;
}

.markdown-rendered code {
    padding: 0.2em 0.4em;
    margin: 0;
    font-size: 85%;
    background-color: rgba(27, 31, 35, 0.05);
    border-radius: 3px;
}

.markdown-rendered pre {
    word-wrap: normal;
    margin-top: 0;
    margin-bottom: 16px;
    padding: 16px;
    overflow: auto;
    font-size: 85%;
    line-height: 1.45;
    background-color: #f6f8fa;
    border-radius: 3px;
}

.markdown-rendered pre > code {
    padding: 0;
    margin: 0;
    font-size: 100%;
    word-break: normal;
    white-space: pre;
    background: transparent;
    border: 0;
}

.markdown-rendered pre code {
    display: inline;
    padding: 0;
    margin: 0;
    overflow: visible;
    line-height: inherit;
    word-wrap: normal;
    background-color: initial;
    border: 0;
}

.markdown-rendered kbd {
    display: inline-block;
    padding: 3px 5px;
    font: 11px var(--font-mono);
    line-height: 10px;
    color: #444d56;
    vertical-align: middle;
    background-color: #fafbfc;
    border: 1px solid #d1d5da;
    border-radius: 3px;
    box-shadow: inset 0 -1px 0 #d1d5da;
}

.markdown-rendered dl {
    padding: 0;
    margin-top: 0;
    margin-bottom: 16px;
}

.markdown-rendered dl dt {
    padding: 0;
    margin-top: 16px;
    font-size: 1em;
    font-style: italic;
    font-weight: 600;
}

.markdown-rendered dl dd {
    padding: 0 16px;
    margin-bottom: 16px;
}

/* Responsive */
@media (max-width: 768px) {
    .output-header {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
    }

    .output-actions {
        width: 100%;
        flex-wrap: wrap;
    }

    .output-actions .action-btn {
        flex: 1;
        justify-content: center;
        padding: 0.5rem;
        font-size: 0.75rem;
    }
}
