/**
 * TikTok Video Downloader - Frontend Stylesheet (Responsive & Multi-Language)
 */

:root {
    --ttd-primary: #fe2c55;
    --ttd-primary-hover: #e02047;
    --ttd-cyan: #25f4ee;
    --ttd-bg-subtle: #f8fafc;
    --ttd-text-main: #0f172a;
    --ttd-text-muted: #64748b;
    --ttd-border: #e2e8f0;
    --ttd-border-hover: #cbd5e1;
    --ttd-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.08);
    --ttd-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
    --ttd-shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
    --ttd-radius-lg: 20px;
    --ttd-radius-md: 12px;
    --ttd-radius-sm: 8px;
}

.ttd-container {
    max-width: 900px;
    margin: 30px auto;
    padding: 36px 30px;
    background: #ffffff;
    border-radius: var(--ttd-radius-lg);
    box-shadow: var(--ttd-shadow-lg);
    border: 1px solid var(--ttd-border);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
    color: var(--ttd-text-main);
    box-sizing: border-box;
    word-break: break-word;
    overflow-wrap: break-word;
}

.ttd-container * {
    box-sizing: border-box;
}

/* RTL Support */
.ttd-container.ttd-rtl {
    direction: rtl;
    text-align: right;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Tahoma, "Noto Sans Arabic", Arial, sans-serif;
}

.ttd-container.ttd-rtl .ttd-header,
.ttd-container.ttd-rtl .ttd-results-header,
.ttd-container.ttd-rtl .ttd-loader-card {
    text-align: center;
}

/* Header */
.ttd-header {
    text-align: center;
    margin-bottom: 28px;
}

.ttd-title {
    font-size: clamp(24px, 4vw, 32px);
    font-weight: 800;
    color: var(--ttd-text-main);
    margin: 0 0 10px 0;
    letter-spacing: -0.02em;
    line-height: 1.25;
}

.ttd-subtitle {
    font-size: clamp(14px, 2vw, 16px);
    color: var(--ttd-text-muted);
    margin: 0 auto;
    max-width: 650px;
    line-height: 1.5;
}

/* Alert Notification */
.ttd-alert {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 18px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
    border-radius: var(--ttd-radius-md);
    margin-bottom: 22px;
    font-size: 14px;
    animation: ttdFadeIn 0.25s ease-out;
}

.ttd-alert-msg {
    flex: 1;
}

