/* Voice Processor Styles */

:root {
    --sidebar-width: 280px;
    --header-height: 50px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: system-ui, -apple-system, sans-serif;
    background: var(--uk-background);
    color: var(--uk-foreground);
}

.container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--uk-card);
    border-right: 1px solid var(--uk-border);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

.section-header:first-child {
    margin-top: 0;
}

.section-header h2 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--uk-muted-foreground);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0;
}

.actions-mini {
    display: flex;
    gap: 0.25rem;
}

.icon-btn {
    padding: 0.25rem !important;
    min-width: auto !important;
}

.icon-btn i {
    width: 16px;
    height: 16px;
}

/* Voice List */
.voice-list {
    flex: 1;
    overflow-y: auto;
    border: 1px solid var(--uk-border);
    border-radius: 0.5rem;
    min-height: 200px;
    padding: 0.5rem;
}

.voice-list.drag-over {
    border: 2px dashed #007bff;
    background: #cce5ff;
}

.voice-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 5px 5px 10px;
    cursor: pointer;
    transition: background 0.15s;
}

.voice-item:hover {
    background-color: #e9ecef;
}

.voice-item.active {
    background-color: #cce5ff;
    border-left: 3px solid #007bff;
    padding-left: 7px;
}

.voice-item-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 0;
}

.voice-item-name {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.voice-item-meta {
    font-size: 0.75rem;
    color: #6c757d;
}

.voice-item-model,
.model-badge {
    font-size: 0.68rem;
    line-height: 1;
    padding: 3px 6px;
    border-radius: 6px;
    border: 1px solid transparent;
    white-space: nowrap;
}

.model-komahi {
    color: #245c35;
    background: #e7f6ec;
    border-color: #b8e0c3;
}

.model-ishikawa {
    color: #5c3b13;
    background: #fff4da;
    border-color: #e9cf92;
}

.voice-item-name.status-green {
    color: #1e7e34;
}

.voice-item-name.status-red {
    color: #a71d2a;
}

.voice-item-actions {
    display: flex;
    gap: 0.25rem;
    opacity: 0;
    transition: opacity 0.15s;
}

.voice-item:hover .voice-item-actions {
    opacity: 1;
}

.voice-item.active .voice-item-actions {
    opacity: 1;
}

.empty-list {
    color: var(--uk-muted-foreground);
    text-align: center;
    padding: 2rem 1rem;
    font-size: 0.875rem;
}

/* Status indicators */
.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.status-indicator.idle {
    background: var(--uk-muted-foreground);
}

.status-indicator.in_progress {
    background: var(--uk-warning);
    animation: pulse 1.5s infinite;
}

.status-indicator.completed {
    background: var(--uk-success);
}

.status-indicator.failed {
    background: var(--uk-destructive);
}

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

/* Main Content */
.content {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
}

.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--uk-muted-foreground);
    font-size: 1.125rem;
}

/* Voice View */
.voice-view {
    max-width: 1000px;
}

.voice-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--uk-border);
}

.voice-title-row {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.voice-title-group {
    display: flex;
    flex-direction: column;
}

.voice-title-row h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
}

.voice-real-name {
    font-size: 0.875rem;
    color: var(--uk-muted-foreground);
    font-weight: normal;
    margin-top: 0.25rem;
}

/* Section Cards */
.section-card {
    background: var(--uk-card);
    border: 1px solid var(--uk-border);
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1rem;
}

.section-card h3 {
    margin: 0 0 1rem 0;
    font-size: 1rem;
    font-weight: 600;
}

.original-info {
    color: var(--uk-muted-foreground);
}

/* Actions */
.splitting-actions,
.embedding-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.status-badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    background: var(--uk-muted);
}

.status-badge.in_progress {
    background: var(--uk-warning);
    color: white;
}

.status-badge.completed {
    background: var(--uk-success);
    color: white;
}

.status-badge.failed {
    background: var(--uk-destructive);
    color: white;
}

/* Samples List */
.samples-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sample-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    background: var(--uk-muted);
    border-radius: 0.375rem;
}

.sample-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.sample-index {
    font-weight: 600;
    min-width: 2rem;
}

