/* ========================================
   Image Compression Tool - yasuo
   Clean modern style, responsive
   ======================================== */

/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
    font-size: 15px;
    line-height: 1.6;
    color: #1e293b;
    background: linear-gradient(135deg, #e8f4fd 0%, #f0f4f8 50%, #e3edf5 100%);
    min-height: 100vh;
}

a { color: #2563eb; text-decoration: none; }
a:hover { color: #1d4ed8; }

/* ============================================ */
/* Topbar Navigation                            */
/* ============================================ */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 56px;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    position: sticky;
    top: 0;
    z-index: 100;
}

.brand {
    font-size: 18px;
    font-weight: 700;
    color: #2563eb;
    letter-spacing: -0.5px;
}

.nav-links { display: flex; gap: 4px; align-items: center; }
.nav-links a {
    color: #475569;
    font-size: 14px;
    padding: 6px 14px;
    border-radius: 6px;
    transition: all 0.2s;
}
.nav-links a:hover {
    background: #f1f5f9;
    color: #2563eb;
}

/* ============================================ */
/* Main Container                               */
/* ============================================ */
#app {
    max-width: 960px;
    margin: 0 auto;
    padding: 24px 20px 60px;
}

/* ============================================ */
/* Page Header                                  */
/* ============================================ */
.page-header {
    text-align: center;
    padding: 40px 0 32px;
}

.page-header h1 {
    font-size: 34px;
    font-weight: 800;
    color: #0f172a;
    letter-spacing: -1px;
    margin-bottom: 10px;
}

.page-header .subtitle {
    font-size: 16px;
    color: #64748b;
    max-width: 480px;
    margin: 0 auto;
}

/* ============================================ */
/* Controls Bar                                 */
/* ============================================ */
.controls-bar {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 16px 24px;
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.control-label {
    font-size: 13px;
    font-weight: 600;
    color: #64748b;
    white-space: nowrap;
}

.quality-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

#qualityRange {
    width: 160px;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: #e2e8f0;
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

#qualityRange::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: #2563eb;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(37,99,235,0.3);
    transition: transform 0.15s;
}

#qualityRange::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.quality-label {
    font-size: 14px;
    font-weight: 600;
    color: #2563eb;
    white-space: nowrap;
}

.dim-input {
    width: 80px;
    padding: 8px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    text-align: center;
    color: #1e293b;
    outline: none;
    transition: border-color 0.2s;
}

.dim-input::placeholder {
    color: #cbd5e1;
    font-size: 13px;
}

.dim-input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.dim-unit {
    color: #94a3b8;
    font-size: 13px;
}

.dim-desc {
    color: #94a3b8;
    font-size: 12px;
    margin-left: 4px;
}

.control-group .dim-input + text {
    color: #94a3b8;
    font-size: 13px;
}

/* ============================================ */
/* Buttons                                      */
/* ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-primary {
    background: #2563eb;
    color: #fff;
}
.btn-primary:hover {
    background: #1d4ed8;
    box-shadow: 0 2px 8px rgba(37,99,235,0.3);
}

.btn-outline {
    background: #fff;
    color: #64748b;
    border: 1px solid #e2e8f0;
}
.btn-outline:hover {
    border-color: #cbd5e1;
    color: #475569;
    background: #f8fafc;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

/* ============================================ */
/* Upload Section / Drop Zone                   */
/* ============================================ */
.upload-section { margin-bottom: 20px; }

.drop-zone {
    position: relative;
    border: 2px dashed #cbd5e1;
    border-radius: 14px;
    background: rgba(255,255,255,0.6);
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s ease;
}

.drop-zone:hover,
.drop-zone.dragover {
    border-color: #2563eb;
    background: rgba(37,99,235,0.04);
    box-shadow: 0 0 0 4px rgba(37,99,235,0.06);
}

.drop-zone.dragover {
    transform: scale(1.01);
}

.drop-zone.has-files {
    padding: 24px;
}

.upload-icon {
    margin-bottom: 12px;
    opacity: 0.6;
    transition: opacity 0.25s;
}

.drop-zone:hover .upload-icon,
.drop-zone.dragover .upload-icon {
    opacity: 1;
}

.drop-text {
    font-size: 17px;
    color: #475569;
    margin-bottom: 8px;
}