.ttd-alert-close {
    background: none;
    border: none;
    font-size: 20px;
    color: #991b1b;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

/* Form & Input Bar */
.ttd-form {
    margin: 0;
}

.ttd-input-group {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.ttd-input-wrap {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    background: #ffffff;
    border: 2px solid var(--ttd-border);
    border-radius: var(--ttd-radius-md);
    padding: 4px 8px 4px 14px;
    transition: all 0.2s ease;
    box-shadow: var(--ttd-shadow-sm);
}

.ttd-input-wrap:focus-within {
    border-color: var(--ttd-primary);
    box-shadow: 0 0 0 4px rgba(254, 44, 85, 0.12);
}

.ttd-container.ttd-rtl .ttd-input-wrap {
    padding: 4px 14px 4px 8px;
}

.ttd-input-icon {
    color: var(--ttd-text-muted);
    display: flex;
    align-items: center;
    margin-right: 10px;
    flex-shrink: 0;
}

.ttd-container.ttd-rtl .ttd-input-icon {
    margin-right: 0;
    margin-left: 10px;
}

.ttd-url-input {
    flex: 1;
    border: none !important;
    outline: none !important;
    background: transparent !important;
    font-size: 15px;
    color: var(--ttd-text-main);
    padding: 10px 0 !important;
    box-shadow: none !important;
    width: 100%;
}

.ttd-url-input::placeholder {
    color: #94a3b8;
}

/* Clear Button */
.ttd-clear-btn {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s ease;
}

.ttd-clear-btn:hover {
    color: #475569;
}

/* Paste Button */
.ttd-paste-btn {
    background: var(--ttd-bg-subtle);
    border: 1px solid var(--ttd-border);
    color: var(--ttd-text-main);
    padding: 7px 12px;
    border-radius: var(--ttd-radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.18s ease;
    flex-shrink: 0;
    margin-left: 6px;
}

.ttd-container.ttd-rtl .ttd-paste-btn {
    margin-left: 0;
    margin-right: 6px;
}

.ttd-paste-btn:hover {
    background: #e2e8f0;
    border-color: #cbd5e1;
}

/* Submit Button */
.ttd-submit-btn {
    padding: 15px 28px;
    background: var(--ttd-primary);
    color: #ffffff;
    font-size: 15px;
    font-weight: 700;
    border: none;
    border-radius: var(--ttd-radius-md);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 14px rgba(254, 44, 85, 0.35);
    transition: all 0.22s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.ttd-submit-btn:hover:not(:disabled) {
    background: var(--ttd-primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(254, 44, 85, 0.45);
}

.ttd-submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    box-shadow: none;
}

/* Privacy Note */
.ttd-privacy-note {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 12px;
    color: var(--ttd-text-muted);
    text-align: center;
    line-height: 1.4;
    margin-top: 6px;
}

.ttd-privacy-note svg {
    color: #10b981;
    flex-shrink: 0;
}

/* TikTok Dancing Dots Loader */
.ttd-loader-overlay {
    position: relative;
    padding: 40px 20px;
    text-align: center;
    animation: ttdFadeIn 0.3s ease;
}

.ttd-loader-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 420px;
    margin: 0 auto;
}

.ttd-tiktok-spinner {
    position: relative;
    width: 60px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
}

.ttd-dot {
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    animation: ttdPulseDots 1.2s infinite ease-in-out;
}

.ttd-dot.cyan {
    background: var(--ttd-cyan);
    left: 8px;
}

.ttd-dot.magenta {
    background: var(--ttd-primary);
    right: 8px;
    animation-delay: -0.6s;
}

.ttd-loader-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--ttd-text-main);
    margin: 0 0 6px 0;
}

.ttd-loader-subtitle {
    font-size: 13px;
    color: var(--ttd-text-muted);
    margin: 0 0 16px 0;
}

.ttd-progress-bar-wrap {
    width: 100%;
    height: 5px;
    background: var(--ttd-border);
    border-radius: 3px;
    overflow: hidden;
}

.ttd-progress-bar {
    height: 100%;
    width: 20%;
    background: var(--ttd-primary);
    border-radius: 3px;
    transition: width 0.35s ease;
}

/* Results Section */
.ttd-results-section {
    animation: ttdFadeIn 0.35s ease-out;
}

.ttd-results-header {
    text-align: center;
    margin-bottom: 22px;
}

.ttd-badge-success {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #ecfdf5;
    color: #059669;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 8px;
}

.ttd-results-title {
    font-size: clamp(20px, 3.5vw, 24px);
    font-weight: 700;
    color: var(--ttd-text-main);
    margin: 0;
}

/* Result Card */
.ttd-result-card {
    background: var(--ttd-bg-subtle);
    border: 1px solid var(--ttd-border);
    border-radius: var(--ttd-radius-md);
    padding: 24px;
    display: flex;
    gap: 24px;
    align-items: flex-start;
}

/* Cover Image Box */
.ttd-cover-box {
    width: 220px;
    flex-shrink: 0;
}

.ttd-cover-wrap {
    position: relative;
    width: 100%;
    padding-top: 133%; /* 3:4 aspect ratio */
    border-radius: var(--ttd-radius-md);
    overflow: hidden;
    background: #0f172a;
    box-shadow: var(--ttd-shadow-md);
}

.ttd-cover-wrap img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.ttd-duration-badge {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(15, 23, 42, 0.8);
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 4px;
    backdrop-filter: blur(4px);
}

.ttd-container.ttd-rtl .ttd-duration-badge {
    right: auto;
    left: 8px;
}

.ttd-preview-play-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(254, 44, 85, 0.9);
    color: #ffffff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
    transition: all 0.2s ease;
}

