/* ============================================================================
 * Repair Tickets - frontend view reportera (krok 5a)
 * Mobile-first, M&P branding (czarny + #FFF001).
 * Prefix `rt-` żeby uniknąć kolizji z innymi modułami.
 * ============================================================================ */

/* ============ LAYOUT BAZOWY ============ */
#repair-tickets-section,
#notifications-section {
    padding: 1rem;
    max-width: 1200px;
    margin: 0 auto;
}

#repair-tickets-content,
#notifications-content {
    min-height: 200px;
}

.rt-loading {
    text-align: center;
    color: #666;
    padding: 2rem;
}

.rt-error {
    background: #fee;
    color: #c62828;
    padding: 1rem;
    border-left: 4px solid #c62828;
    border-radius: 4px;
}

.rt-hint {
    color: #666;
    font-size: 0.875rem;
    margin: 0.25rem 0;
}

.rt-required {
    color: #c62828;
}

.hidden {
    display: none !important;
}

/* ============ PRZYCISKI ============ */
.rt-btn {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: opacity 0.15s;
    text-decoration: none;
    display: inline-block;
}
.rt-btn:hover {
    opacity: 0.85;
}
.rt-btn:focus-visible {
    outline: 2px solid #000;
    outline-offset: 2px;
}

.rt-btn-primary {
    background: #FFF001;
    color: #000;
    font-weight: 600;
}

.rt-btn-secondary {
    background: #fff;
    color: #000;
    border: 1px solid #ddd;
}

.rt-btn-link {
    background: transparent;
    color: #1976d2;
    padding: 0.3rem 0;
    text-decoration: underline;
}

/* ============ LISTA TICKETÓW ============ */
.rt-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.rt-list-header h2 {
    margin: 0;
    font-size: 1.5rem;
}

.rt-filters {
    background: #f5f5f5;
    padding: 0.75rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}
.rt-filters label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}
.rt-filters select {
    padding: 0.4rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: white;
}

.rt-table-wrapper {
    overflow-x: auto;
}
.rt-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.rt-table th {
    background: #000;
    color: #FFF001;
    text-align: left;
    padding: 0.75rem;
    font-weight: 600;
    font-size: 0.9rem;
}
.rt-table td {
    padding: 0.75rem;
    border-bottom: 1px solid #eee;
    font-size: 0.95rem;
}
.rt-table tbody tr {
    cursor: pointer;
    transition: background 0.15s;
}
.rt-table tbody tr:hover {
    background: #fffde7;
}

.rt-cell-id {
    color: #666;
    font-family: monospace;
}
.rt-cell-title {
    font-weight: 500;
}

