/* 移动端兼容样式 - 防止超宽变形 */
/* 适用于所有PHP前端页面 */

/* 基础重置和移动端优化 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f8fafc;
    color: #334155;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    overflow-x: hidden; /* 防止水平滚动 */
    word-wrap: break-word; /* 长单词换行 */
}

/* 容器和布局 */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 15px;
    width: 100%;
}

/* 移动端容器调整 */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 8px;
    }
}

/* 导航栏移动端优化 */
.navbar {
    background: #2c3e50;
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    width: 100%;
}

.navbar-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 50px;
    flex-wrap: wrap;
}

.navbar-brand {
    font-size: 1.2rem;
    font-weight: 600;
    color: #ecf0f1;
    text-decoration: none;
    white-space: nowrap;
}

.navbar-nav {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 8px;
    flex-wrap: wrap;
}

.navbar-nav a {
    color: #bdc3c7;
    text-decoration: none;
    font-weight: 400;
    font-size: 0.8rem;
    padding: 4px 6px;
    border-radius: 3px;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.navbar-nav a:hover {
    color: #ecf0f1;
    background: #34495e;
}

/* 汉堡菜单样式 */
.hamburger-menu {
    display: none;
    flex-direction: column;
    cursor: pointer;
    padding: 8px;
    background: none;
    border: none;
    outline: none;
}

.hamburger-line {
    width: 25px;
    height: 3px;
    background: #ecf0f1;
    margin: 3px 0;
    transition: all 0.3s ease;
    border-radius: 2px;
}

/* 汉堡菜单动画效果 */
.hamburger-menu.active .hamburger-line:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
}

.hamburger-menu.active .hamburger-line:nth-child(2) {
    opacity: 0;
}

.hamburger-menu.active .hamburger-line:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

/* 移动端菜单 */
.mobile-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #1a252f;
    border-top: 1px solid #34495e;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 1001;
}

.mobile-menu.active {
    display: block !important;
}

.mobile-menu ul {
    list-style: none;
    margin: 0;
    padding: 15px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.mobile-menu li {
    border: none;
    border-radius: 8px;
    overflow: hidden;
}

.mobile-menu a {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #2c3e50;
    color: #ecf0f1;
    text-decoration: none;
    padding: 12px 8px;
    font-size: 0.85rem;
    font-weight: 500;
    text-align: center;
    border-radius: 8px;
    transition: all 0.3s ease;
    border: 1px solid #34495e;
    min-height: 44px;
}

.mobile-menu a:hover {
    background: #3498db;
    border-color: #2980b9;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(52, 152, 219, 0.3);
}

/* 首页链接特殊样式 */
.mobile-menu li:first-child a {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    border-color: #2980b9;
    font-weight: 600;
}

.mobile-menu li:first-child a:hover {
    background: linear-gradient(135deg, #2980b9 0%, #1f618d 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(52, 152, 219, 0.4);
}

/* 移动端导航栏调整 */
@media (max-width: 768px) {
    .navbar-content {
        padding: 0 10px;
        height: 50px;
    }
    
    .navbar-brand {
        font-size: 1.1rem;
    }
    
    /* 隐藏桌面端导航，显示汉堡菜单 */
    .navbar-nav {
        display: none;
    }
    
    .hamburger-menu {
        display: flex !important;
    }
}

@media (max-width: 480px) {
    .navbar-content {
        padding: 0 8px;
        height: 50px;
    }
    
    .navbar-brand {
        font-size: 1rem;
    }
    
    .hamburger-menu {
        padding: 6px;
    }
    
    .hamburger-line {
        width: 22px;
        height: 2px;
    }
    
    /* 小屏幕菜单优化 */
    .mobile-menu ul {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
        padding: 12px;
    }
    
    .mobile-menu a {
        padding: 10px 6px;
        font-size: 0.8rem;
        min-height: 40px;
    }
}

/* 清爽卡片配色设计 */
.card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 24px;
    margin-bottom: 24px;
    border-radius: 12px;
    width: 100%;
    overflow: hidden;
    position: relative;
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid #e2e8f0;
    word-wrap: break-word;
    position: relative;
}

/* 移动端卡片调整 */
@media (max-width: 768px) {
    .card {
        padding: 15px;
        margin-bottom: 15px;
    }
    
    .card-title {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .card {
        padding: 12px;
        margin-bottom: 12px;
    }
    
    .card-title {
        font-size: 0.95rem;
    }
}

/* 表格移动端优化 */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
    font-size: 0.9rem;
    overflow-x: auto;
    display: block;
    white-space: nowrap;
}

table thead,
table tbody,
table tr {
    display: table;
    width: 100%;
    table-layout: fixed;
}

table th,
table td {
    padding: 8px 6px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
    word-wrap: break-word;
    overflow: hidden;
    text-overflow: ellipsis;
}

table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #2c3e50;
}

/* 移动端表格调整 */
@media (max-width: 768px) {
    table {
        font-size: 0.8rem;
    }
    
    table th,
    table td {
        padding: 6px 4px;
    }
}

@media (max-width: 480px) {
    table {
        font-size: 0.75rem;
    }
    
    table th,
    table td {
        padding: 4px 2px;
    }
}

/* 表单元素移动端优化 */
input, select, textarea, button {
    font-size: 16px; /* 防止iOS缩放 */
    max-width: 100%;
    box-sizing: border-box;
}

.search-input {
    width: 100%;
    max-width: 400px;
    padding: 12px;
    border: 1px solid #e2e8f0;
    font-size: 1rem;
    transition: border-color 0.2s ease;
    border-radius: 8px;
    background: #ffffff;
}

