/* style.css - 包含手机适配的样式 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
}

body {
    background-color: #f5f7fa;
    color: #333;
    line-height: 1.6;
    padding: 10px;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

header {
    text-align: center;
    margin-bottom: 20px;
    padding: 15px;
    background: linear-gradient(90deg, #2c3e50, #4a6491);
    color: white;
    border-radius: 10px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

h1 {
    font-size: 1.8rem;
    margin-bottom: 8px;
    font-weight: 600;
}

.subtitle {
    font-size: 0.95rem;
    opacity: 0.9;
    line-height: 1.4;
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
    background: white;
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.05);
}

.tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.tab-btn {
    padding: 10px 15px;
    background: #eef2f7;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    color: #4a5568;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    flex: 1;
    min-width: 140px;
    text-align: center;
}

.tab-btn:hover {
    background: #dbe4f0;
    transform: translateY(-2px);
}

.tab-btn.active {
    background: #4a6491;
    color: white;
    box-shadow: 0 3px 6px rgba(74, 100, 145, 0.3);
}

.action-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.btn {
    padding: 10px 15px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    flex: 1;
    min-width: 120px;
}

.btn-primary {
    background: #4a6491;
    color: white;
}

.btn-primary:hover {
    background: #3a5379;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(74, 100, 145, 0.25);
}

.btn-success {
    background: #2e8b57;
    color: white;
}

.btn-success:hover {
    background: #267449;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(46, 139, 87, 0.25);
}

.btn-danger {
    background: #f56c6c;
    color: white;
}

.btn-danger:hover {
    background: #dd6161;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(245, 108, 108, 0.25);
}

.sheet-container {
    background: white;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    margin-bottom: 20px;
    display: none;
    animation: fadeIn 0.5s ease;
}

.sheet-container.active {
    display: block;
}

.sheet-header {
    background: #4a6491;
    color: white;
    padding: 15px;
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    flex-direction: column;
    gap: 10px;
    text-align: center;
}

.sheet-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
}

.total-distance, .row-count {
    font-size: 0.95rem;
    background: rgba(255, 255, 255, 0.15);
    padding: 6px 12px;
    border-radius: 5px;
    width: 100%;
    max-width: 250px;
}

.table-container {
    overflow-x: auto;
    padding: 10px;
    -webkit-overflow-scrolling: touch; /* 平滑滚动iOS */
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 800px; /* 在小屏幕上允许水平滚动 */
    font-size: 0.9rem;
}

thead {
    background: #f1f5f9;
}

th {
    padding: 12px 8px;
    text-align: left;
    font-weight: 600;
    color: #2d3748;
    border-bottom: 2px solid #e2e8f0;
    white-space: nowrap;
    font-size: 0.9rem;
}

td {
    padding: 10px 8px;
    border-bottom: 1px solid #e2e8f0;
    position: relative;
}

tbody tr:hover {
    background-color: #f8fafc;
}

input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    font-size: 0.9rem;
    transition: border-color 0.3s;
}

input:focus {
    outline: none;
    border-color: #4a6491;
    box-shadow: 0 0 0 2px rgba(74, 100, 145, 0.1);
}

.delete-row-btn {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #f56c6c;
    cursor: pointer;
    font-size: 14px;
    opacity: 1; /* 手机上始终显示删除按钮 */
    padding: 5px;
    border-radius: 3px;
    background-color: rgba(255, 255, 255, 0.8);
}

.delete-row-btn:hover {
    background-color: rgba(245, 108, 108, 0.1);
}

.add-row-container {
    padding: 15px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: center;
}

.add-row-btn {
    width: 100%;
    max-width: 300px;
}

.footer {
    text-align: center;
    padding: 20px;
    color: #64748b;
    font-size: 0.85rem;
    background: white;
    border-radius: 10px;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.05);
    margin-top: 20px;
}

.notification {
    position: fixed;
    bottom: 20px;
    right: 10px;
    left: 10px;
    padding: 12px 16px;
    background: #2e8b57;
    color: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 8px;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.4s ease;
    z-index: 1000;
    max-width: 400px;
    margin: 0 auto;
}

.notification.show {
    transform: translateY(0);
    opacity: 1;
}

.notification.warning {
    background: #e6a23c;
}

.notification.error {
    background: #f56c6c;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeOut {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(-20px); }
}

