/* Drag and Drop Styles */

/* Visual feedback for tab drop targets */
.nav-tab.drag-over {
    background: #e0f7fa !important;
    border-bottom: 3px solid #00796b;
    transition: background 0.2s, border-bottom 0.2s;
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0, 121, 107, 0.3);
}

/* Make ticket rows draggable and unselectable */
.draggable-ticket {
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    transition: opacity 0.2s, transform 0.1s;
}

.draggable-ticket:hover {
    background-color: #f8f9fa !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.draggable-ticket.dragging {
    opacity: 0.6;
    background: #e0e7ef !important;
    cursor: grabbing;
    transform: rotate(2deg) scale(0.95);
}

/* Drop zone indicators */
.drop-zone {
    min-height: 40px;
    border: 2px dashed transparent;
    transition: all 0.3s ease;
}

.drop-zone.drag-over {
    border-color: #00796b;
    background-color: rgba(224, 247, 250, 0.5);
    border-radius: 8px;
}

/* Enhanced tab styles for better drop feedback */
.nav-tab {
    position: relative;
    overflow: hidden;
}

.nav-tab::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.nav-tab.drag-over::after {
    left: 100%;
}

/* Dark mode support for drag styles */
.dark-mode .nav-tab.drag-over {
    background: #1a4e42 !important;
    border-bottom-color: #4db6ac;
}

.dark-mode .draggable-ticket:hover {
    background-color: #333 !important;
}

.dark-mode .draggable-ticket.dragging {
    background: #2c3e50 !important;
}

.dark-mode .drop-zone.drag-over {
    background-color: rgba(26, 78, 66, 0.5);
    border-color: #4db6ac;
}

/* Empty drop zone styling */
.empty-drop-zone {
    transition: all 0.3s ease;
}

.empty-drop-zone:hover {
    border-color: #00796b !important;
    background-color: #f0f8f7 !important;
}

.dark-mode .empty-drop-zone {
    background: #1a1a1a !important;
    border-color: #444 !important;
    color: #eee;
}

.dark-mode .empty-drop-zone:hover {
    border-color: #4db6ac !important;
    background-color: #222 !important;
}

.dark-mode .empty-drop-zone h4 {
    color: #eee;
}

.dark-mode .empty-drop-zone p {
    color: #999 !important;
}

/* Dark Mode Styles */
.dark-mode {
    --white: #181818;
    --light-gray: #222;
    --medium-gray: #444;
    --dark-gray: #eee;
    --proqual-blue: #025295;
    --proqual-green: #aed581;
    color: #eee;
    background: #181818;
}

.dark-mode .header {
    background: #181818;
    color: #eee;
}
.dark-mode .header-content .user-name,
.dark-mode .header-content .save-status {
    color: #eee;
}
.dark-mode .container,
.dark-mode .content,
.dark-mode .table {
    background: #222;
    color: #eee;
}
.dark-mode .btn,
.dark-mode .btn-dark {
    background: #333;
    color: #eee;
    border: 1px solid #444;
}
.dark-mode .form-control,
.dark-mode select.form-control,
.dark-mode textarea.form-control {
    background: #222 !important;
    color: #eee !important;
    border: 2px solid #444 !important;
}
.dark-mode .form-control:focus,
.dark-mode select.form-control:focus,
.dark-mode textarea.form-control:focus {
    border-color: var(--proqual-blue) !important;
    background: #181818 !important;
    color: #fff !important;
}
.dark-mode label,
.dark-mode .form-group label {
    color: var(--proqual-blue) !important;
}

/* Global Styles */
:root {
    --proqual-blue: #025295;
    --proqual-blue-rgb: 2, 82, 149;
    --proqual-light-blue: #025295;
    --proqual-cyan: #025295;
    --proqual-green: #8bc34a;
    --proqual-dark-blue: #025295;
    --proqual-logo-height: 90px;
    --proqual-logo-max-width: 380px;
    --white: #ffffff;
    --light-gray: #f5f5f5;
    --medium-gray: #e0e0e0;
    --dark-gray: #333333;
    --error-red: #f44336;
    --success-green: #4caf50;

    /* Aliases used throughout the app */
    --primary-color: var(--proqual-blue);
    --primary-hover: var(--proqual-dark-blue);
    --success-color: var(--success-green);
}

