/* Base styles and variables */
:root {
    --bg-main: #060b14;
    --bg-card: rgba(15, 25, 45, 0.4);
    --bg-card-hover: rgba(30, 38, 59, 0.8);
    --text-primary: #ffffff;
    --text-secondary: #94a3b8;
    --border-color: rgba(59, 130, 246, 0.2);
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --danger: #ef4444;
    
    /* Platform Colors */
    --c-fb: #1877f2;
    --c-tt: #000000;
    --c-ig: #e1306c;
    --c-yt: #ff0000;
    --c-x: #000000;
}

.caption-container {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    position: relative;
    margin-bottom: 1rem;
    overflow: hidden;
}

.media-caption {
    font-size: 0.95rem;
    color: var(--text-primary);
    line-height: 1.5;
    margin-bottom: 0;
    padding-right: 2.5rem;
    word-break: break-word;
    white-space: pre-wrap;
    max-height: 120px;
    overflow-y: auto;
}

.copy-caption-btn {
    position: absolute;
    top: 50%;
    right: 0.8rem;
    transform: translateY(-50%);
    background: var(--bg-card);
    border: 1px solid var(--accent);
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.copy-caption-btn:hover {
    background: var(--accent);
    color: #fff;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
    /* Removed the previous gradient to let the matrix show, we'll keep it semi-transparent if needed, but matrix is better clear */
}

/* Matrix Canvas */
#matrixCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    opacity: 0.6; /* Slight opacity so it doesn't overwhelm the UI */
    pointer-events: none;
}

/* App Container */
.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    position: relative;
    z-index: 1; /* Sit above the canvas */
}

/* Hero Section */
.hero {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
}

.hero-content {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.logo-icon {
    width: 48px;
    height: 48px;
    background: rgba(0, 212, 170, 0.1);
    color: var(--accent);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.hero h1 {
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.hero p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    width: 100%;
}

/* Grid Layout */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    transition: opacity 0.3s ease;
}

/* Platform Cards */
.tool-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(12px); /* Increased blur slightly for better contrast against matrix */
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    z-index: 2;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2), inset 0 1px 1px rgba(255, 255, 255, 0.05);
}

.tool-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: transparent;
    transition: 0.3s ease;
}

.tool-card[data-platform="facebook"]::before { background: var(--c-fb); }
.tool-card[data-platform="tiktok"]::before { background: var(--c-tt); }
.tool-card[data-platform="instagram"]::before { background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888); }
.tool-card[data-platform="youtube"]::before { background: var(--c-yt); }
.tool-card[data-platform="twitter"]::before { background: #333; }

.tool-card:hover {
    transform: translateY(-6px);
    background: var(--bg-card-hover);
    border-color: rgba(59, 130, 246, 0.4);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.4), 0 0 20px rgba(59, 130, 246, 0.15), inset 0 1px 1px rgba(255, 255, 255, 0.08);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.25rem;
}

.platform-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
}

.lg-icon {
    width: 64px;
    height: 64px;
    font-size: 2rem;
}

.fb-gradient { background: #1877f2; }
.tt-gradient { background: #000000; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.1); }
.ig-gradient { background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%); }
.yt-gradient { background: #ff0000; } 
.x-gradient { background: #000000; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.1); }

.badge {
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    background: rgba(255, 255, 255, 0.1);
}

.badge.free { color: #10b981; background: rgba(16, 185, 129, 0.15); }
.badge.new-badge { color: #0ea5e9; background: rgba(14, 165, 233, 0.15); }
.badge.hot-badge { color: #ef4444; background: rgba(239, 68, 68, 0.15); }

.tool-card h3 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.tool-card p {
    color: var(--text-secondary);
    font-size: 0.85rem;
    flex-grow: 1;
    margin-bottom: 1.5rem;
}

.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
}

.arrow-icon {
    color: var(--text-secondary);
    font-size: 1.1rem;
    transform: translateX(0);
    transition: all 0.3s ease;
}

.header-stats {
    display: flex;
    gap: 1.5rem;
}

.header-stat-box {
    background: rgba(10, 20, 40, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.8rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease;
}

.header-stat-box:hover {
    transform: translateY(-2px);
    border-color: rgba(59, 130, 246, 0.4);
}

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-raw {
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1.1;
    color: var(--text-primary);
}

.stat-lbl {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tool-card:hover .arrow-icon {
    transform: translateX(5px);
    color: var(--text-primary);
}

/* Download Panel */
.hidden { display: none !important; }

.download-panel {
    animation: fadeIn 0.4s ease;
}

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

.back-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.95rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 2rem;
    transition: color 0.2s;
    font-family: inherit;
}

.back-btn:hover { color: var(--text-primary); }

.panel-header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.panel-title h2 {
    font-size: 1.8rem;
    font-weight: 700;
}

.panel-title p {
    color: var(--text-secondary);
}

/* Search Box */
.search-box {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3); /* Darker shadow */
    margin-bottom: 2rem;
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
}

#downloadForm {
    display: flex;
    gap: 1rem;
}

.input-wrapper {
    position: relative;
    flex-grow: 1;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 1.25rem;
    color: var(--text-secondary);
}

#urlInput {
    width: 100%;
    padding: 1rem 3rem 1rem 3rem;
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: white;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#urlInput:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 212, 170, 0.1);
}

.paste-btn {
    position: absolute;
    right: 0.5rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
}

.paste-btn:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

.submit-btn {
    background: var(--accent);
    color: #000;
    border: none;
    padding: 0 2rem;
    border-radius: 12px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
    font-family: inherit;
}

.submit-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 212, 170, 0.3);
}

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

/* Loading State */
.loading-state {
    text-align: center;
    padding: 3rem 0;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255,255,255,0.1);
    border-radius: 50%;
    border-top-color: var(--accent);
    animation: spin 1s ease-in-out infinite;
    margin: 0 auto 1rem auto;
}

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

