/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f4f4f4;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 40px;
    background-color: #fff;
    min-height: 100vh;
}

/* 头部样式 */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e0e0e0;
}

.header-buttons {
    display: flex;
    gap: 10px;
    align-items: center;
}

header h1 {
    color: #2c3e50;
    font-size: 24px;
}

/* 按钮样式 */
.post-btn, .back-btn, .admin-btn {
    display: inline-block;
    padding: 10px 20px;
    background-color: #3498db;
    color: #fff;
    text-decoration: none;
    border-radius: 4px;
    font-weight: bold;
    transition: background-color 0.3s;
}

.admin-btn {
    background-color: #9b59b6;
}

.admin-btn:hover {
    background-color: #8e44ad;
}

.post-btn:hover, .back-btn:hover {
    background-color: #2980b9;
}

.back-btn {
    background-color: #95a5a6;
}

.back-btn:hover {
    background-color: #7f8c8d;
}

/* 主要内容 */
main h2 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 20px;
}

/* 标题和按钮布局 - 桌面端默认垂直，手机端水平 */
.mobile-header-layout {
    display: block;
    margin-bottom: 20px;
}

.mobile-header-layout h2 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 20px;
}

.mobile-header-layout .header-buttons {
    display: none;
}

/* 广告列表 */
.ads-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* 广告项基本样式 */
.ad-item {
    display: block;
    text-decoration: none;
    padding: 12px;
    background-color: #f9f9f9;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s, box-shadow 0.3s, background-color 0.3s;
    color: #333;
}

.ad-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    background-color: #f0f8ff;
}

.ad-item h3 {
    margin-bottom: 6px;
    color: #3498db;
    font-size: 18px;
    /* 桌面端标题最多显示一行 */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ad-item:hover h3 {
    text-decoration: underline;
}

.ad-intro {
    color: #666;
    margin-bottom: 6px;
    font-size: 14px;
    /* 桌面端内容最多显示两行 */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
}

.ad-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 6px;
    flex-wrap: wrap;
    gap: 8px;
}

.ad-date {
    color: #999;
    font-size: 12px;
    margin: 0;
}

.ad-views {
    color: #3498db;
    font-size: 12px;
    margin: 0;
    font-weight: bold;
}

.no-ads {
    text-align: center;
    color: #999;
    padding: 40px 0;
    font-style: italic;
}

/* 搜索表单样式 - 默认桌面端水平排列 */
.search-form {
    margin-bottom: 20px;
    padding: 15px;
    background-color: #f9f9f9;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.search-form form {
    display: flex;
    gap: 10px;
    align-items: center;
    width: 100%;
}

.search-form input[type="text"] {
    flex: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    box-sizing: border-box;
}

.search-form button {
    padding: 10px 20px;
    background-color: #3498db;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.search-form button:hover {
    background-color: #2980b9;
}

.search-form .reset-btn {
    padding: 10px 15px;
    background-color: #95a5a6;
    color: #fff;
    text-decoration: none;
    border-radius: 4px;
    font-size: 14px;
    transition: background-color 0.3s;
}

/* 分页样式 */
.pagination {
    margin-top: 25px;
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

.pagination .page-btn {
    padding: 8px 12px;
    background-color: #f0f0f0;
    color: #333;
    text-decoration: none;
    border-radius: 4px;
    font-size: 14px;
    transition: all 0.3s;
    border: 1px solid #ddd;
}

.pagination .page-btn:hover {
    background-color: #3498db;
    color: #fff;
    border-color: #3498db;
}

.pagination .page-btn.active {
    background-color: #3498db;
    color: #fff;
    border-color: #3498db;
    font-weight: bold;
}

.pagination .page-btn:first-child,
.pagination .page-btn:last-child {
    background-color: #f9f9f9;
}

.pagination .page-btn:first-child:hover,
.pagination .page-btn:last-child:hover {
    background-color: #3498db;
    color: #fff;
}

/* 表单样式 */
.post-form {
    background-color: #f9f9f9;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #555;
}

.form-group input[type="text"],
.form-group input[type="url"],
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    font-family: Arial, sans-serif;
}

.form-group textarea {
    resize: vertical;
    min-height: 120px;
}

.form-group button {
    padding: 10px 20px;
    background-color: #27ae60;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 15px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.3s;
}

.form-group button:hover {
    background-color: #229954;
}

/* 响应式表单按钮 */
@media (max-width: 768px) {
    .form-group button {
        padding: 8px 16px;
        font-size: 14px;
        width: auto;
    }
}

/* 广告详情 */
.ad-detail {
    background-color: #f9f9f9;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.ad-detail h2 {
    margin-bottom: 15px;
    color: #2c3e50;
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
}

.ad-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
    flex-wrap: wrap;
    gap: 10px;
}

