:root {
    --primary: #00f2fe;
    --secondary: #4facfe;
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent: #f43f5e;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    line-height: 1.6;
}

/* Navbar */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem max(5%, calc((100vw - 1600px) / 2 + 5%));
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

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

.top-badge {
    background: linear-gradient(
        90deg, 
        #ff2a2a 0%, 
        #ff7a00 15%, 
        #ffed00 30%, 
        #00e676 45%, 
        #00d4ff 60%, 
        #b000ff 75%, 
        #ff0055 90%,
        #ff2a2a 100%
    );
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: shimmer 1.5s linear infinite;
    font-weight: 900;
    font-size: 1.15em;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    margin-left: 4px;
}

@keyframes shimmer {
    0% { background-position: 0% center; }
    100% { background-position: 200% center; }
}

nav a {
    color: var(--text-main);
    text-decoration: none;
    margin-left: 1.5rem;
    font-weight: 600;
    transition: color 0.3s;
}

nav a:hover {
    color: var(--primary);
}

/* Language Dropdown */
.lang-dropdown {
    display: inline-block;
    position: relative;
    margin-left: 1.5rem;
}

.lang-btn {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.lang-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: var(--primary);
}

.lang-content {
    display: none;
    position: absolute;
    right: 0;
    top: 110%;
    background: var(--bg-card);
    min-width: 150px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.5);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 1000;
    overflow: hidden;
}

.lang-content a {
    color: var(--text-main);
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    margin-left: 0;
    font-weight: 400;
    transition: background 0.2s;
}

.lang-content a:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--primary);
}

.lang-dropdown:hover .lang-content {
    display: block;
}

.admin-link {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Main Layout */
.container {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 2rem;
    max-width: 1600px;
    margin: 0 auto;
    padding: 2rem 5%;
    min-height: calc(100vh - 140px);
}

.main-content {
    flex: 1;
    max-width: 900px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Ads Sidebar */
.ad-sidebar {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 1rem;
    border: 1px dashed rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 600px;
    width: 300px;
    flex-shrink: 0;
}

.ad-placeholder {
    color: var(--text-muted);
    text-align: center;
    font-size: 0.9rem;
}

/* Hero Section */
.hero {
    text-align: center;
    padding: 3rem 0;
}

.hero h1 {
    font-size: 3.5rem;
    font-weight: 800;
    margin-bottom: 1rem;
    background: linear-gradient(to right, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero p {
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.search-box {
    display: flex;
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 0.3rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: transform 0.3s;
}

.search-box:focus-within {
    transform: translateY(-2px);
    border-color: var(--primary);
}

.search-box input {
    flex: 1;
    background: transparent;
    border: none;
    padding: 1rem 1.5rem;
    color: white;
    font-size: 1.1rem;
    outline: none;
}

.search-box button {
    background: linear-gradient(to right, var(--primary), var(--secondary));
    color: var(--bg-dark);
    border: none;
    padding: 0.8rem 2rem;
    border-radius: 8px;
    font-weight: 700;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: opacity 0.3s;
}

.search-box button:hover {
    opacity: 0.9;
}

.btn-clear {
    background: transparent;
    color: var(--text-muted);
    border: none;
    padding: 0 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.3s;
}

.btn-clear:hover {
    color: var(--text-main);
    opacity: 1;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.absolute-clear-btn {
    position: absolute;
    right: 10px;
    padding: 0.5rem;
}

.hidden { display: none !important; }

#loading {
    margin-top: 1.5rem;
    color: var(--primary);
    font-weight: 600;
}

.error {
    color: var(--accent);
    margin-top: 1rem;
}

/* Result Card */
.result-card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 1.5rem;
    margin-top: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
    animation: fadeIn 0.5s ease-out;
}

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

#videoThumb {
    width: 200px;
    border-radius: 12px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.5);
    margin-bottom: 1rem;
}

.video-info {
    text-align: center;
    margin-bottom: 1.5rem;
}

#videoTitle { font-size: 1.1rem; margin-bottom: 0.3rem; }
#videoAuthor { color: var(--text-muted); font-size: 0.9rem; }

.download-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
}

.download-actions button {
    padding: 1rem 2rem;
    border-radius: 8px;
    border: none;
    font-weight: 700;
    cursor: pointer;
    flex: 1;
    min-width: 200px;
    transition: transform 0.2s;
}

.download-actions button:active { transform: scale(0.98); }

.btn-primary {
    background: var(--primary);
    color: var(--bg-dark);
}

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

/* Features */
.features-section {
    margin-top: 5rem;
    text-align: center;
}

.features-section h2 { margin-bottom: 2rem; }

.feature-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 2rem;
}

.feature-item {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: 12px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.feature-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 242, 254, 0.1);
}

.feature-item h3 { color: var(--primary); margin-bottom: 0.5rem; }
.feature-item p { color: var(--text-muted); font-size: 0.9rem; }

@media (max-width: 900px) {
    .feature-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 550px) {
    .feature-grid {
        grid-template-columns: 1fr;
    }
}

