/* views.css — View-specific styles */

/* ===== Upload view ===== */

.upload-container {
    max-width: 760px;
    width: 100%;
    text-align: center;
    padding: 24px 0 0;
    border-radius: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
}

.upload-title {
    font-size: clamp(1.85rem, 3.5vw, 2.6rem);
    font-weight: 610;
    letter-spacing: -0.04em;
    line-height: 1.02;
    margin-bottom: 24px;
}

.upload-subtitle {
    color: #666;
    margin-bottom: 32px;
}

.upload-area { margin-bottom: 18px; }

.upload-box {
    border: 1px solid rgba(23, 23, 23, 0.09);
    border-radius: 24px;
    padding: 52px 32px;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
    text-align: center;
    background: #fffdf8;
}

.upload-box:hover {
    border-color: rgba(23, 23, 23, 0.16);
    transform: translateY(-1px);
}
.upload-box.dragover {
    border-color: rgba(23, 23, 23, 0.22);
    background: #ffffff;
}
.upload-box.has-file {
    border-color: rgba(5, 150, 105, 0.22);
    background: #f3fbf7;
    border-style: solid;
}

.upload-box.is-loading {
    border-color: rgba(37, 99, 235, 0.18);
    background: #f8fbff;
    pointer-events: none;
}

.upload-icon {
    width: 62px;
    height: 62px;
    margin: 0 auto 18px;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.85rem;
    background: #f1f1ec;
}
.upload-text {
    color: #171717;
    font-size: 1.08rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}
.upload-hint { font-size: 0.8rem; color: #999; }

.upload-box.is-loading .upload-icon {
    animation: pulse 1.2s infinite;
}

.upload-box.is-loading .upload-text::after {
    content: '';
    display: inline-block;
    width: 1ch;
    text-align: left;
    overflow: hidden;
    vertical-align: bottom;
    animation: loading-dots 1.2s steps(4, end) infinite;
}

@keyframes loading-dots {
    0% { content: ''; }
    25% { content: '.'; }
    50% { content: '..'; }
    75% { content: '...'; }
    100% { content: ''; }
}

#upload-view > .btn-row {
    margin-top: 0;
}

/* ===== Saved scripts ===== */

.saved-scripts {
    margin-top: 40px;
    text-align: left;
    width: 100%;
    border-top: 1px solid rgba(23, 23, 23, 0.08);
    padding-top: 24px;
}

.saved-scripts-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.saved-scripts-title {
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: #4b5563;
}

.saved-scripts-count {
    font-size: 0.72rem;
    color: #6b7280;
    background: rgba(17, 24, 39, 0.05);
    padding: 4px 10px;
    border-radius: 999px;
}

.saved-script-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border: 1px solid rgba(23, 23, 23, 0.07);
    border-radius: 16px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.15s;
    background: rgba(255,255,255,0.92);
}

.saved-script-item:hover {
    border-color: rgba(17, 24, 39, 0.15);
    background: rgba(255,255,255,0.92);
}

