:root {
    /* Light Mode Colors */
    --primary-color: #E60023;
    --primary-dark: #ad081b;
    --secondary-color: #0076D3;
    --video-color: #9b59b6;
    --bg-color: #f8f9fa;
    --card-bg: #ffffff;
    --text-main: #333333;
    --text-muted: #666666;
    --border-color: #e0e0e0;
    --input-bg: #ffffff;
    --stat-bg: #f9f9f9;
    --code-bg: #e9ecef;
    --success-color: #27ae60;
    --warning-color: #f39c12;
    --error-color: #e74c3c;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.15);
    --radius: 16px;
    --radius-sm: 10px;
    --font-family: 'Poppins', sans-serif;
}

/* Dark Mode Colors */
[data-theme="dark"] {
    --bg-color: #0f0f0f;
    --card-bg: #1a1a1a;
    --text-main: #ffffff;
    --text-muted: #a0a0a0;
    --border-color: #333333;
    --input-bg: #252525;
    --stat-bg: #252525;
    --code-bg: #2d2d2d;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.5);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ========== HEADER ========== */
header {
    background: var(--card-bg);
    padding: 15px 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    margin-bottom: 40px;
    transition: background-color 0.3s ease;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo i {
    color: var(--primary-color);
    font-size: 1.8rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Download Counter */
.download-counter {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--stat-bg);
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.download-counter i {
    color: var(--primary-color);
}

.download-counter:hover {
    transform: scale(1.05);
}

/* Theme Toggle Button */
.theme-toggle {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    background: var(--card-bg);
    color: var(--text-main);
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.theme-toggle:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: rotate(20deg);
}

/* ========== HERO SECTION ========== */
.hero {
    text-align: center;
    margin-bottom: 30px;
}

.hero h1 {
    font-size: 2.2rem;
    margin-bottom: 10px;
    background: linear-gradient(45deg, var(--primary-color), #ff6b6b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.description {
    color: var(--text-muted);
    font-size: 1rem;
    max-width: 600px;
    margin: 0 auto 15px;
}

/* Content Type Badges */
.content-badges {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.badge-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 25px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-main);
    transition: all 0.3s ease;
}

.badge-item:first-child i {
    color: var(--primary-color);
}

.badge-item:last-child i {
    color: var(--video-color);
}

.badge-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

/* ========== SUPPORTED LINKS INFO ========== */
.supported-links {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 15px 20px;
    margin-bottom: 30px;
    border-left: 4px solid var(--primary-color);
    transition: background-color 0.3s ease;
}

.supported-links p {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.supported-links p i {
    color: var(--success-color);
}

.link-examples {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.link-examples code {
    background: var(--code-bg);
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    color: var(--text-main);
    font-family: 'Consolas', 'Monaco', monospace;
    transition: background-color 0.3s ease;
}

/* ========== INPUT SECTION ========== */
.input-section {
    max-width: 700px;
    margin: 0 auto 40px;
    text-align: center;
}

.input-wrapper {
    position: relative;
    margin-bottom: 15px;
}

.input-icon {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 1rem;
    z-index: 2;
}

input[type="text"] {
    width: 100%;
    padding: 18px 55px;
    border: 2px solid var(--border-color);
    border-radius: 50px;
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.3s ease;
    outline: none;
    background: var(--input-bg);
    color: var(--text-main);
}

input[type="text"]::placeholder {
    color: var(--text-muted);
}

input[type="text"]:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(230, 0, 35, 0.15);
}

input[type="text"].invalid {
    border-color: var(--error-color);
    box-shadow: 0 0 0 4px rgba(231, 76, 60, 0.15);
}

input[type="text"].valid {
    border-color: var(--success-color);
    box-shadow: 0 0 0 4px rgba(39, 174, 96, 0.15);
}

/* Drop Zone Styles */
.input-wrapper.drag-over {
    border: 2px dashed var(--primary-color);
    border-radius: 50px;
    background: rgba(230, 0, 35, 0.05);
}

.drop-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(230, 0, 35, 0.95);
    border-radius: 50px;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    gap: 8px;
    z-index: 10;
}

.drop-overlay i {
    font-size: 1.5rem;
    animation: bounce 0.5s ease infinite alternate;
}

@keyframes bounce {
    from { transform: translateY(-5px); }
    to { transform: translateY(5px); }
}

.input-wrapper.drag-over .drop-overlay {
    display: flex;
}

.paste-btn {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--stat-bg);
    border: none;
    cursor: pointer;
    padding: 10px;
    color: var(--text-muted);
    font-size: 1rem;
    transition: all 0.3s;
    border-radius: 50%;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

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

.download-btn {
    background: linear-gradient(45deg, var(--primary-color), #ff4757);
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 50px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.download-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(230, 0, 35, 0.3);
}

.download-btn:active { 
    transform: translateY(0); 
}

.download-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.error-msg {
    margin-top: 15px;
    font-size: 0.9rem;
    display: none;
    padding: 12px 20px;
    border-radius: 10px;
    text-align: left;
}

.error-msg.error {
    background: rgba(231, 76, 60, 0.1);
    color: var(--error-color);
    border: 1px solid rgba(231, 76, 60, 0.3);
}

.error-msg.warning {
    background: rgba(243, 156, 18, 0.1);
    color: var(--warning-color);
    border: 1px solid rgba(243, 156, 18, 0.3);
}

.error-msg i {
    margin-right: 8px;
}

/* ========== LOADER / PROGRESS BAR ========== */
.loader-container {
    max-width: 600px;
    margin: 0 auto 40px;
    display: none;
}

.progress-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    margin-bottom: 8px;
    color: var(--text-muted);
    font-weight: 500;
}

.progress-track {
    height: 8px;
    background: var(--border-color);
    border-radius: 10px;
    overflow: hidden;
}

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

/* ========== RESULT CONTAINER ========== */
.result-container {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 25px;
    margin-bottom: 40px;
    animation: fadeIn 0.5s ease;
    transition: background-color 0.3s ease;
}

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

/* Result Header */
.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.result-header h3 {
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-main);
}

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

/* Content Type Badge */
.content-type-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.content-type-badge.image {
    background: linear-gradient(45deg, var(--primary-color), #ff6b6b);
    color: white;
}

.content-type-badge.video {
    background: linear-gradient(45deg, var(--video-color), #8e44ad);
    color: white;
}

/* Preview Container */
.preview-container {
    margin-bottom: 15px;
}

/* Image Preview */
.image-preview-wrapper {
    display: block;
}

.image-wrapper {
    position: relative;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--stat-bg);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 200px;
}

.preview-image {
    max-width: 100%;
    max-height: 500px;
    object-fit: contain;
    display: block;
    transition: transform 0.3s ease;
}

.image-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.image-wrapper:hover .image-overlay {
    opacity: 1;
}

.zoom-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    background: white;
    color: var(--primary-color);
    font-size: 1.5rem;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.zoom-btn:hover {
    transform: scale(1.1);
}

.quality-badge {
    position: absolute;
    top: 15px;
    right: 15px;
    background: var(--primary-color);
    color: white;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.quality-badge.video-badge {
    background: var(--video-color);
}

/* Video Preview */
.video-preview-wrapper {
    display: none;
}

.video-wrapper {
    position: relative;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: #000;
}

.video-wrapper video {
    width: 100%;
    max-height: 500px;
    display: block;
}

/* View Toggle */
.view-toggle {
    display: flex;
    justify-content: center;
    gap: 5px;
    background: var(--stat-bg);
    padding: 4px;
    border-radius: 8px;
    margin-bottom: 15px;
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
}

.view-btn {
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: inherit;
}

.view-btn.active {
    background: var(--primary-color);
    color: white;
}

.view-btn:hover:not(.active) {
    background: var(--border-color);
}

/* Content Info */
.content-info {
    display: flex;
    justify-content: center;
    gap: 25px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

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

.info-item i.video-icon {
    color: var(--video-color);
}

/* Action Buttons */
.action-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 15px;
}

.action-buttons.single {
    grid-template-columns: 1fr;
}

.btn-action {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.95rem;
    gap: 10px;
}

.btn-action.primary {
    background: linear-gradient(45deg, var(--primary-color), #ff4757);
    color: white;
}

.btn-action.primary.video {
    background: linear-gradient(45deg, var(--video-color), #8e44ad);
}

.btn-action.secondary {
    background: linear-gradient(45deg, #2c3e50, #34495e);
    color: white;
}

.btn-action:hover { 
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.2);
}

/* Extra Actions */
.extra-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.extra-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    border: 1px solid var(--border-color);
    background: var(--stat-bg);
    color: var(--text-main);
    border-radius: 8px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
}

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

.extra-btn.saved {
    background: var(--success-color);
    color: white;
    border-color: var(--success-color);
}

/* ========== HISTORY SECTION ========== */
.history-section {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 25px;
    margin-bottom: 40px;
    transition: background-color 0.3s ease;
}

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

.history-header h3 {
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-main);
}

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

.clear-history-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: none;
    background: rgba(231, 76, 60, 0.1);
    color: var(--error-color);
    border-radius: 8px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
}

.clear-history-btn:hover {
    background: var(--error-color);
    color: white;
}

.history-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
}

.history-item {
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s ease;
    aspect-ratio: 1;
}

.history-item:hover {
    transform: scale(1.05);
}

.history-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.history-item .item-type-badge {
    position: absolute;
    bottom: 5px;
    left: 5px;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
}

.history-item .item-type-badge.image {
    background: var(--primary-color);
    color: white;
}

.history-item .item-type-badge.video {
    background: var(--video-color);
    color: white;
}

.history-item .delete-item {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: rgba(0,0,0,0.6);
    color: white;
    font-size: 0.7rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.history-item:hover .delete-item {
    opacity: 1;
}

.empty-history {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.empty-history i {
    font-size: 2.5rem;
    opacity: 0.5;
}

/* ========== LIGHTBOX ========== */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.95);
    z-index: 1000;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.lightbox.active {
    display: flex;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.1);
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.lightbox-close:hover {
    background: var(--primary-color);
    transform: rotate(90deg);
}

.lightbox-content {
    max-width: 90vw;
    max-height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-content img,
.lightbox-content video {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 10px;
}

.lightbox-actions {
    margin-top: 20px;
}

.lightbox-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: var(--primary-color);
    color: white;
    text-decoration: none;
    border-radius: 30px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.lightbox-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 10px 30px rgba(230, 0, 35, 0.4);
}

.lightbox-btn.video {
    background: var(--video-color);
}

/* ========== TOAST ========== */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--card-bg);
    color: var(--text-main);
    padding: 14px 24px;
    border-radius: 30px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 1001;
    opacity: 0;
    transition: all 0.4s ease;
    border: 1px solid var(--border-color);
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast i {
    color: var(--success-color);
    font-size: 1.2rem;
}

/* ========== FOOTER ========== */
footer {
    text-align: center;
    padding: 30px 0;
    color: var(--text-muted);
    font-size: 0.9rem;
    border-top: 1px solid var(--border-color);
    margin-top: 20px;
    transition: border-color 0.3s ease;
}

footer strong {
    color: var(--primary-color);
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
    .hero h1 { 
        font-size: 1.6rem; 
    }
    
    input[type="text"] { 
        padding: 15px 50px 15px 45px; 
        font-size: 0.9rem; 
    }
    
    .download-btn { 
        width: 100%; 
        justify-content: center;
    }

    .link-examples {
        flex-direction: column;
    }

    .link-examples code {
        text-align: center;
    }

    .action-buttons {
        grid-template-columns: 1fr;
    }

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

    .extra-btn {
        justify-content: center;
    }

    .history-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }

    .view-toggle {
        width: 100%;
    }

    .view-btn {
        flex: 1;
        justify-content: center;
    }

    .content-badges {
        gap: 10px;
    }

    .badge-item {
        padding: 6px 12px;
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .header-content {
        padding: 0 10px;
    }
    
    .logo {
        font-size: 1.2rem;
    }

    .logo i {
        font-size: 1.4rem;
    }

    .download-counter {
        display: none;
    }
    
    .theme-toggle {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
    
    .hero h1 {
        font-size: 1.4rem;
    }
    
    .description {
        font-size: 0.85rem;
    }
    
    .result-container {
        padding: 20px 15px;
    }
    
    .btn-action {
        padding: 12px 15px;
        font-size: 0.9rem;
    }

    .supported-links {
        padding: 12px 15px;
    }

    .supported-links p {
        font-size: 0.8rem;
    }

    .content-info {
        gap: 15px;
    }

    .info-item {
        font-size: 0.75rem;
    }

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