.browse-link {
    color: #2563eb;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.drop-hint {
    font-size: 13px;
    color: #94a3b8;
}

.hint-compress {
    margin-top: 8px;
    color: #16a34a;
    font-weight: 500;
}

.drop-zone.has-files .drop-zone-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.drop-zone.has-files .upload-icon { margin-bottom: 0; }
.drop-zone.has-files .drop-text { margin-bottom: 0; font-size: 15px; }

/* ============================================ */
/* Results Section                              */
/* ============================================ */
.results-section {
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    overflow: hidden;
}

.results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #f1f5f9;
    flex-wrap: wrap;
    gap: 12px;
}

.results-header h2 {
    font-size: 20px;
    font-weight: 700;
    color: #0f172a;
}

.results-summary {
    font-size: 14px;
    color: #64748b;
    font-weight: 500;
}

.results-summary .saved-highlight {
    color: #16a34a;
    font-weight: 700;
}

/* Results Table */
.results-table { padding: 0; overflow-x: auto; }

/* Header Row */
.result-header-row {
    display: grid;
    grid-template-columns: 1fr 160px 160px 100px 80px;
    padding: 10px 24px;
    background: #f8fafc;
    border-bottom: 2px solid #e2e8f0;
    font-size: 13px;
    font-weight: 700;
    color: #64748b;
    min-width: 680px;
}