.ad-detail .ad-date {
    font-size: 14px;
    color: #666;
    margin: 0;
}

.ad-views {
    font-size: 14px;
    color: #3498db;
    font-weight: bold;
    margin: 0;
}

.ad-content {
    margin-bottom: 25px;
    line-height: 1.8;
    color: #555;
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
}

.ad-content p {
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
}

.ad-link {
    margin-top: 20px;
}

.ad-link a {
    color: #3498db;
    text-decoration: underline;
    word-break: break-all;
    transition: color 0.3s;
}

.ad-link a:hover {
    color: #2980b9;
    text-decoration: underline;
}

/* 联系方式样式 */
.ad-contact {
    margin-top: 20px;
    padding: 15px;
    background-color: #f0f8ff;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.contact-text {
    flex: 1;
    min-width: 200px;
    font-size: 16px;
    color: #333;
    word-break: break-all;
}

.copy-btn {
    padding: 8px 16px;
    background-color: #27ae60;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.copy-btn:hover {
    background-color: #229954;
}

.copy-message {
    font-size: 14px;
    color: #27ae60;
    opacity: 0;
    transition: opacity 0.3s;
    font-weight: bold;
}

/* 操作按钮 */
.action-buttons {
    margin-top: 20px;
}

/* 分页省略号样式 */
.page-dots {
    padding: 8px 12px;
    color: #666;
    font-weight: bold;
    border: none;
    background: transparent;
}

/* 消息样式 */
.error {
    color: #e74c3c;
    background-color: #fee;
    padding: 12px;
    border-radius: 4px;
    margin-bottom: 20px;
    border: 1px solid #fcc;
}

.success {
    color: #27ae60;
    background-color: #efe;
    padding: 12px;
    border-radius: 4px;
    margin-bottom: 20px;
    border: 1px solid #cfc;
}

.success a {
    color: #27ae60;
    font-weight: bold;
    text-decoration: none;
}

.success a:hover {
    text-decoration: underline;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    header {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: center !important;
        text-align: center;
        padding-bottom: 15px;
        border-bottom: 2px solid #e0e0e0;
    }
    
    header h1 {
        display: block !important;
        font-size: 18px !important;
        text-align: center !important;
        margin: 0 auto !important;
        flex: none !important;
        white-space: nowrap;
    }
    
    header .back-btn {
        display: inline-block !important;
        flex-shrink: 0 !important;
        margin-right: 10px !important;
        vertical-align: middle;
    }
    
    /* 手机端显示标题和按钮在同一行 */
    .mobile-header-layout {
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        margin-bottom: 20px;
    }
    
    .mobile-header-layout h2 {
        font-size: 18px !important;
        margin: 0 !important;
        margin-bottom: 0 !important;
        flex: 1;
        color: #2c3e50;
    }
    
    .mobile-header-layout .header-buttons {
        display: flex !important;
        gap: 8px;
        align-items: center;
    }
    
    .mobile-header-layout .post-btn {
        padding: 8px 12px;
        font-size: 13px;
        background-color: #27ae60;
    }
    
    .mobile-header-layout .post-btn:hover {
        background-color: #229954;
    }
    
    .post-btn {
        width: auto;
        padding: 8px 16px;
        font-size: 14px;
    }
    
    .back-btn {
        width: auto;
        padding: 8px 16px;
        font-size: 14px;
    }
    
    .ad-item {
        padding: 10px;
    }
    
    .ads-list {
        gap: 8px;
    }
    
    /* 响应式搜索表单 - 保持水平排列 */
    .search-form form {
        flex-direction: row;
        align-items: center;
        gap: 8px;
    }
    
    .search-form input[type="text"] {
        margin-bottom: 0;
    }
    
    .search-form button, .search-form .reset-btn {
        width: auto;
        text-align: center;
        padding: 8px 16px;
        font-size: 13px;
    }
    
    /* 手机端广告标题和内容单行显示 */
    .ad-item h3 {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        margin-bottom: 4px;
    }
    
    .ad-intro {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        margin-bottom: 6px;
    }
    
    /* 响应式分页 */
    .pagination {
        gap: 5px;
    }
    
    .pagination .page-btn {
        padding: 6px 10px;
        font-size: 13px;
    }
    
    .post-form {
        padding: 20px;
    }
    
    .ad-detail {
        padding: 20px;
    }
}

/* 底部样式 */
footer {
    text-align: center;
    padding: 20px 0;
    border-top: 1px solid #eee;
    margin-top: 40px;
}

footer p {
    margin: 0;
    color: #666;
    font-size: 14px;
}

/* 底部响应式样式 */
@media (max-width: 768px) {
    footer {
        padding: 15px 0;
        margin-top: 30px;
    }
    
    footer p {
        font-size: 13px;
    }
}