/* theme-config.css v3.0
   ThemeConfig page — tc-* styles only.
   
   TÁCH RA:
     shared-modals.css → ipm-* (InstructionPreviewModal) + shp-* (SubjectHistoryPanel)
   ============================================================ */

/* wwwroot/css/theme-config.css v2.0 — Option A master-detail */

/* ── Reset & base ── */
*, *::before, *::after {
    box-sizing: border-box;
}

.tc-page {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 60px);
    overflow: hidden;
    padding: 0;
}

/* ── Header ── */
.tc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 0.5px solid var(--color-border-tertiary);
    flex-shrink: 0;
    gap: 12px;
    flex-wrap: wrap;
}

.tc-header-left {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.tc-title {
    font-size: 1.05rem;
    font-weight: 500;
    color: var(--color-text-primary);
    display: flex;
    align-items: center;
    gap: 7px;
    margin: 0;
}

.tc-subtitle {
    font-size: 0.78rem;
    color: var(--color-text-secondary);
}

.tc-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ── Global panel ── */
.tc-global-panel {
    padding: 14px 20px;
    border-bottom: 0.5px solid var(--color-border-tertiary);
    background: var(--color-background-secondary);
    flex-shrink: 0;
}

.tc-global-panel-title {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    margin-bottom: 12px;
}

.tc-hint-inline {
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--color-text-tertiary);
    margin-left: 6px;
}

.tc-global-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 12px;
}

.tc-global-card {
    background: var(--color-background-primary);
    border: 0.5px solid var(--color-border-tertiary);
    border-radius: var(--border-radius-md);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ── Master-Detail layout ── */
.tc-master-detail {
    display: flex;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

/* ── Sidebar ── */
.tc-sidebar {
    width: 200px;
    flex-shrink: 0;
    border-right: 0.5px solid var(--color-border-tertiary);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.tc-sidebar-search {
    padding: 8px;
    border-bottom: 0.5px solid var(--color-border-tertiary);
    position: relative;
    flex-shrink: 0;
}

.tc-search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 13px;
    color: var(--color-text-tertiary);
    pointer-events: none;
}

.tc-search-input {
    width: 100%;
    padding: 5px 8px 5px 28px;
    font-size: 12px;
    border: 0.5px solid var(--color-border-tertiary);
    border-radius: var(--border-radius-md);
    background: var(--color-background-secondary);
    color: var(--color-text-primary);
}

    .tc-search-input:focus {
        outline: none;
        border-color: var(--color-border-primary);
    }

.tc-sidebar-list {
    flex: 1;
    overflow-y: auto;
}

.tc-sidebar-loading {
    padding: 20px;
    display: flex;
    justify-content: center;
    color: var(--color-text-tertiary);
}

.tc-sidebar-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 12px;
    color: var(--color-text-secondary);
    border-bottom: 0.5px solid var(--color-border-tertiary);
    transition: background 0.1s;
    gap: 6px;
}

    .tc-sidebar-item:hover {
        background: var(--color-background-secondary);
    }

.tc-sidebar-item--active {
    background: var(--color-background-info) !important;
    color: var(--color-text-info);
}

.tc-sidebar-item--inactive {
    opacity: 0.5;
}

    .tc-sidebar-item--inactive .tc-sidebar-name::after {
        content: " ·off";
        font-size: 10px;
        color: var(--color-text-danger);
    }

.tc-sidebar-name {
    font-weight: 500;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tc-sidebar-type {
    font-size: 9px;
    padding: 1px 4px;
    border-radius: 3px;
    background: var(--color-background-secondary);
    color: var(--color-text-tertiary);
    flex-shrink: 0;
    white-space: nowrap;
}

.tc-sidebar-item--active .tc-sidebar-type {
    background: rgba(255,255,255,.2);
    color: var(--color-text-info);
}

.tc-sidebar-empty {
    padding: 16px 12px;
    font-size: 12px;
    color: var(--color-text-tertiary);
    text-align: center;
}

/* ── Detail panel ── */
.tc-detail {
    flex: 1;
    overflow-y: auto;
    min-width: 0;
}

.tc-detail-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 10px;
    color: var(--color-text-tertiary);
    font-size: 13px;
}

.tc-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-bottom: 0.5px solid var(--color-border-tertiary);
    position: sticky;
    top: 0;
    background: var(--color-background-primary);
    z-index: 2;
    gap: 10px;
    flex-wrap: wrap;
}

