/* ============================================================
 * withU 首页课表模块（与轻屿课表 App 周视图一致）
 * 布局参数对照 mikcb timetable_screen.dart：
 *   表头高 40 / 节次行高 68 / 时间列宽 34 / 课程卡圆角 8
 *   今日强调色 #3482FF（HyperOS 主题 primary）
 * ============================================================ */

.withu-tt-card {
    position: relative;
    background: #ffffff;
    border-radius: 1.5rem;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.04), 0 25px 50px -12px rgba(0, 0, 0, 0.18);
    padding: 20px 20px 24px;
    overflow: hidden;
    user-select: none;
}

/* 登录后才能看到（服务端已 gate）；未登录或数据未就绪时隐藏 */
.withu-tt-card.is-hidden {
    display: none;
}

/* ---------- 切换双方课表的分段控件（放在 section 头部右侧） ---------- */
.withu-tt-tabs {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(0, 0, 0, 0.055);
    border-radius: 999px;
    padding: 3px;
}

.withu-tt-tab {
    appearance: none;
    border: 0;
    background: transparent;
    color: rgba(0, 0, 0, 0.55);
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    padding: 7px 14px;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
    max-width: 120px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.withu-tt-tab:hover {
    color: rgba(0, 0, 0, 0.75);
}

.withu-tt-tab.is-active {
    background: #3482ff;
    color: #ffffff;
    box-shadow: 0 2px 6px -1px rgba(52, 130, 255, 0.5);
}

.withu-tt-tab.is-disabled {
    opacity: 0.45;
    cursor: default;
}

/* ---------- 页面背景调节 ---------- */
.withu-tt-header-actions {
    position: relative;
    gap: 0.5rem;
}

.withu-tt-bg-btn {
    appearance: none;
    border: 0;
    width: 38px;
    height: 38px;
    flex: none;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(52, 130, 255, 0.1);
    color: #3482ff;
    cursor: pointer;
    transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.withu-tt-bg-btn:hover,
.withu-tt-bg-btn[aria-expanded="true"] {
    background: #3482ff;
    color: #ffffff;
}

.withu-tt-bg-btn:active {
    transform: scale(0.94);
}

.withu-tt-bg-btn i {
    font-size: 18px;
    line-height: 1;
}

.withu-tt-bg-popover {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: min(300px, calc(100vw - 24px));
    z-index: 1200;
    padding: 16px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.97);
    box-shadow: 0 18px 45px -12px rgba(15, 23, 42, 0.28), 0 0 0 1px rgba(15, 23, 42, 0.06);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    color: #172033;
    animation: withu-tt-bg-pop-in 0.16s ease;
}

@keyframes withu-tt-bg-pop-in {
    from { opacity: 0; transform: translateY(-5px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.withu-tt-bg-popover__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.withu-tt-bg-popover__title {
    font-size: 13px;
    font-weight: 700;
}

.withu-tt-bg-popover__close {
    appearance: none;
    border: 0;
    width: 28px;
    height: 28px;
    flex: none;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.06);
    color: rgba(15, 23, 42, 0.62);
    cursor: pointer;
}

.withu-tt-bg-popover__close:hover {
    background: rgba(15, 23, 42, 0.12);
    color: rgba(15, 23, 42, 0.9);
}

.withu-tt-bg-field + .withu-tt-bg-field {
    margin-top: 14px;
}

.withu-tt-bg-field__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.withu-tt-bg-field__label {
    font-size: 12px;
    font-weight: 600;
    color: rgba(15, 23, 42, 0.78);
}

.withu-tt-bg-field__value {
    min-width: 48px;
    padding: 3px 7px;
    border-radius: 999px;
    background: rgba(52, 130, 255, 0.1);
    color: #3482ff;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    text-align: center;
}

.withu-tt-bg-field input[type="range"] {
    display: block;
    width: 100%;
    margin: 8px 0 0;
    accent-color: #3482ff;
}

.withu-tt-bg-reset {
    appearance: none;
    border: 0;
    width: 100%;
    margin-top: 16px;
    padding: 9px 12px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    background: rgba(15, 23, 42, 0.06);
    color: rgba(15, 23, 42, 0.72);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.withu-tt-bg-reset:hover {
    background: rgba(15, 23, 42, 0.12);
    color: rgba(15, 23, 42, 0.92);
}

.withu-tt-bg-reset i {
    font-size: 15px;
    line-height: 1;
}

/* ---------- 加载 / 空状态 ---------- */
.withu-tt-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 180px;
    color: rgba(0, 0, 0, 0.45);
    font-size: 13px;
}

.withu-tt-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(0, 0, 0, 0.12);
    border-top-color: #3482ff;
    border-radius: 50%;
    animation: withu-tt-spin 0.8s linear infinite;
}

@keyframes withu-tt-spin {
    to { transform: rotate(360deg); }
}

.withu-tt-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 220px;
    color: rgba(0, 0, 0, 0.45);
    font-size: 13px;
    text-align: center;
    padding: 0 24px;
    line-height: 1.6;
}

.withu-tt-empty-icon {
    font-size: 34px;
    color: rgba(0, 0, 0, 0.18);
}

/* ---------- 周视图骨架 ---------- */
.withu-tt-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: relative;
}

