/* ============================================
   FS Truyền Kỳ - Design System
   Dark Glassmorphic Gaming Theme
   ============================================ */

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

/* --- CSS Variables --- */
:root {
    --font-family: 'Lexend Deca', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    /* Colors adapted for Dark Glassmorphism */
    --white: rgba(15, 23, 42, 0.65); /* Translucent dark panels */
    --gray-50: rgba(15, 23, 42, 0.4);
    --gray-100: rgba(255, 255, 255, 0.08); /* Dividers, table header bg */
    --gray-200: rgba(255, 255, 255, 0.12); /* Standard borders */
    --gray-300: rgba(255, 255, 255, 0.25); /* Input borders */
    --gray-400: rgba(255, 255, 255, 0.4);  /* Secondary icons, muted text */
    --gray-500: rgba(255, 255, 255, 0.55);
    --gray-600: rgba(255, 255, 255, 0.7);  /* Body copy */
    --gray-700: rgba(255, 255, 255, 0.85); /* Emphasis text */
    --gray-800: rgba(255, 255, 255, 0.95); /* Primary text / labels */
    --gray-900: #ffffff;                    /* High contrast title text */

    /* Premium Crimson Gaming Accents */
    --primary: #e11d48;
    --primary-hover: #f43f5e;
    --primary-light: rgba(225, 29, 72, 0.15);
    --primary-50: rgba(225, 29, 72, 0.25);

    --success: #10b981;
    --success-light: rgba(16, 185, 129, 0.15);
    --warning: #f59e0b;
    --warning-light: rgba(245, 158, 11, 0.15);
    --danger: #ef4444;
    --danger-light: rgba(239, 68, 68, 0.15);
    --info: #06b6d4;
    --info-light: rgba(6, 182, 212, 0.15);

    /* Spacing */
    --radius-sm: 6px;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
    --shadow-md: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);
    --shadow-lg: 0 20px 25px -5px rgba(0,0,0,0.08), 0 8px 10px -6px rgba(0,0,0,0.04);

    /* Transitions */
    --transition: all 0.2s ease;
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; scroll-behavior: smooth; }

body {
    font-family: var(--font-family);
    color: var(--gray-800);
    background: linear-gradient(rgba(15, 23, 42, 0.65), rgba(15, 23, 42, 0.65)), url('../images/bg.jpg') no-repeat center center fixed;
    background-size: cover;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--primary-hover); }

img { max-width: 100%; display: block; }

/* --- Glassmorphism components blur --- */
.guest-card, .sidebar, .main-header, .card, .stat-card {
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

/* --- Layout --- */
.container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }

/* --- Guest Layout (Login/Register) --- */
.guest-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(rgba(15, 23, 42, 0.4), rgba(15, 23, 42, 0.4)), url('../images/bg.jpg') no-repeat center center fixed;
    background-size: cover;
    padding: 20px;
}

.guest-card {
    background: var(--white);
    border-radius: var(--radius-xl);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 440px;
    padding: 40px;
    position: relative;
    overflow: hidden;
}

.guest-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), #7c3aed);
}

.guest-logo {
    text-align: center;
    margin-bottom: 32px;
}

.guest-logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 4px;
}

.guest-logo p {
    font-size: 0.875rem;
    color: var(--gray-500);
}

/* --- App Layout (Authenticated) --- */
.app-wrapper {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--white);
    border-right: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    transition: var(--transition);
}

.sidebar-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-100);
}

.sidebar-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--gray-900);
}

.sidebar-header span {
    font-size: 0.75rem;
    color: var(--gray-400);
    font-weight: 400;
}

.sidebar-nav {
    flex: 1;
    padding: 12px;
    overflow-y: auto;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius);
    color: var(--gray-600);
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
    margin-bottom: 2px;
}

.sidebar-nav a:hover {
    background: var(--gray-50);
    color: var(--gray-900);
}

.sidebar-nav a.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}

.sidebar-nav a .nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    opacity: 0.7;
}

.sidebar-nav a.active .nav-icon { opacity: 1; }

.sidebar-section {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 16px 14px 6px;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--gray-100);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
}

.sidebar-user-info { flex: 1; }
.sidebar-user-name { font-size: 0.85rem; font-weight: 600; color: var(--gray-800); }
.sidebar-user-coin { font-size: 0.75rem; color: var(--gray-500); }

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 0;
    min-height: calc(100vh - 70px);
}

.main-header {
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    padding: 16px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}

.main-header h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--gray-900);
}

.main-body {
    padding: 32px;
}

/* --- Card Component --- */
.card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
    overflow: hidden;
    transition: var(--transition);
}

.card:hover { box-shadow: var(--shadow-sm); }

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-800);
}

.card-body { padding: 24px; }

