:root {
  --bg-dark: #0b0f19;
  --bg-card: rgba(18, 24, 38, 0.75);
  --bg-card-hover: rgba(26, 35, 56, 0.85);
  --bg-card-solid: #121826;
  --bg-input: rgba(10, 14, 23, 0.6);

  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-glow: rgba(99, 102, 241, 0.4);

  --accent: #8b5cf6;
  --accent-cyan: #06b6d4;
  --accent-emerald: #10b981;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-sub: #64748b;

  --border-color: rgba(255, 255, 255, 0.08);
  --border-highlight: rgba(99, 102, 241, 0.3);

  --status-active: #10b981;
  --status-pending: #f59e0b;
  --status-expired: #ef4444;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-heading: 'Outfit', sans-serif;

  --glass-blur: blur(16px);
  --glass-border: 1px solid rgba(255, 255, 255, 0.08);
  --box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
  --glow-shadow: 0 0 20px rgba(99, 102, 241, 0.25);
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;

  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
  position: relative;
}

.bg-glow-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  z-index: 0;
  pointer-events: none;
}

.glow-ball {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.25;
  animation: pulseGlow 12s infinite alternate ease-in-out;
}

.glow-1 {
  width: 500px;
  height: 500px;
  background: var(--primary);
  top: -100px;
  left: -100px;
}

.glow-2 {
  width: 600px;
  height: 600px;
  background: var(--accent);
  bottom: -150px;
  right: -100px;
  animation-delay: -4s;
}

.glow-3 {
  width: 400px;
  height: 400px;
  background: var(--accent-cyan);
  top: 40%;
  left: 40%;
  animation-delay: -8s;
}

@keyframes pulseGlow {
  0% { transform: scale(1) translate(0, 0); }
  100% { transform: scale(1.2) translate(30px, 40px); }
}

.app-layout {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.navbar {
  background: rgba(11, 15, 25, 0.8);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: var(--glass-border);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 0.85rem 1.5rem;
}

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

.brand-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--text-main);
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.logo-icon {
  color: var(--primary);
  font-size: 1.4rem;
  filter: drop-shadow(0 0 8px var(--primary-glow));
}

.logo-highlight {
  background: linear-gradient(135deg, var(--primary), var(--accent-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 1.2rem;
}

.mode-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}

.demo-mode {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.demo-mode:hover {
  background: rgba(245, 158, 11, 0.25);
  transform: translateY(-1px);
}

.firebase-mode {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.user-profile-section {
  display: flex;
  align-items: center;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: rgba(255, 255, 255, 0.05);
  padding: 0.35rem 0.85rem 0.35rem 0.4rem;
  border-radius: var(--radius-full);
  border: var(--glass-border);
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--primary);
}

.user-info {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.user-name {
  font-size: 0.85rem;
  font-weight: 600;
}

.main-content {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 2rem auto;
  padding: 0 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.banner {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.2rem 1.5rem;
  border-radius: var(--radius-md);
  border: 1px solid;
  backdrop-filter: var(--glass-blur);
}

.banner-warning {
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.3);
  color: #fde68a;
}

.banner-icon {
  font-size: 1.5rem;
  color: #fbbf24;
  margin-top: 0.1rem;
}

.banner-content h3 {
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

.banner-content p {
  font-size: 0.9rem;
  color: #fef3c7;
}

.card {
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--box-shadow);
  transition: var(--transition-normal);
}

.card:hover {
  border-color: var(--border-highlight);
}

.inner-card {
  background: rgba(18, 24, 38, 0.4);
}

.card-header {
  margin-bottom: 1.75rem;
}

.card-header h2, .card-header h3 {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.text-gradient {
  background: linear-gradient(135deg, var(--primary), var(--accent-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.creator-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.form-group label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-main);
}

.required {
  color: #f43f5e;
}

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

.input-icon {
  position: absolute;
  left: 1rem;
  color: var(--text-sub);
  pointer-events: none;
}

.url-prefix {
  position: absolute;
  left: 1rem;
  color: var(--accent-cyan);
  font-weight: 600;
  font-size: 0.9rem;
  pointer-events: none;
}

input[type="url"],
input[type="text"],
input[type="datetime-local"],
select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.8rem 1rem;
  color: var(--text-main);
  font-size: 0.95rem;
  font-family: var(--font-sans);
  transition: var(--transition-fast);
}

.input-wrapper input {
  padding-left: 2.75rem;
}

.url-prefix + input {
  padding-left: 5.5rem;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  background: rgba(15, 21, 35, 0.9);
}

.input-readonly {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  cursor: not-allowed;
}

.input-hint {
  font-size: 0.78rem;
  color: var(--text-sub);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.5rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.7rem 1.4rem;
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: var(--transition-fast);
  text-decoration: none;
}

.btn-lg {
  padding: 0.9rem 2rem;
  font-size: 1rem;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: #fff;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--glow-shadow);
}

.btn-accent {
  background: linear-gradient(135deg, var(--accent), var(--primary));
  color: #fff;
}

.btn-accent:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 20px rgba(139, 92, 246, 0.4);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border: var(--glass-border);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
}

.btn-glow {
  position: relative;
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  padding: 0.4rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-icon:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.1);
}

.tabs-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.tabs-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.5rem;
  overflow-x: auto;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: var(--transition-fast);
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.04);
}

