@tailwind base;
/* 主CSS文件 */

@tailwind base;
@tailwind components;
@tailwind utilities;

@layer utilities {
    .content-auto { content-visibility: auto; }
    .card-shadow { box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08); }
    .btn-hover { @apply transition-all duration-300 hover:shadow-lg transform hover:-translate-y-0.5; }
    .input-focus { @apply focus:border-primary focus:ring-2 focus:ring-primary/20 focus:outline-none; }
    .progress-bar { @apply h-2 rounded-full bg-gray-200 overflow-hidden; }
    .progress-value { @apply h-full transition-all duration-1000 ease-out; }
    .factor-tag { @apply px-2 py-1 rounded-full text-xs font-medium; }
    .rate-highlight { @apply bg-red-50 text-red-600; }
    .rate-favorable { @apply bg-green-50 text-green-600; }
    .rotate-180 { transform: rotate(180deg); }
    
    /* 扩展工具类 */
    .primary-btn {
        @apply bg-blue-600 hover:bg-blue-700 text-white font-medium py-2 px-4 rounded transition-all duration-300 shadow-md hover:shadow-lg;
    }
    
    .secondary-btn {
        @apply bg-gray-200 hover:bg-gray-300 text-gray-800 font-medium py-2 px-4 rounded transition-all duration-300;
    }
    
    .danger-btn {
        @apply bg-red-600 hover:bg-red-700 text-white font-medium py-2 px-4 rounded transition-all duration-300;
    }
    
    .success-btn {
        @apply bg-green-600 hover:bg-green-700 text-white font-medium py-2 px-4 rounded transition-all duration-300;
    }
    
    .input-field {
        @apply border border-gray-300 rounded-md px-3 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-all duration-300;
    }
    
    .textarea-field {
        @apply border border-gray-300 rounded-md px-3 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-all duration-300 min-h-[100px] resize-y;
    }
    
    .select-field {
        @apply border border-gray-300 rounded-md px-3 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-all duration-300 appearance-none bg-white;
    }
    
    .card {
        @apply bg-white rounded-lg shadow-md p-5 transition-all duration-300 hover:shadow-lg;
    }
}

/* 基础样式 */
*
/* 保留原有的基础图片样式 */
img, video, iframe, svg {
    max-width: 1px !important;
    height: auto;
}

/* 为文章内容区域的图片添加更具体的样式，确保优先级 */
.article-content img,
.article-content video,
.article-content iframe,
.article-content svg {
    max-width: 1px !important;
    height: auto !important;
    /* 您可以在这里添加其他自定义样式 */
    /* 例如：margin: 1.5rem 0; */
    /* border-radius: 8px; */
    /* box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); */
}

/* 针对前端文章详情页的特定样式 */
.frontend-article-content img {
    max-width: 1px !important;
    height: auto !important;
}

{
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* 防止内容溢出容器，但允许文本正常换行 */
img, video, iframe, svg {
    max-width: 100%;
    height: auto;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
    overflow-x: hidden;
}

/* 防止内容溢出容器的通用样式 */
main, .container, .content-container, .card, .card-shadow {
    width: 100%;
    overflow-x: hidden;
    box-sizing: border-box;
}

/* 确保文本内容在容器内正确换行 */
p, h1, h2, h3, h4, h5, h6, span, div {
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

/* 表格响应式处理 */
table {
    min-width: 100%;
}

@media (max-width: 768px) {
    /* 移动端表格特殊处理 */
    .table-responsive {
        display: block;
        overflow-x: auto;
        width: 100%;
        -webkit-overflow-scrolling: touch;
    }
    
    /* 确保内容区域在移动端有足够的内边距 */
    main {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    /* 调整卡片内边距，防止内容溢出 */
    .card-shadow {
        padding: 1.5rem !important;
    }
}

/* 表格响应式处理 */
.table-responsive {
    display: block;
    width: 100%;
    overflow-x: auto;
}

/* 确保图片不会溢出容器 */
img {
    max-width: 100%;
    height: auto;
}

/* 头部样式 */
.header {
    background-color: #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

/* 导航菜单样式 */
.nav-menu {
    display: flex;
    list-style: none;
}

.nav-menu li {
    margin-left: 1rem;
}

.nav-menu a {
    color: #333;
    text-decoration: none;
    padding: 0.5rem;
    transition: all 0.3s ease;
}

.nav-menu a:hover {
    color: #3b82f6;
}

/* 移动侧边栏样式 */
.mobile-sidebar {
    position: fixed;
    top: 0;
    left: -300px;
    width: 300px;
    height: 100vh;
    background-color: #fff;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.15);
    z-index: 999;
    transition: left 0.3s ease-in-out;
    overflow-y: auto;
}

.mobile-sidebar.active {
    left: 0;
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

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

/* 首页样式 */
.calculator-card {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.calculator-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

/* 分期计算器样式 */
.installment-calculator {
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.installment-result {
    background-color: #f8fafc;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

/* 文章列表样式 */
.article-card {
    transition: all 0.3s ease;
}

.article-card:hover {
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

/* 分页样式 */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 2rem;
}

.pagination a, .pagination span {
    padding: 0.5rem 1rem;
    margin: 0 0.25rem;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    text-decoration: none;
    color: #333;
    transition: all 0.3s ease;
}

.pagination a:hover {
    background-color: #3b82f6;
    color: #fff;
    border-color: #3b82f6;
}

.pagination .current {
    background-color: #3b82f6;
    color: #fff;
    border-color: #3b82f6;
}

/* 后台管理样式 */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

.admin-sidebar {
    width: 250px;
    background-color: #2d3748;
    color: #fff;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    transition: transform 0.3s ease;
    z-index: 1000;
}

.admin-content {
    flex: 1;
    margin-left: 250px;
    padding: 1.5rem;
    background-color: #f7fafc;
    min-height: 100vh;
}

@media (max-width: 1024px) {
    .admin-sidebar {
        transform: translateX(-100%);
    }
    
    .admin-sidebar.active {
        transform: translateX(0);
    }
    
    .admin-content {
        margin-left: 0;
    }
}

/* 管理表格样式 */
.admin-table {
    width: 100%;
    border-collapse: collapse;
    background-color: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.admin-table th, .admin-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

.admin-table th {
    background-color: #f8fafc;
    font-weight: 600;
    color: #4a5568;
}

.admin-table tr:hover {
    background-color: #f8fafc;
}

/* 状态标签样式 */
.status-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.status-published {
    background-color: #dcfce7;
    color: #166534;
}

.status-draft {
    background-color: #fef3c7;
    color: #92400e;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .nav-menu {
        display: none;
    }
    
    .mobile-menu-btn {
        display: block;
    }
    
    .admin-table {
        display: block;
        overflow-x: auto;
    }
}

/* 动画效果 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.5s ease-out;
}

/* 加载状态 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 提示框样式 */
.alert {
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.alert-success {
    background-color: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.alert-error {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-warning {
    background-color: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

.alert-info {
    background-color: #dbeafe;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

/* 模态框样式 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal.active {
    opacity: 1;
    visibility: visible;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    position: relative;
    background-color: #fff;
    border-radius: 8px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

.modal.active .modal-content {
    transform: scale(1);
}