.tc-detail-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.tc-detail-title {
    font-size: 1rem;
    font-weight: 500;
    color: var(--color-text-primary);
}

.tc-detail-actions {
    display: flex;
    gap: 4px;
}

/* ── Section blocks ── */
.tc-section-block {
    padding: 16px 20px;
    border-bottom: 0.5px solid var(--color-border-tertiary);
}

.tc-section-block-title {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

/* ── Difficulty selector ── */
.tc-diff-selector {
    display: flex;
    gap: 6px;
    margin-bottom: 14px;
}

.tc-diff-tab {
    font-size: 12px;
    padding: 5px 14px;
    border-radius: 6px;
    border: 0.5px solid var(--color-border-tertiary);
    cursor: pointer;
    background: transparent;
    color: var(--color-text-secondary);
    transition: all 0.15s;
}

    .tc-diff-tab:hover {
        background: var(--color-background-secondary);
    }

.tc-diff-tab--easy.tc-diff-tab--active {
    background: #dcfce7;
    color: #16a34a;
    border-color: #16a34a44;
}

.tc-diff-tab--medium.tc-diff-tab--active {
    background: #fef9c3;
    color: #a16207;
    border-color: #a1620744;
}

.tc-diff-tab--hard.tc-diff-tab--active {
    background: #fee2e2;
    color: #dc2626;
    border-color: #dc262644;
}

.tc-diff-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ── Form elements ── */
.tc-field-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.tc-label {
    font-size: 0.76rem;
    font-weight: 500;
    color: var(--color-text-secondary);
}

.tc-required {
    color: var(--color-text-danger);
}

.tc-input {
    padding: 6px 9px;
    border: 0.5px solid var(--color-border-tertiary);
    border-radius: var(--border-radius-md);
    background: var(--color-background-secondary);
    color: var(--color-text-primary);
    font-size: 0.83rem;
    width: 100%;
}

.tc-input--flex {
    flex: 1;
}

.tc-input:focus, .tc-textarea:focus, .tc-select:focus {
    outline: none;
    border-color: var(--color-border-primary);
}

.tc-textarea {
    padding: 6px 9px;
    border: 0.5px solid var(--color-border-tertiary);
    border-radius: var(--border-radius-md);
    background: var(--color-background-secondary);
    color: var(--color-text-primary);
    font-size: 0.82rem;
    width: 100%;
    resize: vertical;
    line-height: 1.5;
    font-family: inherit;
}

.tc-textarea--code {
    font-family: var(--font-mono, monospace);
    font-size: 0.78rem;
}

.tc-select {
    padding: 6px 9px;
    border: 0.5px solid var(--color-border-tertiary);
    border-radius: var(--border-radius-md);
    background: var(--color-background-secondary);
    color: var(--color-text-primary);
    font-size: 0.83rem;
    width: 100%;
}

.tc-hint {
    font-size: 0.74rem;
    color: var(--color-text-tertiary);
}

    .tc-hint code {
        font-family: var(--font-mono, monospace);
        background: var(--color-background-secondary);
        padding: 1px 4px;
        border-radius: 3px;
        font-size: 0.72rem;
    }

.tc-no-data {
    font-size: 12px;
    color: var(--color-text-tertiary);
    padding: 8px 0;
}

.tc-muted {
    color: var(--color-text-tertiary);
    font-size: 12px;
}

.tc-two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.tc-inline-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
}

    .tc-inline-row .tc-label {
        white-space: nowrap;
    }

.mt-8 {
    margin-top: 8px;
}

