/* ============================================
   common.css — 班级通讯录全局样式
   ============================================ */

/* ---------- CSS 变量 / 设计令牌 ---------- */
:root {
    --primary: #0d6efd;
    --primary-dark: #0b5ed7;
    --success: #198754;
    --danger: #dc3545;
    --warning: #ffc107;
    --info: #0dcaf0;
    --bg-body: #f0f2f5;
    --bg-white: #ffffff;
    --text-dark: #212529;
    --text-muted: #6c757d;
    --border-color: #dee2e6;
    --radius: 0.5rem;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
             "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
    --header-h: 60px;
    --transition: 0.2s ease;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: var(--font);
    background: var(--bg-body);
    color: var(--text-dark);
    min-height: 100vh;
    margin: 0;
}

/* ---------- Header ---------- */
.app-header {
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    height: var(--header-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 1020;
}
.app-header .app-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary);
}
.app-header .app-title i {
    margin-right: 8px;
}

/* ---------- Header：用户信息 ---------- */
.header-user {
    display: flex;
    align-items: center;
    gap: 4px;
}
.header-user .header-user-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-dark);
    white-space: nowrap;
}
.header-user .header-user-name i {
    margin-right: 4px;
    color: var(--primary);
}
.header-user #btnLogout {
    font-size: 0.8rem;
    padding: 2px 10px;
    transition: all var(--transition);
}
.header-user #btnLogout:hover {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}

/* ---------- 主内容区 ---------- */
.app-content {
    max-width: 1200px;
    margin: 24px auto;
    padding: 0 16px;
}

/* ---------- 工具栏 ---------- */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.toolbar .search-box {
    max-width: 420px;
    flex: 1;
    min-width: 200px;
}
.toolbar .search-box .input-group-text {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-right: none;
}
.toolbar .search-box input {
    border: 1px solid var(--border-color);
    border-left: none;
    height: 40px;
}
.toolbar .search-box input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(13,110,253,0.15);
}
.toolbar .search-box input:focus ~ .input-group-text {
    border-color: var(--primary);
}
.toolbar .search-box #btnSearch {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

/* ---------- 表格容器 ---------- */
.table-card {
    background: var(--bg-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}
.table-card .table {
    margin-bottom: 0;
}
.table-card .table th {
    background: #f8f9fa;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
    padding: 12px 16px;
}
.table-card .table td {
    vertical-align: middle;
    padding: 12px 16px;
    font-size: 0.9rem;
}
.table-card tbody tr {
    transition: background var(--transition);
    cursor: pointer;
}
.table-card tbody tr:hover {
    background: rgba(13,110,253,0.03);
}
.table-card tbody tr:last-child td {
    border-bottom: none;
}

/* ---------- 操作按钮 ---------- */
.action-btn {
    padding: 4px 10px;
    font-size: 0.8rem;
    border-radius: var(--radius);
    border: 1px solid transparent;
    background: transparent;
    transition: all var(--transition);
    cursor: pointer;
}
.action-btn:hover {
    transform: translateY(-1px);
}
.action-btn.edit-btn {
    color: var(--primary);
    border-color: var(--primary);
}
.action-btn.edit-btn:hover {
    background: var(--primary);
    color: #fff;
}
.action-btn.delete-btn {
    color: var(--danger);
    border-color: var(--danger);
}
.action-btn.delete-btn:hover {
    background: var(--danger);
    color: #fff;
}
.action-btn.detail-btn {
    color: var(--info);
    border-color: var(--info);
}
.action-btn.detail-btn:hover {
    background: var(--info);
    color: #fff;
}

/* ---------- 分页 ---------- */
.pagination-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 8px;
}
.pagination-info {
    font-size: 0.85rem;
    color: var(--text-muted);
}
.pagination .page-link {
    border-radius: var(--radius);
    margin: 0 2px;
    color: var(--text-dark);
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    font-size: 0.85rem;
    cursor: pointer;
}
.pagination .page-link:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.pagination .page-item.active .page-link {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.pagination .page-item.disabled .page-link {
    color: var(--text-muted);
    pointer-events: none;
    opacity: 0.5;
}

/* ---------- 模态框覆盖 ---------- */
.contact-modal .modal-dialog {
    max-width: 420px;
    margin: 0.5rem auto;
}
.contact-modal .modal-header {
    background: var(--primary);
    color: #fff;
    border-bottom: none;
    padding: 12px 18px;
}
.contact-modal .modal-header .btn-close {
    filter: brightness(0) invert(1);
}
.contact-modal .modal-body {
    padding: 18px 20px;
}
.contact-modal .modal-footer {
    border-top: none;
    padding: 12px 20px;
}

/* ---------- 详情模态框 ---------- */
.detail-modal .modal-header {
    background: var(--info);
    color: #fff;
}
.detail-modal .detail-row {
    display: flex;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
}
.detail-modal .detail-row:last-child {
    border-bottom: none;
}
.detail-modal .detail-label {
    font-weight: 600;
    width: 80px;
    flex-shrink: 0;
    color: var(--text-muted);
}
.detail-modal .detail-value {
    flex: 1;
    word-break: break-word;
}

/* ---------- 加载动画 ---------- */
#loadingSpinner {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}
#loadingSpinner.show {
    display: flex;
}

/* ---------- Toast 通知 ---------- */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 99999;
}

/* ---------- 空状态 ---------- */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}
.empty-state .empty-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.4;
}
.empty-state .empty-text {
    font-size: 1.05rem;
}
.empty-state .empty-hint {
    font-size: 0.9rem;
    margin-top: 8px;
}

/* ---------- 名称首字母圆形头像 ---------- */
.avatar-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
    color: #fff;
    flex-shrink: 0;
}

/* ---------- 头像图片（清单 / 详情） ---------- */
.avatar-img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    margin-right: 8px;
    vertical-align: middle;
    display: inline-block;
}
.avatar-img-lg {
    width: 60px;
    height: 60px;
    margin-right: 0;
}

/* ---------- 头像选择（编辑模态框） ---------- */
.avatar-circle-lg {
    width: 56px;
    height: 56px;
    font-size: 1.1rem;
}
.avatar-preview {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

/* ---------- 响应式 ---------- */
@media (max-width: 768px) {
    .app-content {
        margin: 12px auto;
        padding: 0 8px;
    }
    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .toolbar .search-box {
        max-width: 100%;
    }
    .table-card .table th,
    .table-card .table td {
        padding: 8px 6px;
        font-size: 0.8rem;
    }
    .pagination-wrapper {
        flex-direction: column;
        text-align: center;
    }
    .hide-mobile {
        display: none !important;
    }
    .action-btn {
        font-size: 0.72rem;
        padding: 2px 6px;
    }
}
