:root {
    /* --- Dark Mode (Default) --- */
    --bg-primary: #0f172a;
    --bg-gradient: radial-gradient(circle at top right, #1e1b4b, #020617);
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.08);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --primary: #3b82f6;
    --accent: #8b5cf6;
    --input-bg: rgba(15, 23, 42, 0.6);
    --shadow-color: rgba(0, 0, 0, 0.3);
    --card-hover: rgba(255, 255, 255, 0.03);
    
    /* Stats Pill Colors */
    --pill-bg: rgba(255, 255, 255, 0.05);
    --pill-hover: rgba(255, 255, 255, 0.1);

    /* Navbar Input Specifics */
    --nav-input-bg: rgba(0, 0, 0, 0.2);
    --nav-input-text: #fff;
}

[data-theme="light"] {
    /* --- Light Mode Variables --- */
    --bg-primary: #f0f9ff;
    --bg-gradient: linear-gradient(135deg, #e0f2fe 0%, #f3e8ff 100%);
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(255, 255, 255, 0.6);
    --text-main: #1e293b;
    --text-muted: #64748b;
    --primary: #2563eb;
    --accent: #7c3aed;
    --input-bg: rgba(255, 255, 255, 0.8);
    --shadow-color: rgba(0, 0, 0, 0.08);
    --card-hover: rgba(255, 255, 255, 0.6);

    /* Stats Pill Colors (Light Mode) */
    --pill-bg: rgba(255, 255, 255, 0.5);
    --pill-hover: rgba(255, 255, 255, 0.8);

    --nav-input-bg: rgba(0, 0, 0, 0.05);
    --nav-input-text: #333;
}

/* --- Global Resets --- */
* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    background: var(--bg-gradient);
    color: var(--text-main);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background 0.5s ease, color 0.3s ease;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Background Animation --- */
.bg-orb {
    position: fixed;
    border-radius: 50%;
    filter: blur(80px);
    z-index: -1;
    opacity: 0.4;
    will-change: transform;
    animation: floatOrb 10s infinite alternate cubic-bezier(0.45, 0.05, 0.55, 0.95);
    pointer-events: none;
}

.orb-1 { width: 300px; height: 300px; background: var(--primary); top: -50px; left: -50px; }
.orb-2 { width: 400px; height: 400px; background: var(--accent); bottom: -100px; right: -100px; animation-delay: -5s; }

@keyframes floatOrb {
    from { transform: translate(0, 0); }
    to { transform: translate(30px, 50px); }
}

/* --- Navbar --- */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 5%;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--glass-border);
    position: sticky;
    top: 0;
    z-index: 100;
    transition: background 0.3s ease;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1.5rem;
    color: var(--text-main);
    letter-spacing: -0.5px;
    text-decoration: none;
    cursor: pointer;
}

.logo-icon { color: var(--primary); font-size: 1.4rem; }

.badge {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 800;
    color: white;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
    vertical-align: middle;
}

/* Navbar Center Input (The "Enter Code" section) */
.nav-center {
    flex: 1;
    display: flex;
    justify-content: center;
    padding: 0 20px;
}

.nav-input-wrapper {
    display: flex;
    align-items: center;
    background: var(--nav-input-bg);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 4px 4px 4px 15px;
    width: 100%;
    max-width: 300px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.nav-input-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

#nav-code-input {
    background: transparent;
    border: none;
    color: var(--nav-input-text);
    padding: 5px;
    width: 100%;
    font-size: 0.9rem;
    outline: none;
}

#nav-code-input::placeholder { color: var(--text-muted); }

#nav-go-btn {
    background: var(--primary);
    color: white;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    transition: transform 0.2s;
}

#nav-go-btn:hover { transform: scale(1.1); }

/* Navbar Actions */
.nav-actions { display: flex; align-items: center; gap: 15px; }

.theme-btn {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.theme-btn:hover {
    background: var(--glass-border);
    transform: rotate(15deg);
    color: var(--primary);
}

/* Authentication */
.btn-google {
    display: flex;
    align-items: center;
    gap: 10px;
    background: white;
    color: #3c4043;
    border: 1px solid #dadce0;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    transition: 0.2s;
    white-space: nowrap;
}

.btn-google:hover {
    background: #f8faff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transform: translateY(-1px);
}

.btn-google img { width: 18px; height: 18px; }

.user-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--glass-border);
    padding: 4px 12px 4px 4px;
    border-radius: 30px;
    border: 1px solid var(--glass-border);
}

#user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary);
}

#user-name {
    font-size: 0.85rem;
    font-weight: 600;
    max-width: 100px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-logout {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 5px;
    transition: 0.2s;
    font-size: 0.9rem;
}