/* Ensure default link blue matches brand */
a,
a:visited {
    color: var(--proqual-blue);
}

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

body {
    font-family: 'Arial', sans-serif;
    background: url("images/proqual-building.jpg") no-repeat center center fixed, linear-gradient(135deg, var(--proqual-light-blue) 0%, var(--proqual-blue) 100%);
    background-size: cover;
    min-height: 100vh;
    color: var(--dark-gray);
}

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

/* Header Styles */
.header {
    background: var(--white);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    padding: 1rem 0;
    margin-bottom: 2rem;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo h1 {
    color: var(--proqual-blue);
    font-size: 2rem;
    font-weight: bold;
}

.logo-image {
    height: var(--proqual-logo-height);
    width: auto;
    max-width: var(--proqual-logo-max-width);
    object-fit: contain;
}

/* Some pages set logo height inline; keep them consistent */
.header .logo img {
    height: var(--proqual-logo-height) !important;
    width: auto !important;
    max-width: var(--proqual-logo-max-width) !important;
    object-fit: contain;
}

.logo-icon {
    font-size: 2rem;
    color: var(--proqual-green);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.save-status {
    display: none;
    background: var(--success-green);
    color: var(--white);
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    animation: pulse 2s infinite;
}

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

.save-status.warning {
    background: #ff9800;
}

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

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.7; }
    100% { opacity: 1; }
}

.user-name {
    color: var(--proqual-blue);
    font-weight: 600;
}

.logout-btn {
    background: var(--error-red);
    color: var(--white);
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s;
}

.logout-btn:hover {
    background: #d32f2f;
}

/* Navigation Styles */
.nav-tabs {
    display: flex;
    background: var(--white);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
    overflow: hidden;
}

.nav-tab {
    flex: 1;
    padding: 15px 20px;
    background: var(--medium-gray);
    border: none;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s;
    color: var(--dark-gray);
}

.nav-tab:hover {
    background: var(--light-gray);
}

.nav-tab.active {
    background: var(--proqual-blue);
    color: var(--white);
    box-shadow: inset 0 0 0 2px #000;
}

/* Content Area */
.content {
    background: var(--white);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    padding: 2rem;
    min-height: 400px;
}

.tab-content {
    display: none;
}

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

/* ===== Staff Dashboard: Knowledge Base Tab ===== */
.kb-tab .kb-tab-header {
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--medium-gray);
}

.kb-tab .kb-quick-search {
    margin-top: 1rem;
    margin-bottom: 1.25rem;
}

.kb-tab .kb-quick-search-wrapper {
    position: relative;
}

.kb-tab .kb-quick-search-dropdown {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    margin-top: 0.5rem;
    background: var(--white);
    border: 1px solid var(--medium-gray);
    border-radius: 10px;
    overflow: hidden;
    z-index: 25;
    max-height: 320px;
    overflow-y: auto;
}

.kb-tab .kb-quick-search-item {
    padding: 0.85rem 0.9rem;
    cursor: pointer;
    border-top: 1px solid var(--medium-gray);
    background: var(--white);
    transition: background-color 0.2s;
}

.kb-tab .kb-quick-search-item:first-child {
    border-top: none;
}

.kb-tab .kb-quick-search-item:hover {
    background: var(--light-gray);
}

.kb-tab .kb-quick-search-item-title {
    font-weight: 800;
    color: var(--primary-color);
    margin-bottom: 0.2rem;
}

.kb-tab .kb-quick-search-item-meta {
    font-size: 0.85rem;
    color: var(--dark-gray);
    opacity: 0.8;
    margin-bottom: 0.35rem;
}

.kb-tab .kb-quick-search-item-excerpt {
    font-size: 0.95rem;
    color: var(--dark-gray);
    opacity: 0.85;
    line-height: 1.35;
}

.kb-tab .kb-quick-search .form-control {
    padding: 14px 14px;
    border-radius: 8px;
}

.kb-tab .kb-section {
    margin-top: 1.25rem;
}

.kb-tab .kb-section-spaced {
    margin-top: 2rem;
}

.kb-tab .kb-section-title {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-size: 1.05rem;
    font-weight: 700;
}