/* 周导航：左右圆钮悬浮在网格两侧，回本周胶囊浮在右上 */
.withu-tt-nav {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3;
}

.withu-tt-nav.is-prev { left: -14px; }
.withu-tt-nav.is-next { right: -14px; }

.withu-tt-nav button {
    appearance: none;
    border: 0;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92);
    color: rgba(0, 0, 0, 0.65);
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.14);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.withu-tt-nav button:hover {
    background: #3482ff;
    color: #fff;
    transform: scale(1.06);
}

.withu-tt-nav button:active {
    transform: scale(0.94);
}

.withu-tt-back-week {
    position: absolute;
    top: -4px;
    right: 0;
    z-index: 3;
    appearance: none;
    border: 0;
    background: rgba(52, 130, 255, 0.1);
    color: #3482ff;
    font-size: 11px;
    font-weight: 700;
    padding: 6px 12px;
    border-radius: 999px;
    cursor: pointer;
    transition: opacity 0.2s ease, background 0.15s ease;
}

.withu-tt-back-week:hover {
    background: rgba(52, 130, 255, 0.18);
}

/* 星期表头：左侧周次格 + 7 个天格（高 40） */
.withu-tt-header {
    display: flex;
    align-items: stretch;
    position: relative;
}

.withu-tt-header-week {
    width: 34px;
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px 2px 4px 6px;
    font-size: 11px;
    font-weight: 800;
    color: rgba(0, 0, 0, 0.8);
    cursor: pointer;
    border-radius: 10px;
}

.withu-tt-header-week:hover {
    background: rgba(0, 0, 0, 0.05);
}

.withu-tt-header-days {
    flex: 1;
    display: flex;
}

.withu-tt-header-day {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 3px 0;
    position: relative;
    min-width: 0;
}

.withu-tt-header-day__label {
    font-size: 10px;
    font-weight: 600;
    color: rgba(0, 0, 0, 0.72);
    line-height: 1.1;
}

.withu-tt-header-day__date {
    font-size: 8.5px;
    color: rgba(0, 0, 0, 0.42);
    line-height: 1.1;
}

.withu-tt-header-day.is-today::after {
    content: '';
    position: absolute;
    left: 20%;
    right: 20%;
    bottom: 0;
    height: 2px;
    border-radius: 999px;
    background: rgba(52, 130, 255, 0.35);
}

.withu-tt-header-day.is-today .withu-tt-header-day__label {
    color: #3482ff;
    font-weight: 800;
}

.withu-tt-header-day.is-today .withu-tt-header-day__date {
    color: rgba(52, 130, 255, 0.78);
}

/* 表体：时间列 + 7 个日列 */
.withu-tt-body-row {
    display: flex;
}