/* --- Form Elements --- */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-family: var(--font-family);
    color: var(--gray-800);
    background: var(--white);
    transition: var(--transition);
    outline: none;
}

.form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-input::placeholder { color: var(--gray-400); }

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.form-hint {
    font-size: 0.8rem;
    color: var(--gray-500);
    margin-top: 4px;
}

.form-error {
    font-size: 0.8rem;
    color: var(--danger);
    margin-top: 4px;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 600;
    font-family: var(--font-family);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    line-height: 1.4;
}

.btn:active { transform: scale(0.98); }

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

.btn-success { background: var(--success); color: var(--white); }
.btn-success:hover { background: #15803d; color: var(--white); }

.btn-danger { background: var(--danger); color: var(--white); }
.btn-danger:hover { background: #b91c1c; color: var(--white); }

.btn-outline {
    background: transparent;
    color: var(--gray-600);
    border: 1.5px solid var(--gray-300);
}
.btn-outline:hover { border-color: var(--gray-400); color: var(--gray-800); background: var(--gray-50); }

.btn-block { width: 100%; }
.btn-sm { padding: 6px 14px; font-size: 0.8rem; }
.btn-lg { padding: 12px 24px; font-size: 1rem; }

/* --- Alerts --- */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success { background: var(--success-light); color: var(--success); border: 1px solid #bbf7d0; }
.alert-danger { background: var(--danger-light); color: var(--danger); border: 1px solid #fecaca; }
.alert-warning { background: var(--warning-light); color: var(--warning); border: 1px solid #fed7aa; }
.alert-info { background: var(--info-light); color: var(--info); border: 1px solid #a5f3fc; }

/* --- Stat Cards --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    transition: var(--transition);
}

.stat-card:hover { box-shadow: var(--shadow-sm); }
.stat-label { font-size: 0.8rem; color: var(--gray-500); font-weight: 500; margin-bottom: 4px; }
.stat-value { font-size: 1.75rem; font-weight: 700; color: var(--gray-900); }
.stat-change { font-size: 0.75rem; color: var(--success); margin-top: 4px; }

/* --- Table --- */
.table-wrapper { overflow-x: auto; }

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.table th {
    text-align: left;
    padding: 12px 16px;
    font-weight: 600;
    color: var(--gray-600);
    background: var(--gray-50);
    border-bottom: 2px solid var(--gray-200);
    white-space: nowrap;
}

.table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-700);
}

.table tbody tr:hover { background: var(--gray-50); }

/* --- Badge --- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success { background: #dcfce7; color: #166534; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }

/* --- Links --- */
.text-link {
    color: var(--primary);
    font-size: 0.85rem;
    font-weight: 500;
}

.text-link:hover { text-decoration: underline; }

.text-center { text-align: center; }
.text-muted { color: var(--gray-500); font-size: 0.85rem; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }

/* --- Layout classes --- */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.mobile-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--gray-800);
    cursor: pointer;
    padding: 4px;
}

.sidebar-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 90;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.open { opacity: 1; visibility: visible; }
    .main-content { margin-left: 0; }
    .main-body { padding: 16px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .guest-card { padding: 28px 24px; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .mobile-toggle { display: block; }
}

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

/* --- Premium Iconized Floating Input Box --- */
.input-box-wrapper {
    display: flex;
    align-items: center;
    background: rgba(15, 23, 42, 0.45);
    border: 1.5px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-lg);
    padding: 8px 16px;
    gap: 12px;
    margin-bottom: 20px;
    transition: var(--transition);
}

.input-box-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(225, 29, 72, 0.2);
    background: rgba(15, 23, 42, 0.6);
}

.input-box-wrapper.has-error {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

.input-box-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-400);
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.input-box-icon svg {
    width: 100%;
    height: 100%;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

.input-box-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.input-box-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 2px;
    pointer-events: none;
    text-align: left;
}

.input-box {
    border: none !important;
    outline: none !important;
    background: transparent !important;
    padding: 0 !important;
    color: var(--gray-800) !important;
    font-size: 0.95rem !important;
    width: 100% !important;
    box-shadow: none !important;
}

.input-box::placeholder {
    color: var(--gray-500);
}

.password-toggle {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: var(--gray-400);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.password-toggle:hover {
    color: var(--gray-800);
}

.password-toggle svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

.input-box-error {
    font-size: 0.8rem;
    color: #ef4444;
    margin-top: -14px;
    margin-bottom: 16px;
    text-align: left;
    display: block;
    padding-left: 4px;
}

/* --- Top Navigation --- */
.top-nav {
    background: var(--white);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--gray-200);
    position: sticky;
    top: 0;
    z-index: 100;
}

.top-nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 70px;
}

.top-nav-logo {
    font-size: 1.2rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
}