.ttd-preview-play-btn:hover {
    background: var(--ttd-primary);
    transform: translate(-50%, -50%) scale(1.1);
}

/* Info Box */
.ttd-info-box {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.ttd-video-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--ttd-text-main);
    margin: 0 0 10px 0;
    line-height: 1.4;
}

.ttd-meta-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 18px;
    font-size: 13px;
    color: var(--ttd-text-muted);
}

.ttd-meta-val {
    color: var(--ttd-text-main);
}

/* Download Media Buttons Stack */
.ttd-media-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
}

.ttd-dl-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
    border-radius: var(--ttd-radius-md);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none !important;
    transition: all 0.2s ease;
    cursor: pointer;
    border: 1px solid transparent;
}

.ttd-dl-btn-primary {
    background: var(--ttd-primary);
    color: #ffffff !important;
    box-shadow: 0 4px 12px rgba(254, 44, 85, 0.25);
}

.ttd-dl-btn-primary:hover {
    background: var(--ttd-primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(254, 44, 85, 0.35);
}

.ttd-dl-btn-secondary {
    background: #ffffff;
    color: var(--ttd-text-main) !important;
    border-color: var(--ttd-border);
}

.ttd-dl-btn-secondary:hover {
    background: #f1f5f9;
    border-color: var(--ttd-border-hover);
}

.ttd-dl-btn-audio {
    background: #ffffff;
    color: #0284c7 !important;
    border-color: #bae6fd;
}

.ttd-dl-btn-audio:hover {
    background: #f0f9ff;
    border-color: #7dd3fc;
}

.ttd-dl-btn-label-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ttd-dl-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.25);
    text-transform: uppercase;
}

.ttd-dl-btn-secondary .ttd-dl-badge,
.ttd-dl-btn-audio .ttd-dl-badge {
    background: var(--ttd-bg-subtle);
    color: var(--ttd-text-muted);
}

/* Inline Player */
.ttd-inline-player-wrap {
    margin-bottom: 16px;
    border-radius: var(--ttd-radius-sm);
    overflow: hidden;
    background: #000000;
    box-shadow: var(--ttd-shadow-sm);
}

.ttd-inline-player-wrap video {
    width: 100%;
    max-height: 380px;
    display: block;
}

/* Bottom Action */
.ttd-bottom-actions {
    margin-top: 6px;
}

.ttd-reset-btn {
    padding: 10px 18px;
    background: #ffffff;
    color: var(--ttd-text-main);
    border: 1px solid var(--ttd-border);
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--ttd-radius-sm);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.ttd-reset-btn:hover {
    background: var(--ttd-bg-subtle);
    border-color: var(--ttd-border-hover);
}

/* Animations */
@keyframes ttdFadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes ttdPulseDots {
    0%, 100% {
        transform: scale(0.6);
        z-index: 1;
    }
    50% {
        transform: scale(1.15);
        z-index: 2;
    }
}

/* Responsive Media Queries */
@media (max-width: 768px) {
    .ttd-container {
        padding: 22px 14px;
        margin: 15px auto;
        border-radius: var(--ttd-radius-md);
    }

    .ttd-title {
        font-size: 22px;
    }

    .ttd-input-group {
        flex-direction: column;
        gap: 10px;
    }

    .ttd-input-wrap {
        width: 100%;
    }

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

    .ttd-result-card {
        flex-direction: column;
        align-items: center;
        padding: 18px 14px;
    }

    .ttd-cover-box {
        width: 180px;
    }

    .ttd-info-box {
        width: 100%;
        text-align: center;
    }

    .ttd-meta-row {
        align-items: center;
    }

    .ttd-bottom-actions {
        display: flex;
        justify-content: center;
    }
}