#kbFeaturedArticles {
    display: grid;
    gap: 1rem;
}

#kbCategoriesQuick {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.kb-featured-card {
    background: var(--white);
    border: 1px solid var(--medium-gray);
    border-radius: 10px;
    padding: 1rem;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
}

.kb-featured-card:hover {
    background: var(--light-gray);
    border-color: var(--primary-color);
}

.kb-featured-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    min-width: 0;
}

.kb-featured-icon {
    color: var(--proqual-green);
}

.kb-featured-title {
    color: var(--primary-color);
    font-weight: 800;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kb-featured-excerpt {
    color: var(--dark-gray);
    opacity: 0.85;
    font-size: 0.95rem;
    line-height: 1.45;
}

.kb-featured-meta {
    margin-top: 0.75rem;
    font-size: 0.85rem;
    color: var(--dark-gray);
    opacity: 0.8;
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.kb-category-card {
    background: var(--light-gray);
    border: 1px solid var(--medium-gray);
    border-radius: 10px;
    padding: 1rem;
    text-align: center;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

.kb-category-card:hover {
    background: var(--primary-color);
    color: var(--white);
    border-color: var(--primary-color);
}

.kb-category-icon {
    margin-bottom: 0.5rem;
    font-size: 1.5rem;
}

.kb-category-name {
    font-weight: 700;
}

.kb-category-sub {
    font-size: 0.85rem;
    opacity: 0.85;
    margin-top: 0.25rem;
}

/* ===== Staff Dashboard: Ticket KB Suggestions ===== */
.kb-ticket-suggest {
    margin-top: 0.75rem;
    margin-bottom: 1rem;
    background: var(--white);
    border: 1px solid var(--medium-gray);
    border-radius: 10px;
    padding: 0.9rem;
}

.kb-ticket-suggest-title {
    font-weight: 800;
    color: var(--primary-color);
    margin-bottom: 0.6rem;
}

.kb-ticket-suggest-list {
    display: grid;
    gap: 0.65rem;
}

.kb-ticket-suggest-item {
    display: block;
    text-decoration: none;
    background: var(--light-gray);
    border: 1px solid var(--medium-gray);
    border-radius: 10px;
    padding: 0.85rem;
    transition: background-color 0.2s, border-color 0.2s;
}

.kb-ticket-suggest-item:hover {
    background: var(--white);
    border-color: var(--primary-color);
}

.kb-ticket-suggest-item-title {
    font-weight: 800;
    color: var(--primary-color);
    margin-bottom: 0.25rem;
}

.kb-ticket-suggest-item-meta {
    font-size: 0.85rem;
    color: var(--dark-gray);
    opacity: 0.8;
    margin-bottom: 0.4rem;
}

.kb-ticket-suggest-item-excerpt {
    font-size: 0.95rem;
    color: var(--dark-gray);
    opacity: 0.85;
    line-height: 1.45;
}

/* Button Styles */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

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

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

.btn-secondary {
    background: var(--medium-gray);
    color: var(--dark-gray);
}

.btn-secondary:hover {
    background: #d5d5d5;
}

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

.btn-success:hover {
    background: #7cb342;
}

.btn-warning {
    background: #ff9800;
    color: var(--white);
}

.btn-warning:hover {
    filter: brightness(0.95);
}

.btn-danger {
    background: var(--error-red);
    color: var(--white);
}

.btn-danger:hover {
    background: #d32f2f;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 14px;
}

/* Form Styles */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--dark-gray);
}

.form-control {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--medium-gray);
    border-radius: 4px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.form-control:focus {
    outline: none;
    border-color: var(--proqual-blue);
}

select.form-control {
    cursor: pointer;
}

textarea.form-control {
    min-height: 120px;
    resize: vertical;
}

/* Table Styles */
.table-container {
    overflow-x: auto;
    margin: 1rem 0;
    position: relative;
}

/* Top scrollbar for wide tables */
.table-scrollbar-top {
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    height: 16px;
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--white);
    border-bottom: 1px solid var(--medium-gray);
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--white);
}


.table th,
.table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--medium-gray);
    vertical-align: middle;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Column widths to prevent overlap */
.table th:nth-child(1),
.table td:nth-child(1) {
    width: 60px;
    min-width: 60px;
}

