/**
 * AppTools 统一样式表
 * iOS AppStore风格 - 简洁、现代、专业
 */

/* ===== CSS变量定义 - iOS风格 ===== */
:root {
    /* iOS AppStore主色调 */
    --primary-color: #007AFF;
    --primary-dark: #0056CC;
    --primary-light: #4DA3FF;

    /* 系统颜色 */
    --success-color: #34C759;
    --warning-color: #FF9500;
    --danger-color: #FF3B30;

    /* 文字颜色 */
    --text-primary: #000000;
    --text-secondary: #8E8E93;
    --text-tertiary: #C7C7CC;

    /* 背景颜色 */
    --bg-primary: #FFFFFF;
    --bg-secondary: #F2F2F7;
    --bg-tertiary: #E5E5EA;

    /* 边框和阴影 */
    --border-color: #C6C6C8;
    --separator-color: #C6C6C8;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);

    /* 圆角 - iOS风格 */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    /* 过渡 */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;

    /* 安全区域 */
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ===== 基础重置 ===== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', sans-serif;
    font-size: 17px;
    line-height: 1.47;
    color: var(--text-primary);
    background: var(--bg-secondary);
    min-height: 100vh;
    padding-bottom: 0;
}

/* 移动端底部留白（为底部导航留空间） */
@media screen and (max-width: 768px) {
    body {
        padding-bottom: calc(60px + var(--safe-bottom));
    }
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: opacity var(--transition-fast);
}

a:hover {
    opacity: 0.7;
}

a:active {
    opacity: 0.5;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ===== Font Awesome ===== */
.fa {
    font-size: inherit;
}

/* ===== 容器布局 ===== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.main-content {
    padding-top: 60px;
    min-height: 100vh;
    background: var(--bg-secondary);
}

/* ===== 顶部导航 - iOS风格 ===== */
.nav-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 52px;
    background: rgba(249, 249, 249, 0.94);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    z-index: 1000;
    border-bottom: 0.5px solid rgba(0, 0, 0, 0.1);
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    height: 100%;
}