.fade-out {
    animation: fadeOut 0.3s ease forwards;
}

/* 平板设备适配 */
@media (min-width: 600px) {
    body {
        padding: 15px;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    .controls {
        flex-direction: row;
        justify-content: space-between;
        align-items: flex-start;
    }
    
    .tabs {
        justify-content: flex-start;
    }
    
    .action-buttons {
        justify-content: flex-end;
    }
    
    .tab-btn, .btn {
        flex: none;
    }
    
    .sheet-header {
        flex-direction: row;
        justify-content: space-between;
        text-align: left;
    }
    
    .sheet-info {
        flex-direction: row;
        gap: 15px;
    }
    
    .total-distance, .row-count {
        width: auto;
        max-width: none;
    }
    
    .notification {
        right: 20px;
        left: auto;
        max-width: 300px;
    }
    
    .delete-row-btn {
        opacity: 0;
    }
    
    tr:hover .delete-row-btn {
        opacity: 1;
    }
}

/* 桌面设备适配 */
@media (min-width: 992px) {
    body {
        padding: 20px;
    }
    
    h1 {
        font-size: 2.5rem;
    }
    
    .subtitle {
        font-size: 1.1rem;
    }
    
    .tab-btn {
        padding: 12px 24px;
        font-size: 1rem;
    }
    
    .btn {
        padding: 12px 24px;
        font-size: 1rem;
    }
    
    .sheet-header {
        padding: 20px;
        font-size: 1.4rem;
    }
    
    .total-distance, .row-count {
        font-size: 1.1rem;
        padding: 8px 15px;
    }
    
    table {
        min-width: 1200px;
        font-size: 1rem;
    }
    
    th, td {
        padding: 14px 12px;
    }
    
    th {
        font-size: 1rem;
    }
    
    input {
        padding: 10px 12px;
        font-size: 1rem;
    }
    
    .delete-row-btn {
        font-size: 16px;
    }
}

/* 超大屏幕适配 */
@media (min-width: 1400px) {
    .table-container {
        padding: 20px;
    }
}

/* 手机横屏适配 */
@media (max-height: 500px) and (orientation: landscape) {
    .container {
        max-width: 100%;
    }
    
    header {
        padding: 10px 15px;
        margin-bottom: 15px;
    }
    
    h1 {
        font-size: 1.5rem;
        margin-bottom: 5px;
    }
    
    .subtitle {
        font-size: 0.85rem;
    }
    
    .controls {
        padding: 10px 15px;
        margin-bottom: 15px;
    }
    
    .sheet-header {
        padding: 10px 15px;
        font-size: 1rem;
    }
    
    .table-container {
        padding: 8px;
    }
    
    th, td {
        padding: 8px 6px;
    }
    
    input {
        padding: 6px 8px;
    }
}

/* 高分辨率设备适配 */
@media (min-resolution: 192dpi) {
    input {
        font-size: 16px; /* 防止iOS设备自动放大 */
    }
}

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {
    .btn, .tab-btn, input, .delete-row-btn {
        min-height: 44px; /* 苹果推荐的最小触摸目标尺寸 */
    }
    
    input {
        font-size: 16px; /* 防止iOS设备自动放大 */
    }
    
    .delete-row-btn {
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* 在触摸设备上，删除按钮始终可见 */
    .delete-row-btn {
        opacity: 1 !important;
        background-color: rgba(245, 108, 108, 0.1);
    }
}

/* 暗色模式适配 */
@media (prefers-color-scheme: dark) {
    body {
        background: linear-gradient(135deg, #1a202c 0%, #2d3748 100%);
        color: #e2e8f0;
    }
    
    .controls, .sheet-container, .footer {
        background: #2d3748;
        color: #e2e8f0;
    }
    
    thead {
        background: #4a5568;
    }
    
    th {
        color: #e2e8f0;
        border-bottom-color: #4a5568;
    }
    
    td {
        border-bottom-color: #4a5568;
    }
    
    tbody tr:hover {
        background-color: #4a5568;
    }
    
    input {
        background-color: #4a5568;
        border-color: #718096;
        color: #e2e8f0;
    }
    
    input:focus {
        border-color: #4a6491;
        box-shadow: 0 0 0 2px rgba(74, 100, 145, 0.3);
    }
    
    .delete-row-btn {
        background-color: rgba(45, 55, 72, 0.8);
    }
}