.table th:nth-child(2),
.table td:nth-child(2) {
    width: 280px;
    min-width: 280px;
    white-space: normal;
    overflow: visible;
}

.table th:nth-child(3),
.table td:nth-child(3) {
    width: 130px;
    min-width: 130px;
}

.table th:nth-child(4),
.table td:nth-child(4) {
    width: 90px;
    min-width: 90px;
}

.table th:nth-child(5),
.table td:nth-child(5) {
    width: 110px;
    min-width: 110px;
}

.table th:nth-child(6),
.table td:nth-child(6) {
    width: 110px;
    min-width: 110px;
}

.table th:nth-child(7),
.table td:nth-child(7) {
    width: 110px;
    min-width: 110px;
}

/* Make File column wider and prevent overlap */
.table th:nth-child(8),
.table td:nth-child(8) {
    min-width: 120px;
    max-width: 180px;
    width: 140px;
    text-align: center;
}

.table th {
    background: var(--light-gray);
    font-weight: 600;
    color: var(--proqual-blue);
}

.table tbody tr:hover {
    background: var(--light-gray);
}

/* Status Badges */
.status-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.status-open {
    background: var(--proqual-light-blue);
    color: var(--white);
}

.status-in-progress {
    background: var(--proqual-green);
    color: var(--white);
}

.status-resolved {
    background: var(--success-green);
    color: var(--white);
}

.status-closed {
    background: var(--medium-gray);
    color: var(--dark-gray);
}

/* Priority Badges */
.priority-low {
    background: var(--success-green);
    color: var(--white);
}

.priority-medium {
    background: var(--proqual-green);
    color: var(--white);
}

.priority-high {
    background: var(--error-red);
    color: var(--white);
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    overflow-y: auto; /* Enable scrolling */
    padding: 20px 0; /* Add padding for spacing */
}

.modal-content {
    background-color: var(--white);
    margin: 2% auto;
    padding: 20px;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh; /* Limit height to viewport */
    overflow-y: auto; /* Enable internal scrolling */
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    position: relative;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--medium-gray);
}

.modal-header h3 {
    color: var(--proqual-blue);
    margin: 0;
}

.close {
    color: var(--medium-gray);
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.close:hover {
    color: var(--dark-gray);
}

/* Comments section in modal */
#commentsSection {
    border-top: 2px solid var(--light-gray);
    margin-top: 1.5rem;
    padding-top: 1.5rem;
}

#commentsSection label {
    font-weight: bold;
    color: var(--proqual-blue);
    margin-bottom: 0.5rem;
}

/* Utility Classes */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.mb-3 {
    margin-bottom: 1rem;
}

.mt-3 {
    margin-top: 1rem;
}

.d-flex {
    display: flex;
}

.justify-content-between {
    justify-content: space-between;
}

.align-items-center {
    align-items: center;
}

.gap-2 {
    gap: 0.5rem;
}

.gap-3 {
    gap: 1rem;
}

/* Error and Success Messages */
.error-message {
    background: #ffebee;
    color: var(--error-red);
    padding: 12px;
    border-radius: 4px;
    border-left: 4px solid var(--error-red);
    margin: 1rem 0;
}

.success-message {
    background: #e8f5e8;
    color: var(--success-green);
    padding: 12px;
    border-radius: 4px;
    border-left: 4px solid var(--success-green);
    margin: 1rem 0;
}