.sample-timestamp {
    color: var(--uk-muted-foreground);
    font-size: 0.875rem;
}

.sample-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Samples Section */
.samples-section {
    background: var(--uk-card);
    border: 1px solid var(--uk-border);
    border-radius: 0.5rem;
    padding: 1rem;
}

.section-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.section-title-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.section-title {
    font-size: 1rem;
    font-weight: 600;
}

.section-actions-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Embedding Status */
.embedding-status {
    font-size: 0.75rem;
    color: var(--uk-muted);
    margin-right: 0.5rem;
}

.embedding-success {
    color: #22c55e;
}

.embedding-fail {
    color: #ef4444;
}

.embedding-pending {
    color: #f59e0b;
}

/* Samples Table */
.samples-table {
    width: 100%;
    margin: 0;
}

.samples-table th {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--uk-muted-foreground);
    font-weight: 600;
}

.samples-table .col-preferred {
    width: 60px;
    text-align: center;
}

.samples-table .col-index {
    width: 40px;
}

.samples-table .col-duration {
    width: 80px;
}

.samples-table .col-audio {
    min-width: 250px;
}

.samples-table .col-score {
    width: 60px;
}

.samples-table .col-examples {
    min-width: 220px;
}

.samples-table .col-actions {
    width: 40px;
}

.samples-table .col-audio audio {
    height: 36px;
    width: 100%;
    min-width: 220px;
}

.samples-table.ishikawa-mode .col-preferred,
.samples-table.ishikawa-mode .col-score,
.samples-table.ishikawa-mode .col-examples {
    display: none;
}

.samples-table td {
    vertical-align: top;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
}

.samples-table td.col-preferred {
    vertical-align: middle;
    text-align: center;
}

.samples-table td.col-preferred input[type="radio"] {
    cursor: pointer;
    width: 18px;
    height: 18px;
    accent-color: #007bff;
}

/* Ranked sample rows - gradient from green (best) to red (worst) */
/* Color is set via --rank-color CSS variable from JavaScript */
.sample-row[style*="--rank-color"] td {
    background-color: var(--rank-color) !important;
}

.ishikawa-clones {
    border-top: 1px solid var(--uk-border);
    margin-top: 0.75rem;
    padding-top: 0.75rem;
}

.ishikawa-source-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    font-size: 0.8rem;
    color: var(--uk-muted-foreground);
    margin-bottom: 0.5rem;
}

.ishikawa-source-label {
    font-weight: 600;
    color: var(--uk-foreground);
}

.ishikawa-clones-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 0.5rem;
}

.ishikawa-clone {
    border: 1px solid var(--uk-border);
    border-radius: 8px;
    padding: 0.6rem;
    background: #fff;
}

.clone-main {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    align-items: center;
    min-width: 0;
}

.clone-language {
    font-weight: 700;
    font-size: 0.82rem;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.clone-status {
    font-size: 0.72rem;
    text-transform: uppercase;
    color: var(--uk-muted-foreground);
    flex: 0 0 auto;
}

.clone-id {
    display: block;
    margin-top: 0.4rem;
    font-size: 0.72rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.clone-source-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.5rem;
}

.clone-source {
    flex: 1;
    min-width: 0;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.72rem;
    color: #166534;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.clone-source.missing {
    color: var(--uk-muted-foreground);
}

.clone-source.unavailable {
    flex: 0 0 auto;
    color: #92400e;
}

.ishikawa-clone.clone-unavailable {
    opacity: 0.72;
}

.clone-source svg {
    width: 14px;
    height: 14px;
    flex: 0 0 auto;
}

.clone-error {
    margin-top: 0.4rem;
    color: #b91c1c;
    font-size: 0.72rem;
}

.clone-sample {
    margin-top: 0.5rem;
}

.clone-sample audio {
    display: block;
    width: 100%;
    height: 32px;
}

.clone-sample-status {
    margin-top: 0.5rem;
    font-size: 0.72rem;
    color: var(--uk-muted-foreground);
}

.ishikawa-clone.clone-completed {
    border-color: #9bd4aa;
    background: #f0fbf3;
}

.ishikawa-clone.clone-failed {
    border-color: #f0a8a8;
    background: #fff1f1;
}

.ishikawa-clone.clone-in_progress {
    border-color: #e0c16a;
    background: #fff8e5;
}

/* Score display */
.score-value {
    font-weight: 600;
    color: #155724;
}

/* Examples column - stacked audio players */
.examples-stack {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.examples-stack audio {
    height: 32px;
    width: 100%;
    min-width: 200px;
}

#samples-empty {
    display: none;
}

#samples-table-container:has(tbody:empty) #samples-empty {
    display: block;
}