.nav-logo a {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-toggle {
    display: none;
}

.nav-menu {
    display: flex;
    align-items: center;
    gap: 4px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-menu li a {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.nav-menu li a:hover {
    background: rgba(0, 0, 0, 0.05);
    opacity: 1;
}

.nav-menu li a.active {
    background: var(--primary-color);
    color: #fff;
}

.nav-menu li a .fa {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

/* 移动端隐藏顶部菜单项 */
@media screen and (max-width: 768px) {
    .nav-menu {
        display: none;
    }

    .main-content {
        padding-top: 52px;
    }
}

/* ===== 移动端底部导航 - iOS TabBar风格 ===== */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(50px + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: rgba(249, 249, 249, 0.94);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-top: 0.5px solid rgba(0, 0, 0, 0.1);
    z-index: 1000;
}

.bottom-nav-container {
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: 50px;
    max-width: 500px;
    margin: 0 auto;
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    flex: 1;
    height: 100%;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.bottom-nav-item .fa {
    font-size: 22px;
}

.bottom-nav-item span {
    font-size: 10px;
    font-weight: 500;
}

.bottom-nav-item.active {
    color: var(--primary-color);
}

.bottom-nav-item:hover {
    opacity: 1;
}

@media screen and (max-width: 768px) {
    .bottom-nav {
        display: block;
    }
}

/* ===== 页面标题 - iOS Large Title风格 ===== */
.page-header {
    padding: 20px 0 16px;
}

.page-title {
    font-size: 34px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
    letter-spacing: -0.01em;
}

.page-title .fa {
    margin-right: 8px;
    color: var(--primary-color);
}

.page-subtitle {
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.4;
}

@media screen and (max-width: 768px) {
    .page-title {
        font-size: 28px;
    }

    .page-subtitle {
        font-size: 14px;
    }
}

/* ===== 卡片样式 - iOS风格 ===== */
.card {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 16px;
    box-shadow: var(--shadow-sm);
}

/* ===== 按钮样式 - iOS风格 ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 20px;
    font-size: 17px;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    font-family: inherit;
}

.btn-primary {
    background: var(--primary-color);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-dark);
    color: #fff;
    opacity: 1;
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-secondary {
    background: rgba(0, 122, 255, 0.1);
    color: var(--primary-color);
}

.btn-secondary:hover {
    background: rgba(0, 122, 255, 0.15);
    color: var(--primary-color);
    opacity: 1;
}

.btn-sm {
    padding: 8px 14px;
    font-size: 15px;
    border-radius: var(--radius-sm);
}

/* ===== 表单样式 - iOS风格 ===== */
.search-box {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

.search-form {
    display: flex;
    gap: 12px;
    align-items: stretch;
}

.form-input,
.form-select {
    height: 44px;
    padding: 0 16px;
    font-size: 17px;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-secondary);
    border: none;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    outline: none;
}

.form-input:focus,
.form-select:focus {
    background: var(--bg-tertiary);
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.2);
}

.form-input::placeholder {
    color: var(--text-tertiary);
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238E8E93' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
    cursor: pointer;
}

.search-form .form-input {
    flex: 2;
    min-width: 0;
}

.search-form .form-select {
    flex: 1;
    min-width: 120px;
}

.search-form .btn {
    flex-shrink: 0;
    height: 44px;
    padding: 0 24px;
}

/* 移动端表单垂直布局 */
@media screen and (max-width: 768px) {
    .search-form {
        flex-direction: column;
    }

    .search-form .form-input,
    .search-form .form-select,
    .search-form .btn {
        width: 100%;
        flex: none;
    }
}

/* ===== 网格布局 ===== */
.grid {
    display: grid;
    gap: 16px;
}

.grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

.grid-5 {
    grid-template-columns: repeat(5, 1fr);
}

.grid-6 {
    grid-template-columns: repeat(6, 1fr);
}

@media screen and (max-width: 960px) {

    .grid-5,
    .grid-6 {
        grid-template-columns: repeat(4, 1fr);
    }

    .grid-4 {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media screen and (max-width: 768px) {

    .grid-2,
    .grid-3,
    .grid-4,
    .grid-5,
    .grid-6 {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ===== App卡片 - iOS AppStore风格 ===== */
.app-card {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 16px;
    display: flex;
    flex-direction: column;
    transition: transform var(--transition-fast);
    min-width: 0;
    /* 防止内容撑大 */
    overflow: hidden;
}

.app-card:active {
    transform: scale(0.98);
}

.app-icon {
    width: 64px;
    height: 64px;
    min-width: 64px;
    min-height: 64px;
    border-radius: 14px;
    margin-bottom: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.app-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.3;
    word-break: break-word;
    overflow-wrap: break-word;
}

.app-info {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.app-price {
    font-size: 15px;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 12px;
}

/* App按钮组 */
.app-links {
    margin-top: auto;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.app-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 7px 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--primary-color);
    background: rgba(0, 122, 255, 0.1);
    border-radius: 100px;
    transition: all var(--transition-fast);
    white-space: nowrap;
    flex: 1;
    min-width: 0;
    height: 33px;
    flex-grow: 1;
    flex-shrink: 0;
}

.app-link:hover {
    background: rgba(0, 122, 255, 0.15);
    color: var(--primary-color);
    opacity: 1;
}

.app-link .fa {
    font-size: 12px;
}

/* 单独的app-link（不在app-links容器中） */
.app-card>.app-link {
    margin-top: auto;
    flex-shrink: 0;
    flex-grow: 0;
    align-self: flex-start;
}

/* ===== 国家卡片 - iOS风格 ===== */
.country-card {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 16px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.country-card:active {
    transform: scale(0.96);
    background: var(--bg-tertiary);
}

.country-flag {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    margin: 0 auto 10px;
    object-fit: cover;
    box-shadow: var(--shadow-sm);
}

.country-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.country-name-en {
    font-size: 11px;
    color: var(--text-tertiary);
}

/* ===== 模态框 - iOS风格 ===== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 2000;
    align-items: flex-end;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: var(--bg-primary);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    padding: 24px;
    padding-bottom: calc(24px + var(--safe-bottom));
    width: 100%;
    max-width: 500px;
    position: relative;
    animation: modalSlideUp 0.3s ease;
}

@media screen and (min-width: 769px) {
    .modal-overlay {
        align-items: center;
    }

    .modal-content {
        border-radius: var(--radius-xl);
        max-width: 420px;
        padding-bottom: 24px;
    }
}

@keyframes modalSlideUp {
    from {
        opacity: 0;
        transform: translateY(100%);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-handle {
    width: 36px;
    height: 5px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    margin: 0 auto 16px;
}

.modal-close {
    display: none;
}

.modal-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.modal-flag {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    box-shadow: var(--shadow-sm);
}

.modal-title {
    font-size: 22px;
    font-weight: 700;
}

.modal-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
}

.modal-body {
    margin-bottom: 20px;
}

.modal-body p {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.modal-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.modal-actions .btn {
    width: 100%;
    height: 50px;
    font-size: 17px;
}

/* ===== 表格样式 - iOS风格 ===== */
.table-container {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.data-table th,
.data-table td {
    padding: 12px 14px;
    text-align: left;
    vertical-align: middle;
}

.data-table th {
    background: var(--bg-secondary);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.data-table td {
    border-top: 0.5px solid var(--separator-color);
}

.data-table tr:first-child td {
    border-top: none;
}

/* 表格列宽定义 */
.data-table .col-rank {
    width: 55px;
}

.data-table .col-icon {
    width: 65px;
}

.data-table .col-name {
    width: auto;
}

.data-table .col-developer {
    width: 20%;
}

.data-table .col-date {
    width: 100px;
}

.data-table .col-action {
    width: 90px;
}

/* 表格图标样式 - 保持正方形 */
.table-icon {
    width: 48px;
    height: 48px;
    min-width: 48px;
    min-height: 48px;
    max-width: 48px;
    max-height: 48px;
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
    object-fit: cover;
}

/* 表格文本溢出处理 */
.data-table .cell-text {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 表格内按钮 */
.data-table .btn-sm {
    white-space: nowrap;
    padding: 6px 12px;
    font-size: 13px;
}

/* ===== 描述区块 - iOS风格 ===== */
.info-banner {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

.info-banner-icon i {
    font-size: 40px;
    flex-shrink: 0;
    color: var(--primary-color);
}

.info-banner-content h3 {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 6px;
}

.info-banner-content p {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.info-banner-content ul {
    font-size: 14px;
    color: var(--text-secondary);
    padding-left: 18px;
    margin: 0;
}

.info-banner-content li {
    margin-bottom: 4px;
}

.info-banner .search-input {
    margin-top: 10px;
    height: 36px;
    padding: 0 12px;
    background: var(--bg-secondary);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    width: 100%;
    max-width: 280px;
    outline: none;
}

.info-banner .search-input:focus {
    background: var(--bg-tertiary);
}

@media screen and (max-width: 768px) {
    .info-banner {
        flex-direction: column;
        text-align: center;
        align-items: center;
    }

    .info-banner-content ul {
        text-align: left;
    }

    .info-banner .search-input {
        max-width: 100%;
    }
}

/* ===== 首页样式 - iOS风格 ===== */
.hero-section {
    text-align: center;
    padding: 60px 0 40px;
}

.hero-title {
    font-size: 40px;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.hero-title .fa {
    color: var(--primary-color);
}

.hero-subtitle {
    font-size: 17px;
    color: var(--text-secondary);
    max-width: 400px;
    margin: 0 auto 40px;
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 60px;
}

.feature-card {
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    padding: 32px 24px;
    text-align: center;
    transition: all var(--transition-fast);
    text-decoration: none;
    display: block;
    box-shadow: var(--shadow-sm);
}

.feature-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    opacity: 1;
}

.feature-card:active {
    transform: scale(0.98);
}

.feature-icon {
    font-size: 48px;
    margin-bottom: 16px;
    color: var(--primary-color);
}

.feature-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.feature-desc {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
}

@media screen and (max-width: 768px) {
    .hero-section {
        padding: 40px 0 24px;
    }

    .hero-title {
        font-size: 28px;
    }

    .hero-subtitle {
        font-size: 15px;
        margin-bottom: 24px;
    }

    .feature-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .feature-card {
        padding: 24px 20px;
    }

    .feature-icon {
        font-size: 36px;
        margin-bottom: 12px;
    }
}

/* ===== 空状态 ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-tertiary);
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 12px;
    color: var(--text-tertiary);
}

.empty-state-text {
    font-size: 15px;
}

/* ===== 加载状态 ===== */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 40px;
    color: var(--text-secondary);
    font-size: 15px;
}

.loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--bg-tertiary);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ===== 移动端卡片视图 ===== */
.mobile-cards {
    display: none;
}

@media screen and (max-width: 768px) {
    .table-container {
        display: none;
    }

    .mobile-cards {
        display: grid !important;
    }
}

/* ===== 通用工具类 ===== */
.text-center {
    text-align: center;
}

.text-secondary {
    color: var(--text-secondary);
}

.mt-20 {
    margin-top: 20px;
}

.mb-20 {
    margin-bottom: 20px;
}

/* ===== 页脚 ===== */
.page-footer {
    text-align: center;
    padding: 40px 20px;
    font-size: 13px;
    color: var(--text-tertiary);
}

.page-footer a {
    color: var(--primary-color);
}