.rt-pagination {
    margin-top: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

/* Numerowana paginacja (wzorzec z cenówek) */
.rt-pagination-controls {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.rt-pagination-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: #666;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.rt-pagination-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.rt-pagination-buttons {
    display: flex;
    gap: 0.25rem;
}
.rt-pagination-buttons button {
    min-width: 2.2rem;
    padding: 0.4rem 0.6rem;
    border: 1px solid #ccc;
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
}
.rt-pagination-buttons button:hover:not(:disabled) {
    background: #FFF001;
    border-color: #FFF001;
}
.rt-pagination-buttons button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.rt-page-size-selector {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
}
.rt-page-size-selector select {
    padding: 0.35rem 0.5rem;
    border: 1px solid #ccc;
    border-radius: 4px;
}
/* Szybki filtr po salonie na liście - searchable picker */
.rt-list-salon-filter {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.rt-salon-filter-caption {
    font-size: 0.9rem;
    font-weight: 500;
    color: #555;
}
.rt-list-salon-picker-wrap {
    min-width: 240px;
    flex: 0 1 320px;
}
@media (max-width: 640px) {
    .rt-list-salon-picker-wrap {
        flex-basis: 100%;
        min-width: 0;
    }
}

.rt-empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #666;
}
.rt-empty-state p {
    margin-bottom: 1.5rem;
}

/* ============ BADGES (status, priorytet) ============ */
.rt-status-badge {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    border-radius: 12px;
    color: white;
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.rt-priority-badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
}
.rt-priority-critical { background: #ffebee; color: #c62828; }
.rt-priority-high     { background: #fff3e0; color: #e65100; }
.rt-priority-normal   { background: #fffde7; color: #f57f17; }
.rt-priority-low      { background: #e8f5e9; color: #2e7d32; }
.rt-priority-none     { background: #f5f5f5; color: #757575; }

/* ============ DETAIL TICKETU ============ */
.rt-detail-header {
    margin-bottom: 1.5rem;
}
.rt-detail-header h2 {
    margin: 0.5rem 0;
    font-size: 1.4rem;
}
.rt-detail-meta {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}
.rt-id-label {
    font-family: monospace;
    color: #666;
    font-size: 0.95rem;
}

.rt-detail-section {
    background: #fff;
    border-radius: 4px;
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.rt-detail-section h3 {
    margin: 0 0 0.75rem 0;
    font-size: 1.1rem;
    color: #000;
    border-bottom: 2px solid #FFF001;
    padding-bottom: 0.25rem;
}

.rt-detail-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
    font-size: 0.95rem;
}
.rt-detail-grid div {
    padding: 0.4rem 0;
    border-bottom: 1px solid #f5f5f5;
}
.rt-detail-grid div:last-child {
    border-bottom: none;
}

.rt-description {
    white-space: pre-wrap;
    line-height: 1.5;
}

/* ============ EDIT FORM ============ */
.rt-edit-form {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.rt-edit-form-active {
    background: #fffde7;
    border: 2px solid #FFF001;
    border-radius: 6px;
    padding: 1rem;
    box-shadow: 0 2px 8px rgba(255, 240, 1, 0.3);
    animation: rt-edit-flash 0.4s ease-out;
}
.rt-edit-form-active h4 {
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
    color: #333;
}
@keyframes rt-edit-flash {
    0% { background: #FFF001; }
    100% { background: #fffde7; }
}
.rt-edit-form label,
.rt-form label {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    font-size: 0.9rem;
    font-weight: 500;
}
.rt-edit-form input,
.rt-edit-form textarea,
.rt-edit-form select,
.rt-form input,
.rt-form textarea,
.rt-form select {
    padding: 0.5rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 1rem;
    font-family: inherit;
}
.rt-edit-form textarea,
.rt-form textarea {
    resize: vertical;
    min-height: 80px;
}

/* ============ FORM TWORZENIA ============ */
.rt-form-header {
    margin-bottom: 1rem;
}
.rt-form-header h2 {
    margin: 0.5rem 0;
}

.rt-form {
    background: #fff;
    border-radius: 4px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.rt-checkbox-label {
    flex-direction: row !important;
    align-items: center;
    gap: 0.5rem;
}
.rt-checkbox-label input[type="checkbox"] {
    width: 1.2rem;
    height: 1.2rem;
    cursor: pointer;
}

.rt-form-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

/* ============ KOMENTARZE ============ */
.rt-comments-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
}
.rt-comment {
    background: #fafafa;
    padding: 0.75rem;
    border-left: 3px solid #FFF001;
    border-radius: 0 4px 4px 0;
}
.rt-comment-internal {
    border-left-color: #ff9800;
    background: #fff8e1;
}
.rt-comment-header {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.4rem;
    font-size: 0.85rem;
    color: #666;
}
.rt-comment-date {
    flex: 1;
}
.rt-tag-internal {
    background: #ff9800;
    color: white;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    font-size: 0.75rem;
}
.rt-comment-body {
    white-space: pre-wrap;
    line-height: 1.4;
}

.rt-comment-form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.rt-comment-form textarea {
    padding: 0.5rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.95rem;
}

/* ============ RATING (gwiazdki) ============ */
.rt-rating-section {
    background: #fffde7;
    border: 2px solid #FFF001;
}
.rt-rating-stars {
    display: flex;
    gap: 0.5rem;
    margin: 0.75rem 0;
}
.rt-star {
    background: transparent;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: #ccc;
    padding: 0;
    line-height: 1;
}
.rt-star:hover,
.rt-star-filled {
    color: #fbc02d;
}
.rt-rating-reklamacja {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px dashed #d4d000;
}
.rt-rating-reklamacja .rt-hint {
    margin-bottom: 0.5rem;
}

/* Wyświetlenie oceny po zamknięciu (visible dla wszystkich z dostępem do ticketu) */
.rt-rating-display {
    background: #f1f8e9;
    border: 1px solid #aed581;
}
.rt-rating-display-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0.5rem 0;
    flex-wrap: wrap;
}
.rt-rating-display-stars {
    font-size: 1.75rem;
    color: #fbc02d;
    line-height: 1;
    letter-spacing: 2px;
}
.rt-rating-display-value {
    font-weight: 600;
    color: #555;
}
.rt-rating-display-date {
    font-size: 0.85rem;
    color: #888;
}
.rt-rating-display-comment {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid #c5e1a5;
}
.rt-rating-display-comment p {
    margin: 0.25rem 0 0 0;
    white-space: pre-wrap;
}

/* ============ NOTIFICATION BADGE (top-bar) ============ */
.rt-badge-count {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #c62828;
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 1px 5px;
    border-radius: 10px;
    min-width: 16px;
    text-align: center;
}
#notification-badge-btn {
    position: relative;
}

/* ============ INBOX VIEW ============ */
.rt-inbox-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.rt-inbox-unread-count {
    background: #FFF001;
    color: #000;
    padding: 0.25rem 0.6rem;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
}
.rt-inbox-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.rt-inbox-item {
    display: flex;
    gap: 0.75rem;
    padding: 1rem;
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.rt-inbox-item:hover {
    background: #fffde7;
}
.rt-inbox-unread {
    border-left: 4px solid #FFF001;
    font-weight: 500;
}
.rt-inbox-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}
.rt-inbox-body {
    flex: 1;
    min-width: 0;
}
.rt-inbox-event {
    font-size: 0.95rem;
    margin-bottom: 0.2rem;
}
.rt-inbox-ticket {
    font-size: 0.85rem;
    color: #1976d2;
}
.rt-inbox-date {
    font-size: 0.8rem;
    color: #888;
    margin-top: 0.3rem;
}

/* ============ RESPONSIVE - MOBILE ============ */
@media (max-width: 600px) {
    #repair-tickets-section,
    #notifications-section {
        padding: 0.5rem;
    }
    .rt-list-header h2 {
        font-size: 1.2rem;
    }
    .rt-table th, .rt-table td {
        padding: 0.5rem 0.4rem;
        font-size: 0.85rem;
    }
    .rt-cell-id {
        font-size: 0.8rem;
    }
    /* Ukryj kolumnę "Utworzono" na bardzo wąskich - tytuł i status są ważniejsze */
    .rt-table th:nth-child(5),
    .rt-table td:nth-child(5),
    .rt-table th:nth-child(4),
    .rt-table td:nth-child(4) {
        display: none;
    }
    .rt-detail-grid {
        font-size: 0.9rem;
    }
    .rt-form {
        padding: 1rem;
    }
    .rt-star {
        font-size: 1.7rem;
    }
}

/* Tablet (601-900px) - 2 kolumny w detail grid */
@media (min-width: 601px) {
    .rt-detail-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* ============================================================================
 * KROK 5b - Tabs / Action buttons / Modal / Attachments / SLA timer
 * ============================================================================ */

/* ============ TABS (list technika: Do przyjęcia / Moje aktywne / Wszystkie) ============ */
.rt-tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1rem;
    border-bottom: 2px solid #ddd;
}
.rt-tab {
    flex: 1;
    padding: 0.7rem 0.5rem;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    color: #666;
    transition: all 0.15s;
}
.rt-tab:hover {
    background: #f5f5f5;
}
.rt-tab-active {
    color: #000;
    border-bottom-color: #FFF001;
    font-weight: 600;
}

/* ============ SLA TIMER w liście ============ */
.rt-cell-sla {
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
}
.rt-sla-ok       { color: #2e7d32; }
.rt-sla-warn     { color: #f57f17; }
.rt-sla-danger   { color: #c62828; }
.rt-sla-breach   { color: #000; font-weight: 700; }
.rt-sla-none     { color: #999; }
.rt-cell-salon   { font-family: monospace; color: #666; }

/* ============ AKCJE TECHNIKA (detail) ============ */
.rt-tech-actions {
    background: #fffde7;
    border: 1px solid #FFF001;
}
.rt-action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.rt-action-buttons .rt-btn {
    flex: 1 1 auto;
    min-width: 140px;
}

/* ============ MODAL (status change + transfer) ============ */
.rt-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10001;
}
.rt-modal.rt-modal-open {
    display: block;
}
.rt-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
}
.rt-modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    border-radius: 8px;
    padding: 1.5rem;
    width: calc(100% - 2rem);
    max-width: 500px;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.rt-modal-content-wide {
    max-width: 900px;
}
.rt-modal-content-wide h4 {
    margin: 1.25rem 0 0.5rem 0;
    font-size: 0.95rem;
    color: #333;
}

/* ============ TIMELINE (historia zdarzeń ticketu) ============ */
.rt-timeline {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0 0 0;
    border-left: 2px solid #FFF001;
}
.rt-timeline-item {
    position: relative;
    padding: 0.5rem 0.75rem 0.75rem 1rem;
    margin-left: 0.5rem;
    background: #fafafa;
    border-radius: 0 4px 4px 0;
    margin-bottom: 0.5rem;
    border-left: 1px solid #eee;
}
.rt-timeline-item::before {
    content: '';
    position: absolute;
    left: -1.4rem;
    top: 0.85rem;
    width: 10px;
    height: 10px;
    background: #FFF001;
    border: 2px solid #fff;
    border-radius: 50%;
    box-shadow: 0 0 0 1px #FFF001;
}
.rt-timeline-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.rt-timeline-label {
    font-weight: 600;
    font-size: 0.95rem;
}
.rt-timeline-date {
    font-size: 0.8rem;
    color: #888;
    white-space: nowrap;
}
.rt-timeline-meta {
    font-size: 0.8rem;
    color: #666;
    margin-top: 0.15rem;
}
.rt-timeline-detail {
    margin-top: 0.4rem;
    padding: 0.4rem 0.6rem;
    background: white;
    border-left: 3px solid #FFF001;
    border-radius: 2px;
    font-size: 0.9rem;
    line-height: 1.45;
}
.rt-event-reason {
    margin-top: 0.25rem;
}

/* Tab "🔧 Technicy" w admin panelu - searchable list of candidates */
.rt-tech-users h4 {
    margin: 1rem 0 0.5rem 0;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid #e0e0e0;
}
.rt-tech-grant-form {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 1rem;
}
.rt-tech-grant-form input[type="text"] {
    width: 100%;
    padding: 0.5rem;
    font-size: 1rem;
    border: 1px solid #ccc;
    border-radius: 4px;
}
.rt-tech-search-results {
    max-height: 320px;
    overflow-y: auto;
    margin-top: 0.5rem;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 4px;
}
.rt-tech-candidates-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.rt-tech-candidate {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #f0f0f0;
    gap: 0.75rem;
}
.rt-tech-candidate:last-child {
    border-bottom: none;
}
.rt-tech-candidate:hover {
    background: #fffde7;
}
.rt-tech-candidate-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
    flex: 1;
}
.rt-tech-candidate-info strong {
    font-family: monospace;
    font-size: 0.9rem;
    word-break: break-all;
}
.rt-tech-candidate-meta {
    font-size: 0.8rem;
    color: #666;
}
.rt-btn-small {
    padding: 0.25rem 0.75rem;
    font-size: 0.85rem;
    white-space: nowrap;
}

/* Zestawienie prac salonu - PDF download (w modalu salon report) */
.rt-work-summary-actions {
    background: #fffde7;
    border-left: 4px solid #FFF001;
    padding: 0.75rem 1rem;
    margin: 1rem 0;
    border-radius: 4px;
}
.rt-work-summary-actions h4 {
    margin: 0 0 0.25rem 0;
}
.rt-work-summary-actions .rt-hint {
    margin: 0 0 0.5rem 0;
}
.rt-work-summary-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.rt-work-summary-buttons .rt-btn {
    flex: 1;
    min-width: 200px;
}
.rt-modal-content h3 {
    margin: 0 0 1rem 0;
    padding-right: 2rem;
    border-bottom: 2px solid #FFF001;
    padding-bottom: 0.5rem;
}
.rt-modal-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: #f0f0f0;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.rt-modal-close:hover {
    background: #e0e0e0;
}
.rt-modal-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.rt-modal-form label {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    font-size: 0.9rem;
    font-weight: 500;
}
.rt-modal-form input,
.rt-modal-form select,
.rt-modal-form textarea {
    padding: 0.5rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 1rem;
    font-family: inherit;
}

/* ============ INTERNAL COMMENT CHECKBOX ============ */
.rt-internal-toggle {
    background: #fff3e0;
    padding: 0.5rem;
    border-radius: 4px;
    border-left: 3px solid #ff9800;
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

/* ============ ATTACHMENTS ============ */
.rt-attach-group {
    margin-bottom: 1rem;
}
.rt-attach-group h4 {
    margin: 0 0 0.5rem 0;
    font-size: 0.95rem;
    color: #555;
}
.rt-attach-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 0.5rem;
}
.rt-attach-tile {
    background: #f9f9f9;
    border-radius: 4px;
    padding: 0.5rem;
    cursor: pointer;
    text-align: center;
    transition: background 0.15s;
    border: 1px solid #eee;
    position: relative;  /* anchor dla przycisku X (delete) */
}
.rt-attach-del {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.4);
    color: white;
    font-size: 0.85rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.15s, transform 0.15s;
}
.rt-attach-del:hover {
    background: #c62828;
    transform: scale(1.1);
}
.rt-attach-tile:hover {
    background: #fffde7;
    border-color: #FFF001;
}
.rt-attach-icon {
    font-size: 2rem;
    line-height: 1;
}
.rt-attach-name {
    font-size: 0.75rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-top: 0.25rem;
}
.rt-attach-size {
    font-size: 0.7rem;
    color: #999;
}
.rt-attach-add {
    background: #fff;
    border: 2px dashed #ccc;
    border-radius: 4px;
    padding: 1rem 0.5rem;
    cursor: pointer;
    font-size: 0.85rem;
    color: #666;
    transition: all 0.15s;
}
.rt-attach-add:hover {
    border-color: #FFF001;
    background: #fffde7;
    color: #000;
}

/* ============ IN-PROGRESS BADGE w header (technik) ============ */
.rt-badge-inprogress {
    background: #ff9800 !important;
}

/* ============ MANAGER VIEW (5c) - sekcja akcji + lokacje ============ */
.rt-manager-locations {
    font-size: 0.85rem;
    color: #666;
    font-family: monospace;
    background: #f5f5f5;
    padding: 0.2rem 0.5rem;
    border-radius: 3px;
}
.rt-manager-actions {
    background: #e8f5e9;
    border: 1px solid #4caf50;
}
.rt-manager-actions h3 {
    border-bottom-color: #4caf50;
}

/* Reopen section (etap 2 - reporter widzi gdy completed) */
.rt-reopen-section {
    background: #e3f2fd;
    border: 1px solid #1976d2;
}
.rt-reopen-section h3 {
    border-bottom-color: #1976d2;
}

/* ============================================================================
 * KROK 5d - ADMIN PANEL (dashboard / force-run / export / markdown editor / słowniki)
 * ============================================================================ */

#repair-tickets-admin-section {
    padding: 1rem;
    max-width: 1200px;
    margin: 0 auto;
}
#repair-tickets-admin-content h2 {
    margin: 0 0 1rem 0;
}

/* ============ TILES (dashboard) ============ */
.rt-period-selector {
    margin-bottom: 1rem;
    font-size: 0.9rem;
}
.rt-period-selector select {
    padding: 0.3rem;
    margin-left: 0.5rem;
}
.rt-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.rt-tile {
    background: #fff;
    border-radius: 6px;
    padding: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    text-align: center;
}
.rt-tile-label {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 0.5rem;
}
.rt-tile-value {
    font-size: 2rem;
    font-weight: 700;
    color: #000;
}
.rt-tile-ok {
    border-left: 4px solid #4caf50;
}
.rt-tile-warn {
    border-left: 4px solid #ff9800;
}

/* ============ BAR CHART (stats) ============ */
.rt-bar-chart {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 1rem;
}
.rt-bar-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.rt-bar-label {
    width: 180px;
    font-size: 0.85rem;
    color: #555;
    text-align: right;
}
.rt-bar-track {
    flex: 1;
    background: #f5f5f5;
    border-radius: 3px;
    height: 24px;
    position: relative;
    overflow: hidden;
}
.rt-bar-fill {
    background: linear-gradient(90deg, #FFF001 0%, #ffc107 100%);
    height: 100%;
    color: #000;
    font-size: 0.85rem;
    line-height: 24px;
    padding: 0 0.5rem;
    font-weight: 600;
    min-width: 24px;
    transition: width 0.3s;
}

/* ============ FORCE-RUN cards ============ */
.rt-forcerun {
    max-width: 800px;
}
.rt-action-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 1rem;
}
.rt-action-card h4 {
    margin: 0 0 0.5rem 0;
}
.rt-action-card p {
    color: #666;
    margin: 0 0 0.75rem 0;
}
.rt-result {
    margin-top: 0.75rem;
}
.rt-result-success {
    background: #f1f8e9;
    border-left: 3px solid #4caf50;
    padding: 0.75rem;
    margin: 0;
    overflow-x: auto;
    font-size: 0.85rem;
}

/* ============ EXPORT FORM ============ */
.rt-export-form {
    max-width: 600px;
}
.rt-export-form form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.rt-export-form select[multiple] {
    height: auto;
}

/* ============ MARKDOWN EDITOR SPLIT ============ */
.rt-md-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
.rt-md-input-wrap textarea {
    width: 100%;
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 0.9rem;
    padding: 0.5rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
    min-height: 400px;
}
.rt-md-preview-wrap {
    background: #fafafa;
    padding: 0.75rem;
    border-radius: 4px;
    border: 1px solid #eee;
}
.rt-md-preview {
    margin-top: 0.5rem;
    line-height: 1.5;
}
.rt-md-preview h2,
.rt-md-preview h3,
.rt-md-preview h4 {
    margin: 1.25rem 0 0.5rem 0;
    border-bottom: 1px solid #d4d000;
    padding-bottom: 0.3rem;
    color: #000;
}
.rt-md-preview h2 { font-size: 1.15rem; }
.rt-md-preview h3 { font-size: 1.05rem; }
.rt-md-preview h4 { font-size: 0.95rem; }
.rt-md-preview h2:first-child,
.rt-md-preview h3:first-child,
.rt-md-preview h4:first-child {
    margin-top: 0.25rem;
}
.rt-md-preview ul {
    padding-left: 1.5rem;
    margin: 0.5rem 0 0.75rem 0;
}
.rt-md-preview ul li {
    margin-bottom: 0.35rem;
    line-height: 1.5;
}
.rt-md-preview p {
    line-height: 1.55;
    margin: 0.5rem 0 0.75rem 0;
}
.rt-md-preview p strong {
    display: inline-block;
    margin-bottom: 0.1rem;
}

/* ============ REPORTER INSTRUCTIONS (collapsible markdown w form) ============ */
.rt-reporter-instructions {
    background: #fffde7;
    border: 1px solid #FFF001;
    border-radius: 4px;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
}
.rt-reporter-instructions summary {
    cursor: pointer;
    font-weight: 600;
    color: #000;
    padding: 0.25rem 0;
}
.rt-reporter-instructions summary:hover {
    color: #c62828;
}
.rt-reporter-instructions .rt-md-preview {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid #fff8d6;
}

/* ============ CATEGORY EXPAND ROW + SUBCATEGORIES (admin Słowniki) ============ */
.rt-cat-row {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 0;
    margin-bottom: 0.4rem;
    transition: border-color 0.15s, box-shadow 0.15s, opacity 0.15s;
}
.rt-cat-row[open] {
    border-color: #FFF001;
    box-shadow: 0 2px 6px rgba(255, 240, 1, 0.15);
}
/* Drag-and-drop states */
.rt-drag-handle {
    cursor: grab;
    user-select: none;
    color: #aaa;
    font-size: 1.1rem;
    padding: 0 0.3rem;
    flex-shrink: 0;
    line-height: 1;
}
.rt-drag-handle:hover {
    color: #000;
}
.rt-drag-handle:active {
    cursor: grabbing;
}
.rt-cat-row.rt-dragging {
    opacity: 0.4;
}
.rt-cat-row.rt-drag-over {
    border-color: #4caf50;
    box-shadow: 0 0 0 2px #4caf50, 0 2px 6px rgba(76, 175, 80, 0.2);
}
.rt-cat-row summary {
    cursor: pointer;
    display: flex;
    gap: 0.5rem;
    align-items: center;
    padding: 0.55rem 0.75rem;
    list-style: none;
}
.rt-cat-row summary::-webkit-details-marker {
    display: none;
}
/* Toggle arrow - obraca się przy expand (zamiast natywnego markera) */
.rt-cat-toggle {
    display: inline-block;
    color: #888;
    font-size: 0.75rem;
    transition: transform 0.15s;
    width: 1rem;
    text-align: center;
    flex-shrink: 0;
}
.rt-cat-row[open] .rt-cat-toggle {
    transform: rotate(90deg);
    color: #000;
}
.rt-cat-code {
    background: #f5f5f5;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    font-size: 0.8rem;
    font-family: monospace;
    flex-shrink: 0;
}
.rt-cat-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
/* Badge z liczbą subkategorii */
.rt-cat-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5rem;
    height: 1.4rem;
    padding: 0 0.4rem;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
    flex-shrink: 0;
}
.rt-cat-badge-has {
    background: #FFF001;
    color: #000;
}
.rt-cat-badge-empty {
    background: #e0e0e0;
    color: #888;
}
.rt-cat-status {
    font-size: 0.95rem;
    width: 1.2rem;
    text-align: center;
    flex-shrink: 0;
}
.rt-cat-status-on { color: #4caf50; }
.rt-cat-status-off { color: #c62828; }
.rt-cat-edit-btn {
    margin-left: auto;
    flex-shrink: 0;
    font-size: 0.85rem !important;
    padding: 0.25rem 0.5rem !important;
}
.rt-cat-row summary:hover {
    background: #fafafa;
}
.rt-cat-row[open] summary {
    border-bottom: 1px solid #f0f0f0;
}
.rt-subcat-section {
    padding: 0.6rem 0.75rem;
    background: #fafafa;
    border-radius: 0 0 6px 6px;
}
.rt-btn-add-sub {
    margin-top: 0.25rem;
    font-size: 0.85rem !important;
    padding: 0.35rem 0.7rem !important;
}

/* Mobile: jeszcze ciaśniej żeby się mieściło */
@media (max-width: 640px) {
    .rt-cat-row summary {
        padding: 0.5rem 0.5rem;
        gap: 0.35rem;
        flex-wrap: wrap;
    }
    .rt-cat-name {
        font-size: 0.9rem;
    }
    .rt-cat-edit-btn {
        margin-left: 0;
        order: 10; /* edit button schodzi na koniec, pełna szerokość */
        flex-basis: 100%;
        text-align: right;
    }
}

/* ============ DICTIONARIES (table mini) ============ */
.rt-table-mini {
    width: 100%;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}
.rt-table-mini th,
.rt-table-mini td {
    padding: 0.4rem 0.6rem;
}
.rt-dictionaries h3 {
    margin-top: 2rem;
    border-bottom: 2px solid #FFF001;
    padding-bottom: 0.25rem;
}

/* Mobile (≤640px): tabele słowników przekształcone na karty - każdy wiersz to
   osobna karta z label:value rzędami. Thead ukryty, td z data-label pokazuje
   etykietę nad wartością. Działa bez zmiany HTML - tylko CSS overrides. */
@media (max-width: 640px) {
    .rt-dictionaries .rt-table-mini {
        font-size: 0.85rem;
    }
    .rt-dictionaries .rt-table-mini thead {
        display: none; /* nagłówki niepotrzebne - każda komórka ma własną etykietę */
    }
    .rt-dictionaries .rt-table-mini,
    .rt-dictionaries .rt-table-mini tbody,
    .rt-dictionaries .rt-table-mini tr,
    .rt-dictionaries .rt-table-mini td {
        display: block;
        width: 100%;
        box-sizing: border-box;
    }
    .rt-dictionaries .rt-table-mini tr {
        background: white;
        border: 1px solid #e0e0e0;
        border-radius: 6px;
        padding: 0.5rem;
        margin-bottom: 0.5rem;
        box-shadow: 0 1px 2px rgba(0,0,0,0.04);
    }
    .rt-dictionaries .rt-table-mini td {
        padding: 0.35rem 0.25rem;
        border: none;
        border-bottom: 1px solid #f5f5f5;
        display: flex;
        justify-content: space-between;
        gap: 0.5rem;
        align-items: center;
    }
    .rt-dictionaries .rt-table-mini td:last-child {
        border-bottom: none;
        justify-content: flex-end; /* przycisk edit po prawej */
    }
    /* Pseudo-element pokazuje etykietę z data-label przed wartością */
    .rt-dictionaries .rt-table-mini td[data-label]::before {
        content: attr(data-label);
        font-size: 0.75rem;
        text-transform: uppercase;
        color: #888;
        font-weight: 600;
        letter-spacing: 0.02em;
        flex-shrink: 0;
    }
    /* Pierwsza komórka (kod) - większy + bold */
    .rt-dictionaries .rt-table-mini td:first-child {
        font-weight: 600;
        background: #fffde7;
        margin: -0.5rem -0.5rem 0.25rem -0.5rem;
        padding: 0.5rem 0.75rem;
        border-radius: 6px 6px 0 0;
    }
}

/* ============ MOBILE ============ */
@media (max-width: 900px) {
    .rt-md-split {
        grid-template-columns: 1fr;
    }
}
@media (max-width: 600px) {
    .rt-tiles {
        grid-template-columns: repeat(2, 1fr);
    }
    .rt-tile-value {
        font-size: 1.5rem;
    }
    .rt-bar-label {
        width: 100px;
        font-size: 0.75rem;
    }
}

/* ============ MOBILE RESPONSIVE 5b ============ */
@media (max-width: 600px) {
    .rt-tab {
        padding: 0.5rem 0.3rem;
        font-size: 0.8rem;
    }
    .rt-modal-content {
        padding: 1rem;
        max-width: calc(100% - 1rem);
    }
    .rt-action-buttons .rt-btn {
        flex: 1 1 100%;
        min-width: 0;
    }
    .rt-attach-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    /* Pokaż kolumnę SLA na mobile (zamiast hide z 5a - dla technika SLA jest ważne) */
    .rt-table th:nth-child(5),
    .rt-table td:nth-child(5) {
        display: table-cell;
    }
    /* Salon column ukryj na mobile - id w pierwszej kolumnie pokazuje */
    .rt-table th:nth-child(6),
    .rt-table td:nth-child(6) {
        display: none;
    }
}