.result-header-row > * {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Data Row */
.result-row {
    display: grid;
    grid-template-columns: 1fr 160px 160px 100px 80px;
    align-items: center;
    padding: 14px 24px;
    border-bottom: 1px solid #f1f5f9;
    min-height: 72px;
    transition: background 0.15s;
    min-width: 680px;
}

.result-row:last-child { border-bottom: none; }
.result-row:hover { background: #f8fafc; }

/* Column: Image */
.col-image {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.result-thumb {
    flex-shrink: 0;
    width: 56px;
    height: 56px;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: center;
}

.result-thumb img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.result-filename {
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

/* Column: Original / Compressed */
.col-original,
.col-compressed {
    text-align: center;
}

.cell-dim {
    font-size: 13px;
    color: #64748b;
    margin-bottom: 2px;
}

.cell-size {
    font-size: 13px;
    color: #64748b;
    font-weight: 500;
}

.cell-size-compressed {
    font-size: 13px;
    color: #16a34a;
    font-weight: 600;
}

/* Column: Ratio */
.col-ratio {
    text-align: center;
}

.ratio-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 700;
    background: #dcfce7;
    color: #16a34a;
}

.ratio-badge.ratio-low {
    background: #fef9c3;
    color: #a16207;
}

.ratio-none {
    font-size: 13px;
    color: #94a3b8;
}

/* Column: Action */
.col-action {
    text-align: center;
}

/* Results Actions Footer */
.results-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 20px 24px;
    border-top: 1px solid #f1f5f9;
    flex-wrap: wrap;
}

.results-actions .btn-primary {
    padding: 12px 28px;
    font-size: 16px;
    border-radius: 10px;
}

/* ============================================ */
/* Pending File List (table: thumb | name | size | remove) */
/* ============================================ */
.pending-section {
    margin-bottom: 20px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.pending-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 14px;
    color: #64748b;
}

.pending-count strong {
    color: #2563eb;
}

.pending-table {
    padding: 0;
}

.pending-row {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    border-bottom: 1px solid #f8fafc;
    gap: 12px;
    transition: background 0.15s;
}

.pending-row:last-child { border-bottom: none; }
.pending-row:hover { background: #f8fafc; }

.pending-cell { }

.pending-thumb {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pending-thumb img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.pending-name {
    flex: 1;
    min-width: 0;
    font-size: 14px;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pending-size {
    flex-shrink: 0;
    font-size: 13px;
    color: #94a3b8;
    min-width: 80px;
    text-align: right;
}

.pending-action {
    flex-shrink: 0;
}

.pending-action .remove-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px solid #e2e8f0;
    background: #fff;
    color: #94a3b8;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.pending-action .remove-btn:hover {
    border-color: #ef4444;
    color: #ef4444;
    background: #fef2f2;
}

/* Compress Button Bar */
.compress-bar {
    display: flex;
    justify-content: center;
    margin-top: 20px;
    margin-bottom: 20px;
}

.compress-bar .btn-primary {
    padding: 14px 48px;
    font-size: 17px;
    border-radius: 10px;
}

/* ============================================ */
/* SEO Content Sections                         */
/* ============================================ */
.seo-section {
    margin-top: 48px;
}

.seo-section h2 {
    font-size: 22px;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 20px;
    text-align: center;
}

/* Features Grid */
.features-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.feature-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 24px;
    text-align: center;
    transition: box-shadow 0.2s, transform 0.2s;
}

.feature-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    transform: translateY(-2px);
}

.feature-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #eff6ff;
    border-radius: 12px;
}

.feature-card h3 {
    font-size: 16px;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 8px;
}

.feature-card p {
    font-size: 13px;
    color: #64748b;
    line-height: 1.5;
}

/* FAQ */
.faq-list { max-width: 720px; margin: 0 auto; }

.faq-list dt {
    font-size: 16px;
    font-weight: 600;
    color: #1e293b;
    padding: 16px 0 6px;
    border-top: 1px solid #e2e8f0;
}

.faq-list dt:first-child { border-top: none; }

.faq-list dd {
    font-size: 14px;
    color: #64748b;
    padding-bottom: 16px;
    line-height: 1.7;
}

/* Use Cases */
.usecase-list {
    max-width: 720px;
    margin: 0 auto;
    list-style: none;
    padding: 0;
}

.usecase-list li {
    padding: 12px 16px;
    margin-bottom: 8px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    font-size: 14px;
    color: #475569;
}

.usecase-list li strong {
    color: #2563eb;
}

/* ============================================ */
/* Footer                                       */
/* ============================================ */
.page-footer {
    text-align: center;
    padding: 40px 20px 32px;
    color: #94a3b8;
    font-size: 13px;
}

.contact-us {
    cursor: pointer;
}

/* ============================================ */
/* Responsive - Tablet & Mobile                 */
/* ============================================ */
@media (max-width: 768px) {
    #app { padding: 16px 14px 40px; }

    .topbar {
        padding: 0 14px;
        height: 50px;
    }

    .nav-links a {
        font-size: 13px;
        padding: 5px 8px;
    }

    .page-header { padding: 28px 0 20px; }
    .page-header h1 { font-size: 26px; }
    .page-header .subtitle { font-size: 14px; }

    .controls-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 14px;
        padding: 16px;
    }

    .control-group {
        justify-content: space-between;
    }

    #qualityRange { width: 120px; }

    .dim-desc {
        display: none;
    }

    .features-grid {
        grid-template-columns: 1fr;
    }

    /* Results: keep 5-column grid, shrink thumb & hide filename */
    .result-header-row {
        grid-template-columns: 40px 1fr 1fr 70px 60px;
        padding: 8px 12px;
        font-size: 12px;
    }

    .result-row {
        grid-template-columns: 40px 1fr 1fr 70px 60px;
        padding: 10px 12px;
        min-width: 0;
        gap: 8px;
    }

    .result-thumb {
        width: 36px;
        height: 36px;
    }

    .result-filename { display: none; }

    .cell-dim { font-size: 12px; }
    .cell-size { font-size: 12px; }
    .cell-size-compressed { font-size: 12px; }
    .cell-size { font-size: 12px; }

    .ratio-badge { 
        font-size: 12px; 
        padding: 3px 8px; 
    }
    .ratio-none { font-size: 11px; }

    .btn-sm { 
        padding: 5px 10px; 
        font-size: 12px; 
    }

    .drop-zone { padding: 36px 16px; }
    .drop-text { font-size: 15px; }
}

@media (max-width: 480px) {
    .brand { font-size: 15px; }
    .nav-links a { font-size: 12px; padding: 4px 6px; }

    .page-header h1 { font-size: 22px; }
    .drop-zone { padding: 28px 12px; }

    .result-header-row,
    .result-row {
        grid-template-columns: 36px 1fr 1fr 60px 50px;
        padding: 8px 10px;
    }

    .cell-dim, .cell-size, .cell-size-compressed { font-size: 11px; }
    .ratio-badge { font-size: 11px; padding: 2px 6px; }

    .compress-bar .btn-primary {
        width: 100%;
        padding: 14px 24px;
    }

    .results-actions {
        flex-direction: column;
    }

    .results-actions .btn-primary,
    .results-actions .btn-outline {
        width: 100%;
    }
}
