/* ═══════════════════════════════════════════════════════════
   CampusNotifier - 样式表
   ═══════════════════════════════════════════════════════════ */

:root {
    --primary: #1976D2;
    --primary-dark: #1565C0;
    --primary-light: #BBDEFB;
    --accent: #FF6D00;
    --success: #43A047;
    --error: #E53935;
    --bg: #f5f6fa;
    --card-bg: #ffffff;
    --text: #333333;
    --text-light: #888888;
    --border: #e0e0e0;
    --radius: 8px;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: "Microsoft YaHei", "PingFang SC", "Helvetica Neue", sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* ── 页面切换 ─────────────────────── */
.page { display: none; }
.page.active { display: flex; flex-direction: column; min-height: 100vh; }

.hidden { display: none !important; }

/* ── 登录 / 注册卡片 ─────────────── */
#login-page, #register-page {
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1565C0 0%, #42A5F5 100%);
}

.login-card {
    background: white;
    border-radius: 12px;
    padding: 40px 36px;
    width: 400px;
    max-width: 92vw;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}

.login-header {
    text-align: center;
    margin-bottom: 28px;
}
.login-header .logo { font-size: 48px; margin-bottom: 8px; }
.login-header h1 { font-size: 22px; color: var(--primary); }
.login-header p { font-size: 13px; color: var(--text-light); margin-top: 4px; }

.login-footer {
    text-align: center;
    margin-top: 16px;
    font-size: 13px;
    color: var(--text-light);
}
.login-footer a { color: var(--primary); text-decoration: none; }
.login-footer a:hover { text-decoration: underline; }

/* ── 表单 ─────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: #555;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="time"],
textarea,
select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
    background: #fff;
}
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(25,118,210,0.12);
}

textarea { resize: vertical; }

.form-row {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

/* ── 按钮 ─────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
}
.btn:active { transform: scale(0.97); }

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
}
.btn-outline:hover { background: rgba(25,118,210,0.06); }

.btn-danger { background: var(--error); color: white; }
.btn-danger:hover { background: #C62828; }

.btn-block { width: 100%; }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-lg { padding: 12px 32px; font-size: 15px; }

/* ── 顶部导航 ─────────────────────── */
.top-nav {
    display: flex;
    align-items: center;
    background: var(--primary);
    color: white;
    padding: 0 20px;
    height: 52px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    position: sticky;
    top: 0;
    z-index: 100;
    flex-wrap: wrap;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.nav-logo { font-size: 22px; }
.nav-title { font-size: 16px; font-weight: 700; white-space: nowrap; }

.nav-tabs {
    display: flex;
    gap: 2px;
    flex: 1;
    min-width: 0;
    margin: 0 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.nav-tabs::-webkit-scrollbar { display: none; }

.tab-btn {
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.75);
    padding: 14px 16px;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
}
.tab-btn:hover { color: white; background: rgba(255,255,255,0.08); }
.tab-btn.active {
    color: white;
    border-bottom-color: white;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 12px;
}
.user-info {
    font-size: 13px;
    opacity: 0.9;
}
.nav-right .btn-outline {
    color: white;
    border-color: rgba(255,255,255,0.5);
    padding: 4px 12px;
    font-size: 12px;
}
.nav-right .btn-outline:hover {
    background: rgba(255,255,255,0.12);
    border-color: white;
}

/* ── Tab 内容区 ───────────────────── */
.tab-content { display: none; flex: 1; padding: 24px 0; }
.tab-content.active { display: block; }

.container { max-width: 800px; margin: 0 auto; padding: 0 20px; }

/* ── 卡片 ─────────────────────────── */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}
.card h2 { font-size: 18px; margin-bottom: 16px; color: var(--primary-dark); }

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.card-header h2 { margin-bottom: 0; }

/* ── 消息提示 ─────────────────────── */
.error-msg {
    background: #FFEBEE;
    color: var(--error);
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 13px;
    margin-top: 12px;
}
.success-msg {
    background: #E8F5E9;
    color: var(--success);
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 13px;
    margin-top: 12px;
}
.info-msg {
    background: #E3F2FD;
    color: var(--primary);
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 13px;
}