.btn-logout:hover { color: #ef4444; }

/* --- Main Layout --- */
.container {
    max-width: 800px;
    margin: 3rem auto;
    padding: 0 1.5rem;
    flex: 1;
    width: 100%;
}

.glass-effect {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 2.5rem;
    box-shadow: 0 20px 50px var(--shadow-color);
    transition: transform 0.3s ease, background 0.3s ease;
}

.header-center { text-align: center; margin-bottom: 2rem; }

h1 {
    margin: 0;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    font-size: 2.5rem;
    letter-spacing: -1px;
}

p {
    color: var(--text-muted);
    margin-top: 0.75rem;
    line-height: 1.6;
    font-size: 1.05rem;
}

/* --- Inputs & Forms --- */
.input-group-wrapper {
    display: flex;
    gap: 15px;
    margin-bottom: 1.5rem;
}

.input-group { position: relative; flex: 2; }
.alias-group { flex: 1; }

.input-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    font-size: 1.1rem;
    z-index: 10;
}

/* Main Inputs (not nav) */
.input-group input {
    width: 100%;
    padding: 16px 16px 16px 48px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    background: var(--input-bg);
    color: var(--text-main);
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.3s ease;
}

.input-group input:hover {
    border-color: rgba(59, 130, 246, 0.4);
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
    background: var(--glass-bg);
}

/* --- Buttons --- */
.btn-lg {
    width: 100%;
    padding: 16px;
    border-radius: 12px;
    border: none;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    font-weight: 600;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    justify-content: center;
    gap: 10px;
    align-items: center;
    transition: transform 0.2s, box-shadow 0.2s, filter 0.2s;
    letter-spacing: 0.5px;
}

.btn-lg:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(59, 130, 246, 0.4);
    filter: brightness(1.1);
}

.btn-lg:active { transform: translateY(0); }

/* --- Stats Counter --- */
.stats-display {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.stats-pill {
    background: var(--pill-bg);
    border: 1px solid var(--glass-border);
    padding: 8px 24px;
    border-radius: 50px;
    font-size: 0.9rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 10px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    transition: all 0.3s ease;
    cursor: default;
    user-select: none;
}

.stats-pill:hover {
    transform: translateY(-2px);
    background: var(--pill-hover);
    color: var(--text-main);
    border-color: var(--primary);
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.count-value {
    font-weight: 700;
    color: var(--text-main);
    font-variant-numeric: tabular-nums;
}

/* --- Result Box --- */
.result-box {
    margin-top: 2rem;
    background: var(--input-bg);
    padding: 1.5rem;
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    animation: slideDown 0.4s ease;
}

.success-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
    color: #10b981;
    font-weight: 600;
}

.link-display-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--glass-bg);
    padding: 12px 16px;
    border-radius: 10px;
    border: 1px solid var(--glass-border);
    margin-bottom: 1.5rem;
}

.link-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow: hidden;
    flex: 1;
    margin-right: 10px;
}

.link-text .label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.link-text a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 1.1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.link-text a:hover { text-decoration: underline; }

.btn-copy {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 8px;
    border-radius: 8px;
    transition: 0.2s;
    flex-shrink: 0;
}

.btn-copy:hover {
    color: var(--primary);
    background: var(--glass-border);
}

.qr-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

#qr-code img {
    border: 8px solid white;
    border-radius: 12px;
    display: block;
    margin: 0 auto;
}

.qr-section p { margin: 0; font-size: 0.85rem; }

/* --- Dashboard Table --- */
#dashboard { margin-top: 3rem; }

.section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 1rem;
}

.section-header h3 {
    margin: 0;
    font-size: 1.25rem;
    color: var(--text-main);
}

.table-container {
    overflow-x: auto;
    border-radius: 16px;
    padding: 0; /* Override glass-effect padding for table */
    overflow: hidden;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

thead { background: rgba(0, 0, 0, 0.1); }

th, td {
    padding: 18px 24px;
    text-align: left;
    border-bottom: 1px solid var(--glass-border);
    color: var(--text-main);
}

th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

tr:last-child td { border-bottom: none; }

tr:hover { background: var(--card-hover); }

/* Table Actions */
.btn-delete {
    color: #ef4444;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: 0.2s;
    font-size: 1rem;
}

.btn-delete:hover { transform: scale(1.2); }

/* --- Features Section --- */
.content-section { margin-top: 4rem; }
.info-card { padding: 3rem 2rem; }

.info-header { text-align: center; margin-bottom: 3rem; }
.info-header h2 { font-size: 2rem; margin-bottom: 10px; }

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 2.5rem;
}

.feature-item { text-align: center; }

.feature-icon {
    font-size: 1.5rem;
    color: var(--primary);
    background: rgba(59, 130, 246, 0.1);
    width: 64px;
    height: 64px;
    border-radius: 50%;
    margin: 0 auto 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(59, 130, 246, 0.2);
    transition: transform 0.3s ease;
}

.feature-item:hover .feature-icon { transform: rotateY(180deg); }
.feature-item h3 { margin: 0 0 0.5rem; font-size: 1.1rem; }
.feature-item p { font-size: 0.9rem; margin: 0; color: var(--text-muted); }

/* --- How it works --- */
.how-to-section { margin-top: 4rem; text-align: center; }
.how-to-section h3 { font-size: 1.5rem; margin-bottom: 2rem; }

