/**
 * 家长中心单页应用（SPA）样式
 * 
 * 功能：
 * 1. 左右分栏布局
 * 2. 侧边栏折叠/展开
 * 3. 导航菜单样式
 * 4. 响应式设计（桌面/移动端）
 * 5. 加载和错误状态样式
 * 
 * 使用场景：
 * - student_notice.html（家长中心主页）
 */

/* ===========================
   1. 布局容器
   =========================== */

.parent-spa-layout {
    display: flex;
    min-height: 100vh;
    background-color: #f3f4f6;
}

/* 防止过度滚动时露白 */
html, body {
    background-color: #f3f4f6;
    overscroll-behavior-y: none;
}

/* ===========================
   2. 侧边栏
   =========================== */

.parent-sidebar {
    width: 280px;
    min-width: 280px;
    background: linear-gradient(180deg, #ffffff 0%, #fafafa 100%);
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
}

.parent-sidebar.collapsed {
    width: 80px;
    min-width: 80px;
}

/* 导航菜单 */
.parent-sidebar-nav {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto;
    overflow-x: hidden; /* 隐藏横向滚动条，防止Safari在hover时显示滚动条 */
}

/* 自定义滚动条 */
.parent-sidebar-nav::-webkit-scrollbar {
    width: 6px;
}

.parent-sidebar-nav::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.02);
}

.parent-sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(200, 16, 46, 0.3);
    border-radius: 3px;
}

.parent-sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: rgba(200, 16, 46, 0.5);
}

.parent-nav-item {
    display: flex;
    align-items: center;
    padding: 1rem 1.5rem;
    margin: 0.25rem 0.75rem;
    border-radius: 12px;
    color: #4b5563;
    text-decoration: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.parent-nav-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 70%;
    background: #C8102E;
    border-radius: 0 4px 4px 0;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.parent-nav-item:hover {
    background-color: #fef2f2;
    color: #C8102E;
    transform: translateX(4px);
}

.parent-nav-item:hover::before {
    width: 4px;
}

.parent-nav-item.active {
    background: linear-gradient(135deg, #C8102E 0%, #a80e26 100%);
    color: white;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(200, 16, 46, 0.25);
}

.parent-nav-item.active::before {
    width: 0;
}

.parent-nav-item.active:hover {
    transform: translateX(0);
    box-shadow: 0 6px 16px rgba(200, 16, 46, 0.35);
}

.parent-nav-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 1rem;
    font-size: 1.125rem;
    flex-shrink: 0;
    transition: all 0.3s ease;
}

.parent-nav-item.active .parent-nav-icon {
    filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.5));
}

.parent-nav-text {
    flex: 1;
    font-size: 0.9375rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: all 0.3s ease;
    font-weight: 500;
}

/* 折叠状态下的导航 */
.parent-sidebar.collapsed .parent-nav-item {
    padding: 1rem;
    margin: 0.25rem 0.5rem;
    justify-content: center;
}

.parent-sidebar.collapsed .parent-nav-icon {
    margin-right: 0;
}

.parent-sidebar.collapsed .parent-nav-text {
    display: none;
}

.parent-sidebar.collapsed .parent-nav-item:hover {
    transform: scale(1.1);
}

.parent-sidebar.collapsed .parent-nav-item::before {
    display: none;
}

/* 折叠按钮 - 桌面端（圆形抽屉样式） */
.sidebar-toggle-btn {
    position: absolute;
    top: 50%;
    right: -20px;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #C8102E 0%, #a80e26 100%);
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10;
    box-shadow: 0 2px 12px rgba(200, 16, 46, 0.3);
    color: white;
}

.sidebar-toggle-btn:hover {
    transform: translateY(-50%) scale(1.1);
    background: linear-gradient(135deg, #a80e26 0%, #C8102E 100%);
    box-shadow: 0 4px 16px rgba(200, 16, 46, 0.5);
}

.sidebar-toggle-btn i {
    font-size: 1.125rem;
    transition: none;
}

.parent-sidebar.collapsed .sidebar-toggle-btn {
    right: -20px;
}

.parent-sidebar.collapsed .sidebar-toggle-btn:hover {
    transform: translateY(-50%) scale(1.1);
}

/* 侧边栏备案信息 */
.sidebar-beian {
    padding: 0.875rem 1rem;
    text-align: center;
    overflow: hidden;
    opacity: 1;
    transform: translateX(0);
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1) 0.1s,
                transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 侧边栏底部 */
.parent-sidebar-footer {
    padding: 1rem 1rem 1.5rem;
    border-top: 1px solid #e5e7eb;
    background: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.02) 100%);
}