.hint-text {
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 16px;
    line-height: 1.5;
}

/* ── 通知记录列表 ─────────────────── */
.history-list { max-height: 70vh; overflow-y: auto; }

.history-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 0;
    border-bottom: 1px solid #f0f0f0;
}
.history-item:last-child { border-bottom: none; }

.history-icon {
    width: 36px; height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}
.history-icon.normal { background: #E3F2FD; }
.history-icon.urgent { background: #FFF3E0; }

.history-body { flex: 1; min-width: 0; }
.history-content { font-size: 14px; line-height: 1.5; word-break: break-all; }
.history-meta {
    display: flex;
    gap: 16px;
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-light);
}

.status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}
.status-pending { background: #FFF9C4; color: #F9A825; }
.status-delivered { background: #E3F2FD; color: #1976D2; }
.status-played { background: #E8F5E9; color: #43A047; }
.status-confirmed { background: #C8E6C9; color: #2E7D32; }
.status-confirm-required { background: #FFF3E0; color: #E65100; }

.empty-text {
    text-align: center;
    color: var(--text-light);
    padding: 32px 0;
    font-size: 14px;
}

/* ── 教室列表 ─────────────────────── */
.classroom-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid #f0f0f0;
}
.classroom-item:last-child { border-bottom: none; }

.classroom-info { flex: 1; }
.classroom-name { font-weight: 600; font-size: 15px; }
.classroom-token {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 2px;
    font-family: "Consolas", monospace;
    word-break: break-all;
}

.classroom-actions { display: flex; gap: 8px; }

/* ── 时间表 ───────────────────────── */
.schedule-period {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #f5f5f5;
}
.schedule-period:last-child { border-bottom: none; }

.schedule-period input[type="text"] { width: 120px; }
.schedule-period input[type="time"] { width: 130px; }
.schedule-period .btn-sm { padding: 4px 10px; }

/* ── 汉堡按钮 ─────────────────────── */
.hamburger {
    display: none;
    background: transparent;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
}

/* ── 响应式表单行 ─────────────────── */
.form-row-responsive {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.btn-block-mobile { /* 桌面端普通按钮 */ }

.btn-group-inline {
    display: flex;
    gap: 8px;
    align-items: center;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 8px 0;
}
.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}
.label-hidden-mobile { }

/* ── 远程执行 ─────────────────────── */
.remote-output-box {
    background: #1e1e1e;
    color: #d4d4d4;
    font-family: "Consolas", "Courier New", monospace;
    font-size: 13px;
    line-height: 1.5;
    padding: 16px;
    border-radius: 8px;
    max-height: 400px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-all;
    margin-top: 8px;
}
.cmd-history { max-height: 50vh; overflow-y: auto; }
.cmd-history-item {
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background 0.15s;
}
.cmd-history-item:hover { background: #f5f5f5; border-radius: 4px; padding-left: 8px; }
.cmd-history-item:last-child { border-bottom: none; }
.cmd-history-header {
    display: flex;
    gap: 12px;
    font-size: 12px;
    color: var(--text-light);
    align-items: center;
    flex-wrap: wrap;
}
.cmd-history-time { font-family: "Consolas", monospace; }
.cmd-history-classroom {
    background: var(--primary-light);
    color: var(--primary-dark);
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}
.cmd-history-cmd {
    font-family: "Consolas", monospace;
    font-size: 13px;
    color: var(--text);
    margin-top: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── 我的账户 ─────────────────────── */
.account-info {
    background: #FAFAFA;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 8px;
}
.account-row {
    display: flex;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
}
.account-row:last-child { border-bottom: none; }
.account-label {
    width: 100px;
    flex-shrink: 0;
    font-size: 13px;
    color: var(--text-light);
    font-weight: 600;
}
.account-value {
    font-size: 14px;
    color: var(--text);
}

/* ── 弹窗遮罩 ─────────────────────── */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.modal-overlay.hidden { display: none !important; }

.modal-card {
    background: white;
    border-radius: 12px;
    padding: 28px;
    max-width: 420px;
    width: 100%;
    box-shadow: 0 12px 48px rgba(0,0,0,0.2);
    animation: modalIn 0.2s ease;
}
@keyframes modalIn {
    from { opacity: 0; transform: scale(0.92); }
    to   { opacity: 1; transform: scale(1); }
}
.modal-card h3 {
    font-size: 18px;
    margin-bottom: 8px;
    color: var(--primary-dark);
}

/* ── 响应式 ───────────────────────── */

/* ====== 平板及以下 (<= 768px) ====== */
@media (max-width: 768px) {
    /* 汉堡菜单可见 */
    .hamburger { display: block; }

    /* 顶部导航：固定高度的首行 + 展开式菜单 */
    .top-nav {
        flex-wrap: wrap;
        height: auto;
        min-height: 48px;
        padding: 8px 12px;
    }

    .nav-left {
        flex: 0 0 auto;
    }
    .nav-title { display: none; }

    /* 导航菜单默认隐藏 → 展开时全宽显示在导航栏下方 */
    .nav-tabs {
        display: none;
        flex-direction: column;
        width: 100%;
        order: 10;         /* 确保在 nav-right 下方 */
        background: var(--primary-dark);
        border-radius: 8px;
        margin: 8px 0 0 0;
        padding: 4px 0;
        gap: 0;
        overflow: visible;
    }
    .nav-tabs.mobile-open {
        display: flex;
    }
    .tab-btn {
        text-align: left;
        padding: 12px 16px;
        font-size: 14px;
        border-bottom: none;
        border-left: 3px solid transparent;
        white-space: nowrap;
    }
    .tab-btn.active {
        border-bottom: none;
        border-left-color: white;
        background: rgba(255,255,255,0.10);
    }

    /* 右侧用户信息/退出按钮 */
    .nav-right {
        margin-left: auto;
        flex-shrink: 0;
    }
    .user-info { display: none; }

    /* 内容区 */
    .container { padding: 0 12px; }
    .card { padding: 16px; }
    .card h2 { font-size: 16px; }
    .tab-content { padding: 16px 0; }

    /* 表单 */
    .form-row,
    .form-row-responsive {
        flex-direction: column;
    }
    .form-row-responsive > * {
        width: 100% !important;
        min-width: 0 !important;
    }
    .label-hidden-mobile { display: none; }
    .btn-block-mobile { width: 100%; }

    .login-card { padding: 28px 20px; }

    /* 教室/用户列表项 */
    .classroom-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    .classroom-actions {
        width: 100%;
        justify-content: flex-end;
    }

    /* 通知历史元数据换行 */
    .history-meta {
        flex-wrap: wrap;
        gap: 8px;
    }

    /* 课程时间表行 */
    .schedule-period {
        flex-wrap: wrap;
        gap: 8px;
    }
    .schedule-period input[type="text"] { flex: 1; min-width: 80px; width: auto; }
    .schedule-period input[type="time"] { flex: 0 0 auto; width: 110px; }

    /* 卡片头部按钮 */
    .card-header {
        flex-wrap: wrap;
        gap: 8px;
    }

    /* 远程输出框 */
    .remote-output-box {
        font-size: 11px;
        padding: 12px;
        max-height: 300px;
    }
}

/* ====== 小屏手机 (<= 480px) ====== */
@media (max-width: 480px) {
    .login-card {
        padding: 24px 16px;
        border-radius: 8px;
    }
    .login-header .logo { font-size: 40px; }
    .login-header h1 { font-size: 18px; }

    .btn-lg { padding: 12px 24px; font-size: 14px; }

    .card { padding: 14px; margin-bottom: 14px; }

    /* 所有按钮增大触摸热区 */
    .btn-sm { min-height: 36px; padding: 8px 14px; }
    .btn { min-height: 44px; }

    .modal-card { padding: 20px 16px; }

    .account-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
    }
    .account-label { width: auto; }
}