.saved-script-info { flex: 1; }
.saved-script-name { font-weight: 500; margin-bottom: 2px; }
.saved-script-meta { font-size: 0.75rem; color: #999; }

.saved-script-delete {
    color: #ccc;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 1rem;
    transition: all 0.15s;
}

.saved-script-delete:hover { color: #dc2626; background: #fef2f2; }

.empty-library {
    text-align: center;
    padding: 24px;
    color: #6b7280;
    font-size: 0.875rem;
    border: 1px dashed rgba(17, 24, 39, 0.12);
    border-radius: 16px;
    background: rgba(255,255,255,0.48);
}

/* ===== Review / Edit ===== */

.review-shell {
    display: none;
    margin-top: 18px;
    border: 1px solid rgba(23, 23, 23, 0.08);
    border-radius: 24px;
    padding: 18px;
    max-height: 55vh;
    overflow: auto;
    text-align: left;
    background: rgba(255, 255, 255, 0.86);
    box-shadow: 0 14px 36px rgba(23, 23, 23, 0.06);
}

.review-shell.visible {
    display: block;
}

.review-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.review-title {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.review-title strong {
    font-size: 1rem;
    letter-spacing: -0.02em;
}

.review-title span {
    font-size: 0.82rem;
    color: #6b7280;
}

.review-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.edit-screen {
    width: 100%;
    max-width: 880px;
    text-align: left;
}

.edit-screen .upload-title,
.edit-screen .upload-subtitle {
    text-align: center;
}

.edit-lines-list {
    text-align: left;
    max-height: 50vh;
    overflow-y: auto;
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 12px;
    background: #fff;
    width: 100%;
}

.edit-line-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    width: 100%;
    padding: 14px 4px;
    border-bottom: 1px solid #f2f2f2;
    position: relative;
}

.edit-line-label {
    width: 80px;
    flex: 0 0 80px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: #666;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
    background: #f7f7f7;
    align-self: flex-start;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.edit-line-text-wrap {
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
}

.edit-line-text {
    flex: 1;
    width: 100%;
    display: block;
    border: 1px solid #eee;
    border-radius: 6px;
    padding: 14px 16px;
    font-size: 16px;
    resize: none;
    overflow: hidden;
    line-height: 1.6;
    background: #fcfcfc;
}

.edit-line-controls {
    display: none;
    gap: 6px;
    align-items: center;
    flex: 0 0 auto;
}

.edit-line-row:hover .edit-line-controls,
.edit-line-row:focus-within .edit-line-controls {
    display: flex;
}

.edit-line-picker {
    position: absolute;
    left: 0;
    top: 36px;
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    padding: 6px;
    box-shadow: 0 6px 18px rgba(0,0,0,0.08);
    z-index: 50;
    min-width: 180px;
}

.edit-line-picker button {
    width: 100%;
    text-align: left;
    padding: 6px 8px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 0.85rem;
}

.edit-line-picker button:hover {
    background: #f5f5f5;
}

/* ===== Practice view ===== */

.practice-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 980px;
}

.progress-bar {
    height: 3px;
    background: rgba(23, 23, 23, 0.08);
    border-radius: 2px;
    margin-bottom: 8px;
}

.progress-fill {
    height: 100%;
    background: #1a1a1a;
    border-radius: 2px;
    transition: width 0.3s;
}

.progress-text {
    font-size: 0.78rem;
    color: #7a7a72;
    margin-bottom: 20px;
}

.practice-script {
    height: min(72vh, 760px);
    overflow-y: auto;
    padding: 6px 0 36px;
    margin-bottom: 16px;
    border: 1px solid rgba(23, 23, 23, 0.08);
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.62);
    scroll-behavior: smooth;
}

.practice-edit-actions-inline {
    display: none;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 0 18px 10px;
    position: sticky;
    top: 0;
    z-index: 4;
    background: linear-gradient(180deg, rgba(255,255,255,0.96) 0%, rgba(255,255,255,0.78) 70%, rgba(255,255,255,0) 100%);
}

.practice-script-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.practice-script-line {
    padding: 18px 22px;
    border-radius: 18px;
    background: transparent;
    border: 1px solid transparent;
    opacity: 0.42;
    transition: opacity 0.18s ease, background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.practice-script-line.is-nearby {
    opacity: 0.72;
}

.practice-script-line.is-active {
    opacity: 1;
    background: #fffdfa;
    border-color: rgba(23, 23, 23, 0.08);
    transform: none;
    box-shadow: 0 6px 18px rgba(23, 23, 23, 0.04);
}

.practice-script-line.is-you {
    background: rgba(5, 150, 105, 0.045);
}

.practice-script-line.is-concealed .practice-script-dialogue {
    filter: blur(9px);
    opacity: 0.4;
    user-select: none;
    transition: filter 0.16s ease, opacity 0.16s ease;
}

.practice-script-line.is-concealed .practice-script-speaker {
    opacity: 0.55;
}

.practice-script-line.is-concealed.is-active .practice-script-dialogue {
    filter: blur(11px);
    opacity: 0.34;
}

.practice-script-line.is-other {
    background: rgba(23, 23, 23, 0.015);
}

.practice-script-line.is-stage {
    background: rgba(17, 24, 39, 0.03);
    font-style: italic;
}

.practice-script-line.is-editing {
    opacity: 1;
    background: #fffdfa;
    border-color: rgba(23, 23, 23, 0.08);
    box-shadow: 0 3px 12px rgba(23, 23, 23, 0.03);
}

.practice-script-line-tools {
    display: none;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 12px;
}

.practice-script-line.is-editing .practice-script-line-tools {
    display: flex;
}

.practice-add-row {
    display: none;
    justify-content: center;
    padding: 8px 0;
}

.practice-editing .practice-add-row {
    display: flex;
}

.practice-script-field,
.practice-script-textarea {
    width: 100%;
    border: none;
    background: transparent;
    color: inherit;
    font: inherit;
    padding: 0;
    margin: 0;
    outline: none;
}

.practice-script-field {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.practice-script-textarea {
    resize: none;
    line-height: 1.7;
    min-height: 34px;
    overflow: hidden;
}

.practice-script-speaker {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #6b7280;
    margin-bottom: 6px;
}

.practice-script-line.is-you .practice-script-speaker {
    color: #059669;
}

.practice-script-line.is-other .practice-script-speaker {
    color: #2563eb;
}

.practice-script-line.is-stage .practice-script-speaker {
    color: #888;
}

.practice-script-dialogue {
    color: #171717;
    font-size: 1.02rem;
    line-height: 1.7;
    white-space: pre-wrap;
}

.practice-script-line.is-cueable {
    cursor: pointer;
}

.practice-script-line.is-cueable .practice-script-dialogue {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35em;
    align-items: baseline;
}

.cue-mask-word {
    color: #b3b3ab;
    letter-spacing: 0.04em;
}

.practice-state {
    display: none;
}

.line-display {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    text-align: center;
    padding: 8px 0 20px;
}

.speaker-label {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 16px;
}

.speaker-label.other { color: #2563eb; }
.speaker-label.you { color: #059669; }
.speaker-label.stage-direction { color: #888; font-style: italic; }

.dialogue-text {
    font-size: 1.35rem;
    line-height: 1.45;
    color: #1a1a1a;
}

.word-correct { color: #059669; }
.word-incorrect { color: #dc2626; text-decoration: line-through; }
.word-expected { color: #059669; font-weight: 600; }

.status-area {
    text-align: center;
    padding: 12px 0 18px;
}

.status-text {
    font-size: 0.9rem;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ccc;
}

.status-dot.listening { background: #059669; animation: pulse 1.5s infinite; }
.status-dot.speaking { background: #2563eb; animation: pulse 1s infinite; }
.status-dot.error { background: #dc2626; animation: pulse 1.5s infinite; }

.controls {
    display: flex;
    gap: 12px;
    justify-content: center;
    padding-top: 18px;
    margin-bottom: 24px;
    border-top: 1px solid #eee;
    flex-wrap: wrap;
}

.feedback {
    margin-top: 16px;
    padding: 16px;
    border-radius: 8px;
    font-size: 0.9rem;
}

.feedback.correct { background: #f0fdf4; color: #059669; }
.feedback.incorrect { background: #fef2f2; color: #666; }

.feedback-words {
    margin-top: 12px;
    font-size: 1.1rem;
    line-height: 1.8;
}

/* ===== Record view ===== */

.record-status {
    margin-top: 12px;
    font-size: 0.85rem;
    color: #666;
    min-height: 20px;
}

.empty-lines {
    padding: 24px;
    text-align: center;
    color: #999;
}

.record-characters {
    margin: 16px 0;
    text-align: left;
}

.record-characters-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-weight: 600;
}

#record-character-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.record-lines-section {
    margin-bottom: 16px;
    text-align: left;
}

.record-lines-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-weight: 600;
}

.recorded-lines-list {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #eee;
    border-radius: 8px;
    background: #fafafa;
}

.recorded-line-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 12px;
    border-bottom: 1px solid #eee;
    font-size: 0.85rem;
}

.recorded-line-item:last-child {
    border-bottom: none;
}

.recorded-line-char {
    font-weight: 600;
    color: #2563eb;
    min-width: 80px;
}

.recorded-line-text {
    flex: 1;
    color: #333;
}

.recorded-line-delete {
    color: #999;
    cursor: pointer;
    padding: 2px 6px;
}

.recorded-line-delete:hover {
    color: #dc2626;
}

/* ===== Problem lines ===== */

.problem-lines-section {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #eee;
}

.problem-line-item {
    padding: 8px 12px;
    background: #fff;
    border: 1px solid #eee;
    border-radius: 6px;
    margin-bottom: 6px;
    font-size: 0.8rem;
}

.problem-line-text {
    color: #666;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.problem-line-count {
    font-size: 0.7rem;
    color: #dc2626;
    margin-top: 4px;
}

/* Mobile responsive */
@media (max-width: 479px) {
    .practice-script {
        height: calc(100vh - 380px);
        min-height: 300px;
    }

    .practice-script-line {
        padding: 14px 16px;
    }

    .practice-script-dialogue {
        font-size: 0.92rem;
    }

    .controls {
        flex-direction: column;
        gap: 8px;
    }

    .controls .btn {
        width: 100%;
    }

    .upload-box {
        padding: 28px 16px;
    }
}

/* Line progress tracking */
.line-progress-chunks {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid rgba(23, 23, 23, 0.08);
}

.chunk {
    font-size: 0.85rem;
    padding: 6px 10px;
    margin-bottom: 6px;
    border-radius: 8px;
    background: rgba(23, 23, 23, 0.03);
    color: #666;
    transition: all 0.3s ease;
}

.chunk.covered {
    background: rgba(5, 150, 105, 0.1);
    color: #059669;
    font-weight: 500;
}

.line-progress-bar {
    height: 6px;
    background: rgba(23, 23, 23, 0.08);
    border-radius: 3px;
    margin: 12px 0 8px 0;
    overflow: hidden;
}

.line-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #059669 0%, #10b981 100%);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.line-progress-text {
    font-size: 0.75rem;
    color: #059669;
    font-weight: 600;
    text-align: center;
}
