/* === TUBERADAR.CSS ===
   assets/css/tuberadar.css
   НАЗНАЧЕНИЕ: Layout TubeRadar SPA - header, tabs, sidebar, content, list items, cards, tables, badges
   СВЯЗИ: main.css (CSS переменные), index.php
   РАЗМЕР: ~300 строк */

/* -- Header -- */
.tr-header {
    display: flex;
    align-items: center;
    padding: 0 10px;
    gap: 10px;
    border-bottom: 1px solid var(--border-color);
    height: 48px;
    background: var(--bg-secondary);
    flex-shrink: 0;
}

.tr-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 16px;
    color: var(--color-primary);
    flex-shrink: 0;
}

.tr-tabs {
    display: flex;
    gap: 4px;
    overflow-x: auto;
}

.tr-tab {
    padding: 6px 12px;
    border-radius: 6px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13px;
    white-space: nowrap;
    transition: color 0.15s, background 0.15s;
}

.tr-tab:hover {
    color: var(--text-primary);
    background: hsla(0, 0%, 50%, 0.1);
    text-decoration: none;
}

.tr-tab.active {
    color: var(--color-primary);
    background: var(--color-primary-bg);
    font-weight: 600;
}

.tr-header-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* -- Main layout -- */
.tr-main {
    display: flex;
    height: calc(100vh - 48px);
    overflow: hidden;
}

.tr-sidebar {
    width: 280px;
    flex-shrink: 0;
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    padding: 10px;
    background: var(--bg-secondary);
}

.tr-sidebar.hidden {
    display: none;
}

.tr-content {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.tr-content-full {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

/* -- List items in sidebar -- */
.tr-list-item {
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    margin-bottom: 4px;
    transition: background 0.15s;
    border: 1px solid transparent;
}

.tr-list-item:hover {
    background: hsla(0, 0%, 50%, 0.08);
}

.tr-list-item.active {
    background: var(--color-primary-bg);
    border-color: var(--color-primary);
}

.tr-list-item-title {
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tr-list-item-meta {
    font-size: 11px;
    color: var(--text-muted);
}

/* -- Action bar (top of sidebar) -- */
.tr-action-bar {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
}

.tr-action-bar input {
    flex: 1;
    padding: 6px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
    outline: none;
}

.tr-action-bar input:focus {
    border-color: var(--color-primary);
}

.tr-action-bar input::placeholder {
    color: var(--text-muted);
}

/* -- Buttons -- */
.tr-btn {
    padding: 6px 12px;
    background: var(--color-primary);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: opacity 0.15s;
    white-space: nowrap;
    font-family: inherit;
}

.tr-btn:hover {
    opacity: 0.85;
}

.tr-btn-sm {
    padding: 4px 8px;
    font-size: 12px;
}

.tr-btn-danger {
    background: var(--color-danger);
}

.tr-btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.tr-btn-secondary:hover {
    background: var(--hover-bg);
    opacity: 1;
}

/* -- Cards / detail sections -- */
.tr-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 10px;
}

.tr-card-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
}

.tr-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

/* -- Table -- */
.tr-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.tr-table th,
.tr-table td {
    padding: 6px 10px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.tr-table th {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tr-table tr:hover td {
    background: hsla(0, 0%, 50%, 0.05);
}

.tr-table .sortable {
    cursor: pointer;
    user-select: none;
}

.tr-table .sortable:hover {
    color: var(--text-primary);
}

/* -- Status badges -- */
.tr-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.tr-badge-ok {
    background: hsla(142, 76%, 36%, 0.15);
    color: #10b981;
}

.tr-badge-error {
    background: hsla(0, 84%, 60%, 0.15);
    color: var(--color-danger);
}

.tr-badge-pending {
    background: hsla(45, 93%, 47%, 0.15);
    color: #f59e0b;
}

.tr-badge-running {
    background: hsla(217, 91%, 60%, 0.15);
    color: var(--color-info);
}

.tr-badge-done {
    background: hsla(142, 76%, 36%, 0.15);
    color: #10b981;
}

/* -- Empty state -- */
.tr-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.tr-empty-icon {
    font-size: 48px;
    margin-bottom: 10px;
    opacity: 0.3;
}

.tr-empty-text {
    font-size: 14px;
}

/* -- Transcript view -- */
.tr-transcript {
    font-size: 14px;
    line-height: 1.7;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

.tr-transcript-segment {
    padding: 2px 0;
}

.tr-transcript-time {
    color: var(--color-primary);
    font-size: 12px;
    cursor: pointer;
    margin-right: 8px;
    font-family: var(--font-mono);
}

.tr-transcript-time:hover {
    text-decoration: underline;
}

/* -- Chart container -- */
.tr-chart-wrap {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px;
}

/* -- Loading -- */
.tr-loading {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
}

/* -- Search input full-width -- */
.tr-search {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 14px;
    margin-bottom: 10px;
    font-family: inherit;
    outline: none;
}

.tr-search:focus {
    border-color: var(--color-primary);
}

.tr-search::placeholder {
    color: var(--text-muted);
}

/* -- Settings sections -- */
.tr-settings-section {
    margin-bottom: 16px;
}

.tr-settings-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.tr-settings-value {
    font-size: 14px;
    font-family: var(--font-mono);
    padding: 6px 10px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

/* -- Pagination -- */
.tr-pagination {
    display: flex;
    gap: 6px;
    margin-top: 10px;
    justify-content: center;
}

.tr-page-btn {
    padding: 4px 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 12px;
    font-family: inherit;
    transition: background 0.15s;
}

.tr-page-btn:hover {
    background: var(--hover-bg);
}

.tr-page-btn.active {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

.tr-page-btn:disabled {
    opacity: 0.4;
    cursor: default;
}

/* -- Toggle switch -- */
.tr-toggle {
    position: relative;
    width: 36px;
    height: 20px;
    flex-shrink: 0;
}

.tr-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.tr-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--border-color);
    border-radius: 20px;
    transition: background 0.2s;
}

.tr-toggle-slider::before {
    content: '';
    position: absolute;
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s;
}

.tr-toggle input:checked + .tr-toggle-slider {
    background: var(--color-primary);
}

.tr-toggle input:checked + .tr-toggle-slider::before {
    transform: translateX(16px);
}

/* -- Detail grid (two-column) -- */
.tr-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    align-content: start;
}

.tr-detail-col-stack {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* -- Disk usage bar -- */
.tr-disk-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 6px;
}

.tr-disk-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s;
}

/* -- Keyword position indicator -- */
.tr-position {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-family: var(--font-mono);
    font-weight: 600;
}

.tr-position-up {
    color: #10b981;
}

.tr-position-down {
    color: var(--color-danger);
}

.tr-position-same {
    color: var(--text-muted);
}

/* -- Inline form row -- */
.tr-form-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.tr-form-row label {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    min-width: 100px;
}

.tr-form-row input,
.tr-form-row select {
    flex: 1;
    padding: 6px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
    outline: none;
}

.tr-form-row input:focus,
.tr-form-row select:focus {
    border-color: var(--color-primary);
}

.tr-form-row select {
    cursor: pointer;
}