.tab-btn.active {
  color: var(--text-main);
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid var(--border-highlight);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeIn 0.3s ease-out;
}

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

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

.search-box {
  position: relative;
  flex: 1;
  min-width: 260px;
}

.search-box i {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-sub);
}

.search-box input {
  padding-left: 2.6rem;
}

.filter-group select {
  min-width: 150px;
}

.links-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1.25rem;
}

.link-card {
  background: var(--bg-card);
  border: var(--glass-border);
  border-radius: var(--radius-md);
  padding: 1.35rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1rem;
  transition: var(--transition-normal);
}

.link-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-highlight);
  transform: translateY(-3px);
  box-shadow: var(--box-shadow);
}

.link-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.link-title-group {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  overflow: hidden;
}

.link-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.short-url-text {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent-cyan);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.short-url-text:hover {
  text-decoration: underline;
}

.link-target {
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.link-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--text-sub);
  border-top: 1px solid var(--border-color);
  padding-top: 0.75rem;
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.link-card-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-success { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.badge-danger { background: rgba(239, 68, 68, 0.15); color: #f87171; }
.badge-beta { background: rgba(139, 92, 246, 0.2); color: #c084fc; font-size: 0.7rem; }

.role-tag {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
}

.tag-admin { background: #8b5cf6; color: #fff; }
.tag-user { background: #10b981; color: #fff; }
.tag-pending { background: #f59e0b; color: #000; }

/* 權限控制按鈕 經典 btn-secondary 壓入與禁用樣式 */
.btn-secondary:disabled,
.btn-secondary.active-pressed {
  opacity: 0.55 !important;
  background: rgba(255, 255, 255, 0.08) !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.7) !important;
  cursor: not-allowed !important;
  transform: translateY(1px) !important;
  filter: grayscale(30%);
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

.data-table th, .data-table td {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
}

.data-table th {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  font-weight: 600;
}

.data-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.tester-box {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  max-width: 650px;
  margin: 1rem auto;
}

.input-group {
  display: flex;
  align-items: center;
  gap: 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.input-group .url-prefix {
  position: static;
  background: rgba(255, 255, 255, 0.05);
  padding: 0.8rem 1rem;
}

.input-group input {
  border: none;
  border-radius: 0;
}

.input-group button {
  border-radius: 0;
  white-space: nowrap;
}

.result-display {
  padding: 1.5rem;
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-color);
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-card {
  background: var(--bg-card-solid);
  border: var(--glass-border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.8);
  animation: modalPop 0.25s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.modal-sm { max-width: 380px; }

@keyframes modalPop {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.justify-center { justify-content: center; }
.text-center { text-align: center; }

.qrcode-wrapper img {
  width: 220px;
  height: 220px;
  border-radius: var(--radius-md);
  border: 4px solid #fff;
  margin: 1rem auto;
}

.qr-url-text {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--accent-cyan);
}

.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 1.25rem;
  border-radius: var(--radius-md);
  background: var(--bg-card-solid);
  color: var(--text-main);
  border: var(--glass-border);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6);
  animation: slideInRight 0.3s ease-out;
  min-width: 280px;
}

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.toast-success { border-left: 4px solid #10b981; }
.toast-error { border-left: 4px solid #ef4444; }
.toast-info { border-left: 4px solid #6366f1; }

.hidden { display: none !important; }
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}
.empty-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  color: var(--text-sub);
}

.app-footer {
  text-align: center;
  padding: 2rem 1rem;
  border-top: 1px solid var(--border-color);
  color: var(--text-sub);
  font-size: 0.85rem;
  margin-top: 3rem;
}

.footer-sub {
  margin-top: 0.3rem;
  font-size: 0.78rem;
}