/* Admin Base */
.admin-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 3rem 5%;
}

.admin-card {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: 12px;
    margin-bottom: 2rem;
}

.admin-card input, .admin-card textarea {
    width: 100%;
    background: rgba(0,0,0,0.2);
    border: 1px solid rgba(255,255,255,0.1);
    color: white;
    padding: 0.8rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-family: inherit;
}

/* Tool Switcher */
.tool-switcher {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.tool-switcher button {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    padding: 0.8rem 2rem;
    border-radius: 12px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tool-switcher button:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.tool-switcher button.active {
    background: linear-gradient(to right, var(--primary), var(--secondary));
    color: var(--bg-dark);
    border-color: transparent;
    box-shadow: 0 4px 15px rgba(0, 242, 254, 0.3);
}

/* QR Generator */
.qr-generator-card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 2rem;
    max-width: 800px;
    margin: 0 auto;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    animation: fadeIn 0.5s ease-out;
}

.qr-input-group {
    margin-bottom: 1.5rem;
}

.qr-input-group input, .qr-input-group select, .qr-select {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    font-size: 1.1rem;
    outline: none;
    transition: border-color 0.3s;
}

.qr-input-group input:focus {
    border-color: var(--primary);
}

.qr-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.qr-file-upload .file-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px dashed rgba(255, 255, 255, 0.3);
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    color: var(--text-muted);
}

.qr-file-upload .file-label:hover {
    border-color: var(--primary);
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.1);
}

.qr-colors label {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    color: var(--text-muted);
}

.qr-colors input[type="color"] {
    -webkit-appearance: none;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    padding: 0;
    overflow: hidden;
}

.qr-colors input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

.qr-colors input[type="color"]::-webkit-color-swatch {
    border: 2px solid rgba(255,255,255,0.2);
    border-radius: 50%;
}

#generateQrBtn {
    width: 100%;
    padding: 1rem;
    border-radius: 12px;
    font-size: 1.1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    border: none;
    cursor: pointer;
    transition: transform 0.2s, opacity 0.3s;
}

#generateQrBtn:hover {
    opacity: 0.9;
}
#generateQrBtn:active {
    transform: scale(0.98);
}

#qrResultArea {
    margin-top: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    padding-top: 2rem;
    border-top: 1px solid rgba(255,255,255,0.1);
}

#qrcode-canvas-wrapper {
    background: white;
    padding: 1rem;
    border-radius: 12px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.5);
}

#qrcode-canvas-wrapper canvas, #qrcode-canvas-wrapper img {
    max-width: 100%;
    height: auto;
    width: 256px;
    display: block;
    margin: 0 auto;
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
}

#downloadQrBtn {
    padding: 0.8rem 2rem;
    border-radius: 8px;
    border: none;
    font-weight: 600;
    cursor: pointer;
}

/* Responsive */
@media (max-width: 1024px) {
    .navbar {
        padding: 1rem 4%;
    }

    .logo {
        font-size: 1.2rem;
    }

    nav a {
        margin-left: 0.8rem;
        font-size: 0.85rem;
    }

    .container {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
        padding: 1rem 3%;
    }

    /* Quảng cáo trái -> hiện trên cùng, chiếm 25% màn hình */
    .ad-left {
        order: -1; /* Đẩy lên trên cùng */
        min-height: 25vh;
        height: 25vh;
        width: 100%;
        border-radius: 12px;
        overflow: hidden;
    }

    /* Nội dung chính ở giữa */
    .main-content {
        order: 0;
    }

    /* Quảng cáo phải -> hiện dưới cùng, chiếm 25% màn hình */
    .ad-right {
        order: 1; /* Đẩy xuống dưới cùng */
        min-height: 25vh;
        height: 25vh;
        width: 100%;
        border-radius: 12px;
        overflow: hidden;
    }

    .hero h1 {
        font-size: 1.6rem;
    }

    .search-box {
        flex-direction: column;
        border-radius: 16px;
        gap: 0.5rem;
    }

    .search-box button {
        border-radius: 12px;
        justify-content: center;
        width: 100%;
    }
}

/* Image Resizer Custom Styling */
.resize-upload-area {
    border: 2px dashed rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    padding: 3.5rem 2rem;
    text-align: center;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.02);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.resize-upload-area:hover {
    border-color: var(--primary);
    background: rgba(0, 242, 254, 0.03);
    box-shadow: 0 0 15px rgba(0, 242, 254, 0.1);
}

.resize-upload-area svg {
    color: var(--text-muted);
    transition: color 0.3s;
}

.resize-upload-area:hover svg {
    color: var(--primary);
}

.resize-upload-text {
    color: var(--text-muted);
    font-size: 1rem;
}

.resize-preset-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.resize-preset-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    border-color: rgba(255, 255, 255, 0.3);
}

.resize-preset-btn.active {
    background: rgba(0, 242, 254, 0.15) !important;
    border-color: var(--primary) !important;
    color: var(--primary) !important;
    box-shadow: 0 0 10px rgba(0, 242, 254, 0.1);
}