.steps-grid {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    position: relative;
    max-width: 600px;
    margin: 0 auto;
}

.step {
    position: relative;
    z-index: 2;
    flex: 1;
    text-align: center;
}

.step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--bg-primary); /* Matches bg to create "cutout" effect over line */
    border: 2px solid var(--primary);
    color: var(--primary);
    border-radius: 50%;
    font-weight: 700;
    margin-bottom: 10px;
    box-shadow: 0 4px 10px rgba(59, 130, 246, 0.2);
}

.step-line {
    position: absolute;
    top: 18px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--glass-border);
    z-index: 1;
}

/* --- Footer --- */
footer {
    text-align: center;
    padding: 3rem 1rem;
    margin-top: auto;
    border-top: 1px solid var(--glass-border);
    background: rgba(0,0,0,0.1);
    backdrop-filter: blur(5px);
}

footer p { font-size: 0.9rem; color: var(--text-muted); }

footer a {
    color: var(--primary);
    text-decoration: none;
    transition: 0.2s;
    font-weight: 500;
}

footer a:hover { color: var(--accent); }

.footer-links { margin-top: 15px; font-size: 0.9rem; }
.footer-links a { margin: 0 12px; color: var(--text-muted); }
.footer-links a:hover { color: var(--primary); }

/* --- Utilities & Animations --- */
.hidden { display: none !important; }

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.fade-in-up {
    animation: fadeInUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    opacity: 0;
}

/* --- Media Queries --- */
@media (max-width: 768px) {
    .hide-mobile { display: none !important; }
    
    .container { margin: 1.5rem auto; padding: 0 1rem; }
    .glass-effect { padding: 1.5rem; }
    
    .navbar { padding: 0.8rem 1rem; }
    .logo-text { display: none; } /* Hide text logo on small screens, keep icon */
    .logo-icon { font-size: 1.6rem; }

    /* Inputs stack on mobile */
    .input-group-wrapper { flex-direction: column; gap: 10px; }
    
    /* Stats stack */
    .stats-display { flex-direction: row; justify-content: space-around; }
    .stats-pill { padding: 6px 15px; font-size: 0.8rem; }
    
    /* Result box adjustments */
    .link-display-container {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    
    .link-text { margin-right: 0; text-align: center; }
    .btn-copy { width: 100%; border: 1px solid var(--glass-border); }

    /* Vertical Steps on Mobile */
    .steps-grid { flex-direction: column; align-items: center; gap: 20px; }
    .step-line {
        width: 2px;
        height: 100%;
        left: 50%;
        top: 0;
        transform: translateX(-50%);
    }
    .step-num { background: var(--bg-primary); z-index: 2; position: relative; }
}

@media (max-width: 480px) {
    h1 { font-size: 2rem; }
    .btn-google span { display: none; } /* Show only G icon on very small screens */
    .btn-google { padding: 8px; border-radius: 50%; }
    
    .user-wrapper { padding: 2px; border: none; background: transparent; }
    #user-name { display: none; }
}

.action-btns {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.btn-table-copy, .btn-table-delete {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    transition: transform 0.2s, color 0.2s;
}

.btn-table-copy { color: #60a5fa; }
.btn-table-copy:hover { transform: scale(1.2); color: #3b82f6; }

.btn-table-delete { color: #f87171; }
.btn-table-delete:hover { transform: scale(1.2); color: #ef4444; }

.url-truncate {
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Redirect Loader Styling --- */
#redirect-loader {
  backdrop-filter: blur(12px); /* Blurred background effect */
  background-color: rgba(2, 6, 23, 0.95); /* Deep dark semi-transparent */
  transition: opacity 0.4s ease;
}

/* Glowing Orbs in the background */
.loader-orb {
  position: absolute;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  filter: blur(100px);
  z-index: -1;
  opacity: 0.2;
  animation: pulse-orb 6s infinite alternate;
}

@keyframes pulse-orb {
  from { transform: scale(1); opacity: 0.1; }
  to { transform: scale(1.3); opacity: 0.3; }
}

/* The Spinning Ring */
.spinner-ring {
  width: 80px;
  height: 80px;
  border: 4px solid rgba(59, 130, 246, 0.1); /* Light blue faint ring */
  border-top: 4px solid #3b82f6; /* Bright blue spinning part */
  border-right: 4px solid #8b5cf6; /* Purple gradient touch */
  border-radius: 50%;
  animation: spin 1s cubic-bezier(0.5, 0, 0.5, 1) infinite;
  box-shadow: 0 0 15px rgba(59, 130, 246, 0.4);
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Status Text Gradient */
#loader-status {
  background: linear-gradient(90deg, #94a3b8, #f8fafc, #94a3b8);
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: shine-text 3s linear infinite;
  font-family: 'Inter', sans-serif;
  letter-spacing: 0.5px;
}

@keyframes shine-text {
  to { background-position: 200% center; }
}

/* Center Container */
.loader-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}