/* Punkteliste App Specific Styling */

.app-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    max-width: 95%; /* 95% to allow wide tables */
    width: 1400px;
    padding: 2rem 3rem;
    overflow: hidden; /* Contains the scrollable table inside */
}

.page-title {
    text-align: center;
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    color: var(--primary-color);
    text-transform: uppercase;
}

/* Controls */
.controls-section {
    display: flex;
    justify-content: center;
    align-items: center;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 1.5rem;
}

.action-buttons {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.btn-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    padding: 0.8rem 2rem;
    background: linear-gradient(135deg, var(--primary-color), var(--hover-color));
    border: none;
    border-radius: 30px;
    color: white;
    font-weight: 600;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    box-shadow: 0 4px 15px rgba(0, 136, 204, 0.4);
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 136, 204, 0.6);
}

.btn-primary:active {
    transform: translateY(0);
}

.loading {
    color: #cbd5e1;
    font-style: italic;
    animation: pulse 1.5s infinite;
}

/* Filters */
.filter-section {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    background: rgba(0, 0, 0, 0.2);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
    min-width: 200px;
}

.primary-filters {
    display: flex;
    width: 100%;
    align-items: flex-end;
    gap: 1rem;
}

.main-search {
    flex: 1;
}

.advanced-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    width: 100%;
    margin-top: 1rem;
    padding-top: 1.5rem;
    border-top: 1px dashed var(--glass-border);
}

.btn-toggle-filters {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--glass-border);
    color: white;
    border-radius: 8px;
    padding: 0.7rem 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    height: 43px; 
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-toggle-filters:hover {
    background: rgba(0, 136, 204, 0.3);
    border-color: var(--primary-color);
}

.btn-toggle-filters.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.filter-group label {
    font-size: 0.9rem;
    color: #e2e8f0;
    font-weight: 600;
    text-transform: uppercase;
}

.filter-group input, 
.filter-group select {
    padding: 0.7rem 1rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: #ffffff;
    font-family: 'Montserrat', sans-serif;
    outline: none;
    transition: border-color 0.3s, background 0.3s;
}

.filter-group input::placeholder {
    color: #94a3b8;
}

.filter-group input:focus, 
.filter-group select:focus {
    border-color: var(--primary-color);
    background: rgba(255, 255, 255, 0.15);
}

.filter-group select option {
    background: #1a1a1a;
    color: #fff;
}

/* Table Area */
.table-container {
    width: 100%;
    overflow-x: auto;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    border: 1px solid var(--glass-border);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    color: #f8fafc;
    font-size: 0.95rem;
    white-space: nowrap;
}

.data-table thead {
    background: rgba(0, 136, 204, 0.2);
}

.data-table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--primary-color);
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
    cursor: pointer;
    position: sticky;
    top: 0;
    background: rgba(26, 32, 44, 0.95); /* Solid header instead of blur to mask scrolling text */
    border-bottom: 2px solid var(--primary-color);
    user-select: none;
    z-index: 10;
}

.data-table th:hover {
    background: rgba(45, 55, 72, 0.95);
}

.data-table th span.sort-icon {
    display: inline-block;
    margin-left: 0.5rem;
    font-size: 0.8rem;
    color: #cbd5e1;
}

.data-table td {
    padding: 0.8rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: transparent;
}

.data-table tbody tr:hover td {
    background: rgba(255, 255, 255, 0.05); /* Highlight whole row */
}

/* Sticky first 3 columns (PNr, Nachname, Vorname) */
.data-table th:nth-child(1), .data-table td:nth-child(1) {
    position: sticky;
    left: 0;
    width: 100px;
    min-width: 100px;
    max-width: 100px;
    box-shadow: inset -1px 0 0 rgba(255,255,255,0.1);
}

.data-table th:nth-child(2), .data-table td:nth-child(2) {
    position: sticky;
    left: 100px;
    width: 180px;
    min-width: 180px;
    max-width: 180px;
    box-shadow: inset -1px 0 0 rgba(255,255,255,0.1);
}

.data-table th:nth-child(3), .data-table td:nth-child(3) {
    position: sticky;
    left: 280px;
    width: 160px;
    min-width: 160px;
    max-width: 160px;
    box-shadow: 2px 0 5px rgba(0,0,0,0.3); /* Stronger shadow on the last sticky column */
}

/* Ensure sticky cells have background so scrolling text hides behind them */
.data-table tbody td:nth-child(1),
.data-table tbody td:nth-child(2),
.data-table tbody td:nth-child(3) {
    background: #252d3a; /* Match the panel tint roughly */
    z-index: 5;
}

.data-table tbody tr:hover td:nth-child(1),
.data-table tbody tr:hover td:nth-child(2),
.data-table tbody tr:hover td:nth-child(3) {
    background: #2d3748; /* Highlight for sticky rows */
}