/* ── Toggle ── */
.tc-toggle {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

    .tc-toggle input {
        display: none;
    }

.tc-toggle-slider {
    width: 34px;
    height: 18px;
    background: var(--color-border-tertiary);
    border-radius: 9px;
    position: relative;
    transition: background 0.2s;
}

    .tc-toggle-slider::after {
        content: '';
        position: absolute;
        width: 14px;
        height: 14px;
        background: #fff;
        border-radius: 50%;
        top: 2px;
        left: 2px;
        transition: left 0.2s;
    }

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

    .tc-toggle input:checked + .tc-toggle-slider::after {
        left: 18px;
    }

/* ── Override block ── */
.tc-override-details {
    border: 0.5px dashed var(--color-border-tertiary);
    border-radius: var(--border-radius-md);
    padding: 8px 10px;
}

.tc-override-summary {
    font-size: 0.78rem;
    color: var(--color-text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    user-select: none;
    list-style: none;
}

    .tc-override-summary::-webkit-details-marker {
        display: none;
    }

    .tc-override-summary::before {
        content: '›';
        font-size: 14px;
        transition: transform 0.15s;
        display: inline-block;
    }

details[open] .tc-override-summary::before {
    transform: rotate(90deg);
}

.tc-override-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--color-text-info);
}

.tc-override-body {
    padding-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ── Buttons ── */
.tc-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 13px;
    border-radius: var(--border-radius-md);
    border: 0.5px solid var(--color-border-tertiary);
    cursor: pointer;
    font-size: 0.83rem;
    font-weight: 500;
    transition: opacity 0.15s, background 0.15s;
    background: transparent;
    color: var(--color-text-primary);
}

    .tc-btn:hover {
        background: var(--color-background-secondary);
    }

.tc-btn--primary {
    background: var(--color-background-info);
    color: var(--color-text-info);
    border-color: transparent;
}

    .tc-btn--primary:hover {
        opacity: 0.85;
        background: var(--color-background-info);
    }

.tc-btn--ghost {
    color: var(--color-text-secondary);
}

.tc-btn--save {
    background: var(--color-background-success);
    color: var(--color-text-success);
    border-color: transparent;
}

    .tc-btn--save:hover {
        opacity: 0.85;
        background: var(--color-background-success);
    }

.tc-btn--sm {
    padding: 4px 9px;
    font-size: 0.78rem;
}

.tc-btn--xs {
    padding: 2px 6px;
    font-size: 0.72rem;
}

.tc-icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    border-radius: var(--border-radius-md);
    color: var(--color-text-secondary);
    font-size: 15px;
    transition: background 0.1s, color 0.1s;
}

    .tc-icon-btn:hover {
        background: var(--color-background-secondary);
        color: var(--color-text-primary);
    }

.tc-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text-secondary);
    font-size: 16px;
    padding: 4px;
}

/* ── Badges ── */
.tc-type-badge {
    font-size: 0.68rem;
    padding: 2px 6px;
    border-radius: 3px;
    background: var(--color-background-secondary);
    color: var(--color-text-secondary);
    font-family: var(--font-mono, monospace);
}

.tc-inactive-badge {
    font-size: 0.68rem;
    padding: 2px 6px;
    border-radius: 3px;
    background: var(--color-background-danger);
    color: var(--color-text-danger);
}

.tc-diff-badge {
    font-size: 0.7rem;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 4px;
    width: fit-content;
}

.tc-diff-badge--easy {
    background: #dcfce7;
    color: #16a34a;
}

.tc-diff-badge--medium {
    background: #fef9c3;
    color: #a16207;
}

.tc-diff-badge--hard {
    background: #fee2e2;
    color: #dc2626;
}

.tc-change-badge {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 3px;
}

.tc-change-badge--create {
    background: #dcfce7;
    color: #16a34a;
}

.tc-change-badge--update {
    background: #dbeafe;
    color: #1d4ed8;
}

.tc-change-badge--deactivate, .tc-change-badge--activate {
    background: #fee2e2;
    color: #dc2626;
}

/* ── Spin animation ── */
.tc-spin {
    animation: tc-spin 1s linear infinite;
    display: inline-block;
}

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

/* ── Modal ── */
.tc-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.tc-modal {
    background: var(--color-background-primary);
    border-radius: var(--border-radius-lg);
    width: 100%;
    max-width: 460px;
    box-shadow: 0 8px 40px rgba(0,0,0,.2);
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}

.tc-modal--wide {
    max-width: 680px;
}

.tc-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 0.5px solid var(--color-border-tertiary);
    font-size: 0.9rem;
    font-weight: 500;
}

