/* Training Data Manager Styles */

:root {
    --t-primary: #3b82f6;
    --t-primary-hover: #2563eb;
    --t-danger: #ef4444;
    --t-danger-hover: #dc2626;
    --t-success: #22c55e;
    --t-success-hover: #16a34a;
    --t-warning: #f59e0b;
    --t-bg: #f8fafc;
    --t-surface: #ffffff;
    --t-border: #e2e8f0;
    --t-border-dark: #cbd5e1;
    --t-text: #1e293b;
    --t-text-secondary: #475569;
    --t-text-muted: #94a3b8;
    --t-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    padding: 0;
    font-family: var(--t-font);
    background: var(--t-bg);
    color: var(--t-text);
}

/* Navigation styles now in shared /admin/includes/nav.css */

/* ========== Container ========== */

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

/* ========== Meta Banner ========== */

.training-meta {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 6px;
    padding: 8px 16px;
    margin-bottom: 16px;
    font-size: 13px;
    color: var(--t-text-secondary);
}

/* ========== Tab Bar ========== */

.tab-bar {
    display: flex;
    gap: 2px;
    background: var(--t-border);
    border-radius: 8px;
    padding: 3px;
    margin-bottom: 24px;
}

.tab-btn {
    flex: 1;
    padding: 10px 16px;
    border: none;
    background: transparent;
    color: var(--t-text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
    font-family: var(--t-font);
    white-space: nowrap;
}

.tab-btn:hover {
    color: var(--t-text);
    background: rgba(255, 255, 255, 0.5);
}

.tab-btn.active {
    background: var(--t-surface);
    color: var(--t-primary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* ========== Tab Content ========== */

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

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

.tab-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
}

.tab-description {
    color: var(--t-text-muted);
    font-size: 13px;
    margin: 0 0 20px 0;
}

.tab-actions {
    margin-top: 20px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ========== Buttons ========== */

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    font-family: var(--t-font);
    transition: all 0.2s;
}

.btn-primary { background: var(--t-primary); color: white; }
.btn-primary:hover { background: var(--t-primary-hover); }
.btn-success { background: var(--t-success); color: white; }
.btn-success:hover { background: var(--t-success-hover); }
.btn-danger { background: var(--t-danger); color: white; }
.btn-danger:hover { background: var(--t-danger-hover); }
.btn-secondary { background: var(--t-border); color: var(--t-text); }
.btn-secondary:hover { background: var(--t-border-dark); }

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

.btn-icon {
    padding: 4px 8px;
    background: none;
    border: 1px solid var(--t-border);
    border-radius: 4px;
    cursor: pointer;
    color: var(--t-text-secondary);
    font-size: 14px;
    transition: all 0.2s;
}
.btn-icon:hover { background: var(--t-bg); }
.btn-icon.btn-icon-danger:hover { background: #fef2f2; color: var(--t-danger); border-color: #fecaca; }

/* ========== Table ========== */

.table-wrap {
    overflow-x: auto;
}

.training-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.training-table th {
    background: var(--t-bg);
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    color: var(--t-text-secondary);
    border-bottom: 2px solid var(--t-border);
    white-space: nowrap;
}

.training-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--t-border);
    vertical-align: top;
}

.training-table tbody tr:hover {
    background: #f1f5f9;
}

.training-table .cell-actions {
    white-space: nowrap;
    display: flex;
    gap: 4px;
}

/* ========== Type Badges ========== */

.type-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    margin-right: 4px;
}

.type-badge-dslr {
    background: #dbeafe;
    color: #1e40af;
}

.type-badge-microcontroller {
    background: #fef3c7;
    color: #92400e;
}

/* ========== Severity Badges ========== */

.severity-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