/* Ensure sticky headers stay above everything else */
.data-table th:nth-child(1),
.data-table th:nth-child(2),
.data-table th:nth-child(3) {
    z-index: 15;
    background: #1e2532; 
}

.data-table tbody tr {
    cursor: pointer;
}

.data-table tbody tr:hover {
    background: transparent; /* Reset to rely on td background */
}

/* Pagination */
.pagination-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 0.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.pagination-info {
    color: #cbd5e1;
    font-size: 0.9rem;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.rows-per-page-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #e2e8f0;
    font-size: 0.9rem;
    margin-right: 1rem;
}

.rows-per-page-selector select {
    padding: 0.3rem 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    color: #ffffff;
    font-family: 'Montserrat', sans-serif;
    outline: none;
}

.rows-per-page-selector select option {
    background: #1a1a1a;
    color: #fff;
}

.btn-pagination {
    padding: 0.6rem 1.2rem;
    background: transparent;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 600;
}

.btn-pagination:hover:not(:disabled) {
    background: var(--primary-color);
    color: white;
}

.btn-pagination:disabled {
    border-color: #64748b;
    color: #64748b;
    cursor: not-allowed;
    opacity: 0.5;
}

.page-display {
    color: white;
    font-weight: 600;
}

/* Utils */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center !important;
}

.error-notification {
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid #ef4444;
    color: #fca5a5;
    padding: 1rem;
    border-radius: 8px;
    text-align: center;
    font-weight: 500;
}

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

/* Modal */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: #1e2532;
    padding: 2rem;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    position: relative;
    border: 1px solid var(--glass-border);
    color: white;
}

.close-modal {
    position: absolute;
    top: 15px;
    right: 20px;
    color: #cbd5e1;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close-modal:hover,
.close-modal:focus {
    color: var(--primary-color);
    text-decoration: none;
}

.modal-body {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    overflow-y: auto;
    flex: 1;
    min-height: 0; /* Ensures flex scrolling works */
    padding-right: 0.5rem; /* Space for scrollbar */
}

.detail-row {
    display: flex;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 0.5rem;
}

.detail-row strong {
    flex: 1;
    color: var(--primary-color);
}

.detail-row span {
    flex: 2;
}

@media (max-width: 768px) {
    .app-container {
        padding: 1rem 0.8rem;
        max-width: 100%;
        width: 100%;
    }
    
    .page-title {
        font-size: 1.8rem;
    }
    
    .action-buttons {
        flex-direction: column;
        width: 100%;
    }
    
    .btn-primary {
        width: 100%;
    }
    
    .primary-filters {
        flex-direction: row; /* Keep search and button inline */
        gap: 0.5rem;
    }

    .btn-toggle-filters {
        padding: 0.7rem 1rem;
        flex-shrink: 0; /* Prevent the button from shrinking */
    }
    
    .filter-group {
        min-width: 100%;
    }

    .main-search {
        min-width: 0; /* Allow the search bar to shrink instead of forcing 100% */
    }
    
    .pagination-section {
        flex-direction: column;
        justify-content: center;
        gap: 1.5rem;
    }
    
    .pagination-controls {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .rows-per-page-selector {
        width: 100%;
        justify-content: center;
        margin-right: 0;
        margin-bottom: 0.5rem;
    }
    
    /* Disable horizontal sticky columns on mobile to prevent blocking scroll (width > screen) */
    .data-table th:nth-child(1), .data-table td:nth-child(1),
    .data-table th:nth-child(2), .data-table td:nth-child(2),
    .data-table th:nth-child(3), .data-table td:nth-child(3) {
        position: static;
        left: auto;
        box-shadow: none;
        width: auto;
        min-width: 0;
        max-width: none;
    }
    
    /* Re-enable top sticky for headers only */
    .data-table th:nth-child(1),
    .data-table th:nth-child(2),
    .data-table th:nth-child(3) {
        position: sticky;
        top: 0;
        z-index: 10;
        background: rgba(26, 32, 44, 0.95);
    }
    
    /* Reset tbody cell backgrounds back to normal */
    .data-table tbody td:nth-child(1),
    .data-table tbody td:nth-child(2),
    .data-table tbody td:nth-child(3) {
        background: transparent;
        z-index: 1;
    }
    
    /* Reset hover state for the un-stickied rows */
    .data-table tbody tr:hover td:nth-child(1),
    .data-table tbody tr:hover td:nth-child(2),
    .data-table tbody tr:hover td:nth-child(3) {
        background: transparent; 
    }
    
    /* Hide all columns after the 3rd one */
    .data-table th:nth-child(n+4), 
    .data-table td:nth-child(n+4) {
        display: none;
    }
    
    /* Make the 3 visible columns span neatly */
    .data-table th:nth-child(1), .data-table td:nth-child(1) { width: 30%; }
    .data-table th:nth-child(2), .data-table td:nth-child(2) { width: 40%; }
    .data-table th:nth-child(3), .data-table td:nth-child(3) { width: 30%; }
}