/* Responsive Design */
@media (max-width: 768px) {
    :root {
        --proqual-logo-height: 70px;
        --proqual-logo-max-width: 320px;
    }

    .header-content {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .nav-tabs {
        flex-direction: column;
    }
    
    .container {
        padding: 10px;
    }
    
    .content {
        padding: 1rem;
    }
    
    .table-container {
        font-size: 14px;
    }
    
    .modal-content {
        width: 95%;
        margin: 1% auto; /* Reduced margin for mobile */
        max-height: 95vh; /* Increased height for mobile */
        padding: 15px; /* Reduced padding for mobile */
    }
    
    .comments-list {
        max-height: 150px; /* Even smaller for mobile */
    }
}

/* Comments System Styles */
.comments-container {
    margin-bottom: 1rem;
}

.comments-list {
    max-height: 200px; /* Reduced height to fit better in modal */
    overflow-y: auto;
    border: 1px solid var(--medium-gray);
    border-radius: 4px;
    padding: 1rem;
    margin-bottom: 1rem;
    background: var(--light-gray);
}

.comment-item {
    background: var(--white);
    border: 1px solid var(--medium-gray);
    border-radius: 6px;
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    position: relative;
}

.comment-item:last-child {
    margin-bottom: 0;
}

.comment-item.internal {
    background: #fff3cd;
    border-left: 4px solid #ffc107;
}

.comment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.comment-author {
    font-weight: bold;
    color: var(--proqual-blue);
}

.comment-date {
    color: var(--medium-gray);
    font-size: 0.8rem;
}

.comment-text {
    white-space: pre-wrap;
    word-wrap: break-word;
    line-height: 1.4;
}

.comment-actions {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    opacity: 0;
    transition: opacity 0.2s;
}

.comment-item:hover .comment-actions {
    opacity: 1;
}

.comment-actions button {
    background: none;
    border: none;
    color: var(--medium-gray);
    cursor: pointer;
    font-size: 0.8rem;
    margin-left: 0.25rem;
    padding: 0.25rem;
}

.comment-actions button:hover {
    color: var(--proqual-blue);
}

.add-comment-section {
    margin-top: 1rem;
}

.comment-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.5rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    font-size: 0.9rem;
    color: var(--dark-gray);
}

.checkbox-label input[type="checkbox"] {
    margin-right: 0.5rem;
}

.internal-badge {
    background: #ffc107;
    color: #000;
    padding: 0.15rem 0.4rem;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: bold;
    margin-left: 0.5rem;
}

.no-comments {
    text-align: center;
    color: var(--medium-gray);
    font-style: italic;
    padding: 1rem;
}

/* Staff Comments Display Styles */
.original-notes {
    margin-bottom: 1rem;
}

.admin-comments {
    font-weight: bold;
    margin-bottom: 0.5rem;
    color: var(--proqual-blue);
}

.comment-display {
    border-left: 3px solid var(--proqual-blue);
    background: #f8f9fa !important;
    margin-top: 0.75rem;
    padding: 0.5rem;
    border-radius: 4px;
}

.comment-header {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 0.25rem;
}

.comment-text {
    white-space: pre-wrap;
    word-wrap: break-word;
    line-height: 1.4;
}

/* Related Tickets System Styles - Professional Design */
.related-tickets-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    padding: 0;
    margin-bottom: 1.5rem;
    background: #fafbfc;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

.related-ticket-item {
    background: var(--white);
    border: none;
    border-bottom: 1px solid #f0f3f6;
    border-radius: 0;
    padding: 1rem 1.25rem;
    margin-bottom: 0;
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    transition: all 0.2s ease;
    cursor: pointer;
}

.related-ticket-item:first-child {
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
}

.related-ticket-item:last-child {
    border-bottom: none;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
}

