/* МедЗапись — Clean medical-style CSS */

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --success: #16a34a;
    --error: #dc2626;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-muted: #64748b;
    --radius: 8px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    padding: 16px 0;
    margin-bottom: 24px;
}

header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

header h1 {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--primary);
}

header .subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Flash messages */
.flash {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 0.9rem;
}

.flash.error {
    background: #fef2f2;
    color: var(--error);
    border: 1px solid #fecaca;
}

.flash.success {
    background: #f0fdf4;
    color: var(--success);
    border: 1px solid #bbf7d0;
}

/* Cards */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
}

.card h2 {
    font-size: 1.1rem;
    margin-bottom: 16px;
    color: var(--text);
}

/* Forms */
label {
    display: block;
    font-weight: 500;
    margin-bottom: 6px;
    font-size: 0.9rem;
    color: var(--text);
}

input[type="file"] {
    display: block;
    width: 100%;
    padding: 12px;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    cursor: pointer;
    font-size: 0.9rem;
}

input[type="file"]:hover {
    border-color: var(--primary);
}

textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.9rem;
    resize: vertical;
    line-height: 1.5;
}

textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group {
    margin-bottom: 20px;
}

.form-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Radio buttons */
.radio-group {
    display: flex;
    gap: 20px;
    margin-top: 6px;
}

.radio-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 400;
    cursor: pointer;
}

.radio-group input[type="radio"] {
    accent-color: var(--primary);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #15803d;
}

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
}

.btn-outline:hover {
    background: rgba(37, 99, 235, 0.05);
}

.btn-sm {
    padding: 5px 10px;
    font-size: 0.8rem;
}

.btn-copy {
    background: #f1f5f9;
    color: var(--text);
    border: 1px solid var(--border);
    font-size: 0.8rem;
    padding: 4px 10px;
}

.btn-copy:hover {
    background: #e2e8f0;
}

.btn-copy.copied {
    background: #f0fdf4;
    color: var(--success);
    border-color: #bbf7d0;
}

/* Input tabs (3 cards in a row) */
.input-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.input-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 20px 12px;
    background: var(--card-bg);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.input-tab:hover {
    border-color: var(--primary);
    background: #f8faff;
}

.input-tab.active {
    border-color: var(--primary);
    background: #eff6ff;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.input-tab-icon {
    font-size: 1.6rem;
    line-height: 1;
}

.input-tab-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text);
}

.input-tab-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.input-tab.active .input-tab-title {
    color: var(--primary);
}

/* Input panels (shown/hidden by tabs) */
.input-panel {
    display: none;
}

.input-panel.active {
    display: block;
}

/* Settings grid */
.settings-card h2 {
    margin-bottom: 20px;
}

.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

.radio-group-vertical {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 6px;
}

.radio-group-vertical label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 400;
    cursor: pointer;
    font-size: 0.88rem;
}

.radio-group-vertical input[type="radio"] {
    accent-color: var(--primary);
}

.btn-lg {
    padding: 14px 32px;
    font-size: 1rem;
    width: 100%;
    justify-content: center;
}

@media (max-width: 768px) {
    /* Шапка: столбик вместо ряда */
    header .container {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    header h1 {
        font-size: 1.1rem;
    }

    header .subtitle {
        font-size: 0.75rem;
    }

    .container {
        padding: 12px;
    }

    /* Табы: 3 в ряд, компактнее */
    .input-tabs {
        grid-template-columns: 1fr 1fr 1fr;
        gap: 8px;
    }

    .input-tab {
        padding: 14px 8px;
    }

    .input-tab-icon {
        font-size: 1.2rem;
    }

    .input-tab-title {
        font-size: 0.82rem;
    }

    .input-tab-desc {
        font-size: 0.7rem;
    }

    /* Карточки компактнее */
    .card {
        padding: 16px;
        margin-bottom: 12px;
    }

    .card h2 {
        font-size: 1rem;
    }

    /* Настройки в столбик */
    .settings-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    /* Кнопки навигации */
    .btn-sm {
        padding: 4px 8px;
        font-size: 0.75rem;
    }

    /* Обработка — компактнее */
    .processing-card {
        margin: 16px auto;
    }

    /* Результаты */
    .action-bar {
        flex-direction: column;
    }

    .action-bar .btn {
        width: 100%;
        justify-content: center;
    }

    .action-bar .form-hint {
        margin-left: 0;
        text-align: center;
    }

    /* Таблица записей — горизонтальный скролл */
    .records-table {
        font-size: 0.78rem;
    }

    .records-title {
        max-width: 120px;
    }

    .records-date {
        font-size: 0.72rem;
    }
}

/* Divider (kept for compatibility) */
.divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 16px 0;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.divider::before,
.divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* Results layout */
.results-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

@media (max-width: 768px) {
    .results-grid {
        grid-template-columns: 1fr;
    }
}

.transcript-panel {
    position: sticky;
    top: 20px;
    align-self: start;
}

.transcript-text {
    max-height: 70vh;
    overflow-y: auto;
    padding: 12px;
    background: var(--bg);
    border-radius: var(--radius);
    font-size: 0.88rem;
    line-height: 1.7;
    white-space: pre-wrap;
}

/* Field cards */
.field-card {
    margin-bottom: 12px;
}

.field-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.field-label {
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--text);
}