.tc-modal-body {
    padding: 18px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.tc-modal-footer {
    padding: 12px 18px;
    border-top: 0.5px solid var(--color-border-tertiary);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ── History table ── */
.tc-history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

    .tc-history-table th {
        text-align: left;
        padding: 7px 10px;
        border-bottom: 0.5px solid var(--color-border-tertiary);
        color: var(--color-text-secondary);
        font-weight: 500;
        font-size: 0.75rem;
    }

    .tc-history-table td {
        padding: 7px 10px;
        border-bottom: 0.5px solid var(--color-border-tertiary);
    }

.tc-empty {
    padding: 24px;
    text-align: center;
    color: var(--color-text-tertiary);
    font-size: 0.85rem;
}

/* ── Dark mode tweaks ── */
.adm-dark .tc-diff-tab--easy.tc-diff-tab--active {
    background: #14532d;
    color: #86efac;
}

.adm-dark .tc-diff-tab--medium.tc-diff-tab--active {
    background: #713f12;
    color: #fde68a;
}

.adm-dark .tc-diff-tab--hard.tc-diff-tab--active {
    background: #7f1d1d;
    color: #fca5a5;
}

.adm-dark .tc-diff-badge--easy {
    background: #14532d;
    color: #86efac;
}

.adm-dark .tc-diff-badge--medium {
    background: #713f12;
    color: #fde68a;
}

.adm-dark .tc-diff-badge--hard {
    background: #7f1d1d;
    color: #fca5a5;
}

.adm-dark .tc-change-badge--create {
    background: #14532d;
    color: #86efac;
}

.adm-dark .tc-change-badge--update {
    background: #1e3a5f;
    color: #93c5fd;
}

.adm-dark .tc-change-badge--deactivate {
    background: #7f1d1d;
    color: #fca5a5;
}


/* ============================================================
   SUBJECT BUCKET — ThemeConfig additions
   ============================================================ */

/* ── Bucket list in detail panel ── */
.tc-bucket-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 4px;
}

.tc-bucket-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--border-radius-md);
    border: 0.5px solid var(--color-border-tertiary);
    background: var(--color-background-primary);
    transition: background 0.1s;
}

    .tc-bucket-row:hover {
        background: var(--color-background-secondary);
    }

.tc-bucket-row--inactive {
    opacity: 0.5;
}

.tc-bucket-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.tc-bucket-name {
    font-size: 0.83rem;
    font-weight: 500;
    color: var(--color-text-primary);
}

.tc-bucket-type-badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.68rem;
    padding: 1px 5px;
    border-radius: 3px;
    width: fit-content;
    font-weight: 500;
}

.tc-bucket-type-badge--species {
    background: #dbeafe;
    color: #1d4ed8;
}

.tc-bucket-type-badge--scenario {
    background: #fef3c7;
    color: #92400e;
}

.adm-dark .tc-bucket-type-badge--species {
    background: #1e3a5f;
    color: #93c5fd;
}

.adm-dark .tc-bucket-type-badge--scenario {
    background: #78350f;
    color: #fde68a;
}

.tc-bucket-hints {
    font-size: 0.73rem;
    color: var(--color-text-tertiary);
    line-height: 1.5;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.tc-bucket-actions {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
    align-items: center;
}

.tc-icon-btn--xs {
    padding: 3px;
    font-size: 13px;
}

.tc-icon-btn--danger:hover {
    color: var(--color-text-danger);
    background: var(--color-background-danger);
}

/* ── Segmented control (bucket type toggle in modal) ── */
.tc-segmented {
    display: flex;
    border: 0.5px solid var(--color-border-tertiary);
    border-radius: var(--border-radius-md);
    overflow: hidden;
}

.tc-seg-btn {
    flex: 1;
    padding: 5px 10px;
    border: none;
    background: var(--color-background-secondary);
    color: var(--color-text-secondary);
    font-size: 0.78rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.12s;
}

    .tc-seg-btn + .tc-seg-btn {
        border-left: 0.5px solid var(--color-border-tertiary);
    }

    .tc-seg-btn.active {
        background: var(--color-background-info);
        color: var(--color-text-info);
    }

    .tc-seg-btn:hover:not(.active) {
        background: var(--color-background-primary);
        color: var(--color-text-primary);
    }