.withu-tt-time-col {
    width: 34px;
    flex: none;
}

.withu-tt-time-cell {
    height: 68px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
}

.withu-tt-time-cell__num {
    font-size: 10px;
    font-weight: 700;
    color: rgba(0, 0, 0, 0.8);
    line-height: 1.05;
}

.withu-tt-time-cell__time {
    font-size: 7.5px;
    color: rgba(0, 0, 0, 0.42);
    line-height: 1.05;
}

.withu-tt-day-col {
    flex: 1;
    min-width: 0;
    position: relative;
    margin-left: 2px;
}

/* 行分隔线（对齐 App 的 HyperOS dividerLine） */
.withu-tt-day-col::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.055) 1px, transparent 1px);
    background-size: 100% 68px;
    pointer-events: none;
}

.withu-tt-day-col::after {
    content: '';
    position: absolute;
    inset: 0 0 0 -2px;
    border-left: 1px solid rgba(0, 0, 0, 0.055);
    pointer-events: none;
}

/* ---------- 课程卡片（compact 卡：圆角 8、渐变、白字） ---------- */
.withu-tt-course {
    position: absolute;
    left: 0;
    right: 0;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: filter 0.12s ease, transform 0.12s ease;
}

.withu-tt-course:hover {
    filter: brightness(1.08);
    transform: scale(1.015);
    z-index: 4;
}

.withu-tt-course__inner {
    width: 100%;
    height: 100%;
    padding: 6px 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    overflow: hidden;
}

