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

:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --background: #f8fafc;
    --surface: #ffffff;
    --border-color: #e2e8f0;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --border-radius: 12px;
    --transition: all 0.3s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #ffffff;
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    padding: 20px 0;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

/* 头部样式 */
.header {
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
    text-align: center;
    padding: 40px 20px 30px;
    background: #ffffff;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    margin-bottom: 30px;
    border: 1px solid var(--border-color);
}

.header-logo {
    margin-bottom: 20px;
    animation: logoFloat 3s ease-in-out infinite;
}

.header-logo img {
    display: inline-block;
    max-width: 100%;
    height: auto;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

@keyframes logoFloat {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-8px);
    }
}

.header h1 {
    font-size: 2.5rem;
    color: var(--primary-color);
    margin-bottom: 10px;
    font-weight: 700;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* 转换器区域 */
.converter-section {
    margin-bottom: 40px;
    display: flex;
    justify-content: center;
}

.converter-box-unified {
    max-width: 1200px;
    background: var(--surface);
    border-radius: var(--border-radius);
    padding: 35px;
    box-shadow: var(--shadow-lg);
    max-width: 1200px;
    width: 100%;
    border: 1px solid var(--border-color);
}

/* 模式切换 */
.mode-switch {
    display: flex;
    gap: 10px;
    margin-bottom: 25px;
    background: #f8fafc;
    padding: 8px;
    border-radius: 10px;
}

.mode-btn {
    flex: 1;
    padding: 14px 20px;
    border: none;
    background: transparent;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.mode-btn:hover {
    background: #e2e8f0;
    color: var(--text-primary);
}

.mode-btn.active {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 2px 4px rgba(79, 70, 229, 0.3);
}

.mode-icon {
    font-size: 1.2rem;
}

/* 输入输出组 */
.input-group,
.output-group {
    margin-bottom: 20px;
}

.input-group label,
.output-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-primary);
}

textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-family: 'Courier New', monospace;
    transition: var(--transition);
    resize: vertical;
    background: #f8fafc;
}

textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--surface);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

textarea[readonly] {
    background: #f1f5f9;
    cursor: default;
}

/* 格式选项 */
.format-options {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 25px;
    padding: 18px;
    background: #f8fafc;
    border-radius: 8px;
    align-items: center;
}

.format-label {
    font-weight: 600;
    color: var(--text-primary);
    margin-right: 10px;
}

.radio-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.radio-label input[type="radio"] {
    margin-right: 6px;
    cursor: pointer;
    width: 18px;
    height: 18px;
}

.radio-label span {
    font-size: 0.95rem;
    color: var(--text-primary);
}

/* 转换按钮区域 */
.convert-action {
    display: flex;
    justify-content: center;
    margin-bottom: 25px;
}

.btn-convert {
    padding: 16px 50px;
    background: linear-gradient(135deg, var(--primary-color), #6366f1);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.btn-convert:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(79, 70, 229, 0.4);
}

.btn-convert:active {
    transform: translateY(-1px);
}

.convert-icon {
    font-size: 1.3rem;
    animation: rotate 2s linear infinite;
}

@keyframes rotate {
    0%, 100% {
        transform: rotate(0deg);
    }
    50% {
        transform: rotate(180deg);
    }
}

.btn-convert:hover .convert-icon {
    animation-duration: 0.5s;
}

/* 按钮组 */
.button-group {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 20px;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
}

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

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background: #475569;
    transform: translateY(-2px);
}

.btn:active {
    transform: translateY(0);
}

/* 表格区域 */
.table-section {
    background: var(--surface);
    border-radius: var(--border-radius);
    padding: 30px;
    box-shadow: var(--shadow-lg);
    margin: 0 auto 40px;
    max-width: 1200px;
    border: 1px solid var(--border-color);
}

.table-header {
    margin-bottom: 25px;
}

.table-header h2 {
    color: var(--primary-color);
    font-size: 1.8rem;
    margin-bottom: 10px;
}

.table-description {
    color: var(--text-secondary);
    margin-bottom: 20px;
}

