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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    font-size: 28px;
    font-weight: 600;
}

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

.connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.2);
    padding: 8px 15px;
    border-radius: 20px;
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ffc107;
    animation: pulse 2s infinite;
}

.status-indicator.connected {
    background: #4caf50;
    animation: none;
}

.status-indicator.disconnected {
    background: #f44336;
    animation: none;
}

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

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
}

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

.btn-primary {
    background: #2196F3;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #1976D2;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.4);
}

.btn-secondary {
    background: #607D8B;
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #455A64;
}

.btn-warning {
    background: #FF9800;
    color: white;
}

.btn-warning:hover:not(:disabled) {
    background: #F57C00;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 152, 0, 0.4);
}

.btn-danger {
    background: #f44336;
    color: white;
    padding: 6px 12px;
    font-size: 12px;
}

.btn-danger:hover:not(:disabled) {
    background: #d32f2f;
}

.filters {
    padding: 20px 30px;
    background: #f5f5f5;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    align-items: center;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-group label {
    font-size: 14px;
    font-weight: 500;
    color: #555;
}

.filter-group select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    background: white;
    cursor: pointer;
}

.filter-group-search {
    flex: 1;
    min-width: 250px;
}

.filter-group-search input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    width: 100%;
    transition: border-color 0.3s;
}

.filter-group-search input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.stage-filters {
    padding: 20px 30px;
    background: #f9f9f9;
    border-bottom: 1px solid #e0e0e0;
}

.stage-filters-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
    font-weight: 600;
    color: #555;
}

.btn-link {
    background: none;
    border: none;
    color: #667eea;
    cursor: pointer;
    font-size: 13px;
    text-decoration: underline;
    padding: 0;
    transition: color 0.2s;
}

.btn-link:hover {
    color: #764ba2;
}

.stage-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
}

.stage-checkbox-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 14px;
    color: #555;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: 4px;
    transition: background-color 0.2s;
    user-select: none;
}

.stage-checkbox-label:hover {
    background-color: #e8e8e8;
}

.stage-checkbox {
    cursor: pointer;
    width: 16px;
    height: 16px;
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    padding: 30px;
    background: #fafafa;
}

.stat-card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.stat-label {
    font-size: 14px;
    color: #777;
    margin-bottom: 8px;
    font-weight: 500;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: #333;
}

/* Charts Section */
.charts-section {
    padding: 30px;
    background: #fafafa;
    border-bottom: 1px solid #e0e0e0;
}

/* Trends Section */
.trends-section {
    padding: 30px;
    background: #f5f5f5;
    border-bottom: 1px solid #e0e0e0;
}

.charts-title {
    font-size: 24px;
    font-weight: 700;
    color: #333;
    margin-bottom: 25px;
    text-align: center;
}

.chart-subtitle {
    text-align: center;
    color: #777;
    font-size: 13px;
    margin-top: -10px;
    margin-bottom: 15px;
    font-style: italic;
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 25px;
    max-width: 1400px;
    margin: 0 auto 30px auto;
}

.charts-grid-single {
    display: flex;
    justify-content: center;
    margin: 0 auto 30px auto;
    max-width: 1400px;
}

.charts-grid-trends {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 25px;
    max-width: 1400px;
    margin: 0 auto;
}

.chart-card {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
}

.chart-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.chart-card-wide {
    width: 100%;
    max-width: 800px;
}

.chart-card-trend {
    min-height: 350px;
}

.chart-title {
    font-size: 18px;
    font-weight: 600;
    color: #555;
    margin-bottom: 20px;
    text-align: center;
    border-bottom: 2px solid #667eea;
    padding-bottom: 10px;
}

.chart-card canvas {
    max-height: 300px;
    margin: 0 auto;
}

.chart-legend {
    margin-top: 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: center;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #555;
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    flex-shrink: 0;
}

.legend-label {
    font-weight: 500;
}

.legend-value {
    color: #999;
}

.stat-display {
    margin-bottom: 20px;
}

.big-stat {
    text-align: center;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
    color: white;
    margin-bottom: 15px;
}

.big-stat-small {
    padding: 15px;
}

.big-stat-small .big-number {
    font-size: 36px;
}

.big-stat-small .big-label {
    font-size: 14px;
}