.field-empty {
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.85rem;
    padding: 8px 0;
}

/* Action bar */
.action-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

/* Loading */
.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.85);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    gap: 16px;
}

.loading-overlay.active {
    display: flex;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-text {
    font-size: 1rem;
    color: var(--text);
    font-weight: 500;
}

/* Voice recorder */
.recorder {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-record {
    background: #f1f5f9;
    color: var(--text);
    border: 2px solid var(--border);
    font-weight: 500;
    padding: 12px 24px;
    font-size: 0.95rem;
}

.btn-record:hover {
    border-color: var(--error);
    background: #fef2f2;
}

.btn-record.recording {
    background: #fef2f2;
    border-color: var(--error);
    color: var(--error);
    animation: pulse-border 1.5s ease-in-out infinite;
}

@keyframes pulse-border {
    0%, 100% { border-color: var(--error); }
    50% { border-color: #fecaca; }
}

.rec-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-muted);
    margin-right: 4px;
}

.rec-dot.active {
    background: var(--error);
    animation: blink 1s ease-in-out infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.rec-timer {
    font-family: monospace;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    min-width: 50px;
}

.rec-status {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.audio-preview audio {
    border-radius: var(--radius);
}

/* Processing steps */
.processing-card {
    max-width: 600px;
    margin: 40px auto;
}

.steps {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.step {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
    opacity: 0.5;
    transition: opacity 0.3s;
}

.step:last-child {
    border-bottom: none;
}

.step.active, .step.done {
    opacity: 1;
}

.step-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 600;
    flex-shrink: 0;
    transition: all 0.3s;
}

.step-icon.pending {
    background: #f1f5f9;
    color: var(--text-muted);
    border: 2px solid var(--border);
}

.step-icon.active {
    background: #eff6ff;
    color: var(--primary);
    border: 2px solid var(--primary);
}

.step-icon.done {
    background: #f0fdf4;
    color: var(--success);
    border: 2px solid var(--success);
}

.step-icon.error {
    background: #fef2f2;
    color: var(--error);
    border: 2px solid var(--error);
}

.step-body {
    flex: 1;
    padding-top: 2px;
}

.step-title {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 2px;
}

.step-desc {
    font-size: 0.83rem;
    color: var(--text-muted);
}

.step.active .step-desc {
    color: var(--primary);
    font-weight: 500;
}

.step.done .step-desc {
    color: var(--success);
}

.step-spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid #dbeafe;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.step-progress {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
}

.progress-bar {
    flex: 1;
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    width: 0%;
    transition: width 0.5s ease;
}

.progress-pct {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--primary);
    min-width: 35px;
}

.step-error {
    margin-top: 16px;
    padding: 12px 16px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--radius);
    color: var(--error);
    font-size: 0.9rem;
}

/* Records list component */
.records-card {
    margin-top: 24px;
}

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

.records-header h2 {
    margin-bottom: 0;
}

.records-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.records-table th {
    text-align: left;
    padding: 8px 10px;
    border-bottom: 2px solid var(--border);
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.records-table td {
    padding: 10px 10px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.records-table tbody tr:hover {
    background: var(--bg);
}

.records-table tbody tr:last-child td {
    border-bottom: none;
}

.records-date {
    font-family: monospace;
    font-size: 0.83rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.records-title {
    font-weight: 500;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.records-title a {
    color: var(--text);
    text-decoration: none;
}

.records-title a:hover {
    color: var(--primary);
}

.records-provider {
    font-size: 0.83rem;
}

.records-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
    white-space: nowrap;
}

.records-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 24px 0;
    font-size: 0.9rem;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge-audio {
    background: #eff6ff;
    color: var(--primary);
}

.badge-text {
    background: #f0fdf4;
    color: var(--success);
}

/* Status dots */
.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 4px;
}

.status-done {
    background: var(--success);
}

.status-error {
    background: var(--error);
}

.status-processing {
    background: #f59e0b;
    animation: blink 1s ease-in-out infinite;
}

/* Delete button */
.btn-delete {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
    font-size: 0.78rem;
    padding: 4px 8px;
}

.btn-delete:hover {
    background: #fef2f2;
    color: var(--error);
    border-color: #fecaca;
}

@media (max-width: 768px) {
    .records-actions {
        flex-direction: column;
        gap: 4px;
    }
}

/* Errors panel */
.errors-panel {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 16px;
    font-size: 0.85rem;
    color: var(--error);
}
