/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    width: 100%;
    overflow-x: auto;
    /* Ensure proper scrolling on mobile */
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #222;
    color: #f3f8fb;
    line-height: 1.6;
}

/* Home navigation button */
.home-nav {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 1000;
}

.home-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    background-color: rgba(82, 203, 84, 0.9);
    color: white;
    text-decoration: none;
    border-radius: 50%;
    font-size: 1.5rem;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.home-btn:hover {
    background-color: rgba(82, 203, 84, 1);
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(82, 203, 84, 0.3);
}

/* Main container */
.tickets-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 100px 20px 40px 20px;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 40px;
}

.header h1 {
    color: #52cb54;
    font-size: 2.5rem;
    font-weight: 600;
    margin-bottom: 10px;
}

.header p {
    color: #b0b0b0;
    font-size: 1.1rem;
}

/* Controls */
.controls {
    background-color: #333;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    margin-bottom: 30px;
    border: 1px solid #444;
}

.search-section {
    margin-bottom: 20px;
}

.search-input {
    width: 100%;
    padding: 15px;
    border: 2px solid #555;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
    background-color: #444;
    color: #f3f8fb;
}

.search-input:focus {
    outline: none;
    border-color: #52cb54;
    box-shadow: 0 0 0 3px rgba(82, 203, 84, 0.1);
}

.search-input::placeholder {
    color: #888;
}

.filter-section {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.filter-select {
    padding: 12px 15px;
    border: 2px solid #555;
    border-radius: 8px;
    font-size: 0.95rem;
    background-color: #444;
    color: #f3f8fb;
    cursor: pointer;
    transition: border-color 0.3s ease;
    min-width: 150px;
}

.filter-select:focus {
    outline: none;
    border-color: #52cb54;
}

.filter-select option {
    background-color: #444;
    color: #f3f8fb;
}

/* Statistics Summary */
.stats-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background-color: #333;
    padding: 25px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    border: 1px solid #444;
    transition: transform 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-number {
    font-size: 2.5rem;
    font-weight: 700;
    color: #52cb54;
    margin-bottom: 10px;
}

.stat-label {
    color: #b0b0b0;
    font-size: 1rem;
    font-weight: 500;
}

/* Table Container */
.table-container {
    background-color: #333;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    border: 1px solid #444;
    overflow: visible; /* Allow content to overflow for proper scrolling */
}

/* Table wrapper for horizontal scrolling */
.table-wrapper {
    position: relative;
    overflow-x: auto;
    overflow-y: visible; /* Allow vertical scrolling to pass through */
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    scrollbar-width: thin;
    scrollbar-color: #555 #333;
    /* Touch-friendly scrolling - allow both horizontal and vertical */
    touch-action: pan-x pan-y;
    /* Ensure smooth scrolling on all devices */
    scroll-behavior: smooth;
    /* Prevent interference with page scrolling */
    will-change: scroll-position;
}

/* Custom scrollbar styling for webkit browsers */
.table-wrapper::-webkit-scrollbar {
    height: 8px;
}

.table-wrapper::-webkit-scrollbar-track {
    background: #333;
    border-radius: 4px;
}

.table-wrapper::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 4px;
}

.table-wrapper::-webkit-scrollbar-thumb:hover {
    background: #666;
}

/* Mobile scroll hint */
@media (max-width: 768px) {
    .table-wrapper::after {
        content: '← Swipe to see more columns →';
        display: block;
        text-align: center;
        padding: 10px;
        color: #888;
        font-size: 0.8rem;
        background: linear-gradient(90deg, transparent, #444, transparent);
        margin-top: 10px;
    }
    
    /* Scroll position indicators */
    .table-wrapper.can-scroll-left::before {
        content: '◀';
        position: absolute;
        left: 10px;
        top: 50%;
        transform: translateY(-50%);
        color: #52cb54;
        font-size: 1.2rem;
        z-index: 5;
        pointer-events: none;
        animation: pulse 2s infinite;
    }
    
    .table-wrapper.can-scroll-right::after {
        content: '▶';
        position: absolute;
        right: 10px;
        top: 50%;
        transform: translateY(-50%);
        color: #52cb54;
        font-size: 1.2rem;
        z-index: 5;
        pointer-events: none;
        animation: pulse 2s infinite;
    }
    
    /* Ensure proper scrolling behavior on mobile */
    .tickets-container {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Prevent table wrapper from blocking vertical scroll */
    .table-wrapper {
        touch-action: pan-x pan-y;
        overflow-y: visible;
        /* Ensure it doesn't interfere with page scrolling */
        isolation: isolate;
    }
}

.tickets-table {
    width: 100%;
    min-width: 800px; /* Ensure table doesn't get too narrow */
    border-collapse: collapse;
    font-size: 0.9rem;
    white-space: nowrap; /* Prevent text wrapping */
}



.tickets-table th {
    background-color: #444;
    padding: 18px 15px;
    text-align: left;
    font-weight: 600;
    color: #f3f8fb;
    border-bottom: 2px solid #555;
    position: sticky;
    top: 0;
    z-index: 10;
}

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

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

.tickets-table th.sortable:active {
    background-color: #666;
}

.sort-indicator {
    display: inline-block;
    margin-left: 8px;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    opacity: 0.5;
}

.sort-indicator.asc {
    border-bottom: 6px solid #52cb54;
    opacity: 1;
}

.sort-indicator.desc {
    border-top: 6px solid #52cb54;
    opacity: 1;
}

.tickets-table td {
    padding: 15px;
    border-bottom: 1px solid #555;
    color: #f3f8fb;
    white-space: nowrap; /* Prevent text wrapping */
    overflow: hidden;
    text-overflow: ellipsis; /* Show ... for long text */
    max-width: 200px; /* Limit cell width */
}

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

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

/* Status badges */
.status-badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-unused {
    background-color: #e3f2fd;
    color: #1976d2;
}

.status-used {
    background-color: #e8f5e8;
    color: #2e7d32;
}

/* Loading and no tickets messages */
.loading-message, .no-tickets-message {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #52cb54;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

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

/* Responsive Design */
@media (max-width: 1200px) {
    .tickets-container {
        padding: 100px 15px 30px 15px;
    }
    
    .filter-section {
        flex-direction: column;
    }
    
    .filter-select {
        min-width: 100%;
    }
}

@media (max-width: 768px) {
    .tickets-container {
        padding: 80px 10px 20px 10px;
    }
    
    .header h1 {
        font-size: 2rem;
    }
    
    .controls {
        padding: 20px;
    }
    
    .stats-summary {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .stat-card {
        padding: 20px;
    }
    
    .stat-number {
        font-size: 2rem;
    }
    
    .tickets-table {
        font-size: 0.8rem;
    }
    
    .tickets-table th,
    .tickets-table td {
        padding: 12px 8px;
    }
    

}

@media (max-width: 480px) {
    .tickets-container {
        padding: 70px 5px 15px 5px;
    }
    
    .header h1 {
        font-size: 1.8rem;
    }
    
    .controls {
        padding: 15px;
    }
    
    .search-input {
        padding: 12px;
        font-size: 0.9rem;
    }
    
    .filter-select {
        padding: 10px 12px;
        font-size: 0.9rem;
    }
    
    .tickets-table th,
    .tickets-table td {
        padding: 10px 6px;
        font-size: 0.75rem;
    }
    
    /* Ensure table wrapper is properly sized on mobile */
    .table-wrapper {
        margin: 0 -5px; /* Extend to edges on mobile */
    }
    
    /* Add some padding to the table container on mobile */
    .table-container {
        margin: 0 5px;
    }
}