.big-number {
    display: block;
    font-size: 48px;
    font-weight: 800;
    margin-bottom: 5px;
}

.big-label {
    display: block;
    font-size: 16px;
    font-weight: 400;
    opacity: 0.9;
}

.stat-details {
    display: flex;
    justify-content: space-around;
    gap: 15px;
    padding: 15px;
    background: #f9f9f9;
    border-radius: 8px;
}

.detail-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.detail-label {
    font-size: 13px;
    color: #777;
    font-weight: 500;
}

.detail-value {
    font-size: 24px;
    font-weight: 700;
    color: #667eea;
}


#ticketsContainer {
    padding: 30px;
}

.group-section {
    margin-bottom: 40px;
}

.group-header {
    background: #667eea;
    color: white;
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 15px;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.group-count {
    background: rgba(255, 255, 255, 0.3);
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 14px;
}

.table-wrapper {
    overflow-x: auto;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.tickets-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    min-width: 1200px;
    table-layout: auto;
}

.tickets-table thead {
    background: #f5f5f5;
}

.tickets-table th {
    padding: 8px;
    text-align: left;
    font-weight: 600;
    color: #555;
    font-size: 14px;
    border-bottom: 2px solid #e0e0e0;
    position: relative;
    min-width: 30px;
    max-width: 600px;
}

.tickets-table th.sortable {
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s;
}

.tickets-table th.sortable:hover {
    background-color: #e8e8e8;
}

.tickets-table th.sortable .header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 5px;
}

.tickets-table th.sortable .sort-icon {
    font-size: 10px;
    color: #999;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.tickets-table th.sortable:hover .sort-icon {
    opacity: 1;
}

.tickets-table th.resizable {
    position: relative;
    overflow: hidden;
    text-overflow: ellipsis;
}

.resize-handle {
    position: absolute;
    top: 0;
    right: 0;
    width: 5px;
    height: 100%;
    cursor: col-resize;
    background: transparent;
    z-index: 10;
}

.resize-handle:hover {
    background: rgba(102, 126, 234, 0.3);
}