.parent-sidebar.collapsed .parent-sidebar-footer {
    padding: 1rem 0.5rem 1.5rem;
}

.beian-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.375rem 0.5rem;
    font-size: 0.6875rem;
    color: #9ca3af;
    text-decoration: none;
    transition: all 0.2s ease;
    border-radius: 6px;
    line-height: 1.3;
}

.beian-link:hover {
    color: #6b7280;
    background-color: rgba(0, 0, 0, 0.02);
}

.beian-link i {
    font-size: 0.75rem;
    margin-right: 0.375rem;
    flex-shrink: 0;
}

.beian-icon-img {
    width: 14px;
    height: 14px;
    margin-right: 0.375rem;
    flex-shrink: 0;
    object-fit: contain;
}

.beian-text {
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 折叠状态下隐藏备案信息 - 左右滑动 */
.parent-sidebar.collapsed .sidebar-beian {
    opacity: 0;
    transform: translateX(-100%);
    transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 主内容区体验模式横幅 */
.guest-banner-main {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    color: #92400e;
    font-size: 0.8125rem;
    font-weight: 600;
    flex-shrink: 0;
}

.guest-banner-main i {
    font-size: 0.875rem;
    color: #d97706;
}

/* ===========================
   3. 主内容区域
   =========================== */

.parent-main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin-left: 280px;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.parent-sidebar.collapsed ~ .parent-main-content {
    margin-left: 80px;
}

#content-container {
    flex: 1;
    overflow-y: auto;
    background-color: #f3f4f6;
    padding: 1rem 0;
}

/* ===========================
   4. 加载状态
   =========================== */

.spa-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    padding: 2rem;
}

.spa-loading-spinner {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #C8102E 0%, #a80e26 100%);
    border-radius: 50%;
    margin-bottom: 1rem;
    animation: pulse-loading 1.5s infinite;
    box-shadow: 0 4px 16px rgba(200, 16, 46, 0.3);
}

.spa-loading-spinner i {
    font-size: 2rem;
    color: white;
}

@keyframes pulse-loading {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 4px 16px rgba(200, 16, 46, 0.3);
    }
    50% {
        transform: scale(1.08);
        box-shadow: 0 8px 24px rgba(200, 16, 46, 0.5);
    }
}

.spa-loading-text {
    font-size: 1rem;
    color: #6b7280;
    font-weight: 500;
}

/* ===========================
   5. 错误状态
   =========================== */

.spa-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    padding: 2rem;
    text-align: center;
}

.spa-error-icon {
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    border-radius: 50%;
    margin-bottom: 1.5rem;
}

.spa-error-icon i {
    font-size: 2.5rem;
    color: #dc2626;
}

.spa-error-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 0.5rem;
}

.spa-error-details {
    font-size: 0.9375rem;
    color: #6b7280;
    margin-bottom: 1.5rem;
}

.spa-error-retry {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, #C8102E 0%, #a80e26 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(200, 16, 46, 0.3);
}

.spa-error-retry:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(200, 16, 46, 0.5);
}

/* ===========================
   6. 响应式设计
   =========================== */