.search-button {
    background: #3b82f6;
    color: #ffffff;
    border: none;
    padding: 12px 24px;
    margin-left: 10px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
    border-radius: 8px;
}

/* 移动端表单调整 */
@media (max-width: 768px) {
    .search-input {
        font-size: 16px; /* 防止iOS缩放 */
        padding: 12px;
    }
    
    .search-button {
        padding: 12px 16px;
        margin-left: 8px;
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .search-button {
        margin-left: 0;
        margin-top: 8px;
        width: 100%;
    }
}

/* 网格布局移动端优化 */
.currencies-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.currency-item {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    padding: 15px;
    text-align: center;
    transition: background 0.2s ease;
    border-radius: 6px;
    word-wrap: break-word;
}

/* 移动端网格调整 */
@media (max-width: 768px) {
    .currencies-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 12px;
    }
    
    .currency-item {
        padding: 12px;
    }
}

@media (max-width: 480px) {
    .currencies-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 10px;
    }
    
    .currency-item {
        padding: 10px;
    }
}

/* 图表容器移动端优化 */
.chart-container {
    width: 100%;
    height: 400px;
    margin: 20px 0;
    overflow: hidden;
}

@media (max-width: 768px) {
    .chart-container {
        height: 300px;
        margin: 15px 0;
    }
}

@media (max-width: 480px) {
    .chart-container {
        height: 250px;
        margin: 12px 0;
    }
}

/* 文本内容移动端优化 */
h1, h2, h3, h4, h5, h6 {
    word-wrap: break-word;
    line-height: 1.3;
}

p, span, div {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* 移动端标题调整 */
@media (max-width: 768px) {
    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.3rem; }
    h3 { font-size: 1.1rem; }
    h4 { font-size: 1rem; }
}

@media (max-width: 480px) {
    h1 { font-size: 1.3rem; }
    h2 { font-size: 1.2rem; }
    h3 { font-size: 1rem; }
    h4 { font-size: 0.95rem; }
}

/* 清爽按钮配色设计 */
.btn, button, .button {
    display: inline-block;
    background: #3b82f6;
    color: #ffffff !important;
    text-decoration: none !important;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.875rem;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
    font-family: inherit;
    letter-spacing: 0.025em;
    min-height: 44px; /* iOS推荐的最小触摸目标 */
    min-width: 44px;
}

.btn:hover, button:hover, .button:hover {
    background: #2563eb;
    transform: translateY(-1px);
}

.btn:visited, button:visited, .button:visited {
    color: #ffffff;
    text-decoration: none !important;
}

.btn:focus, button:focus, .button:focus {
    color: #ffffff;
    text-decoration: none !important;
    outline: none;
}

/* 按钮变体 */
.btn-secondary {
    background: #64748b;
    color: #ffffff;
}

.btn-secondary:hover {
    background: #475569;
    color: #ffffff;
}

.btn-primary {
    background: #3b82f6;
    color: #ffffff;
}

.btn-primary:hover {
    background: #2563eb;
    color: #ffffff;
}

.btn-success {
    background: #10b981;
    color: #ffffff;
}

.btn-success:hover {
    background: #059669;
    color: #ffffff;
}

.btn-warning {
    background: #f59e0b;
    color: #ffffff;
}

.btn-warning:hover {
    background: #d97706;
    color: #ffffff;
}

.btn-danger {
    background: #ef4444;
    color: #ffffff;
}

.btn-danger:hover {
    background: #dc2626;
    color: #ffffff;
}

.btn-outline {
    background: transparent;
    color: #3b82f6;
    border: 2px solid #3b82f6;
}

.btn-outline:hover {
    background: #3b82f6;
    color: #ffffff;
}

/* 自适应按钮字号 - 防止换行 */
.currency-link, .btn, button, .button {
    font-size: 0.875rem;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* 根据按钮宽度自动调整字号 */
.currency-link {
    font-size: clamp(0.75rem, 2.5vw, 0.875rem);
}

/* 移动端进一步优化 */
@media (max-width: 768px) {
    .currency-link {
        font-size: clamp(0.7rem, 3vw, 0.8rem);
        padding: 10px 16px;
    }
}

@media (max-width: 480px) {
    .currency-link {
        font-size: clamp(0.65rem, 3.5vw, 0.75rem);
        padding: 8px 12px;
    }
}

a {
    color: #3498db;
    text-decoration: none;
    word-wrap: break-word;
}

a:hover {
    text-decoration: underline;
}

/* 响应式图片 */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* 工具提示和弹出层移动端优化 */
.tooltip, .popup {
    max-width: 90vw;
    word-wrap: break-word;
}

/* 防止水平滚动 */
.no-scroll-x {
    overflow-x: hidden;
}

/* 移动端专用样式 */
.mobile-only {
    display: none;
}

.desktop-only {
    display: block;
}

@media (max-width: 768px) {
    .mobile-only {
        display: block;
    }
    
    .desktop-only {
        display: none;
    }
}

/* 触摸友好的间距 */
@media (max-width: 768px) {
    .touch-friendly {
        padding: 12px;
        margin: 8px 0;
    }
    
    .touch-friendly button {
        margin: 4px;
    }
}

/* 确保所有内容都在视口内 */
.viewport-safe {
    max-width: 100vw;
    overflow-x: hidden;
}

/* 移动端状态栏适配 */
@media (max-width: 768px) {
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
}
