/* ============================================
   Tenor GIF Downloader
   Dark Mode Support with Light Mode Default
   Green Theme
   ============================================ */

/* CSS Variables - Light Mode (Default) */
:root {
    --transition-speed: 0.25s;
    
    /* Primary Colors - Green Theme */
    --primary: #339966;
    --primary-light: #e6f5ee;
    --primary-dark: #2d8659;
    --accent: #4ebb82;
    
    /* Status Colors */
    --success: #339966;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #e64e4e;
    --danger-light: #fee2e2;
    
    /* Background Colors */
    --bg: #f0faf5;
    --bg-elevated: #ffffff;
    --bg-secondary: #e6f5ee;
    --bg-tertiary: #c8e6d6;
    
    /* Text Colors */
    --text: #0d3d24;
    --text-secondary: #16633e;
    --text-muted: #6b7280;
    
    /* Border Colors */
    --border: #c8e6d6;
    --border-light: #e6f5ee;
    
    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
    --shadow-primary: 0 4px 14px rgba(51, 153, 102, 0.25);
    --shadow-primary-hover: 0 6px 20px rgba(51, 153, 102, 0.35);
    
    /* Radius */
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;
    
    /* Input */
    --input-bg: #ffffff;
    --input-border: #c8e6d6;
}

/* Dark Mode Colors */
[data-theme="dark"] {
    --primary: #4ebb82;
    --primary-light: rgba(78, 187, 130, 0.15);
    --primary-dark: #3dae72;
    --accent: #6dd5a0;
    
    --success: #34d399;
    --success-light: rgba(52, 211, 153, 0.15);
    --warning: #fbbf24;
    --warning-light: rgba(251, 191, 36, 0.15);
    --danger: #f87171;
    --danger-light: rgba(248, 113, 113, 0.15);
    
    --bg: #0c1f15;
    --bg-elevated: #152e20;
    --bg-secondary: #1e3d2c;
    --bg-tertiary: #264e39;
    
    --text: #e0f5eb;
    --text-secondary: #b8e6d0;
    --text-muted: #a8a8b3;
    
    --border: #264e39;
    --border-light: #1e3d2c;
    
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.4);
    --shadow-primary: 0 4px 14px rgba(78, 187, 130, 0.2);
    --shadow-primary-hover: 0 6px 20px rgba(78, 187, 130, 0.3);
    
    --input-bg: #1e3d2c;
    --input-border: #264e39;
}

/* Base Styles */
* { box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    margin: 0;
    padding: 0;
    transition: background-color var(--transition-speed), color var(--transition-speed);
}

/* Container */
.tool-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem;
}

/* Tool Header */
.tool-header { text-align: center; margin-bottom: 2rem; }

.tool-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin: 0 0 0.75rem;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary);
}

.tool-title i { color: var(--primary); }

.tool-description {
    max-width: 800px;
    margin: 0 auto;
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.7;
}

.tool-description a { color: var(--primary); text-decoration: none; }
.tool-description a:hover { text-decoration: underline; }

/* Input Section */
.input-section {
    background: var(--bg-elevated);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-md);
    margin-bottom: 1.5rem;
}

.input-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    color: var(--text);
    font-weight: 600;
    font-size: 1.1rem;
}

.input-header i { color: var(--primary); }

.url-input-wrapper {
    display: flex;
    align-items: stretch;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.url-input {
    flex: 1 1 0%;
    width: 0;
    padding: 0.875rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    background: var(--input-bg);
    color: var(--text);
    outline: none;
    transition: border-color var(--transition-speed), box-shadow var(--transition-speed);
}

.url-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(51, 153, 102, 0.15);
}

.url-input::placeholder { color: var(--text-muted); opacity: 0.6; }

.paste-btn {
    flex: 0 0 auto;
    width: 46px;
    height: auto;
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    border-radius: var(--radius-md);
    transition: color var(--transition-speed), background var(--transition-speed), border-color var(--transition-speed);
    display: flex;
    align-items: center;
    justify-content: center;
}

.paste-btn:hover {
    color: var(--primary);
    background: var(--primary-light);
    border-color: var(--primary);
}

.paste-btn i { width: 18px; height: 18px; }

.input-hints {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.hint-item {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.hint-item i { opacity: 0.6; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-speed);
}

.btn-primary {
    background: var(--primary);
    color: #ffffff;
    box-shadow: var(--shadow-primary);
    width: 100%;
}

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: var(--shadow-primary-hover);
    transform: translateY(-1px);
}

