/* Base table styles */
.custom-timetable table,
.custom-timetable td,
.custom-timetable th {
    border: 1px solid #ddd !important;
    text-align: center;
}

.custom-timetable table {
    border-collapse: collapse;
    width: 100%;
    min-width: 800px; /* Ensure minimum width for proper layout */
}

.custom-timetable th,
.custom-timetable td {
    padding: 15px;
    vertical-align: middle;
}

/* Mobile scroll hint */
.mobile-scroll-hint {
    display: none;
    background: linear-gradient(90deg, rgba(134, 180, 114, 0.1) 0%, rgba(168, 208, 218, 0.1) 100%);
    padding: 8px 16px;
    margin-bottom: 10px;
    border-radius: 8px;
    border-left: 4px solid var(--color-primary, #86b472);
    font-size: 0.875rem;
    color: var(--color-text, #5c5c5c);
    text-align: center;
}

/* Mobile optimization for timetables */
@media (max-width: 768px) {
    /* Show scroll hint on mobile */
    .mobile-scroll-hint {
        display: block;
    }
    
    /* Improve container scrolling */
    .custom-timetable {
        -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
        overflow-x: auto;
        overflow-y: visible;
        width: 100%;
        margin: 0 -1rem; /* Extend beyond container padding */
        padding: 0 1rem; /* Add back internal padding */
        border-radius: 8px;
        box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.05);
    }
    
    /* Ensure table maintains minimum width */
    .custom-timetable table {
        min-width: 700px; /* Slightly smaller for mobile but still readable */
        white-space: nowrap;
    }
    
    /* Optimize cell padding for mobile */
    .custom-timetable th,
    .custom-timetable td {
        padding: 8px 6px;
        font-size: 0.875rem; /* 14px */
        line-height: 1.25;
    }
    
    /* Time column specific styling */
    .custom-timetable th:first-child,
    .custom-timetable td:first-child {
        position: sticky;
        left: 0;
        background-color: var(--waldorf-parchment, #faf9f7);
        z-index: 10;
        min-width: 80px;
        box-shadow: 2px 0 4px rgba(0, 0, 0, 0.1);
    }
    
    /* Header row styling */
    .custom-timetable thead th {
        position: sticky;
        top: 0;
        background-color: var(--waldorf-soft-green-30, rgba(163, 205, 178, 0.3));
        z-index: 11;
    }
    
    /* Corner cell (time header) gets highest z-index */
    .custom-timetable thead th:first-child {
        z-index: 12;
    }
    
    /* Day headers - more compact text */
    .custom-timetable th span {
        font-size: 0.75rem; /* 12px */
        font-weight: 600;
    }
    
    /* Subject text optimization */
    .custom-timetable td span {
        font-size: 0.75rem; /* 12px */
        line-height: 1.2;
        display: block;
        word-break: break-word;
        hyphens: auto;
    }
    
    /* Add subtle gradient to indicate scrollable content */
    .custom-timetable::after {
        content: '';
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        width: 20px;
        background: linear-gradient(to left, rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0));
        pointer-events: none;
        z-index: 5;
    }
    
    /* Container for the table with relative positioning */
    .bg-card {
        position: relative;
    }
}

/* Extra small screens */
@media (max-width: 480px) {
    .custom-timetable table {
        min-width: 600px; /* Even more compact for very small screens */
    }
    
    .custom-timetable th,
    .custom-timetable td {
        padding: 6px 4px;
        font-size: 0.8125rem; /* 13px */
    }
    
    .custom-timetable th:first-child,
    .custom-timetable td:first-child {
        min-width: 70px;
    }
    
    .custom-timetable th span,
    .custom-timetable td span {
        font-size: 0.6875rem; /* 11px */
    }
    
    .mobile-scroll-hint {
        font-size: 0.8125rem;
        padding: 6px 12px;
    }
}

/* Scrollbar styling for better UX */
.custom-timetable::-webkit-scrollbar {
    height: 8px;
}

.custom-timetable::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.custom-timetable::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.custom-timetable::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Improved focus states for accessibility */
.custom-timetable:focus {
    outline: 2px solid var(--color-primary, #86b472);
    outline-offset: 2px;
}

/* Animation for better user experience */
.custom-timetable {
    transition: box-shadow 0.3s ease;
}

.custom-timetable:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}