/* =========================================================
   图灵码字 - 全局样式表（手机端极简侧边栏优化版）
   ========================================================= */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Microsoft YaHei", "PingFang SC", sans-serif;
    color: #2d3436;
    background: #f6f5fb;
    min-height: 100vh;
}

/* ========== 登录/注册/找回密码 ========== */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, #6c5ce7 0%, #a29bfe 100%);
}
.auth-card {
    width: 100%;
    max-width: 400px;
    background: #fff;
    border-radius: 16px;
    padding: 40px 32px;
    box-shadow: 0 20px 50px rgba(108, 92, 231, 0.25);
}
.auth-title { font-size: 24px; font-weight: 700; margin-bottom: 6px; text-align: center; }
.auth-subtitle { font-size: 14px; color: #999; text-align: center; margin-bottom: 28px; }

.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 13px; color: #636e72; margin-bottom: 6px; }
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    font-size: 15px;
    font-family: inherit;
    transition: border-color 0.2s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #6c5ce7;
    box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.1);
}

.code-row { display: flex; gap: 8px; }
.code-row input { flex: 1; }

.btn-secondary {
    white-space: nowrap; padding: 0 14px; border: 1px solid #6c5ce7;
    background: #fff; color: #6c5ce7; border-radius: 10px; font-size: 13px; cursor: pointer;
    transition: background 0.2s;
}
.btn-secondary:hover { background: #f0eefe; }
.btn-secondary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary.small { padding: 6px 14px; font-size: 13px; border-radius: 20px; }

.btn-primary {
    display: inline-block; padding: 12px 30px; border: none; border-radius: 10px;
    background: linear-gradient(135deg, #6c5ce7, #a29bfe); color: #fff;
    font-size: 15px; font-weight: 600; cursor: pointer; text-align: center;
    text-decoration: none; transition: opacity 0.2s;
}
.btn-primary:hover { opacity: 0.9; }

.btn-danger.small {
    padding: 6px 14px; font-size: 13px; border-radius: 20px;
    background: #d63031; color: #fff; border: none; cursor: pointer; text-decoration: none;
    display: inline-block;
}
.btn-danger.small:hover { opacity: 0.9; }

.auth-footer { margin-top: 20px; text-align: center; font-size: 14px; color: #999; }
.auth-links { margin-top: 20px; display: flex; justify-content: space-between; font-size: 14px; }
a { color: #6c5ce7; text-decoration: none; }
a:hover { text-decoration: underline; }

.alert { padding: 10px 14px; border-radius: 8px; font-size: 14px; margin-bottom: 16px; }
.alert-error { background: #ffeaea; color: #d63031; }
.alert-success { background: #e8f9ee; color: #00b894; }
.alert-warning { background: #fff8e1; color: #e67e22; }

/* ========== 前台主布局（电脑端） ========== */
.app-wrapper { display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
    flex-shrink: 0; height: 60px; background: #fff; border-bottom: 1px solid #eee;
    display: flex; align-items: center; justify-content: space-between; padding: 0 24px;
    position: sticky; top: 0; z-index: 100;
}
.topbar .logo { font-size: 22px; font-weight: 700; color: #6c5ce7; }
.topbar .user-info { display: flex; align-items: center; gap: 16px; font-size: 14px; }
.topbar .logout-btn {
    padding: 4px 14px; background: #f0edf9; color: #6c5ce7;
    border-radius: 20px; font-size: 13px; text-decoration: none;
}
.topbar .logout-btn:hover { background: #e0daf5; text-decoration: none; }

.app-body { display: flex; flex: 1; overflow: hidden; }

.sidebar {
    width: 200px; flex-shrink: 0; background: #fff; border-right: 1px solid #eee;
    padding: 20px 0; overflow-y: auto; height: calc(100vh - 60px);
    position: sticky; top: 60px;
}
.menu-item {
    display: flex; align-items: center; gap: 12px; padding: 12px 20px;
    color: #333; text-decoration: none; font-size: 15px; transition: all 0.2s;
    border-left: 3px solid transparent;
}
.menu-item:hover { background: #f0eefe; text-decoration: none; border-left-color: #a29bfe; }
.menu-item.active { background: #f0eefe; color: #6c5ce7; font-weight: 600; border-left-color: #6c5ce7; }
.menu-item .icon { font-size: 20px; width: 24px; text-align: center; }

.main-content {
    flex: 1; padding: 24px 30px; overflow-y: auto; height: calc(100vh - 60px); background: #f6f5fb;
}
.content-body { max-width: 100%; }

/* 通用卡片 / 统计 / 列表 */
.card, .placeholder-page {
    background: #fff; border-radius: 16px; padding: 24px; margin-bottom: 20px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
}
.card h3 { margin-bottom: 16px; padding-bottom: 12px; border-bottom: 2px solid #f0edf9; }

.stats-row { display: flex; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.stat-item { background: #fff; padding: 10px 20px; border-radius: 30px; font-size: 14px; border: 1px solid #eee; }

.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 10px; }
.toolbar h2 { margin: 0; font-size: 22px; }

/* 书籍网格 */
.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 20px; margin-top: 16px; }
.book-card {
    background: #fff; border-radius: 14px; overflow: hidden; box-shadow: 0 3px 12px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s, box-shadow 0.2s; display: flex; flex-direction: column;
}
.book-card:hover { transform: translateY(-4px); box-shadow: 0 8px 25px rgba(108, 92, 231, 0.1); }
.book-cover { padding: 16px 14px 12px; color: #fff; min-height: 80px; display: flex; flex-direction: column; justify-content: space-between; }
.book-title { font-size: 17px; font-weight: 700; line-height: 1.3; text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); }
.book-meta-tag { align-self: flex-start; background: rgba(255, 255, 255, 0.25); padding: 1px 10px; border-radius: 20px; font-size: 10px; margin-top: 4px; }
.book-info { padding: 10px 14px 12px; flex: 1; display: flex; flex-direction: column; }
.book-desc { font-size: 12px; color: #666; margin-bottom: 10px; flex: 1; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.book-actions { display: flex; gap: 4px; flex-wrap: wrap; }

/* 日历 */
.calendar-wrapper { background: #fff; border-radius: 14px; padding: 12px 14px 10px; margin: 14px 0 18px; box-shadow: 0 2px 10px rgba(108, 92, 231, 0.06); }
.calendar-header { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.cal-nav { color: #6c5ce7; text-decoration: none; font-size: 18px; padding: 0 6px; line-height: 1; }
.cal-title { font-weight: 600; font-size: 15px; flex: 1; }
.cal-stats { font-size: 12px; color: #999; margin-left: auto; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-weekday { text-align: center; font-size: 11px; color: #999; padding: 3px 0; font-weight: 500; }
.cal-day { text-align: center; padding: 4px 2px; border-radius: 8px; font-size: 12px; min-height: 36px; display: flex; flex-direction: column; justify-content: center; align-items: center; }
.cal-day-num { font-weight: 600; font-size: 13px; line-height: 1.2; }
.cal-day-words { font-size: 8px; margin-top: 1px; opacity: 0.7; line-height: 1; }

/* 返回按钮 */
.back-link {
    display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px;
    padding: 0; background: #f0edf9; border-radius: 50%; font-size: 0; text-decoration: none; transition: all 0.2s;
}
.back-link:hover { background: #e0daf5; transform: scale(1.05); }
.back-link::before { content: ""; display: inline-block; width: 24px; height: 24px; background: url("../images/icons/back-arrow.png") no-repeat center; background-size: contain; }

/* ========== 管理后台（电脑端） ========== */
.admin-wrapper { display: flex; flex-direction: column; min-height: 100vh; }
.admin-topbar { background: #2d3436; color: #fff; padding: 12px 24px; display: flex; justify-content: space-between; align-items: center; flex-shrink: 0; }
.admin-topbar a { color: #ddd; text-decoration: none; }
.admin-topbar a:hover { color: #fff; }
.admin-body { display: flex; flex: 1; overflow: hidden; }
.admin-sidebar { width: 200px; background: #2d3436; padding: 20px 0; flex-shrink: 0; overflow-y: auto; }
.admin-sidebar a { display: block; padding: 10px 20px; color: #ccc; text-decoration: none; transition: background 0.2s; }
.admin-sidebar a:hover { background: #3d3d3d; color: #fff; }
.admin-sidebar a.active { background: #6c5ce7; color: #fff; }
.admin-content { flex: 1; padding: 24px; background: #f6f5fb; overflow-y: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid #eee; font-size: 14px; }
th { background: #f8f7fc; }

/* =========================================================
   📱 手机端专属优化（极简左侧图标栏）
   ========================================================= */
@media screen and (max-width: 768px) {
    /* ========== 全局 ========== */
    body { -webkit-tap-highlight-color: transparent; }

    /* ========== 前台顶部导航 ========== */
    .topbar { padding: 0 12px; height: 54px; }
    .topbar .logo { font-size: 18px; }
    .topbar .user-info { gap: 8px; font-size: 13px; }
    .topbar .user-info > span { display: none; } /* 隐藏昵称 */
    .topbar .logout-btn { padding: 4px 10px; font-size: 12px; }

    /* ========== 前台主体：极简图标左侧边栏 ========== */
    .app-body {
        flex-direction: row; /* 保持左右结构 */
    }
    
    .sidebar {
        width: 60px; /* 侧边栏极窄，只显示图标 */
        flex-shrink: 0;
        display: flex;
        flex-direction: column;
        padding: 10px 0;
        background: #fff;
        border-right: 1px solid #eee;
        position: static;
        height: auto;
        overflow-y: visible;
    }

    .menu-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 12px 0;
        font-size: 0; /* 隐藏文字 */
        border-left: none;
        border-radius: 0;
        background: transparent;
        margin: 0;
        text-align: center;
    }
    .menu-item .icon {
        font-size: 22px;
        width: auto;
        margin: 0;
        line-height: 1;
    }
    .menu-item.active {
        background: #f0eefe;
        border-left: 3px solid #6c5ce7;
    }

    /* ========== 前台主内容区 ========== */
    .main-content { 
        flex: 1;
        padding: 12px; 
        height: auto; 
        overflow-y: visible; 
    }

    /* 卡片和统计 */
    .card, .placeholder-page { padding: 16px; border-radius: 12px; margin-bottom: 12px; }
    .card h3 { font-size: 16px; margin-bottom: 12px; padding-bottom: 8px; }
    .stats-row { flex-direction: column; gap: 8px; margin-bottom: 12px; }
    .stat-item { width: 100%; text-align: center; padding: 8px 14px; font-size: 13px; }
    .toolbar h2 { font-size: 18px; }
    .toolbar .btn-primary { width: 100%; text-align: center; padding: 10px; }

    /* 书籍卡片 */
    .book-grid { grid-template-columns: 1fr; gap: 12px; }
    .book-card { border-radius: 12px; }
    .book-cover { min-height: 70px; padding: 12px 14px 10px; }
    .book-title { font-size: 16px; }
    .book-actions { justify-content: flex-end; }

    /* 日历 */
    .calendar-wrapper { padding: 10px; }
    .calendar-grid { gap: 2px; }
    .cal-day { padding: 4px 2px; min-height: 32px; border-radius: 6px; }
    .cal-day-num { font-size: 12px; }
    .cal-day-words { font-size: 7px; }
    .cal-weekday { font-size: 10px; }

    /* 表单和按钮 */
    .form-group input, .form-group select, .form-group textarea { font-size: 14px; padding: 10px 12px; }
    .btn-primary { padding: 10px 20px; font-size: 14px; }

    /* ========== 管理后台：极简图标左侧边栏 ========== */
    .admin-topbar { padding: 8px 12px; flex-wrap: wrap; gap: 6px; height: auto; }
    .admin-topbar > div:first-child { font-size: 16px; }
    .admin-topbar a, .admin-topbar span { font-size: 12px; }
    .admin-topbar .back-home { padding: 4px 8px !important; font-size: 12px !important; }

    .admin-body { flex-direction: row; }
    .admin-sidebar {
        width: 60px; /* 极窄边栏，只显示图标 */
        flex-shrink: 0;
        display: flex;
        flex-direction: column;
        padding: 10px 0;
        background: #2d3436;
        overflow-y: visible;
    }
    
    .admin-sidebar a {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 12px 0;
        font-size: 0; /* 隐藏文字 */
        margin: 0;
        border-radius: 0;
        background: transparent;
    }
    .admin-sidebar a .icon { font-size: 22px; margin: 0; }
    .admin-sidebar a.active { background: #6c5ce7; }

    /* 后台内容区 */
    .admin-content { flex: 1; padding: 10px; overflow-x: hidden; }

    /* 后台表格：横向滑动防挤压 */
    .card { overflow-x: auto; }
    table { min-width: 100%; font-size: 13px; }
    th, td { padding: 8px 10px; font-size: 13px; white-space: nowrap; }
}

/* 超小屏（≤480px）进一步收紧 */
@media screen and (max-width: 480px) {
    .topbar { padding: 0 10px; height: 50px; }
    .topbar .logo { font-size: 16px; }
    .main-content { padding: 10px; }
    .card, .placeholder-page { padding: 14px; }
    .toolbar h2 { font-size: 17px; }
    .cal-day { min-height: 28px; padding: 2px 1px; font-size: 11px; }
    .cal-day-num { font-size: 11px; }
    .cal-day-words { font-size: 6px; }
    .cal-stats { font-size: 10px; }
    .book-cover { min-height: 60px; padding: 10px 12px 8px; }
    .book-title { font-size: 15px; }
    .book-desc { font-size: 11px; }
    .sidebar { width: 50px; }
    .menu-item .icon { font-size: 20px; }
    .admin-sidebar { width: 50px; }
    .admin-sidebar a .icon { font-size: 20px; }
}