.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-download {
    background: var(--success);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(51, 153, 102, 0.25);
}

.btn-download:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn-download:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

/* Download Options */
.download-options {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.download-options .btn { flex: 1; min-width: 140px; }

/* GIF Options */
.gif-options {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.gif-options-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    font-weight: 600;
    color: var(--text);
}

.gif-options-header i { color: var(--primary); }

.gif-options-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
}

.gif-option label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.375rem;
}

.gif-option select {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--input-bg);
    color: var(--text);
    font-size: 0.9rem;
    cursor: pointer;
    outline: none;
    transition: border-color var(--transition-speed);
}

.gif-option select:focus { border-color: var(--primary); }

/* Filename */
.filename-wrapper {
    display: flex;
    align-items: center;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--input-bg);
    overflow: hidden;
}

.filename-input {
    flex: 1;
    padding: 0.625rem 0.875rem;
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 0.9rem;
    outline: none;
}

.file-ext {
    padding: 0.625rem 0.875rem;
    background: var(--bg-tertiary);
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
}

/* Supported Formats */
.supported-formats {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-light);
}

.formats-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.format-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.625rem;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 500;
}

/* Loading State */
.loading-section {
    text-align: center;
    padding: 3rem 1rem;
    background: var(--bg-elevated);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: 1.5rem;
}

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

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text { font-size: 1.1rem; font-weight: 600; color: var(--text); margin: 0 0 0.25rem; }
.loading-subtext { font-size: 0.875rem; color: var(--text-muted); margin: 0; }

/* Error Message */
.error-message {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: var(--danger-light);
    border-radius: var(--radius-md);
    color: var(--danger);
    margin: 1rem auto;
    max-width: 900px;
    position: relative;
}

.error-message i:first-child { flex-shrink: 0; margin-top: 0.125rem; }
.error-message div { flex: 1; font-size: 0.9rem; line-height: 1.5; }
.error-message small { color: var(--text-muted); }
.error-message small a { color: var(--primary); text-decoration: none; }
.error-message small a:hover { text-decoration: underline; }

.error-close {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    padding: 0.25rem;
    opacity: 0.6;
    transition: opacity var(--transition-speed);
    flex-shrink: 0;
}

.error-close:hover { opacity: 1; }

/* Results Section */
.results-section {
    background: var(--bg-elevated);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-md);
    margin-bottom: 1.5rem;
}

.results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.results-header h2 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text);
}

.results-header h2 i { color: var(--primary); }

/* Single Result Preview */
.single-result { text-align: center; }

.single-preview {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    overflow: hidden;
}

.single-preview img,
.single-preview video {
    max-width: 100%;
    max-height: 400px;
    border-radius: var(--radius-sm);
    object-fit: contain;
}

.single-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.single-info-item {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.single-info-item i { color: var(--primary); }

.gif-title-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    margin-bottom: 1rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.gif-title-row i { color: var(--primary); }

/* Progress */
.download-progress { margin-bottom: 1rem; }

.progress-bar {
    height: 6px;
    background: var(--bg-secondary);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: var(--radius-full);
    transition: width 0.3s ease;
    width: 0%;
}

.progress-text { font-size: 0.8rem; color: var(--text-muted); }

/* New URL Button */
.btn-new-url {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    color: var(--text);
    cursor: pointer;
    transition: all var(--transition-speed);
}

.btn-new-url:hover { border-color: var(--primary); color: var(--primary); }

/* ==================== RELATED GIFS ==================== */
.related-section {
    background: var(--bg-elevated);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-md);
    margin-bottom: 1.5rem;
}

.related-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
}

.related-header i { color: var(--primary); }

.related-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
}

.related-card {
    position: relative;
    border-radius: var(--radius-md);
    overflow: hidden;
    cursor: pointer;
    aspect-ratio: 1;
    background: var(--bg-secondary);
    transition: transform var(--transition-speed), box-shadow var(--transition-speed);
}

.related-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.related-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.related-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,0.7));
    padding: 2rem 0.5rem 0.5rem;
    opacity: 0;
    transition: opacity var(--transition-speed);
}

.related-card:hover .related-overlay { opacity: 1; }

