:root {
    --primary: #6366f1;
    --primary-dark: #4338ca;
    --accent: #ec4899;
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

[data-theme="light"] {
    --bg-gradient: linear-gradient(135deg, #e0e7ff 0%, #f3e8ff 100%);
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.5);
    --text-main: #1e293b;
    --text-muted: #64748b;
    --shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

body {
    background: var(--bg-gradient);
    font-family: 'Roboto', sans-serif;
    color: var(--text-main);
    min-height: 100vh;
    margin: 0;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    transition: background 0.3s ease;
}

/* --- Animated Background Elements --- */
.bg-blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    z-index: -1;
    opacity: 0.6;
    animation: float 10s infinite ease-in-out;
}
.blob-1 { top: -10%; left: -10%; width: 500px; height: 500px; background: var(--primary); }
.blob-2 { bottom: -10%; right: -10%; width: 400px; height: 400px; background: var(--accent); animation-delay: 2s; }

@keyframes float {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(30px, -30px); }
}

/* --- Main Container --- */
.app-container {
    max-width: 800px;
    margin: 50px auto;
    width: 95%;
    position: relative;
    z-index: 1;
}

/* --- Header --- */
.navbar-custom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    margin-bottom: 40px;
}
.logo {
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--text-main);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
}
.logo i { color: var(--accent); }

/* --- Main Card (Glassmorphism) --- */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 40px;
    box-shadow: var(--shadow);
    text-align: center;
}

.hero-title {
    font-size: 3rem;
    font-weight: 800;
    margin-bottom: 10px;
    line-height: 1.2;
}
.text-gradient {
    background: linear-gradient(to right, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.hero-desc { color: var(--text-muted); margin-bottom: 30px; font-size: 1.1rem; }

/* --- Input Area --- */
.input-wrapper {
    position: relative;
    margin-bottom: 20px;
    width: 100%; /* Đảm bảo wrapper không vượt quá cha */
    max-width: 100%;
}

.main-input {
    width: 100%;
    box-sizing: border-box; /* Quan trọng: tính padding vào trong chiều rộng */
    padding: 18px 25px;
    
    /* Chừa chỗ cho nút bấm bên phải (để chữ không bị chèn) */
    padding-right: 170px; 
    
    border-radius: 50px;
    border: 2px solid var(--glass-border);
    background: rgba(255,255,255,0.05);
    color: var(--text-main);
    font-size: 1.1rem;
    transition: all 0.3s;
    
    /* Xử lý text dài */
    white-space: nowrap; 
    overflow: hidden;
    text-overflow: ellipsis; /* Hiện dấu ... nếu dài quá */
}

[data-theme="light"] .main-input { background: #fff; }

.main-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.2);
}

.btn-submit {
    position: absolute;
    right: 6px;
    top: 6px;
    bottom: 6px;
    padding: 0 25px; /* Giảm padding nút một chút cho gọn */
    border-radius: 40px;
    border: none;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s;
    white-space: nowrap; /* Giữ chữ trên nút không bị xuống dòng */
    z-index: 10;
}
.btn-submit:hover { transform: scale(1.05); }

/* --- Mobile Responsiveness (Sửa lỗi vỡ trên điện thoại) --- */
@media (max-width: 576px) {
    .glass-card {
        padding: 25px 15px; /* Giảm padding card trên mobile */
    }

    .hero-title {
        font-size: 2rem; /* Giảm cỡ chữ tiêu đề */
    }

    /* Trên mobile: Đưa nút xuống dòng để không chiếm chỗ input */
    .input-wrapper {
        display: flex;
        flex-direction: column;
        gap: 15px;
    }

    .main-input {
        padding-right: 25px; /* Trả lại padding bình thường */
        text-overflow: clip; /* Để người dùng scroll xem được link */
    }

    .btn-submit {
        position: static; /* Bỏ vị trí tuyệt đối */
        width: 100%; /* Full chiều rộng */
        height: 50px;
    }
}

/* --- Alias Toggle --- */
.alias-toggle {
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: color 0.3s;
}
.alias-toggle:hover { color: var(--primary); }
.alias-box { display: none; margin-top: 15px; }
.alias-input {
    background: transparent;
    border: 1px solid var(--glass-border);
    padding: 10px 20px;
    border-radius: 12px;
    color: var(--text-main);
    width: 100%;
    max-width: 300px;
}

/* --- Result Area --- */
#result-area { display: none; margin-top: 30px; }
.res-card {
    background: rgba(0,0,0,0.2);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    border: 1px solid var(--primary);
}
[data-theme="light"] .res-card { background: rgba(255,255,255,0.8); }

.res-link {
    color: var(--accent);
    font-weight: 700;
    font-size: 1.2rem;
    text-decoration: none;
    word-break: break-all;
}
.action-btns button {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    width: 40px;
    height: 40px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
}
.action-btns button:hover { background: var(--primary); color: white; border-color: var(--primary); }

/* --- History Section --- */
.history-section { margin-top: 60px; }
.hist-header {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-main);
    margin-bottom: 20px;
    font-weight: 600;
    font-size: 1.2rem;
}
.hist-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}
.hist-item {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 15px;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: transform 0.2s;
    cursor: pointer;
}
.hist-item:hover { transform: translateY(-5px); border-color: var(--primary); }
.favicon-box img { width: 32px; height: 32px; border-radius: 8px; }
.hist-info { flex: 1; overflow: hidden; }
.h-title {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.95rem;
}
.h-link { color: var(--text-muted); font-size: 0.85rem; }
.h-actions button {
    background: none; border: none; color: var(--text-muted); cursor: pointer;
    padding: 5px; transition: color 0.2s;
}
.h-actions button:hover { color: var(--primary); }

/* Mobile */
@media (max-width: 768px) {
    .hero-title { font-size: 2rem; }
    .main-input { padding-right: 20px; margin-bottom: 10px; }
    .btn-submit { position: static; width: 100%; padding: 15px; margin-top: 10px; }
    .res-card { flex-direction: column; text-align: center; }
}