@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');

:root {
    --bg-body: #f4f4f5;
    --bg-surface: #ffffff;
    --bg-surface-hover: #f8fafc;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --accent: #2563eb;
    --accent-light: #eff6ff;
    --danger: #ef4444;
    --success: #10b981;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body.dark-theme {
    --bg-body: #0f172a; /* Màu tối nền tảng như ảnh bạn gửi */
    --bg-surface: #1e293b;
    --bg-surface-hover: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --border-color: #334155;
    --accent: #0ea5e9; /* Xanh ngọc nổi bật */
    --accent-light: rgba(14, 165, 233, 0.15);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Poppins', sans-serif; }
body { background-color: var(--bg-body); color: var(--text-primary); transition: var(--transition); overflow-x: hidden; }
a { text-decoration: none; }

.app-layout { display: flex; min-height: 100vh; position: relative; width: 100%; }

/* --- SIDEBAR --- */
.sidebar { width: 260px; background-color: var(--bg-surface); border-right: 1px solid var(--border-color); display: flex; flex-direction: column; padding: 1.5rem; position: fixed; top: 0; left: 0; height: 100vh; z-index: 100; transition: transform 0.4s ease; }
.brand { display: flex; align-items: center; gap: 1rem; margin-bottom: 2.5rem; }
.brand-logo { width: 45px; height: 45px; border-radius: 10px; object-fit: cover; box-shadow: var(--shadow); }
.brand-name { font-weight: 700; font-size: 1.2rem; }
.brand-sub { font-size: 0.8rem; color: var(--text-secondary); }

.menu { display: flex; flex-direction: column; gap: 0.5rem; flex-grow: 1; }
.menu-label { font-size: 0.75rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 0.5rem; letter-spacing: 1px; }
.menu-item { display: flex; align-items: center; gap: 1rem; padding: 0.8rem 1rem; color: var(--text-secondary); border-radius: 10px; font-weight: 500; transition: var(--transition); }
.menu-item i { font-size: 1.4rem; }
.menu-item:hover { background-color: var(--bg-surface-hover); color: var(--text-primary); }
.menu-item.active { background-color: var(--accent-light); color: var(--accent); }
.sidebar-footer { border-top: 1px solid var(--border-color); padding-top: 1rem; margin-top: auto; }

/* --- MAIN CONTENT --- */
.main-content { margin-left: 260px; padding: 2.5rem 3rem; width: calc(100% - 260px); min-height: 100vh; display: flex; flex-direction: column; }
.topbar { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 2rem; }
.page-title { font-size: 2rem; font-weight: 700; line-height: 1.2; }
.page-subtitle { color: var(--text-secondary); margin-top: 0.5rem; font-size: 0.95rem; }

/* --- UI COMPONENTS --- */
.tool-container { background: var(--bg-surface); padding: 2.5rem; border-radius: 16px; width: 100%; box-shadow: var(--shadow); border: 1px solid var(--border-color); margin: 0 auto; }
.tool-input { width: 100%; padding: 1rem; border-radius: 10px; border: 1px solid var(--border-color); background: var(--bg-body); color: var(--text-primary); font-size: 0.95rem; outline: none; transition: var(--transition); }
.tool-input:focus { border-color: var(--accent); }
.tool-btn { background: var(--accent); color: white; border: none; padding: 1rem 1.5rem; border-radius: 10px; cursor: pointer; font-weight: 600; transition: var(--transition); display: flex; justify-content: center; align-items: center; gap: 0.5rem; }
.tool-btn:hover { filter: brightness(1.1); transform: translateY(-2px); }
.tool-btn:disabled { opacity: 0.7; cursor: not-allowed; }

.tools-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.5rem; }
.tool-card { background-color: var(--bg-surface); border: 1px solid var(--border-color); border-radius: 16px; padding: 1.5rem; display: flex; align-items: center; gap: 1.25rem; transition: var(--transition); box-shadow: var(--shadow); }
.tool-card:hover { transform: translateY(-5px); border-color: var(--accent); }
.card-icon { width: 55px; height: 55px; background-color: var(--accent-light); color: var(--accent); border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 1.8rem; flex-shrink: 0; }
.card-info h3 { font-size: 1.1rem; margin-bottom: 0.25rem; color: var(--text-primary); }
.card-info p { font-size: 0.85rem; color: var(--text-secondary); }

/* --- TYPING TEST UI --- */
.typing-wrapper { position: relative; border-radius: 12px; padding: 2rem; background: var(--bg-body); border: 1px solid var(--border-color); text-align: left; margin-bottom: 1.5rem; cursor: text; }
.type-text { font-size: 1.5rem; line-height: 1.6; color: var(--text-secondary); font-family: monospace; letter-spacing: 1px; user-select: none; }
.type-char { transition: color 0.1s; }
.type-char.correct { color: var(--success); }
.type-char.incorrect { color: var(--danger); background: rgba(239, 68, 68, 0.2); border-radius: 3px; }
.type-char.current { border-bottom: 3px solid var(--accent); color: var(--text-primary); animation: blink 1s infinite; }
@keyframes blink { 50% { border-color: transparent; } }
.hidden-input { position: absolute; top: 0; left: 0; width: 100%; height: 100%; opacity: 0; z-index: 10; cursor: text; }