/* 搜索框 */
.search-box {
    position: relative;
    max-width: 500px;
}

.search-box input {
    width: 100%;
    padding: 12px 40px 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: var(--transition);
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.search-icon {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.2rem;
    pointer-events: none;
}

/* ASCII 表格 */
.table-container {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.ascii-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.ascii-table thead {
    background: linear-gradient(135deg, var(--primary-color), #6366f1);
    color: white;
    position: sticky;
    top: 0;
    z-index: 10;
}

.ascii-table th {
    padding: 15px 12px;
    text-align: left;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    transition: var(--transition);
}

.ascii-table th:hover {
    background: var(--primary-hover);
}

.ascii-table tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: var(--transition);
}

.ascii-table tbody tr:hover {
    background: #f8fafc;
}

.ascii-table tbody tr:nth-child(even) {
    background: #fafbfc;
}

.ascii-table tbody tr:nth-child(even):hover {
    background: #f1f5f9;
}

.ascii-table td {
    padding: 12px;
    font-family: 'Courier New', monospace;
}

.ascii-table td:nth-child(5) {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--primary-color);
}

.ascii-table td:nth-child(6) {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--text-secondary);
}

.control-char {
    color: #dc2626;
    font-weight: 600;
}

.printable-char {
    color: var(--success-color);
    font-weight: 600;
}

/* 信息区域 */
.info-section {
    background: var(--surface);
    border-radius: var(--border-radius);
    padding: 30px;
    box-shadow: var(--shadow-lg);
    margin: 0 auto 40px;
    max-width: 1200px;
    border: 1px solid var(--border-color);
}

.info-section h2 {
    color: var(--primary-color);
    font-size: 1.8rem;
    margin-bottom: 20px;
}

.info-section h3 {
    color: var(--text-primary);
    font-size: 1.3rem;
    margin: 20px 0 10px;
}

.info-content {
    color: var(--text-primary);
    line-height: 1.8;
}

.info-content p {
    margin-bottom: 15px;
}

.info-content ul {
    margin-left: 25px;
    margin-bottom: 15px;
}

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

.info-content strong {
    color: var(--primary-color);
}

/* 页脚 */
.footer {
    text-align: center;
    padding: 30px 20px;
    background: var(--surface);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    color: var(--text-secondary);
    margin: 0 auto;
    max-width: 1200px;
    border: 1px solid var(--border-color);
}

/* 返回顶部按钮 */
.back-to-top {
    position: fixed;
    bottom: 40px;
    right: 40px;
    width: 50px;
    height: 50px;
    background: #ffffff;
    color: var(--primary-color);
    border: 2px solid var(--border-color);
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: var(--transition);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(100px);
}

.back-to-top.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.back-to-top:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
    border-color: var(--primary-color);
    background: #f8fafc;
}

.back-to-top:active {
    transform: translateY(-2px);
}

.back-to-top-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-5px);
    }
}

.back-to-top:hover .back-to-top-icon {
    animation: none;
}

/* 响应式设计 */
@media (max-width: 1200px) {
    .converter-box-unified {
    max-width: 1200px;
        max-width: 100%;
    }
}

@media (max-width: 768px) {
    .header h1 {
        font-size: 2rem;
    }

    .header-logo img {
        height: 50px;
    }

    .converter-box-unified,
    .table-section,
    .info-section {
        padding: 20px;
    }

    .mode-switch {
        flex-direction: column;
    }

    .mode-btn {
        padding: 12px;
    }

    .format-options {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }

    .format-label {
        margin-bottom: 5px;
    }

    .btn-convert {
        width: 100%;
        padding: 14px;
    }

    .button-group {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }

    .ascii-table {
        font-size: 0.85rem;
    }

    .ascii-table th,
    .ascii-table td {
        padding: 8px 6px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px 0;
    }

    .header {
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
        padding: 25px 15px;
    }

    .header h1 {
        font-size: 1.6rem;
    }

    .subtitle {
        font-size: 0.95rem;
    }

    .table-section,
    .info-section {
        padding: 20px;
    }

    .back-to-top {
        bottom: 20px;
        right: 20px;
        width: 45px;
        height: 45px;
        font-size: 20px;
    }
}