.top-nav-logo span {
    background: linear-gradient(90deg, var(--primary), #7c3aed);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.top-nav-wrapper {
    display: flex;
    align-items: center;
    gap: 32px;
    flex: 1;
    justify-content: space-between;
    margin-left: 40px;
}

.top-nav-links {
    display: flex;
    align-items: center;
    gap: 6px;
}

.top-nav-links a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: var(--radius);
    color: var(--gray-600);
    font-size: 0.85rem;
    font-weight: 500;
    transition: var(--transition);
}

.top-nav-links a:hover {
    background: var(--gray-50);
    color: var(--gray-900);
}

.top-nav-links a.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}

.top-nav-links a .nav-icon {
    width: 18px;
    height: 18px;
    opacity: 0.7;
    stroke-width: 2;
}

.top-nav-links a.active .nav-icon {
    opacity: 1;
}

.top-nav-user {
    display: flex;
    align-items: center;
    gap: 16px;
}

.top-nav-user-info {
    text-align: right;
    line-height: 1.3;
}

.top-nav-username {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gray-800);
}

.top-nav-coin {
    font-size: 0.75rem;
    color: var(--primary-hover);
    font-weight: 600;
}

.top-nav-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--gray-800);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius);
    transition: var(--transition);
}

.top-nav-toggle:hover {
    background: var(--gray-50);
}

.top-nav-toggle svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
    stroke-width: 2;
}

/* Card Header Title with SVG */
.card-header-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-header-title .header-icon {
    width: 20px;
    height: 20px;
    color: var(--primary);
    stroke-width: 2;
    flex-shrink: 0;
}

/* Adjust layout on medium screens */
@media (max-width: 1024px) {
    .top-nav-container {
        position: relative;
    }
    .top-nav-toggle {
        display: block;
    }
    .top-nav-wrapper {
        position: absolute;
        top: 70px;
        left: 0;
        right: 0;
        background: rgba(15, 23, 42, 0.95);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border-bottom: 1px solid var(--gray-200);
        flex-direction: column;
        align-items: stretch;
        padding: 20px;
        gap: 16px;
        margin-left: 0;
        display: none;
        box-shadow: var(--shadow-lg);
    }
    .top-nav-wrapper.open {
        display: flex;
    }
    .top-nav-links {
        flex-direction: column;
        align-items: stretch;
        gap: 4px;
    }
    .top-nav-user {
        border-top: 1px solid var(--gray-100);
        padding-top: 16px;
        justify-content: space-between;
    }
    .top-nav-user-info {
        text-align: left;
    }
}

/* --- Dropdown Menu --- */
.top-nav-dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.dropdown-arrow {
    width: 12px;
    height: 12px;
    transition: transform 0.2s ease;
    opacity: 0.7;
    stroke-width: 2.5;
}

.top-nav-dropdown:hover .dropdown-arrow {
    transform: rotate(180deg);
}

.dropdown-menu-items {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 200px;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    z-index: 200;
    margin-top: 4px;
}

.top-nav-dropdown:hover .dropdown-menu-items {
    display: block;
}

.dropdown-menu-items a {
    display: block !important;
    padding: 8px 12px !important;
    color: var(--gray-600) !important;
    font-size: 0.85rem !important;
    border-radius: var(--radius-sm) !important;
    transition: var(--transition) !important;
    text-align: left !important;
    background: transparent !important;
}

.dropdown-menu-items a:hover {
    background: var(--primary-light) !important;
    color: var(--primary) !important;
}

/* --- Profile Tabs --- */
.profile-tabs-wrapper {
    display: flex;
    justify-content: center;
    margin-bottom: 24px;
    width: 100%;
}

.profile-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    background: rgba(15, 23, 42, 0.45);
    border: 1px solid var(--gray-200);
    padding: 6px;
    border-radius: var(--radius-lg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    justify-content: center;
}

.tab-btn {
    background: transparent;
    border: none;
    padding: 8px 18px;
    border-radius: var(--radius);
    color: var(--gray-600);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font-family);
}

.tab-btn:hover {
    color: var(--gray-900);
    background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
    background: var(--primary);
    color: #ffffff;
}

.profile-tab-content {
    display: none;
    width: 100%;
}

.profile-tab-content.active {
    display: block;
}

/* Adjust layout on medium screens for dropdown */
@media (max-width: 1024px) {
    .top-nav-dropdown {
        display: block;
    }
    .dropdown-menu-items {
        position: static;
        display: block; /* show by default on mobile */
        border: none;
        background: transparent;
        backdrop-filter: none;
        box-shadow: none;
        padding-left: 20px;
        margin-top: 0;
    }
    .dropdown-menu-items a {
        padding: 6px 12px !important;
        font-size: 0.8rem !important;
    }
    .dropdown-arrow {
        display: none;
    }
}