.severity-badge-critical { background: #fef2f2; color: #991b1b; }
.severity-badge-warning { background: #fffbeb; color: #92400e; }
.severity-badge-info { background: #eff6ff; color: #1e40af; }
.severity-badge-healthy { background: #f0fdf4; color: #166534; }

/* ========== Threshold severity cells ========== */

.cell-normal { color: #166534; }
.cell-warning { color: #92400e; }
.cell-critical { color: #991b1b; }

/* ========== Issue Cards ========== */

.issues-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.issue-card {
    background: var(--t-surface);
    border: 1px solid var(--t-border);
    border-radius: 8px;
    overflow: hidden;
}

.issue-card-header {
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: background 0.15s;
}

.issue-card-header:hover {
    background: #f8fafc;
}

.issue-card-title {
    flex: 1;
    font-weight: 600;
    font-size: 14px;
}

.issue-card-badges {
    display: flex;
    gap: 6px;
    align-items: center;
}

.issue-card-counts {
    font-size: 12px;
    color: var(--t-text-muted);
}

.issue-card-expand {
    color: var(--t-text-muted);
    font-size: 18px;
    transition: transform 0.2s;
}

.issue-card.expanded .issue-card-expand {
    transform: rotate(180deg);
}

.issue-card-body {
    display: none;
    padding: 0 16px 16px;
    border-top: 1px solid var(--t-border);
}

.issue-card.expanded .issue-card-body {
    display: block;
}

.issue-section {
    margin-top: 14px;
}

.issue-section-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--t-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.issue-card-actions {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--t-border);
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* ========== List Editor ========== */

.list-editor {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.list-editor-item {
    display: flex;
    gap: 6px;
    align-items: center;
}

.list-editor-item input {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid var(--t-border);
    border-radius: 4px;
    font-size: 13px;
    font-family: var(--t-font);
}

.list-editor-item input:focus {
    outline: none;
    border-color: var(--t-primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.list-editor-add {
    padding: 4px 10px;
    font-size: 12px;
    color: var(--t-primary);
    background: none;
    border: 1px dashed var(--t-border);
    border-radius: 4px;
    cursor: pointer;
    text-align: left;
    font-family: var(--t-font);
    transition: all 0.15s;
}

.list-editor-add:hover {
    border-color: var(--t-primary);
    background: #eff6ff;
}

/* ========== Image Expectations ========== */

.ie-section {
    background: var(--t-surface);
    border: 1px solid var(--t-border);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 16px;
}

.ie-section h3 {
    margin: 0 0 16px 0;
    font-size: 16px;
}

.ie-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.ie-field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--t-text-secondary);
    margin-bottom: 4px;
}

.ie-field input,
.ie-field textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--t-border);
    border-radius: 4px;
    font-size: 13px;
    font-family: var(--t-font);
}

.ie-field textarea {
    resize: vertical;
    min-height: 60px;
}

.ie-field input:focus,
.ie-field textarea:focus {
    outline: none;
    border-color: var(--t-primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.ie-field-wide {
    grid-column: 1 / -1;
}

/* ========== Camera Types ========== */

.ct-section {
    background: var(--t-surface);
    border: 1px solid var(--t-border);
    border-radius: 8px;
    margin-bottom: 16px;
    overflow: hidden;
}

.ct-section-header {
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: background 0.15s;
}

.ct-section-header:hover { background: #f8fafc; }

.ct-section-header h3 {
    margin: 0;
    font-size: 16px;
}

.ct-section-body {
    display: none;
    padding: 16px;
    border-top: 1px solid var(--t-border);
}

.ct-section.expanded .ct-section-body {
    display: block;
}

.ct-section .issue-card-expand {
    color: var(--t-text-muted);
    font-size: 18px;
    transition: transform 0.2s;
}

.ct-section.expanded .issue-card-expand {
    transform: rotate(180deg);
}

.ct-field {
    margin-bottom: 14px;
}

.ct-field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--t-text-secondary);
    margin-bottom: 4px;
}

.ct-field input,
.ct-field textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--t-border);
    border-radius: 4px;
    font-size: 13px;
    font-family: var(--t-font);
}

.ct-field textarea {
    resize: vertical;
    min-height: 80px;
}

.ct-field input:focus,
.ct-field textarea:focus {
    outline: none;
    border-color: var(--t-primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.ct-monitoring-files {
    margin-top: 14px;
}

.ct-monitoring-file {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 6px;
}

.ct-monitoring-file input:first-child {
    width: 180px;
    flex-shrink: 0;
}

.ct-monitoring-file input:last-of-type {
    flex: 1;
}

.ct-section-actions {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--t-border);
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* ========== Guidelines ========== */

.guidelines-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.guideline-row {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

.guideline-number {
    width: 28px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--t-bg);
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    color: var(--t-text-muted);
    flex-shrink: 0;
}

.guideline-row textarea {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid var(--t-border);
    border-radius: 4px;
    font-size: 13px;
    font-family: var(--t-font);
    resize: vertical;
    min-height: 34px;
}

.guideline-row textarea:focus {
    outline: none;
    border-color: var(--t-primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.guideline-actions {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
}

/* ========== Modal ========== */

.training-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.training-modal {
    background: var(--t-surface);
    border-radius: 12px;
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

.training-modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--t-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.training-modal-header h3 {
    margin: 0;
    font-size: 16px;
}

.training-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--t-text-muted);
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.training-modal-close:hover { color: var(--t-text); }

.training-modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.training-modal-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--t-border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.modal-field {
    margin-bottom: 14px;
}

.modal-field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--t-text-secondary);
    margin-bottom: 4px;
}

.modal-field input,
.modal-field select,
.modal-field textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--t-border);
    border-radius: 4px;
    font-size: 13px;
    font-family: var(--t-font);
}

.modal-field textarea {
    resize: vertical;
    min-height: 60px;
}

.modal-field input:focus,
.modal-field select:focus,
.modal-field textarea:focus {
    outline: none;
    border-color: var(--t-primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.modal-field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.modal-checkbox-group {
    display: flex;
    gap: 16px;
    padding-top: 4px;
}

.modal-checkbox-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: normal;
    cursor: pointer;
}

.modal-checkbox-group input[type="checkbox"] {
    width: auto;
}

/* ========== Confirm Overlay ========== */

.confirm-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.confirm-box {
    background: var(--t-surface);
    border-radius: 12px;
    padding: 24px;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

.confirm-box h3 {
    margin: 0 0 8px 0;
    font-size: 16px;
}

.confirm-box p {
    margin: 0 0 20px 0;
    color: var(--t-text-secondary);
    font-size: 14px;
}

.confirm-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* ========== Toast ========== */

.training-toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #1e293b;
    color: white;
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    z-index: 10002;
    transition: transform 0.3s ease;
    pointer-events: none;
}

.training-toast.visible {
    transform: translateX(-50%) translateY(0);
}

.training-toast.toast-error {
    background: var(--t-danger);
}

/* ========== Responsive ========== */

@media (max-width: 768px) {
    .training-container {
        padding: 16px;
    }

    .tab-bar {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .tab-btn {
        padding: 8px 12px;
        font-size: 13px;
    }

    .training-table {
        font-size: 12px;
    }

    .training-table th,
    .training-table td {
        padding: 8px 8px;
    }

    .tab-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .ie-grid {
        grid-template-columns: 1fr;
    }

    .modal-field-row {
        grid-template-columns: 1fr;
    }

    .ct-monitoring-file {
        flex-direction: column;
    }

    .ct-monitoring-file input:first-child {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .tab-btn {
        padding: 7px 10px;
        font-size: 12px;
    }

    .training-modal {
        max-height: 90vh;
    }
}

/* =============================================
   DARK MODE
   ============================================= */
[data-theme="dark"] {
    --t-primary: #60a5fa;
    --t-primary-hover: #3b82f6;
    --t-danger: #f87171;
    --t-danger-hover: #ef4444;
    --t-success: #4ade80;
    --t-success-hover: #22c55e;
    --t-warning: #fbbf24;
    --t-bg: #0f172a;
    --t-surface: #1e293b;
    --t-border: #334155;
    --t-border-dark: #475569;
    --t-text: #e2e8f0;
    --t-text-secondary: #94a3b8;
    --t-text-muted: #64748b;
}

[data-theme="dark"] .training-meta {
    background: rgba(96, 165, 250, 0.1);
    border-color: #334155;
    color: #94a3b8;
}

[data-theme="dark"] .training-table th {
    background: #0f172a;
    color: #94a3b8;
}

[data-theme="dark"] .training-table td {
    border-bottom-color: #334155;
}

[data-theme="dark"] .training-table tbody tr:hover {
    background: rgba(51, 65, 85, 0.3);
}

[data-theme="dark"] .training-modal-overlay {
    background: rgba(0, 0, 0, 0.7);
}

[data-theme="dark"] .training-modal {
    background: #1e293b;
    color: #e2e8f0;
}

[data-theme="dark"] .training-input,
[data-theme="dark"] .training-select,
[data-theme="dark"] .training-textarea {
    background: #0f172a;
    border-color: #334155;
    color: #e2e8f0;
}

[data-theme="dark"] .training-input:focus,
[data-theme="dark"] .training-select:focus,
[data-theme="dark"] .training-textarea:focus {
    border-color: #60a5fa;
}

[data-theme="dark"] .training-toast {
    background: #334155;
    color: #e2e8f0;
}

[data-theme="dark"] .issue-card {
    background: var(--t-surface);
    border-color: var(--t-border);
}

[data-theme="dark"] .issue-card-header:hover {
    background: #0f172a;
}

[data-theme="dark"] .type-badge-dslr {
    background: rgba(96, 165, 250, 0.15);
    color: #60a5fa;
}

[data-theme="dark"] .type-badge-microcontroller {
    background: rgba(251, 191, 36, 0.15);
    color: #fbbf24;
}

[data-theme="dark"] .severity-badge-critical {
    background: rgba(248, 113, 113, 0.15);
    color: #f87171;
}

[data-theme="dark"] .severity-badge-warning {
    background: rgba(251, 191, 36, 0.15);
    color: #fbbf24;
}

[data-theme="dark"] .severity-badge-info {
    background: rgba(96, 165, 250, 0.15);
    color: #60a5fa;
}

[data-theme="dark"] .severity-badge-healthy {
    background: rgba(74, 222, 128, 0.15);
    color: #4ade80;
}

[data-theme="dark"] .ct-section-header:hover {
    background: #0f172a;
}

[data-theme="dark"] .list-editor-add:hover {
    background: rgba(96, 165, 250, 0.1);
    border-color: #60a5fa;
}

[data-theme="dark"] .tab-btn {
    color: #94a3b8;
}

[data-theme="dark"] .tab-btn:hover {
    color: #e2e8f0;
}

[data-theme="dark"] .tab-btn.active {
    color: #60a5fa;
    border-bottom-color: #60a5fa;
}