.tickets-table td {
    padding: 8px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 14px;
    max-width: 600px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tickets-table tbody tr:hover {
    background: #f9f9f9;
}

.tickets-table tbody tr.rerunning-row {
    background: #fff9e6;
    border-left: 4px solid #FFC107;
}

.tickets-table tbody tr.rerunning-row:hover {
    background: #fff3d4;
}

.tickets-table tbody tr:last-child td {
    border-bottom: none;
}

.ticket-id {
    font-weight: 600;
}

.ticket-id a {
    color: #667eea;
    text-decoration: none;
    transition: color 0.2s, text-decoration 0.2s;
}

.ticket-id a:hover {
    color: #764ba2;
    text-decoration: underline;
}

.ticket-name a {
    color: #667eea;
    text-decoration: none;
    transition: color 0.2s, text-decoration 0.2s;
}

.ticket-name a:hover {
    color: #764ba2;
    text-decoration: underline;
}

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.badge-success {
    background: #4caf50;
    color: white;
}

.badge-error {
    background: #f44336;
    color: white;
}

.badge-processing {
    background: #2196F3;
    color: white;
}

.badge-pending {
    background: #FF9800;
    color: white;
}

.badge-warning {
    background: #FFC107;
    color: #333;
    font-weight: 600;
}

.badge-pr-open {
    background: #28a745;
    color: white;
}

.badge-pr-merged {
    background: #6f42c1;
    color: white;
}

.badge-pr-closed {
    background: #dc3545;
    color: white;
}

.badge-pr-not_found {
    background: #6c757d;
    color: white;
}

.badge-pr-error {
    background: #fd7e14;
    color: white;
}

.badge-validation-passed {
    background: #28a745;
    color: white;
}

.badge-validation-failed {
    background: #dc3545;
    color: white;
}

.badge-validation-pending {
    background: #ffc107;
    color: #333;
}

.badge-validation-unknown {
    background: #6c757d;
    color: white;
}

.badge-validation-no_comments {
    background: #17a2b8;
    color: white;
}

.badge-validation-error {
    background: #fd7e14;
    color: white;
}

.pr-link {
    max-width: 300px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pr-link a {
    color: #2196F3;
    text-decoration: none;
}

.pr-link a:hover {
    text-decoration: underline;
}

.checkbox-cell {
    width: 35px;
    padding: 5px !important;
}

.checkbox-cell input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.checkbox-cell input[type="checkbox"]:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Set initial column widths */
.tickets-table th[data-column="ticket_id"] {
    width: 80px;
    white-space: nowrap;
}

.tickets-table th[data-column="ticket_name"] {
    width: 200px;
}

.tickets-table th[data-column="project"] {
    width: 150px;
}

.tickets-table th[data-column="ticket_classification"] {
    width: 120px;
}

.tickets-table th[data-column="stage_name"] {
    width: 120px;
    white-space: nowrap;
}

.tickets-table th[data-column="success"] {
    width: 90px;
    white-space: normal;
    word-wrap: break-word;
    line-height: 1.3;
}

.tickets-table th[data-column="pr_link"] {
    width: 180px;
}

.tickets-table th[data-column="pr_status"] {
    width: 100px;
    white-space: nowrap;
}

.tickets-table th[data-column="pr_validation_status"] {
    width: 100px;
    white-space: nowrap;
}

.tickets-table th[data-column="failure_analysis"] {
    width: 250px;
}

.tickets-table td.failure-analysis {
    white-space: normal;
    word-break: break-word;
    font-size: 13px;
    color: #d32f2f;
    font-style: italic;
}

.tickets-table th[data-column="processing_time"] {
    width: 120px;
    white-space: nowrap;
}

.tickets-table th[data-column="processed_at"] {
    width: 150px;
    white-space: nowrap;
}

.action-cell {
    width: 100px;
    white-space: nowrap;
}

/* Allow table cells to wrap for long content */
.tickets-table td.ticket-name,
.tickets-table td.pr-link {
    white-space: normal;
    word-break: break-word;
}

/* Make all td elements respect column widths */
.tickets-table td {
    white-space: nowrap;
}

.tickets-table td.ticket-name,
.tickets-table td.pr-link {
    white-space: normal !important;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-content h2 {
    margin-bottom: 20px;
    color: #333;
}

.progress-bar {
    width: 100%;
    height: 30px;
    background: #e0e0e0;
    border-radius: 15px;
    overflow: hidden;
    margin-bottom: 15px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    width: 0%;
    transition: width 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 14px;
}

#progressText {
    text-align: center;
    color: #555;
    margin-bottom: 20px;
}

#progressResults {
    max-height: 300px;
    overflow-y: auto;
}

.progress-item {
    padding: 10px;
    margin: 5px 0;
    border-radius: 4px;
    font-size: 14px;
}

.progress-item.success {
    background: #c8e6c9;
    color: #2e7d32;
}

.progress-item.error {
    background: #ffcdd2;
    color: #c62828;
}

.no-tickets {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.no-tickets h2 {
    font-size: 24px;
    margin-bottom: 10px;
}

@media (max-width: 768px) {
    header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .header-actions {
        flex-direction: column;
        width: 100%;
    }
    
    .filters {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filter-group {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filter-group select {
        width: 100%;
    }
}


/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    padding: 30px 20px;
    background: white;
}

.pagination #pageInfo {
    min-width: 120px;
    text-align: center;
    color: #666;
    font-weight: 500;
}

.per-page-select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    font-size: 14px;
}

.per-page-select:focus {
    outline: none;
    border-color: #667eea;
}

/* Notification System */
.notification-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 400px;
}

.notification {
    background: white;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-left: 4px solid #2196F3;
    transform: translateX(450px);
    transition: transform 0.3s ease, opacity 0.3s ease;
    opacity: 0;
    font-size: 14px;
    line-height: 1.4;
}

.notification.show {
    transform: translateX(0);
    opacity: 1;
}

.notification-success {
    border-left-color: #4caf50;
    background: #f1f8f4;
    color: #2d5f3a;
}

.notification-error {
    border-left-color: #f44336;
    background: #fef1f0;
    color: #721c24;
}

.notification-warning {
    border-left-color: #FF9800;
    background: #fff8e1;
    color: #7f5d00;
}

.notification-info {
    border-left-color: #2196F3;
    background: #e3f2fd;
    color: #0d47a1;
}
