/**
 * Offcanvas 移动端菜单样式修复
 * 确保菜单内容可见且样式美观
 */

/* ========== Offcanvas 基础样式 ========== */
.offcanvas {
    position: fixed;
    bottom: 0;
    z-index: 1045;
    display: flex;
    flex-direction: column;
    max-width: 100%;
    visibility: hidden;
    background-color: #fff;
    background-clip: padding-box;
    outline: 0;
    transition: transform 0.3s ease-in-out;
}

.offcanvas-start {
    top: 0;
    left: 0;
    width: 300px;
    border-right: 1px solid rgba(0, 0, 0, 0.2);
    transform: translateX(-100%);
}

.offcanvas.show {
    transform: none;
    visibility: visible;
}

/* ========== Offcanvas Header ========== */
.offcanvas-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem 1.5rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.offcanvas-title {
    margin-bottom: 0;
    line-height: 1.5;
    font-size: 1.25rem;
    font-weight: 600;
    color: white;
}

.btn-close {
    box-sizing: content-box;
    width: 1em;
    height: 1em;
    padding: 0.25em;
    color: white;
    background: transparent url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23fff'%3e%3cpath d='M.293.293a1 1 0 011.414 0L8 6.586 14.293.293a1 1 0 111.414 1.414L9.414 8l6.293 6.293a1 1 0 01-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 01-1.414-1.414L6.586 8 .293 1.707a1 1 0 010-1.414z'/%3e%3c/svg%3e") center/1em auto no-repeat;
    border: 0;
    border-radius: 0.25rem;
    opacity: 0.8;
    cursor: pointer;
}

.btn-close:hover {
    opacity: 1;
}

/* ========== Offcanvas Body ========== */
.offcanvas-body {
    flex-grow: 1;
    padding: 1.5rem;
    overflow-y: auto;
    background: white;
}

/* ========== Mobile Nav 样式 ========== */
.mobile-nav {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.mobile-nav .nav-link {
    display: block;
    padding: 1rem 1.25rem;
    color: #333;
    text-decoration: none;
    font-weight: 500;
    font-size: 1rem;
    border-bottom: 1px solid #f0f0f0;
    transition: all 0.3s ease;
    position: relative;
}

.mobile-nav .nav-link:hover,
.mobile-nav .nav-link:active {
    background: linear-gradient(90deg, rgba(102, 126, 234, 0.1) 0%, transparent 100%);
    color: #667eea;
    padding-left: 1.5rem;
}

.mobile-nav .nav-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    transition: width 0.3s ease;
}

.mobile-nav .nav-link:hover::before {
    width: 4px;
}

.mobile-nav hr {
    margin: 1rem 0;
    border: 0;
    border-top: 2px solid #f0f0f0;
}

.mobile-nav .btn {
    margin-top: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    border-radius: 8px;
    text-align: center;
    text-decoration: none;
    display: block;
}

.mobile-nav .btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
}

.mobile-nav .btn-warning {
    background: linear-gradient(135deg, #f7971e 0%, #ffd200 100%);
    border: none;
    color: #1a1a2e;
}

.mobile-nav .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* ========== Backdrop ========== */
.offcanvas-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1040;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.5);
}

.offcanvas-backdrop.fade {
    opacity: 0;
}

.offcanvas-backdrop.show {
    opacity: 1;
}

/* ========== 防止页面滚动 ========== */
body.offcanvas-open {
    overflow: hidden;
}

/* ========== 响应式优化 ========== */
@media (max-width: 480px) {
    .offcanvas-start {
        width: 280px;
    }
    
    .offcanvas-header {
        padding: 1.25rem 1rem;
    }
    
    .offcanvas-body {
        padding: 1rem;
    }
    
    .mobile-nav .nav-link {
        padding: 0.875rem 1rem;
        font-size: 0.95rem;
    }
}

/* ========== 确保在所有设备上可见 ========== */
.offcanvas,
.offcanvas-header,
.offcanvas-body,
.mobile-nav,
.mobile-nav .nav-link,
.mobile-nav .btn {
    visibility: visible !important;
    opacity: 1 !important;
    display: block !important;
}

.mobile-nav {
    display: flex !important;
}

/* ========== 修复可能的冲突 ========== */
.offcanvas * {
    box-sizing: border-box;
}

.offcanvas a {
    color: inherit;
}

.offcanvas .nav-link {
    display: block !important;
}

/* ========== 动画效果 ========== */
@keyframes slideInLeft {
    from {
        transform: translateX(-100%);
    }
    to {
        transform: translateX(0);
    }
}

.offcanvas.show {
    animation: slideInLeft 0.3s ease-out;
}

/* ========== 滚动条样式 ========== */
.offcanvas-body::-webkit-scrollbar {
    width: 6px;
}

.offcanvas-body::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.offcanvas-body::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.offcanvas-body::-webkit-scrollbar-thumb:hover {
    background: #555;
}