/* 移动端汉堡菜单按钮 */
.hamburger-menu-btn {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    width: 44px;
    height: 44px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    cursor: pointer;
    z-index: 200;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.hamburger-menu-btn:hover {
    background: #f9fafb;
    border-color: #d1d5db;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.hamburger-menu-btn:active {
    transform: scale(0.95);
}

/* 汉堡线条样式 */
.hamburger-line {
    display: block;
    width: 20px;
    height: 2px;
    background: linear-gradient(90deg, #4a5568 0%, #718096 100%);
    border-radius: 2px;
    transition: all 0.35s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    transform-origin: center;
    position: relative;
}

/* Hover 效果 */
.hamburger-menu-btn:hover .hamburger-line {
    background: linear-gradient(90deg, #C8102E 0%, #e53e3e 100%);
}

.hamburger-menu-btn:hover .hamburger-line:nth-child(1) {
    transform: translateY(-1px);
}

.hamburger-menu-btn:hover .hamburger-line:nth-child(3) {
    transform: translateY(1px);
}

/* 菜单打开状态 - X 图标动画 */
.hamburger-menu-btn.active .hamburger-line {
    background: linear-gradient(90deg, #C8102E 0%, #e53e3e 100%);
}

.hamburger-menu-btn.active .hamburger-line:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.hamburger-menu-btn.active .hamburger-line:nth-child(2) {
    opacity: 0;
    transform: scaleX(0) rotate(180deg);
}

.hamburger-menu-btn.active .hamburger-line:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* 移动端导航遮罩层 */
.parent-nav-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 140;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.35s ease, visibility 0.35s ease;
}

.parent-nav-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* 平板和手机端（< 768px） */
@media (max-width: 768px) {
    .parent-spa-layout {
        position: relative;
    }
    
    /* 显示汉堡菜单 */
    .hamburger-menu-btn {
        display: flex;
    }
    
    /* 侧边栏从左侧滑入 - 优化动画曲线 */
    .parent-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        z-index: 150;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15), 2px 0 8px rgba(0, 0, 0, 0.08);
        width: 280px !important;
        max-width: 85vw;
        min-width: 280px !important;
        /* 使用与教师端相同的流畅动画曲线 */
        transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) !important;
        will-change: transform;
    }
    
    /* 折叠状态 - 向左滑出 */
    .parent-sidebar.collapsed {
        width: 280px !important;
        min-width: 280px !important;
        transform: translateX(-100%) !important;
    }
    
    /* 展开状态 - 回到原位 */
    .parent-sidebar:not(.collapsed) {
        transform: translateX(0) !important;
    }
    
    /* 移动端隐藏桌面折叠按钮 */
    .sidebar-toggle-btn {
        display: none;
    }
    
    /* 主内容区域占满 */
    .parent-main-content {
        width: 100%;
        margin-left: 0;
    }
    
    .parent-sidebar.collapsed ~ .parent-main-content {
        margin-left: 0;
    }
    
    /* 移动端内容容器统一边距 - 上下左右都是1rem */
    #content-container {
        padding: 1rem;
    }
    
    /* 移除之前的::after伪元素蒙层 */
    .parent-sidebar::after {
        display: none;
    }
    
    /* 汉堡按钮在菜单展开时保持白色背景 */
    .hamburger-menu-btn.active {
        background: white;
        border-color: #e5e7eb;
    }
    
    .hamburger-menu-btn.active:hover {
        background: #f9fafb;
    }
    
    /* 避免汉堡按钮遮挡第一个导航项 - 只针对导航区域 */
    .parent-sidebar-nav .parent-nav-item:first-child {
        margin-top: 4rem;
    }

    /* 主内容区横幅移动端缩小 */
    .guest-banner-main {
        font-size: 0.75rem;
        padding: 0.375rem 0.75rem;
    }
}

/* 小手机端（< 480px） */
@media (max-width: 480px) {
    .parent-sidebar {
        width: 90% !important;
        max-width: 90vw;
        min-width: 90% !important;
    }
    
    .parent-sidebar.collapsed {
        width: 90% !important;
        min-width: 90% !important;
    }
    
    .hamburger-menu-btn {
        width: 40px;
        height: 40px;
    }
    
    .hamburger-line {
        width: 18px;
    }
    
    /* 小屏幕内容容器保持1rem边距 */
    #content-container {
        padding: 1rem;
    }
    
    .spa-loading,
    .spa-error {
        min-height: 300px;
        padding: 1rem;
    }
    
    .spa-loading-spinner,
    .spa-error-icon {
        width: 60px;
        height: 60px;
    }
    
    .spa-loading-spinner i,
    .spa-error-icon i {
        font-size: 1.75rem;
    }
}

/* 大屏幕（> 1280px） */
@media (min-width: 1280px) {
    .parent-sidebar {
        width: 300px;
        min-width: 300px;
    }
    
    .parent-sidebar.collapsed {
        width: 80px;
        min-width: 80px;
    }
    
    .parent-main-content {
        margin-left: 300px;
    }
    
    .parent-sidebar.collapsed ~ .parent-main-content {
        margin-left: 80px;
    }
}

/* ===========================
   7. 动画效果
   =========================== */

@keyframes contentFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#content-container > * {
    animation: contentFadeIn 0.3s ease;
}

/* ===========================
   8. 滚动条样式
   =========================== */

#content-container::-webkit-scrollbar {
    width: 8px;
}

#content-container::-webkit-scrollbar-track {
    background: #f3f4f6;
}

#content-container::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #C8102E 0%, #a80e26 100%);
    border-radius: 4px;
}

#content-container::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #a80e26 0%, #C8102E 100%);
}

/* ===========================
   9. 打印样式
   =========================== */

@media print {
    .parent-sidebar,
    .hamburger-menu-btn,
    .sidebar-toggle-btn {
        display: none !important;
    }
    
    .parent-main-content {
        width: 100% !important;
        margin-left: 0 !important;
    }
}
