/* CodeEasy编程社区 - Custom Styles */

/* 基础响应式设计 */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

/* General Styles */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans SC', sans-serif;
    background-color: #f8f9fa;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

main {
    flex: 1;
}

/* Hero Section */
.hero-section {
    background: linear-gradient(135deg, #0d6efd 0%, #6610f2 100%);
    padding: 60px 0;
}

/* Cards */
.card {
    border: none;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
}

.article-card .card-title a:hover {
    color: #0d6efd !important;
}

.tool-card .card-title a:hover {
    color: #0d6efd !important;
}

/* Tool Logos */
.tool-logo {
    width: 48px;
    height: 48px;
    background-color: #e9ecef;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-size: cover;
    background-position: center;
    font-size: 1.5rem;
    color: #6c757d;
}

.tool-logo-sm {
    width: 32px;
    height: 32px;
    background-color: #e9ecef;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-size: cover;
    background-position: center;
    font-size: 1rem;
    color: #6c757d;
}

.tool-logo-lg {
    width: 100px;
    height: 100px;
    background-color: #e9ecef;
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-size: cover;
    background-position: center;
    color: #6c757d;
}

/* Profile */
.profile-avatar {
    width: 120px;
    height: 120px;
    margin: 0 auto;
    border-radius: 50%;
    background-color: #e9ecef;
    background-size: cover;
    background-position: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Stats */
.stat-card {
    padding: 20px;
}

/* Article Content */
.article-content {
    line-height: 1.8;
    font-size: 1.1rem;
}

.article-content h1, 
.article-content h2, 
.article-content h3 {
    margin-top: 1.5rem;
    margin-bottom: 1rem;
}

.article-content p {
    margin-bottom: 1rem;
}

.article-content pre {
    background-color: #f4f4f4;
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
}

.article-content code {
    background-color: #f4f4f4;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
}

.article-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}

/* Rating Stars */
.rating {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Navbar */
.navbar-brand {
    font-size: 1.4rem;
}

/* Footer */
footer {
    margin-top: auto;
}

/* Comments */
.comment-list .card {
    border-left: 3px solid #0d6efd;
}

/* Badges */
.badge {
    font-weight: 500;
}

/* Buttons */
.btn-primary {
    background: linear-gradient(135deg, #0d6efd 0%, #0b5ed7 100%);
    border: none;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #0b5ed7 0%, #0a58ca 100%);
}

/* Table */
.table th {
    font-weight: 600;
    white-space: nowrap;
}

/* Pagination */
.pagination .page-link {
    border-radius: 8px;
    margin: 0 2px;
}

/* List Groups */
.list-group-item-action:hover {
    background-color: #f8f9fa;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.card {
    animation: fadeIn 0.3s ease;
}

/* Responsive - Tablet */
@media (max-width: 992px) {
    .navbar .form-control {
        width: 150px;
    }
    
    .hero-section .btn-lg {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }
}

/* Responsive - Mobile */
@media (max-width: 768px) {
    /* Hero Section */
    .hero-section {
        padding: 30px 0;
    }
    
    .hero-section h1 {
        font-size: 1.8rem;
    }
    
    .hero-section .lead {
        font-size: 1rem;
    }
    
    .hero-section .btn-lg {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
    }
    
    .hero-section .d-flex.gap-3 {
        flex-direction: column;
        gap: 0.5rem !important;
    }
    
    /* Stats Section */
    .stat-card {
        padding: 15px 10px;
    }
    
    .stat-card h3 {
        font-size: 1.3rem;
    }
    
    .stat-card .display-4 {
        font-size: 2rem;
    }
    
    /* Tool Logos */
    .tool-logo-lg {
        width: 70px;
        height: 70px;
    }
    
    .tool-logo {
        width: 40px;
        height: 40px;
    }
    
    /* Profile */
    .profile-avatar {
        width: 100px;
        height: 100px;
    }
    
    /* Cards */
    .card-body {
        padding: 1rem;
    }
    
    .card-title {
        font-size: 1rem;
    }
    
    /* Buttons */
    .btn-lg {
        padding: 0.5rem 1rem;
        font-size: 1rem;
    }
    
    .btn-sm {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }
    
    /* Typography */
    h1 {
        font-size: 1.5rem;
    }
    
    h2 {
        font-size: 1.3rem;
    }
    
    h3 {
        font-size: 1.1rem;
    }
    
    /* Article Content */
    .article-content {
        font-size: 1rem;
        line-height: 1.7;
    }
    
    /* Navbar */
    .navbar-brand {
        font-size: 1.1rem;
    }
    
    .navbar .form-control {
        width: 100%;
    }
    
    .navbar-nav {
        padding-top: 0.5rem;
    }
    
    /* 搜索框移动端样式 */
    .navbar .search-form,
    .navbar form.d-flex {
        width: 100%;
        margin: 0.5rem 0;
        order: -1;
    }
    
    .navbar .input-group {
        width: 100%;
        flex-wrap: nowrap;
    }
    
    .navbar .input-group .form-control {
        flex: 1;
        min-width: 0;
    }
    
    .navbar .input-group .btn {
        flex-shrink: 0;
    }
    
    .navbar-collapse {
        display: flex;
        flex-direction: column;
    }
    
    .navbar-collapse.show,
    .navbar-collapse.collapsing {
        background-color: #0d6efd;
        margin: 0 -12px;
        padding: 10px 15px;
        border-radius: 0 0 10px 10px;
    }
    
    .navbar-collapse .navbar-nav.me-auto {
        order: 0;
    }
    
    .navbar-collapse .navbar-nav:last-child {
        order: 1;
    }
    
    /* Footer */
    footer .row > div {
        margin-bottom: 1.5rem;
        text-align: center;
    }
    
    footer h5 {
        font-size: 1.1rem;
    }
    
    /* Forms */
    .form-control-lg {
        font-size: 1rem;
        padding: 0.5rem 0.75rem;
    }
    
    /* Tables */
    .table-responsive {
        font-size: 0.85rem;
    }
    
    .table th,
    .table td {
        padding: 0.5rem;
        white-space: nowrap;
    }
    
    /* Pagination */
    .pagination {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .pagination .page-link {
        padding: 0.4rem 0.7rem;
        font-size: 0.85rem;
    }
    
    /* List Group */
    .list-group-item {
        padding: 0.75rem 1rem;
    }
    
    /* Leaderboard Specific */
    .leaderboard-rank {
        font-size: 0.9rem;
    }
    
    /* Comments Section */
    .comment-list .card-body {
        padding: 0.75rem;
    }
    
    .comment-list .display-6 {
        font-size: 1.5rem;
    }
    
    /* Container padding */
    .container {
        padding-left: 15px;
        padding-right: 15px;
    }
    
    /* Section padding */
    .py-5 {
        padding-top: 2rem !important;
        padding-bottom: 2rem !important;
    }
    
    .py-4 {
        padding-top: 1.5rem !important;
        padding-bottom: 1.5rem !important;
    }
    
    /* Hide text, show icon only on mobile for some buttons */
    .btn .bi + span.d-none-mobile {
        display: none;
    }
    
    /* Category filter buttons */
    .btn-group.flex-wrap {
        gap: 5px;
    }
    
    .btn-group.flex-wrap .btn {
        font-size: 0.8rem;
        padding: 0.35rem 0.6rem;
        margin-bottom: 5px;
    }
    
    /* Dropdown menus */
    .dropdown-menu {
        min-width: auto;
    }
    
    /* Alert messages */
    .alert {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }
    
    /* Modal adjustments */
    .modal-dialog {
        margin: 0.5rem;
    }
}

/* Responsive - Small Mobile */
@media (max-width: 576px) {
    /* Hero Section */
    .hero-section h1 {
        font-size: 1.5rem;
    }
    
    .hero-section .lead {
        font-size: 0.9rem;
    }
    
    /* Stats - 2 columns on small mobile */
    .stat-card {
        padding: 10px 5px;
    }
    
    .stat-card h3 {
        font-size: 1.1rem;
    }
    
    .stat-card .display-4 {
        font-size: 1.5rem;
    }
    
    .stat-card p {
        font-size: 0.8rem;
    }
    
    /* Cards */
    .card-body {
        padding: 0.75rem;
    }
    
    /* Tool cards */
    .tool-logo {
        width: 36px;
        height: 36px;
        font-size: 1.2rem;
    }
    
    .tool-logo-lg {
        width: 60px;
        height: 60px;
    }
    
    /* Profile */
    .profile-avatar {
        width: 80px;
        height: 80px;
    }
    
    .profile-avatar .display-1 {
        font-size: 3rem;
    }
    
    /* Typography */
    h1 {
        font-size: 1.3rem;
    }
    
    h2 {
        font-size: 1.2rem;
    }
    
    /* Article list card image */
    .article-card .card-img-top {
        height: 120px !important;
    }
    
    /* Forms */
    .form-label {
        font-size: 0.9rem;
    }
    
    .form-control,
    .form-select {
        font-size: 0.9rem;
    }
    
    textarea.form-control {
        min-height: 100px;
    }
    
    /* Buttons */
    .d-flex.justify-content-between {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .d-flex.justify-content-between .btn {
        width: 100%;
    }
    
    /* Actions row */
    .d-flex.align-items-center.mb-4 {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    /* Category filter */
    .btn-group.flex-wrap .btn {
        font-size: 0.75rem;
        padding: 0.3rem 0.5rem;
    }
    
    /* Footer */
    footer {
        font-size: 0.9rem;
    }
    
    footer .list-unstyled {
        margin-bottom: 0;
    }
    
    /* Navbar brand */
    .navbar-brand {
        font-size: 1rem;
    }
    
    /* Rating display */
    .display-6 {
        font-size: 1.5rem;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    .btn-sm {
        min-height: 36px;
        min-width: 36px;
    }
    
    .nav-link {
        padding: 0.75rem 1rem;
    }
    
    .dropdown-item {
        padding: 0.75rem 1.5rem;
    }
    
    .list-group-item {
        padding: 1rem;
    }
    
    .form-control,
    .form-select {
        min-height: 44px;
    }
    
    .form-check-input {
        width: 1.25em;
        height: 1.25em;
    }
    
    /* Remove hover effects on touch devices */
    .card:hover {
        transform: none;
    }
}

/* Form Focus States */
.form-control:focus,
.form-select:focus {
    border-color: #0d6efd;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.15);
}

/* Alert Styles */
.alert {
    border: none;
    border-radius: 10px;
}

/* Card Headers */
.card-header {
    background-color: #f8f9fa;
    font-weight: 600;
}

/* Dropdown Menu */
.dropdown-menu {
    border: none;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border-radius: 10px;
}

.dropdown-item:hover {
    background-color: #f0f7ff;
}

/* Search Input */
.navbar .form-control {
    border-radius: 20px;
    padding-left: 15px;
}

/* Loading States */
.btn.loading {
    pointer-events: none;
    opacity: 0.7;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* ===== 响应式工具类 ===== */

/* 只在手机端显示 */
.mobile-only {
    display: none;
}

/* 只在电脑端显示 */
.desktop-only {
    display: block;
}

@media (max-width: 768px) {
    .mobile-only {
        display: block;
    }
    
    .desktop-only {
        display: none;
    }
    
    /* 手机端随边栏缩小 */
    .mobile-scrollbar::-webkit-scrollbar {
        width: 4px;
        height: 4px;
    }
}

/* 图片响应式 */
img {
    max-width: 100%;
    height: auto;
}

/* 视频和嵌入内容响应式 */
video, iframe, embed, object {
    max-width: 100%;
}

/* 滑动优化 */
.smooth-scroll {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* 防止内容溢出 */
.overflow-hidden {
    overflow: hidden;
}

.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.text-truncate-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 安全区域适配（用于全面屏手机） */
@supports (padding: max(0px)) {
    body {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
    }
    
    footer {
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
}