.related-ticket-item:hover {
    background: #f8f9fa;
    transform: translateX(2px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.related-ticket-info {
    flex-grow: 1;
    min-width: 0; /* Prevents flex item from growing beyond container */
}

.relationship-badge {
    display: inline-flex;
    align-items: center;
    background: linear-gradient(135deg, var(--proqual-green), #28a745);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 16px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

.relationship-badge::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.relationship-badge:hover::before {
    left: 100%;
}

.relationship-badge.duplicate {
    background: linear-gradient(135deg, #ffc107, #ffcd39);
    color: #212529;
    box-shadow: 0 2px 4px rgba(255, 193, 7, 0.3);
}

.relationship-badge.blocks {
    background: linear-gradient(135deg, #dc3545, #e85d75);
    box-shadow: 0 2px 4px rgba(220, 53, 69, 0.3);
}

.relationship-badge.blocked-by {
    background: linear-gradient(135deg, #fd7e14, #ff922b);
    box-shadow: 0 2px 4px rgba(253, 126, 20, 0.3);
}

.relationship-badge.parent {
    background: linear-gradient(135deg, var(--proqual-blue), var(--proqual-blue));
    box-shadow: 0 2px 4px rgba(var(--proqual-blue-rgb, 52, 144, 220), 0.3);
}

.relationship-badge.child {
    background: linear-gradient(135deg, #6f42c1, #845ef7);
    box-shadow: 0 2px 4px rgba(111, 66, 193, 0.3);
}

.related-ticket-title {
    font-weight: 600;
    color: var(--proqual-blue);
    margin-bottom: 0.375rem;
    font-size: 0.95rem;
    line-height: 1.4;
    transition: color 0.2s ease;
    text-decoration: none;
}

.related-ticket-title:hover {
    color: var(--proqual-blue);
    text-decoration: none;
}

.related-ticket-meta {
    font-size: 0.8rem;
    color: #6c757d;
    line-height: 1.3;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.related-ticket-meta span {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.related-ticket-meta .status-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 0.25rem;
}

.related-ticket-meta .status-open {
    background: #28a745;
}

.related-ticket-meta .status-in-progress {
    background: #ffc107;
}

.related-ticket-meta .status-resolved {
    background: #17a2b8;
}

.related-ticket-meta .status-closed {
    background: #6c757d;
}

.related-ticket-actions {
    margin-left: 1rem;
    display: flex;
    align-items: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.related-ticket-item:hover .related-ticket-actions {
    opacity: 1;
}

.related-ticket-actions button {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    color: #6c757d;
    cursor: pointer;
    font-size: 0.75rem;
    padding: 0.375rem 0.5rem;
    border-radius: 4px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
}

.related-ticket-actions button:hover {
    background: #dc3545;
    border-color: #dc3545;
    color: white;
    transform: scale(1.05);
}

.add-related-ticket-section {
    margin-top: 1.5rem;
    padding: 1.25rem;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    position: relative;
}

.add-related-ticket-section::before {
    content: 'Link Related Ticket';
    position: absolute;
    top: -0.5rem;
    left: 1rem;
    background: var(--white);
    padding: 0 0.5rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--proqual-blue);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 1rem;
    align-items: end;
}

.form-row .form-group {
    margin-bottom: 0;
}

.form-row .form-group label {
    font-weight: 500;
    font-size: 0.85rem;
    color: #495057;
    margin-bottom: 0.375rem;
}

.form-row select {
    border: 1px solid #ced4da;
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-row select:focus {
    border-color: var(--proqual-blue);
    box-shadow: 0 0 0 2px rgba(var(--proqual-blue-rgb, 52, 144, 220), 0.25);
    outline: none;
}

.form-row button {
    background: linear-gradient(135deg, var(--proqual-blue), var(--proqual-blue));
    border: none;
    color: white;
    padding: 0.5rem 1.25rem;
    border-radius: 6px;
    font-weight: 500;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.form-row button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.form-row button:active {
    transform: translateY(0);
}

.no-related-tickets {
    text-align: center;
    color: #6c757d;
    font-style: italic;
    padding: 2rem;
    background: var(--white);
    border-radius: 8px;
    border: 2px dashed #dee2e6;
    margin: 0;
}

.no-related-tickets::before {
    content: '🔗';
    display: block;
    font-size: 2rem;
    margin-bottom: 0.5rem;
    opacity: 0.5;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .form-row {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .related-ticket-actions {
        opacity: 1; /* Always show on mobile */
    }
    
    .related-ticket-item {
        flex-direction: column;
        align-items: stretch;
    }
    
    .related-ticket-actions {
        margin-left: 0;
        margin-top: 0.75rem;
        justify-content: flex-end;
    }
}

/* Drag and drop ticket reordering styles */
.drag-handle {
    cursor: grab !important;
    user-select: none;
}

.drag-handle:active {
    cursor: grabbing !important;
}

.sortable-ghost {
    opacity: 0.5;
    background-color: #f0f8ff !important;
}

.sortable-chosen {
    background-color: #e3f2fd !important;
}

.sortable-drag {
    transform: rotate(5deg);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.drag-handle-header {
    text-align: center;
    width: 30px;
    padding: 8px 4px !important;
}

/* Pagination Controls */
.pagination-controls {
    display: flex;
    gap: 4px;
    align-items: center;
}

.pagination-controls .btn {
    min-width: 36px;
    padding: 4px 8px;
    font-size: 0.875rem;
}

.pagination-controls .btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#archivedTicketsInfo {
    font-size: 0.875rem;
    color: #6c757d;
}