.loading-state p {
    color: var(--text-secondary);
}

/* Results Section */
.results-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.5rem;
    margin-top: 2rem;
    animation: fadeIn 0.4s ease;
}

.media-info {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.media-thumbnail {
    width: 160px;
    height: 160px;
    border-radius: 12px;
    object-fit: cover;
    background: #000;
}

.video-player {
    width: 140px;
    border-radius: 12px;
    background: #000;
}

.media-details {
    flex-grow: 1;
}

.media-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
}

.media-author, .media-stats {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.download-options {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.dl-btn {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: white;
    text-decoration: none;
    padding: 1rem;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.2s;
}

.dl-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
    border-color: rgba(255,255,255,0.2);
}

.dl-btn i {
    color: var(--text-secondary);
}

/* Platform Specific Button Accents */
.btn-fb:hover { border-color: var(--c-fb); background: rgba(24, 119, 242, 0.1); }
.btn-tt:hover { border-color: var(--c-tt); background: rgba(255, 0, 80, 0.1); }
.btn-ig:hover { border-color: var(--c-ig); background: rgba(225, 48, 108, 0.1); }
.btn-yt:hover { border-color: var(--c-yt); background: rgba(255, 0, 0, 0.1); }

/* Playlist Styles */
.playlist-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    max-height: 60vh;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.playlist-grid::-webkit-scrollbar { width: 6px; }
.playlist-grid::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 4px; }

.playlist-item {
    display: flex;
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.8rem;
    gap: 1rem;
    transition: all 0.2s;
}

.playlist-item:hover {
    border-color: var(--c-yt);
    background: rgba(255,0,0,0.05);
}

.pi-thumb {
    width: 100px;
    height: 70px;
    object-fit:cover;
    border-radius: 8px;
    background: #000;
}

.pi-info {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.pi-title {
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: auto;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-bottom: 0.5rem;
}

.pi-actions {
    display: flex;
    gap: 0.4rem;
}

.pi-btn {
    flex: 1;
    background: rgba(255,255,255,0.1);
    border: none;
    color: #fff;
    padding: 0.4rem 0.2rem;
    font-size: 0.75rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    font-weight: 600;
}

.pi-btn.yt:hover { background: var(--c-yt); }
.pi-btn.audio:hover { background: #3b82f6; }

/* Toasts */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 9999;
}

.toast {
    background: #1e293b;
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    animation: slideIn 0.3s ease forwards;
    border-left: 4px solid var(--accent);
}

.toast.error { border-left-color: var(--danger); }
.toast i { font-size: 1.1rem; }
.toast.error i { color: var(--danger); }
.toast:not(.error) i { color: var(--accent); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
@keyframes fadeOut {
    to { opacity: 0; transform: translateY(10px); }
}

footer {
    margin-top: auto;
    text-align: center;
    padding-top: 3rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Responsive */
@media (max-width: 768px) {
    .header-stats { width: 100%; justify-content: space-between; gap: 1rem; }
    .header-stat-box { flex: 1; padding: 0.8rem; }
    #downloadForm { flex-direction: column; }
    .submit-btn { width: 100%; padding: 1rem; justify-content: center; }
    .hero { flex-direction: column; gap: 2rem; align-items: flex-start; }
    .hero-content { justify-content: flex-start; text-align: left; }
    .media-info { flex-direction: column; align-items: center; text-align: center; }
}
