:root {
    --primary: #6c5ce7;
    --primary-hover: #5649c0;
    --bg-gradient-1: #74b9ff;
    --bg-gradient-2: #a29bfe;
    --card-bg: #ffffff;
    --text-main: #2d3436;
    --text-sub: #636e72;
    --border: #b2bec3;
    --green: #00b894;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: linear-gradient(135deg, var(--bg-gradient-1) 0%, var(--bg-gradient-2) 100%);
    /* Changed to allow scrolling for SEO content */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    min-height: 100vh;
    margin: 0;
    padding: 40px 15px; /* Added top padding */
}

/* Wrapper to hold everything */
.page-wrapper {
    width: 100%;
    max-width: 800px; /* Limits width of SEO text */
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* --- Main Tool Card --- */
.main-card {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    width: 100%;
    max-width: 480px; /* Tool stays compact */
    text-align: center;
    transition: all 0.3s ease;
    z-index: 10;
}

/* --- Header Section (State Management) --- */
.header {
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: all 0.3s ease;
    margin-bottom: 20px;
}

.logo-icon {
    font-size: 3rem;
    color: var(--primary);
    margin-bottom: 10px;
    transition: all 0.3s ease;
}

.header h1 {
    margin: 0;
    color: var(--text-main);
    font-size: 1.6rem;
    transition: font-size 0.3s ease;
}

.header p {
    color: var(--text-sub);
    margin: 5px 0 0 0;
    font-size: 0.9rem;
    line-height: 1.4;
    transition: all 0.3s ease;
}

.header.compact {
    flex-direction: row;
    align-items: center;
    text-align: left;
    background: #f8f9fa;
    padding: 15px;
    border-radius: 12px;
    gap: 15px;
    margin-bottom: 15px;
}

.header.compact .logo-icon { font-size: 2rem; margin-bottom: 0; }
.header.compact h1 { font-size: 1.2rem; }
.header.compact p { font-size: 0.8rem; margin: 2px 0 0 0; }

/* --- Upload Area --- */
input[type="file"] { display: none; }

.upload-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 30px 20px;
    cursor: pointer;
    background-color: #f9f9f9;
    transition: all 0.3s ease;
    color: var(--text-sub);
}

.upload-label:active { transform: scale(0.98); }
.upload-label:hover { border-color: var(--primary); background-color: #f0f0ff; color: var(--primary); }
.upload-label i { font-size: 2rem; margin: 10px; transition: margin 0.3s ease; }

.upload-label.compact { padding: 20px 20px; flex-direction: row; gap: 10px; }
.upload-label.compact i { font-size: 1.5rem; margin: 0; }

/* --- Utilities --- */
.hidden { display: none !important; }

/* --- File Info Box --- */
.file-info {
    display: flex;
    align-items: center;
    background: #f1f2f6;
    padding: 12px;
    border-radius: 10px;
    margin-top: 15px;
    text-align: left;
    overflow: hidden;
}

.info-icon {
    font-size: 1.5rem;
    color: var(--text-sub);
    min-width: 40px;
    text-align: center;
}

.info-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
    overflow: hidden; /* CRITICAL for truncation */
    padding-right: 10px;
}

.fname, .apk-name {
    font-weight: 700;
    color: var(--text-main);
    white-space: nowrap;
    display: inline-block; /* Allows width measurement */
}

.fsize, .apk-size { font-size: 0.8rem; color: var(--text-sub); margin-top: 2px; }

/* --- Action Button --- */
.action-btn {
    background-color: var(--primary);
    color: white;
    border: none;
    padding: 15px;
    border-radius: 10px;
    width: 100%;
    font-size: 1rem;
    font-weight: 600;
    margin-top: 20px;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
}
.action-btn:active { background-color: var(--primary-hover); transform: translateY(1px); }
.action-btn:disabled { opacity: 0.7; cursor: default; }

/* Spinner */
.loader {
    width: 22px;
    height: 22px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s infinite linear;
    display: none;
}
.action-btn.loading .loader { display: block; }
.action-btn.loading .btn-text { display: none; }
@keyframes spin { 100% { transform: rotate(360deg); } }

/* --- Results List --- */
.status-text { margin-top: 15px; font-size: 0.9rem; color: var(--text-sub); }

.apk-card {
    background: #fff;
    border: 1px solid #dfe6e9;
    border-radius: 10px;
    padding: 12px;
    margin-top: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
}

.apk-left {
    display: flex;
    align-items: center;
    gap: 12px;
    text-align: left;
    min-width: 0;
    flex: 1;
    overflow: hidden;
}

.apk-icon { color: #a4c639; font-size: 1.8rem; flex-shrink: 0; }
.apk-meta { display: flex; flex-direction: column; min-width: 0; overflow: hidden; width: 100%; padding-right: 10px; }

.download-btn {
    background-color: var(--green);
    color: white;
    text-decoration: none;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 0.85rem;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background 0.2s;
}
.download-btn:hover { background-color: #00997b; }

/* --- SEO Content Section --- */
.seo-content {
    background: rgba(255, 255, 255, 0.95); /* Slightly transparent white */
    margin-top: 40px;
    padding: 2.5rem;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
    color: var(--text-main);
    line-height: 1.6;
}

.seo-content h2 { margin-top: 0; color: var(--primary); }
.seo-content h3 { color: var(--text-main); margin-top: 25px; }
.seo-content p { color: #555; }

.seo-list { list-style: none; padding: 0; }
.seo-list li { margin-bottom: 10px; color: #555; }
.seo-list i { color: var(--green); margin-right: 10px; }

.faq-item { margin-bottom: 20px; }
.faq-item h4 { margin-bottom: 5px; color: #444; }
.faq-item p { margin-top: 0; font-size: 0.95rem; }

code { background: #eee; padding: 2px 5px; border-radius: 4px; color: #d63031; }

.footer {text-align: center; margin-top: 40px; color: white; opacity: 0.8; font-size: 0.8rem; }

/* --- Mobile Specific --- */
@media (max-width: 480px) {
    .main-card { padding: 1.5rem; border-radius: 16px; }
    .header h1 { font-size: 1.4rem; }
    .seo-content { padding: 1.5rem; margin-top: 30px; }
    
    @media (max-width: 340px) {
        .apk-card { flex-direction: column; text-align: center; }
        .apk-left { flex-direction: column; margin-bottom: 10px; }
    }
}