.withu-tt-course__name {
    font-size: 9px;
    font-weight: 700;
    line-height: 1.15;
    text-align: center;
    word-break: break-all;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.withu-tt-course__sub {
    font-size: 8px;
    line-height: 1.1;
    text-align: center;
    opacity: 0.92;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.withu-tt-course__sub.is-teacher {
    opacity: 0.85;
}

/* 课程时段天气（周视图 compact 密度：图标 + 温度优先的一项文字） */
.withu-tt-course__weather {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1px;
    max-width: 100%;
    font-size: 8px;
    line-height: 1.1;
    white-space: nowrap;
    opacity: 0.95;
}

.withu-tt-course__weather i {
    font-size: 9px;
    line-height: 1;
    flex: none;
}

.withu-tt-course__weather span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 同日冲突课：背景压暗（App timetableConflictCourseOpacity=0.7，由渐变透明度实现），
   名称上方加「冲突」小字，右上角红色角标 */
.withu-tt-course__over {
    font-size: 7px;
    line-height: 1.05;
    text-align: center;
    opacity: 0.85;
}

.withu-tt-course__badge {
    position: absolute;
    top: 6px;
    right: 6px;
    padding: 2px 6px;
    border-radius: 999px;
    background: #e53935;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    line-height: 1.2;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.16);
}

/* ---------- 课程详情弹层 ---------- */
.withu-tt-pop {
    position: fixed;
    z-index: 9999;
    background: rgba(30, 30, 30, 0.55);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-radius: 16px;
    color: #fff;
    padding: 14px 16px;
    width: 260px;
    box-shadow: 0 20px 50px -12px rgba(0, 0, 0, 0.45);
    animation: withu-tt-pop-in 0.18s cubic-bezier(0.2, 0.8, 0.3, 1);
    will-change: transform, opacity;
}

@keyframes withu-tt-pop-in {
    from { opacity: 0; transform: translateY(8px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes withu-tt-pop-in-up {
    from { opacity: 0; transform: translateY(-8px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes withu-tt-pop-out {
    to { opacity: 0; transform: translateY(6px) scale(0.97); }
}

@keyframes withu-tt-pop-out-up {
    to { opacity: 0; transform: translateY(-6px) scale(0.97); }
}

.withu-tt-pop--above {
    transform-origin: bottom center;
    animation-name: withu-tt-pop-in-up;
}

.withu-tt-pop--below {
    transform-origin: top center;
}

.withu-tt-pop.is-closing {
    pointer-events: none;
    animation: withu-tt-pop-out 0.16s cubic-bezier(0.4, 0, 1, 1) forwards;
}

.withu-tt-pop--above.is-closing {
    animation-name: withu-tt-pop-out-up;
}

@media (prefers-reduced-motion: reduce) {
    .withu-tt-pop,
    .withu-tt-pop.is-closing {
        animation: none;
    }
}

.withu-tt-pop__title {
    font-size: 14px;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 8px;
    word-break: break-all;
}

.withu-tt-pop__row {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    font-size: 12px;
    line-height: 1.45;
    color: rgba(255, 255, 255, 0.85);
    margin-top: 4px;
}

.withu-tt-pop__row i {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 1px;
}

/* ---------- 桌面端放大约 1.3 倍（保持 App 视觉比例，避免字过小） ---------- */
@media (min-width: 768px) {
    .withu-tt-header-week { font-size: 13px; }
    .withu-tt-header-day__label { font-size: 13px; }
    .withu-tt-header-day__date { font-size: 11px; }
    .withu-tt-time-cell__num { font-size: 13px; }
    .withu-tt-time-cell__time { font-size: 9.5px; }
    .withu-tt-course__name { font-size: 12px; }
    .withu-tt-course__sub { font-size: 10.5px; }
    .withu-tt-course__over { font-size: 9px; }
    .withu-tt-course__badge { top: 8px; right: 8px; font-size: 11px; }
}

/* 超窄屏（<380px）时间列收窄，标题字号同步压缩 */
@media (max-width: 379px) {
    .withu-tt-card { padding: 14px 12px 18px; }
    .withu-tt-time-col,
    .withu-tt-header-week { width: 30px; }
    .withu-tt-nav.is-prev { left: -10px; }
    .withu-tt-nav.is-next { right: -10px; }
    .withu-tt-header-actions { gap: 4px; }
    .withu-tt-bg-btn { width: 34px; height: 34px; }
    .withu-tt-bg-popover { right: -2px; width: min(288px, calc(100vw - 16px)); }
}

/* 跟随站内 AOS 进入动画时先隐藏，避免闪现 */
.withu-tt-card[data-aos] {
    opacity: 0;
}

/* 修改记录 */
.withu-tt-history-overlay {
    position: fixed;
    z-index: 9999;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(15, 17, 22, .42);
    backdrop-filter: blur(8px);
}
.withu-tt-history-modal {
    width: min(420px, 100%);
    max-height: min(72vh, 560px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, .14);
    border-radius: 18px;
    background: rgba(24, 25, 30, .94);
    color: #fff;
    box-shadow: 0 22px 60px rgba(0, 0, 0, .34);
}
.withu-tt-history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 17px 18px 12px;
}
.withu-tt-history-close {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 10px;
    color: #fff;
    background: rgba(255, 255, 255, .10);
    cursor: pointer;
}
.withu-tt-history-list {
    min-height: 82px;
    padding: 0 12px 14px;
    overflow: auto;
}
.withu-tt-history-state {
    display: grid;
    min-height: 78px;
    place-items: center;
    color: rgba(255, 255, 255, .62);
    font-size: 13px;
}
.withu-tt-history-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 2px 10px;
    width: 100%;
    margin-bottom: 8px;
    padding: 11px 12px;
    border: 0;
    border-radius: 12px;
    color: #fff;
    text-align: left;
    background: rgba(255, 255, 255, .07);
    cursor: pointer;
}
.withu-tt-history-item:hover:not(:disabled) {
    background: rgba(255, 255, 255, .13);
}
.withu-tt-history-item:disabled {
    opacity: .55;
    cursor: wait;
}
.withu-tt-history-item__title {
    overflow: hidden;
    font-size: 14px;
    font-weight: 650;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.withu-tt-history-item__meta {
    grid-column: 1 / -1;
    overflow: hidden;
    color: rgba(255, 255, 255, .60);
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.withu-tt-history-item > i {
    grid-row: 1;
    grid-column: 2;
    color: rgba(255, 255, 255, .58);
}