/* --- LUCKY DRAW UI (HỘP QUÀ) --- */
.tabs { display: flex; gap: 1rem; margin-bottom: 1.5rem; border-bottom: 1px solid var(--border-color); padding-bottom: 1rem; }
.tab-btn { background: none; border: none; color: var(--text-secondary); font-size: 1.1rem; font-weight: 600; cursor: pointer; padding: 0.5rem 1rem; border-radius: 8px; transition: var(--transition); }
.tab-btn.active { color: var(--accent); background: var(--accent-light); }
.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.4s ease; }

.draw-layout { display: flex; gap: 2rem; flex-wrap: wrap; }
.draw-play-area { flex: 2; min-width: 300px; background: var(--bg-body); padding: 1.5rem; border-radius: 16px; border: 1px solid var(--border-color); }
.draw-config-area { flex: 1; min-width: 300px; background: var(--bg-body); padding: 1.5rem; border-radius: 16px; border: 1px solid var(--border-color); }
.draw-status-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; flex-wrap: wrap; gap: 1rem; }
.status-badges { display: flex; gap: 0.5rem; }
.badge { background: var(--bg-surface); padding: 0.4rem 0.8rem; border-radius: 20px; font-size: 0.85rem; color: var(--text-secondary); border: 1px solid var(--border-color); }

.boxes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 1rem; }
.gift-box { background: #0ea5e9; border-radius: 12px; aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: white; cursor: pointer; transition: all 0.3s; font-weight: bold; position: relative; overflow: hidden; box-shadow: 0 4px 10px rgba(0,0,0,0.1); }
.gift-box i { font-size: 2.5rem; margin-bottom: 0.5rem; }
.gift-box:hover:not(.opened) { transform: translateY(-5px) scale(1.02); box-shadow: 0 10px 20px rgba(14, 165, 233, 0.4); }
.gift-box.opened { background: var(--bg-surface); color: var(--text-secondary); cursor: not-allowed; border: 2px dashed var(--border-color); box-shadow: none; transform: none; }

/* --- RESPONSIVE --- */
.mobile-header { display: none; }
.sidebar-overlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.6); z-index: 95; backdrop-filter: blur(3px); opacity: 0; transition: opacity 0.3s ease; }

@media (max-width: 992px) {
    .mobile-header { display: flex; justify-content: space-between; align-items: center; padding: 0 1.5rem; background-color: var(--bg-surface); border-bottom: 1px solid var(--border-color); position: fixed; top: 0; left: 0; right: 0; height: 70px; z-index: 90; box-shadow: var(--shadow); }
    .mobile-brand { font-weight: 700; font-size: 1.2rem; display: flex; align-items: center; gap: 0.5rem; color: var(--text-primary); }
    .mobile-brand i { color: var(--accent); font-size: 1.6rem; }
    .menu-toggle { font-size: 2rem; color: var(--text-primary); cursor: pointer; }
    .main-content { margin-left: 0; padding: 90px 1.25rem 2rem 1.25rem; width: 100%; }
    .sidebar { transform: translateX(-100%); width: 280px; box-shadow: 5px 0 25px rgba(0,0,0,0.1); }
    .sidebar.active { transform: translateX(0); }
    .sidebar-overlay.active { display: block; opacity: 1; }
    .draw-layout { flex-direction: column-reverse; }
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
/* =========================================
   VÒNG QUAY MAY MẮN (CANVAS)
   ========================================= */
.wheel-wrapper {
    position: relative;
    width: 100%;
    max-width: 450px;
    aspect-ratio: 1;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wheel-pointer {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 32px;
    height: 40px;
    background-color: var(--text-primary);
    clip-path: polygon(50% 100%, 0 0, 100% 0);
    z-index: 10;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

.wheel-pointer::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(to bottom, rgba(255,255,255,0.2), transparent);
}

#wheel-canvas {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 8px solid var(--bg-surface);
    box-shadow: 0 10px 30px rgba(0,0,0,0.2), inset 0 0 15px rgba(0,0,0,0.2);
    background-color: #fff;
}

.wheel-center-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: #0ea5e9;
    color: white;
    font-weight: 700;
    font-size: 1.1rem;
    border: 6px solid white;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    cursor: pointer;
    z-index: 5;
    transition: transform 0.1s, background 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wheel-center-btn:hover {
    background: #0284c7;
    transform: translate(-50%, -50%) scale(1.05);
}

.wheel-center-btn:active {
    transform: translate(-50%, -50%) scale(0.95);
}

body.dark-theme .wheel-center-btn {
    border-color: #1e293b;
}
body.dark-theme #wheel-canvas {
    border-color: #334155;
}

/* =========================================
   TRANG 404 (ERROR PAGE)
   ========================================= */
.error-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    text-align: center;
    padding: 2rem;
    background-color: var(--bg-body);
    color: var(--text-primary);
}
.error-gif {
    max-width: 280px;
    width: 100%;
    border-radius: 20px;
    margin-bottom: 2rem;
}
.error-title {
    font-size: 6rem;
    font-weight: 700;
    color: var(--accent);
    line-height: 1;
    margin-bottom: 0.5rem;
}
.error-subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
    max-width: 450px;
}
.error-btn {
    display: inline-flex;
    width: auto;
    padding: 1rem 2rem;
}