/* Global Table Styles */
.table-container {
    margin-top: 2rem;
    background: var(--background-glass);
    border-radius: 15px;
    padding: 1.5rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 100%;
}

.table-container h2 {
    margin: 0 0 1rem 0;
    color: var(--text-color);
    font-size: 1.5rem;
    font-weight: 600;
}

/* =======================================Custom Scrollbar for Tables */
/* Generic scrollable wrapper class for tables */
.table-scrollable-wrapper {
    overflow-x: auto;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    width: 100%;
    max-width: 100%;
}

/* Custom scrollbar for scrollable table wrappers */
.table-scrollable-wrapper::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

/* Track (the background of the scrollbar) */
.table-scrollable-wrapper::-webkit-scrollbar-track {
    background: var(--container-color);
    border-radius: 4px;
}

/* Handle (the draggable part of the scrollbar) */
.table-scrollable-wrapper::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
    transition: background 0.3s;
}

/* Handle on hover */
.table-scrollable-wrapper::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color-hover);
}

.table-scrollable-wrapper::-webkit-scrollbar-corner {
    background: var(--container-color);
}

/* =======================================Base Table Styles */
.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--container-color);
    table-layout: auto;
}

/* Table Header */
.table th {
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.75), rgba(102, 1, 128, 0.75));
    color: white;
    font-weight: bold;
    font-size: 12px;
    position: sticky;
    top: -1px;
    z-index: 20;
    user-select: none;
    transition: background-color 0.3s ease;
    border-top: 2px solid var(--primary-color);
    border: 1px solid var(--border-color);
    padding: 12px 8px;
    text-align: left;
    vertical-align: middle;
}

/* Table Cells */
.table td {
    border: 1px solid var(--border-color);
    padding: 12px 8px;
    text-align: left;
    vertical-align: middle;
    word-wrap: break-word;
    font-size: 12px;
    color: var(--text-color);
    height: auto;
    min-height: 40px;
}

/* Table row hover effects */
.table tr:nth-child(even) {
    background-color: rgba(255, 255, 255, 0.05);
}

.table tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.1);
    transition: background-color 0.2s ease;
}

/* Table Inputs */
.table input[type="text"] {
    width: 100%;
    padding: 2px 4px;
    border: none;
    background: var(--container-color);
    color: var(--text-color);
    height: 22px;
    line-height: 22px;
    font-size: 1.5em;
}

/* Table Controls */
.table-controls {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
}

/* Action Buttons - Standardized across all tables */
.action-buttons {
    display: flex;
    gap: 3px;
    justify-content: center;
    align-items: center;
    text-align: center;
    width: 100%;
    height: 100%;
}

.action-buttons button {
    padding: 4px 6px;
    width: 55px;
    height: 22px;
    color: var(--text-color);
    font-weight: 700;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    text-transform: uppercase;
    overflow: hidden;
    position: relative;
    font-family: "Poppins";
    background: var(--container-color);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-size: 8px;
    margin: 0;
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.action-buttons button::before {
    content: '';
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(120deg, transparent,
             var(--primary-color), transparent);
    transform: translateX(-100%);
    transition: 0.6s;
    position: absolute;
}

.action-buttons button:hover {
    background: transparent;
    transform: translateY(-1px);
    box-shadow: 0 0 10px 2px var(--primary-color);
}

/* Restore borders for action buttons column - Universal rule */
.table td:last-child {
    text-align: center;
    vertical-align: middle;
    padding: 12px 8px;
    position: relative;
    border: 1px solid var(--border-color);
}

.table th:last-child {
    text-align: center;
    vertical-align: middle;
}

/* Responsive Design */
@media (max-width: 768px) {
    .table-container {
        margin: var(--spacing-sm) 0;
        padding: 1rem;
    }

    .table-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .table {
        font-size: 0.8rem;
    }

    .table th,
    .table td {
        padding: 0.5rem;
    }

    .action-buttons button {
        width: 60px;
        height: 24px;
        font-size: 8px;
        padding: 4px 8px;
    }
}

/* Print Styles */
@media print {
    .table-controls {
        display: none;
    }

    .table {
        border: 1px solid #000;
    }

    .table th {
        background-color: #f5f5f5 !important;
        color: #000 !important;
    }

    .table td {
        border: 1px solid #000;
    }
}
