/* History item styles */
.transcription-item {
    background-color: var(--history-item-bg);
    border: 1px solid var(--history-item-border);
    border-radius: 0.375rem;
    padding: 1rem;
    position: relative;
    transition: all 0.3s ease;
}

/* Failed transcription styling */
.transcription-item.transcription-failed {
    border-color: var(--error-color);
    background-color: var(--failed-bg-color);
}

.transcription-item.transcription-failed .text {
    color: var(--error-color);
    font-style: italic;
}

.transcription-item .metadata {
    font-size: 0.875rem;
    color: var(--text-muted-color);
    margin-bottom: 0.5rem;
}

.transcription-item .text {
    margin-bottom: 0.5rem;
    white-space: pre-wrap;
    color: var(--text-color);
}

/* New styles for collapsed text */
.transcription-item .text.collapsed {
    display: -webkit-box;
    -webkit-line-clamp: 5;
    -webkit-box-orient: vertical;
    overflow: hidden;
    position: relative;
}

.expand-collapse-btn {
    background-color: var(--card-bg-color);
    color: var(--primary-color);
    border: none;
    padding: 2px 8px;
    margin-bottom: 8px;
    cursor: pointer;
    font-size: 0.8rem;
    border-radius: 4px;
    transition: background-color 0.2s, color 0.2s;
    border: 1px solid var(--border-color);
}

.expand-collapse-btn:hover {
    background-color: var(--hover-bg-color);
}

.dark-theme .expand-collapse-btn {
    border-color: var(--border-color);
}

.transcription-item .actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.history-item-header {
    gap: 1rem;
}

.history-item-title {
    font-weight: 600;
    word-break: break-word;
}

.history-item-title-input {
    max-width: 320px;
}

.history-item-select .history-select-checkbox {
    margin-top: 0.35rem;
    cursor: pointer;
}

.history-item-select {
    flex-shrink: 0;
}

.history-item-metadata p {
    margin-bottom: 0.25rem;
}

.history-tags-section {
    margin-top: 0.5rem;
}

.history-tags {
    cursor: pointer;
}

.history-tags .history-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.history-tag-remove {
    background: transparent;
    border: none;
    color: inherit;
    font-size: 0.75rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}

.history-tag-remove:hover {
    color: var(--error-color);
}

.history-tags-empty {
    cursor: pointer;
}

.history-tags-edit-btn {
    flex-shrink: 0;
}

.tag-editor {
    position: relative;
    z-index: 2;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.1);
    border: 1px solid var(--border-color);
    max-width: 100%;
}

.tag-editor .badge {
    font-size: 0.85rem;
}

.tag-editor .tag-editor-remove-btn {
    opacity: 0.7;
}

.tag-editor .tag-editor-remove-btn:hover {
    opacity: 1;
}

.history-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.history-toolbar-title {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.history-toggle {
    white-space: nowrap;
}

.history-toolbar-controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.history-bulk-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.history-bulk-actions .btn i {
    margin-right: 0.35rem;
}

.history-sort-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.history-sort-controls select {
    min-width: 12rem;
}

.history-search-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.history-search-options {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.history-filters-trigger {
    display: flex;
    justify-content: flex-end;
}

.history-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
}

.history-page-size {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.history-page-size-select {
    min-width: 5rem;
    width: auto;
}

.filter-tags-container {
    max-height: 100px;
    overflow-y: auto;
}

.history-pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
}

.history-pagination-summary {
    color: var(--text-muted-color);
}

.history-pagination-nav {
    display: flex;
}

.history-pagination-nav.d-none {
    display: none !important;
}

.transcription-item textarea {
    width: 100%;
    min-height: 100px;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    font-size: 1rem;
    resize: vertical;
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

.transcription-item .edit-container {
    display: none;
}

.transcription-item.editing .text {
    display: none;
}

.transcription-item.editing .edit-container {
    display: block;
}

/* Retry button styling */
.transcription-item .retry {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(var(--primary-rgb), 0.4);
    }
    70% {
        box-shadow: 0 0 0 6px rgba(var(--primary-rgb), 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(var(--primary-rgb), 0);
    }
}

/* Loading animation */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .history-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .history-toolbar-controls {
        width: 100%;
        justify-content: space-between;
    }

    .history-bulk-actions {
        width: 100%;
    }

    .history-bulk-actions .btn {
        flex: 1 1 48%;
    }

    .history-sort-controls {
        width: 100%;
        justify-content: space-between;
    }

    .history-sort-controls select {
        flex: 1 1 auto;
    }

    .history-search-options {
        width: 100%;
        justify-content: space-between;
    }

    .history-filters-trigger {
        justify-content: flex-start;
    }

    .history-footer {
        align-items: stretch;
    }

    .history-page-size {
        width: 100%;
        justify-content: space-between;
    }

    .history-pagination {
        width: 100%;
        justify-content: center;
    }

    .history-pagination-summary {
        width: 100%;
        text-align: center;
    }

    .transcription-item .actions {
        flex-wrap: wrap;
    }

    .btn-sm {
        width: auto;
    }

    .upload-zone {
        min-height: 150px;
        padding: 1rem;
    }

    #recordingTimer {
        font-size: 1rem;
        min-width: 60px;
    }

    .theme-toggle-btn {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }
}

@media (max-width: 576px) {
    .history-toolbar-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .history-bulk-actions .btn {
        flex: 1 1 100%;
    }

    .history-sort-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .history-sort-controls button {
        align-self: flex-start;
    }

    .history-search-options {
        flex-direction: row;
        justify-content: space-between;
    }

    .history-pagination {
        gap: 0.75rem;
    }
}