#samples-table-container:has(tbody:empty) .samples-table {
    display: none;
}

.sample-actions audio {
    height: 32px;
}

/* Drop Zone */
.drop-zone {
    border: 2px dashed var(--uk-border);
    border-radius: 0.5rem;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s;
    color: var(--uk-muted-foreground);
}

.drop-zone:hover {
    border-color: #007bff;
    background: #f8f9fa;
}

.drop-zone.drag-over {
    border-color: #007bff;
    background: #cce5ff;
}

.drop-zone p {
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.drop-zone i {
    width: 24px;
    height: 24px;
}

/* File Preview */
.file-preview {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: var(--uk-muted);
    border-radius: 0.375rem;
    margin-top: 0.5rem;
}

/* Test Samples Table */
#test-samples-section table {
    width: 100%;
}

#test-samples-section audio {
    height: 32px;
    max-width: 200px;
}

/* Queue Widget */
.queue-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    min-width: 150px;
    z-index: 2000;
    border-radius: 0.5rem;
    overflow: hidden;
    cursor: pointer;
    opacity: 0.4;
    transition: opacity 0.2s ease;
}

.queue-widget:hover {
    opacity: 1;
}

.queue-header {
    padding: 0.5rem 0.75rem !important;
    font-weight: 600;
    font-size: 0.875rem;
}

.queue-content {
    padding: 0.5rem 0.75rem !important;
}

.queue-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
    padding: 0.125rem 0;
}

.queue-label {
    color: var(--uk-muted-foreground);
}

/* Spinner */
.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid #ccc;
    border-top-color: #007bff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 5px;
    flex-shrink: 0;
}

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

/* Processing state */
.voice-view.processing {
    position: relative;
}

.voice-view.processing::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.5);
    pointer-events: none;
    z-index: 10;
}

.voice-view.processing .section-card {
    opacity: 0.7;
}

/* Accordion Styling */
.uk-accordion > li {
    margin: 0;
}

.uk-accordion-title {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
}

.uk-accordion-icon {
    display: inline-flex;
    align-items: center;
    transition: transform 0.3s ease;
}

.uk-accordion-icon svg {
    width: 16px;
    height: 16px;
}

/* Rotate chevron when closed */
.uk-accordion > li:not(.uk-open) .uk-accordion-icon {
    transform: rotate(-90deg);
}

.section-actions-bar {
    margin-bottom: 10px;
}

/* Status badges for accordion headers (using Franken UI uk-badge) */
.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px !important;
    flex-shrink: 0;
    min-width: 22px;
    min-height: 22px;
}

.status-badge svg {
    width: 14px;
    height: 14px;
    stroke: white;
    stroke-width: 2;
}

/* Custom badge colors - explicit styling to ensure visibility */
.status-badge.status-ok {
    background-color: #28a745 !important;
    color: white !important;
}

.status-badge.uk-badge-destructive {
    background-color: #dc3545 !important;
    color: white !important;
}

.accordion-meta {
    font-size: 0.75rem;
    color: #6c757d;
    font-weight: normal;
}

.original-audio-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.original-label {
    font-weight: 600;
    color: var(--uk-muted-foreground);
}

.original-duration {
    color: #6c757d;
    font-size: 0.875rem;
}

/* Modal Overrides */
.uk-modal-dialog {
    max-width: 500px;
}

.uk-modal-body .uk-margin {
    margin-bottom: 1.5rem;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        min-width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--uk-border);
    }

    .voice-list {
        max-height: 200px;
    }
}
