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

:root {
    --primary: #E1306C;
    --primary-dark: #C13584;
    --secondary: #405DE6;
    --bg: #fafafa;
    --card-bg: #ffffff;
    --text: #262626;
    --text-light: #8e8e8e;
    --shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
    --radius: 20px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    background-image: radial-gradient(circle at 10% 20%, rgba(225, 48, 108, 0.03) 0%, transparent 50%),
                      radial-gradient(circle at 90% 80%, rgba(64, 93, 230, 0.03) 0%, transparent 50%);
}

.container {
    width: 100%;
    max-width: 900px;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 40px 45px 30px;
    position: relative;
    overflow: hidden;
}

.container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--secondary), var(--primary), var(--primary-dark));
    background-size: 200% 100%;
    animation: gradientMove 3s ease-in-out infinite;
}

@keyframes gradientMove {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

/* Header */
header {
    text-align: center;
    margin-bottom: 35px;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 8px;
}

.logo svg {
    color: var(--primary);
}

.logo h1 {
    font-size: 32px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.logo h1 span {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-light);
    font-size: 16px;
    font-weight: 400;
}

/* Input Section */
.input-section {
    margin-bottom: 30px;
}

.input-group {
    display: flex;
    gap: 12px;
    background: var(--bg);
    border-radius: 60px;
    padding: 6px;
    box-shadow: inset 0 2px 6px rgba(0,0,0,0.04);
    transition: var(--transition);
}

.input-group:focus-within {
    box-shadow: 0 0 0 3px rgba(225, 48, 108, 0.2), inset 0 2px 6px rgba(0,0,0,0.04);
}

#urlInput {
    flex: 1;
    border: none;
    background: transparent;
    padding: 16px 24px;
    font-size: 15px;
    color: var(--text);
    outline: none;
    min-width: 0;
}

#urlInput::placeholder {
    color: var(--text-light);
}

#downloadBtn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 32px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    border-radius: 60px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

#downloadBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(225, 48, 108, 0.35);
}

#downloadBtn:active {
    transform: translateY(0);
    box-shadow: none;
}

#downloadBtn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

#downloadBtn svg {
    flex-shrink: 0;
}

/* Info Badge */
.info-badge {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin-top: 14px;
    flex-wrap: wrap;
}

.info-badge span {
    font-size: 13px;
    color: var(--text-light);
    background: var(--bg);
    padding: 6px 16px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Loading */
#loadingContainer {
    text-align: center;
    padding: 30px 0;
}

.loader {
    width: 48px;
    height: 48px;
    border: 4px solid var(--bg);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

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

#loadingContainer p {
    color: var(--text-light);
    font-size: 15px;
    margin-bottom: 16px;
}

.progress-bar {
    width: 100%;
    max-width: 400px;
    height: 6px;
    background: var(--bg);
    border-radius: 10px;
    overflow: hidden;
    margin: 0 auto 8px;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--secondary), var(--primary));
    border-radius: 10px;
    transition: width 0.4s ease;
}

#progressText {
    font-size: 13px;
    color: var(--text-light);
}

/* Result Container */
#resultContainer {
    margin-top: 20px;
}

.result-card {
    background: var(--bg);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 20px;
    animation: slideUp 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.result-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.result-badge {
    font-size: 12px;
    padding: 4px 14px;
    border-radius: 20px;
    font-weight: 600;
}

.badge-image {
    background: #e8f5e9;
    color: #2e7d32;
}

.badge-video {
    background: #e3f2fd;
    color: #0d47a1;
}

.result-content {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.thumbnail-wrapper {
    flex-shrink: 0;
    width: 120px;
    height: 120px;
    border-radius: 12px;
    overflow: hidden;
    background: #e0e0e0;
}

.thumbnail-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.media-details {
    flex: 1;
    min-width: 200px;
}

.media-details p {
    font-size: 14px;
    color: var(--text-light);
    margin-bottom: 6px;
}

.download-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.download-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    background: var(--card-bg);
    border: 2px solid var(--primary);
    color: var(--primary);
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: var(--transition);
    cursor: pointer;
}

.download-btn:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(225, 48, 108, 0.25);
}

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

.download-btn.primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.download-btn.small {
    padding: 6px 14px;
    font-size: 12px;
}

.resolutions-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.resolution-tag {
    background: var(--card-bg);
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 12px;
    border: 1px solid #e0e0e0;
}

.error-message {
    background: #fce4ec;
    color: #c62828;
    padding: 16px 20px;
    border-radius: 12px;
    font-size: 14px;
    border-left: 4px solid #c62828;
}

.error-message .error-detail {
    font-size: 12px;
    color: #d32f2f;
    margin-top: 6px;
    opacity: 0.7;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-light);
}

.empty-state svg {
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-state p {
    font-size: 16px;
}

/* Footer */
footer {
    text-align: center;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid rgba(0,0,0,0.06);
}

footer p {
    font-size: 13px;
    color: var(--text-light);
}

.footer-note {
    font-size: 11px;
    margin-top: 4px;
    opacity: 0.6;
}

/* Responsive */
@media (max-width: 640px) {
    .container {
        padding: 20px;
        border-radius: 16px;
    }

    .logo h1 {
        font-size: 24px;
    }

    .input-group {
        flex-direction: column;
        background: transparent;
        padding: 0;
        border-radius: 0;
        gap: 10px;
    }

    #urlInput {
        background: var(--bg);
        border-radius: 60px;
        padding: 16px 20px;
    }

    #downloadBtn {
        justify-content: center;
        padding: 16px;
        border-radius: 60px;
        width: 100%;
    }

    .info-badge {
        gap: 10px;
    }

    .info-badge span {
        font-size: 11px;
        padding: 4px 12px;
    }

    .result-content {
        flex-direction: column;
        align-items: center;
    }

    .thumbnail-wrapper {
        width: 100%;
        height: 200px;
    }

    .result-header {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
    }

    .download-actions {
        flex-direction: column;
        width: 100%;
    }

    .download-btn {
        justify-content: center;
        width: 100%;
    }
}