.related-overlay span {
    display: block;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Related Tools */
.tgd-related-tools {
    max-width: 1000px;
    margin: 0 auto 2rem;
    padding: 0 2rem;
}

.tgd-related-tools-box {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem;
    background: var(--bg-elevated);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.tgd-related-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    color: var(--text-muted);
    white-space: nowrap;
}

.tgd-related-label i { color: var(--primary); }

.tgd-related-links { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.tgd-related-link {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.875rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-full);
    color: var(--text);
    text-decoration: none;
    font-size: 0.875rem;
    transition: all var(--transition-speed);
}

.tgd-related-link:hover { background: var(--primary-light); color: var(--primary); }
.tgd-related-link i { width: 16px; height: 16px; }

/* Info Sections */
.tgd-info-sections {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 2rem 2rem;
}

.tgd-info-card {
    background: var(--bg-elevated);
    border-radius: var(--radius-xl);
    padding: 2rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-md);
}

.tgd-info-card h2 {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 1.25rem;
}

.tgd-info-card h2 i { color: var(--primary); }

.tgd-info-card p,
.tgd-info-card li { color: var(--text-muted); line-height: 1.7; margin: 0 0 0.75rem; }
.tgd-info-card a { color: var(--primary); text-decoration: none; }
.tgd-info-card a:hover { text-decoration: underline; }

/* Steps List */
.tgd-steps-list { counter-reset: step; list-style: none; padding: 0; margin: 0 0 1rem; }

.tgd-steps-list li { position: relative; padding-left: 3rem; margin-bottom: 1rem; line-height: 1.6; }

.tgd-steps-list li::before {
    counter-increment: step;
    content: counter(step);
    position: absolute;
    left: 0;
    top: 0;
    width: 28px;
    height: 28px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 600;
}

.tgd-steps-list li strong { color: var(--text); }
.tgd-steps-list a { color: var(--primary); text-decoration: none; }
.tgd-steps-list a:hover { text-decoration: underline; }

/* Features Grid */
.tgd-features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
}

.tgd-feature-item {
    padding: 1.25rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
}

.tgd-feature-item i { color: var(--primary); margin-bottom: 0.75rem; display: block; }

.tgd-feature-item h4 { margin: 0 0 0.375rem; font-size: 0.95rem; font-weight: 600; color: var(--text); }
.tgd-feature-item p { font-size: 0.85rem; margin: 0; line-height: 1.5; }
.tgd-feature-item a { color: var(--primary); text-decoration: none; }
.tgd-feature-item a:hover { text-decoration: underline; }

/* FAQ Section */
.tgd-faq-list { display: flex; flex-direction: column; gap: 0.5rem; }

.tgd-faq-item { background: var(--bg-secondary); border-radius: var(--radius-md); overflow: hidden; }

.tgd-faq-question {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    text-align: left;
    transition: background-color var(--transition-speed);
}

.tgd-faq-question:hover { background: var(--bg-tertiary); }

.tgd-faq-question i {
    color: var(--text-muted);
    transition: transform 0.3s ease;
    flex-shrink: 0;
}

.tgd-faq-item.active .tgd-faq-question i { transform: rotate(180deg); }

.tgd-faq-answer { display: none; padding: 0 1.25rem 1rem; }

.tgd-faq-item.active .tgd-faq-answer { display: block; }

.tgd-faq-answer p { font-size: 0.9rem; margin: 0; color: var(--text-muted); line-height: 1.6; }
.tgd-faq-answer a { color: var(--primary); text-decoration: none; }
.tgd-faq-answer a:hover { text-decoration: underline; }

/* Responsive */
@media (max-width: 768px) {
    .tool-container { padding: 1rem; }
    .tool-title { font-size: 1.35rem; }
    .input-section { padding: 1.25rem; }
    .download-options { flex-direction: column; }
    .download-options .btn { width: 100%; }
    .gif-options-grid { grid-template-columns: 1fr; }
    .tgd-features-grid { grid-template-columns: 1fr; }
    .tgd-related-tools { padding: 0 1rem; }
    .tgd-info-sections { padding: 0 1rem 1rem; }
    .tgd-info-card { padding: 1.25rem; }
    .related-section { padding: 1.25rem; }
    .related-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 0.5rem; }
}

@media (max-width: 480px) {
    .single-info { gap: 0.75rem; }
    .results-header { flex-direction: column; align-items: flex-start; }
    .related-grid { grid-template-columns: repeat(3, 1fr); }
}
