:root {
    font-size: 16px;
}

/* Mobile and touch device styles */
@media (hover: none), (max-width: 768px) {
    :root {
        font-size: 12px;
    }
    
    html {
        -webkit-text-size-adjust: none;
        text-size-adjust: none;
    }

    /* Enable horizontal scrolling for table container */
    body {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: 100vw;
    }
    
    /* Adjust cell padding for mobile */
    th,
    td {
        padding: 3px 4px;
        font-size: 12px;
    }

    /* Ensure program column doesn't grow too wide */
    td:last-child {
        max-width: 140px;
        overflow-wrap: break-word;
        word-wrap: break-word;
        hyphens: auto;
    }
}

table {
    border-collapse: collapse;
    font-family: Arial, sans-serif;
    font-size: 1rem;
    width: 100%;
}

th,
td {
    border: 1px solid #ddd;
    padding: 4px 6px;
    text-align: left;
}

/* Sticky header container */
thead {
    position: sticky;
    top: 0;
    z-index: 1;
    background-color: #f1f1f1;
}

@media (hover: none), (max-width: 768px) {
    .github-corner svg {
        width: 40px !important;
        height: 40px !important;
    }
}

@media print {
    thead {
        position: static;
        top: auto;
        z-index: auto;
        display: table-row-group;
        break-after: avoid;
        break-before: page;
    }
}

th {
    background-color: #f1f1f1;
    text-align: center;
}

/* Add a subtle shadow to make the sticky header more visible */
tr:has(th) {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 10%);
}

/* First column (time) should be no wider than content */
td:first-child,
th:first-child {
    width: 1%;
    white-space: nowrap;
}

.channel-name {
    font-weight: bold;
    font-size: 1rem;
}

.program-time {
    font-weight: bold;
}

.program-title {
    font-style: italic;
}

.drawer {
    position: fixed;
    bottom: 0;
    right: 20px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px 8px 0 0;
    box-shadow: 0 0 10px rgba(0, 0, 0, 10%);
    transition: transform 0.3s ease;
    transform: translateY(calc(100% - 40px));
    z-index: 1000;
}

.drawer.open {
    transform: translateY(0);
}

.drawer-tab {
    padding: 10px 20px;
    background: #f1f1f1;
    cursor: pointer;
    border-radius: 8px 8px 0 0;
    font-weight: bold;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.drawer-tab:hover {
    background: #e5e5e5;
}

.hidden-count {
    text-align: center;
    flex-grow: 1;
    min-width: 120px;
    padding: 0 30px;
}

.globe-icon {
    position: absolute;
    right: 20px;
}

.drawer-arrow {
    position: absolute;
    left: 20px;
    transition: transform 0.3s ease;
}

.drawer.open .drawer-tab::before {
    transform: rotate(180deg);
}

.drawer-content {
    padding: 10px;
    max-height: 300px;
    overflow-y: auto;
}

.language-toggle {
    text-align: right;
    margin-bottom: 10px;
}

.language-toggle button {
    margin-left: 8px;
}

.hidden {
    display: none;
}

.program-cell {
    cursor: pointer;
    position: relative;
}

.program-cell:hover {
    background-color: #f5f5f5;
}

/* Show hide/show text on hover for table cells */
.program-cell:hover::after {
    content: attr(data-action);
    position: absolute;
    right: 8px;
    color: #666;
    font-size: 0.8em;
}

/* Style for hidden programs list items */
#hidden-programs {
    text-size-adjust: 100%;
}

#hidden-programs li {
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    position: relative;
    font-size: 0.875rem;
    line-height: 1.4;
}

#hidden-programs li:hover {
    background-color: #f5f5f5;
}

#hidden-programs li:hover::after {
    content: attr(data-action);
    position: absolute;
    right: 8px;
    color: #666;
    font-size: 0.8em;
}

/* Current time and week highlighting */

/* Time highlighting */
tr.current-time {
    background-color: rgba(255, 243, 224, 30%); /* Light orange background */
}

@media print {
    tr.current-time {
        display: none;
    }
}

/* Week highlighting */
td.current-week {
    background-color: rgba(232, 245, 233, 30%); /* Light green background */
}

@media print {
    td.current-week:not(.marked) {
        background-color: transparent !important;
    }

    td.current-week.marked {
        background-color: #f8f8f8 !important;
    }
}

/* Marked program */
td.marked {
    background-color: #f8f8f8;
    color: #2e7d32;
    font-weight: bold;
    text-align: center;
}

/* Marked program in current time row */
tr.current-time td.marked {
    background-color: rgba(255, 243, 224, 80%); /* Stronger orange */
}

/* Marked program in current week */
td.current-week.marked {
    background-color: rgba(232, 245, 233, 80%); /* Stronger green */
}

/* Marked program at current time in current week */
tr.current-time td.current-week.marked {
    background-color: #4caf50; /* Prominent green */
    color: white;
    font-weight: bold;
    box-shadow: 0 0 4px rgba(0, 0, 0, 20%);
}

@media print {
    /* Hide the hidden programs section and GitHub corner when printing */
    .hidden-programs,
    .drawer,
    .github-corner {
        display: none !important;
    }

    /* Force page break before each weekday section */
    thead {
        break-before: page;
    }

    /* Remove pointer and color from toggle buttons when printing */
    .toggle-btn {
        cursor: default;
        color: black;
        text-decoration: none;
    }
}