/* 滚动条样式 */
.table-container::-webkit-scrollbar {
    height: 8px;
}

.table-container::-webkit-scrollbar-track {
    background: #f1f5f9;
}

.table-container::-webkit-scrollbar-thumb {
    background: var(--secondary-color);
    border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb:hover {
    background: #475569;
}

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

.converter-box,
.table-section,
.info-section {
    animation: fadeIn 0.5s ease-out;
}

/* 复制成功提示 */
.copy-success {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--success-color);
    color: white;
    padding: 15px 25px;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}


/* 优化后的表格标题区域 */
.table-title-row {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 24px;
}

.table-icon-wrapper {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #4f46e5, #6366f1);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.table-icon-wrapper i,
.table-icon-wrapper svg {
    width: 28px;
    height: 28px;
    color: white;
}

.table-title-text h2 {
    margin: 0 0 6px 0;
    font-size: 1.6rem;
}

.table-title-text .table-description {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.5;
}

/* 优化后的搜索框 */
.search-box {
    position: relative;
    max-width: 100%;
    display: flex;
    align-items: center;
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 4px;
    transition: all 0.2s ease;
}

.search-box:focus-within {
    border-color: #4f46e5;
    background: white;
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

.search-icon-lucide {
    width: 20px;
    height: 20px;
    color: #94a3b8;
    margin-left: 12px;
    flex-shrink: 0;
}

.search-box input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 12px;
    font-size: 1rem;
    outline: none;
}

.search-box input::placeholder {
    color: #94a3b8;
}

.search-kbd {
    background: #e2e8f0;
    color: #64748b;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-family: inherit;
    margin-right: 8px;
    white-space: nowrap;
}

/* 隐藏原来的搜索图标 */
.search-icon {
    display: none;
}

/* ==================== ASCII 卡片网格布局 ==================== */
.ascii-cards-section {
    max-width: 1200px;
}

.filter-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.filter-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 2px solid #e2e8f0;
    background: white;
    border-radius: 20px;
    font-size: 0.9rem;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-tab i, .filter-tab svg {
    width: 16px;
    height: 16px;
}

.filter-tab:hover {
    border-color: #4f46e5;
    color: #4f46e5;
}

.filter-tab.active {
    background: linear-gradient(135deg, #4f46e5, #6366f1);
    border-color: transparent;
    color: white;
}

/* 卡片网格 */
.ascii-cards-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 12px;
    max-height: 600px;
    overflow-y: auto;
    padding: 4px;
}

/* 单个卡片 */
.ascii-card {
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.ascii-card:hover {
    border-color: #4f46e5;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(79, 70, 229, 0.15);
}

.ascii-card.control {
    background: linear-gradient(135deg, #fef2f2, #fee2e2);
    border-color: #fecaca;
}

.ascii-card.control:hover {
    border-color: #f87171;
}

.ascii-card.number {
    background: linear-gradient(135deg, #eff6ff, #dbeafe);
    border-color: #bfdbfe;
}

.ascii-card.number:hover {
    border-color: #3b82f6;
}

.ascii-card.upper {
    background: linear-gradient(135deg, #f0fdf4, #dcfce7);
    border-color: #bbf7d0;
}

.ascii-card.upper:hover {
    border-color: #22c55e;
}

.ascii-card.lower {
    background: linear-gradient(135deg, #fefce8, #fef9c3);
    border-color: #fef08a;
}

.ascii-card.lower:hover {
    border-color: #eab308;
}

.ascii-card.symbol {
    background: linear-gradient(135deg, #faf5ff, #f3e8ff);
    border-color: #e9d5ff;
}

.ascii-card.symbol:hover {
    border-color: #a855f7;
}

/* 卡片内容 */
.ascii-card-char {
    font-size: 1.8rem;
    font-weight: 700;
    color: #1e293b;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Courier New', monospace;
}

.ascii-card-char.special {
    font-size: 0.7rem;
    color: #dc2626;
    font-weight: 600;
    background: #fee2e2;
    padding: 4px 6px;
    border-radius: 4px;
}

.ascii-card-codes {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 8px;
    font-size: 0.75rem;
    color: #64748b;
}

.ascii-card-dec {
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
}

.ascii-card-hex {
    background: #e0e7ff;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    color: #4f46e5;
}

/* 卡片详情弹出层 */
.ascii-card-detail {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) scale(0.9);
    background: #1e293b;
    color: white;
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 0.8rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 100;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.ascii-card-detail::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #1e293b;
}

.ascii-card:hover .ascii-card-detail {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) scale(1);
}

.ascii-card-detail-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin: 4px 0;
}

.ascii-card-detail-label {
    color: #94a3b8;
}

.ascii-card-detail-value {
    font-family: monospace;
    color: #67e8f9;
}

/* 隐藏卡片 */
.ascii-card.hidden {
    display: none;
}

/* 响应式 */
@media (max-width: 1024px) {
    .ascii-cards-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

@media (max-width: 768px) {
    .ascii-cards-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    .filter-tabs {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .ascii-cards-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }
    .ascii-card {
        padding: 8px;
    }
    .ascii-card-char {
        font-size: 1.4rem;
    }
    .filter-tab {
        padding: 6px 12px;
        font-size: 0.8rem;
    }
}

/* 滚动条美化 */
.ascii-cards-grid::-webkit-scrollbar {
    width: 8px;
}
.ascii-cards-grid::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}
.ascii-cards-grid::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
.ascii-cards-grid::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* 修复：详情弹出层改为下方显示 */
.ascii-card-detail {
    bottom: auto;
    top: calc(100% + 8px);
}

.ascii-card-detail::after {
    top: auto;
    bottom: 100%;
    border-top-color: transparent;
    border-bottom-color: #1e293b;
}

/* 修复弹出层被遮挡问题 */
.ascii-card {
    position: relative;
    z-index: 1;
}

.ascii-card:hover {
    z-index: 1000;
}

.ascii-card-detail {
    z-index: 1001;
}

/* Lucide 图标样式 */
.mode-icon {
    width: 20px;
    height: 20px;
    display: inline-block;
    vertical-align: middle;
}

.convert-icon {
    width: 22px;
    height: 22px;
    display: inline-block;
    vertical-align: middle;
}

.btn-icon {
    width: 18px;
    height: 18px;
    display: inline-block;
    vertical-align: middle;
    margin-right: 4px;
}

.back-to-top-icon {
    width: 24px;
    height: 24px;
}

.mode-btn i, .mode-btn svg,
.btn-convert i, .btn-convert svg,
.btn i, .btn svg,
.back-to-top i, .back-to-top svg {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* 新表头样式 */
.header-content-new {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-bottom: 10px;
}

.header-icon-wrapper {
    width: 72px;
    height: 72px;
    background: linear-gradient(135deg, #4f46e5, #6366f1);
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 8px 24px rgba(79, 70, 229, 0.35);
}

.header-icon-wrapper i,
.header-icon-wrapper svg {
    width: 36px;
    height: 36px;
    color: white;
}

.header-text {
    text-align: left;
}

.header-text h1 {
    font-size: 2.2rem;
    color: #1e293b;
    margin: 0 0 6px 0;
    font-weight: 700;
}

.header-text .subtitle {
    margin: 0;
    font-size: 1.1rem;
    color: #64748b;
}

@media (max-width: 480px) {
    .header-content-new {
        flex-direction: column;
        text-align: center;
    }
    .header-text {
        text-align: center;
    }
    .header-text h1 {
        font-size: 1.6rem;
    }
    .header-icon-wrapper {
        width: 60px;
        height: 60px;
    }
    .header-icon-wrapper i,
    .header-icon-wrapper svg {
        width: 30px;
        height: 30px;
    }
}
