/* ==========================================================================
   Base Table Styles - Common styles for all tables
   ========================================================================== */

/* == 1. Generic Card & Container Styles == */
.card {
    background: #1e293b;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    border: 1px solid #334155;
    padding: 24px;
    margin-bottom: 24px;
    overflow: hidden;
}

.cards {
    width: 100%;
}

/* == 2. Generic Table Styles == */
table.list {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: transparent;
    table-layout: fixed; /* Changed to fixed for better column control */
    min-width: 100%;
}

/* Table Header */
table.list th {
    background: #0b1220;
    color: #f1f5f9;
    font-weight: 600;
    font-size: 13.5px; /* Reduced from 15px by 10% */
    padding: 14px 18px;
    text-align: left;
    border-bottom: 1px solid #334155;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Table Cells */
table.list td {
    color: #e2e8f0;
    font-size: 12.6px; /* Reduced from 14px by 10% */
    padding: 14px 18px;
    border-bottom: 1px solid #334155;
    vertical-align: middle;
    word-break: normal;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Remove bottom border from the last row */
table.list tbody tr:last-child td {
    border-bottom: none;
}

/* Hover effect for rows */
table.list tbody tr:hover td {
    background-color: rgba(255, 255, 255, 0.05);
}

/* Wrapper for tables to allow horizontal scrolling */
.grid-wrap {
    overflow-x: auto;
    width: 100%;
    max-width: 100%;
    position: relative;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #4b5563 #1f2937;
    margin-bottom: 1rem;
}

/* Custom scrollbar for Webkit browsers */
.grid-wrap::-webkit-scrollbar {
    height: 8px;
    background-color: #1f2937;
}

.grid-wrap::-webkit-scrollbar-thumb {
    background-color: #4b5563;
    border-radius: 4px;
}

.grid-wrap::-webkit-scrollbar-thumb:hover {
    background-color: #6b7280;
}

/* == 3. Toolbar & Form Elements == */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    margin-bottom: 20px;
}

.toolbar input[type="text"],
.toolbar input[type="date"],
.toolbar select {
    background: #1f2937;
    border: 1px solid #374151;
    color: #e5e7eb;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    min-width: 200px;
    max-width: 100%;
}

.toolbar input[type="text"]::placeholder {
    color: #94a3b8;
}

/* Form fields */
.field {
    margin-bottom: 16px;
}

.field label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    color: #e2e8f0;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    background: #1f2937;
    border: 1px solid #374151;
    color: #e5e7eb;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    border-color: #3b82f6;
    outline: none;
}

/* Grid form layout */
.grid-form {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 16px;
}

/* == 4. Buttons & Badges == */
.btn {
    min-width: 100px;
    padding: 8px 16px;
    font-size: 14px;
    border-radius: 6px;
    border: 1px solid #3b82f6;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
    background: transparent;
    color: #3b82f6;
    text-align: center;
    display: inline-block;
    line-height: 1.5;
}

.btn:hover {
    background: #3b82f6;
    color: #fff;
}

.btn.primary {
    background: linear-gradient(180deg, #3b82f6, #1d4ed8);
    border-color: #1d4ed8;
    color: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.btn.primary:hover {
    background: linear-gradient(180deg, #2563eb, #1e40af);
}

.btn.warn {
    background: linear-gradient(90deg, #f59e42, #f97316);
    border-color: #f97316;
    color: #fff;
}

.btn.warn:hover {
    filter: brightness(1.1);
}

.btn.ghost {
    background: transparent;
    border-color: #64748b;
    color: #e2e8f0;
}

.btn.ghost:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: #94a3b8;
}

.row-actions {
    display: flex;
    gap: 8px;
    flex-wrap: nowrap;
    justify-content: flex-end;
}

.row-actions .btn {
    min-width: auto;
    padding: 6px 12px;
    font-size: 11.7px; /* Reduced from 13px by 10% */
    white-space: nowrap;
}

/* Status Badges */
.badge {
    font-size: 0.75em;
    font-weight: 500;
    padding: 0.35em 0.65em;
    border-radius: 4px;
    display: inline-block;
    text-align: center;
    white-space: nowrap;
}

.badge.success {
    background-color: rgba(16, 185, 129, 0.2);
    color: #10b981;
}

.badge.warning {
    background-color: rgba(245, 158, 11, 0.2);
    color: #f59e0b;
}

.badge.danger {
    background-color: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.badge.info {
    background-color: rgba(59, 130, 246, 0.2);
    color: #3b82f6;
}

/* Removed partial payment row styling */

/* == 5. Responsive Design == */
@media (max-width: 992px) {
    table.list th,
    table.list td {
        padding: 12px 14px;
    }
    
    .grid-form {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }
}

@media (max-width: 768px) {
    .card {
        padding: 16px;
    }

    table.list th,
    table.list td {
        padding: 10px 8px;
        font-size: 11.7px; /* Reduced from 13px by 10% */
    }

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

    .row-actions {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    .btn {
        width: 100%;
    }
    
    .grid-form {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .card {
        padding: 12px;
        border-radius: 6px;
    }
    
    table.list th,
    table.list td {
        padding: 8px 6px;
        font-size: 10.8px; /* Reduced from 12px by 10% */
    }
    
    .toolbar input[type="text"],
    .toolbar input[type="date"],
    .toolbar select {
        min-width: 100%;
    }
}