/* ==========================================================================
   DESIGN SYSTEM & VARIABLES
   ========================================================================== */
:root {
  --bg-primary: #0b0f19;
  --bg-secondary: #111827;
  --glass-bg: rgba(17, 24, 39, 0.6);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-shadow: rgba(0, 0, 0, 0.4);
  
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  
  /* Neon Accents */
  --accent-cyan: #00f2fe;
  --accent-blue: #4facfe;
  --accent-primary: linear-gradient(135deg, #00f2fe 0%, #4facfe 100%);
  --accent-primary-hover: linear-gradient(135deg, #00d2de 0%, #3f9cfe 100%);
  
  --color-success: #10b981;
  --color-success-glow: rgba(16, 185, 129, 0.3);
  --color-danger: #ef4444;
  --color-danger-glow: rgba(239, 68, 68, 0.3);
  --color-info: #0284c7;
  
  --font-body: 'Inter', sans-serif;
  --font-heading: 'Montserrat', sans-serif;
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   RESET & BASE STYLES
   ========================================================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

/* Background Ambient Glows */
.bg-glow {
  position: fixed;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.15;
  z-index: -1;
  pointer-events: none;
}

.bg-glow-1 {
  background: var(--accent-cyan);
  top: -100px;
  right: -100px;
}

.bg-glow-2 {
  background: var(--accent-blue);
  bottom: -150px;
  left: -150px;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ==========================================================================
   REUSABLE UTILITIES & GLASSMORPHISM
   ========================================================================== */
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  box-shadow: 0 8px 32px 0 var(--glass-shadow);
}

.card {
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
  transition: var(--transition);
}

.card:hover {
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.5);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 14px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: var(--transition);
  outline: none;
}

.btn-primary {
  background: var(--accent-primary);
  color: #fff;
  box-shadow: 0 4px 15px rgba(0, 242, 254, 0.25);
}

.btn-primary:hover {
  background: var(--accent-primary-hover);
  box-shadow: 0 6px 20px rgba(0, 242, 254, 0.4);
  transform: translateY(-1px);
}

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

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

.btn-danger {
  background: var(--color-danger);
  color: #fff;
  box-shadow: 0 4px 12px var(--color-danger-glow);
}

.btn-danger:hover {
  background: #dc2626;
  box-shadow: 0 6px 16px rgba(239, 68, 68, 0.5);
  transform: translateY(-1px);
}

.btn-success {
  background: var(--color-success);
  color: #fff;
  box-shadow: 0 4px 12px var(--color-success-glow);
}

.btn-success:hover {
  background: #059669;
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.5);
  transform: translateY(-1px);
}

.btn-info {
  background: var(--color-info);
  color: #fff;
}

.btn-info:hover {
  background: #0369a1;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

.btn-block {
  width: 100%;
  padding: 12px;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
}

.badge-pinyin {
  background: rgba(0, 242, 254, 0.15);
  color: var(--accent-cyan);
  border: 1px solid rgba(0, 242, 254, 0.3);
}

.badge-hanviet {
  background: rgba(79, 172, 254, 0.15);
  color: #a5f3fc;
  border: 1px solid rgba(79, 172, 254, 0.3);
}

.db-badge {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 20px;
  font-weight: 500;
}

/* Form Styling */
.form-group {
  margin-bottom: 18px;
}

label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 500;
}

input[type="text"],
input[type="password"],
input[type="url"],
select {
  width: 100%;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  transition: var(--transition);
  outline: none;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="url"]:focus,
select:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 10px rgba(0, 242, 254, 0.25);
  background: rgba(0, 0, 0, 0.45);
}

.form-row {
  display: flex;
  gap: 16px;
}

.col {
  flex: 1;
}

.required {
  color: var(--color-danger);
}

/* Input with icon wrapper */
.input-with-icon {
  position: relative;
}

.input-with-icon i {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.input-with-icon input {
  padding-left: 45px;
}

.icon-btn-inside {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 5px;
}

.icon-btn-inside:hover {
  color: var(--text-primary);
}

.error-msg {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  margin-bottom: 18px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ==========================================================================
   1. LOGIN SCREEN STYLING
   ========================================================================== */
#login-container {
  width: 100%;
  max-width: 420px;
  margin: 120px auto;
  position: relative;
  border-radius: 24px;
  padding: 40px;
}

.login-header {
  text-align: center;
  margin-bottom: 30px;
}

.logo-icon {
  width: 64px;
  height: 64px;
  background: var(--accent-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: #fff;
  margin: 0 auto 16px auto;
  box-shadow: 0 8px 24px rgba(0, 242, 254, 0.3);
}

.login-header h2 {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 24px;
  letter-spacing: -0.5px;
}

.login-header p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-top: 4px;
}

/* ==========================================================================
   2. DASHBOARD MAIN LAYOUT
   ========================================================================== */
#dashboard-container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  border-radius: var(--radius-lg);
  margin-bottom: 20px;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-glow {
  font-size: 22px;
  background: var(--accent-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 2px 8px rgba(0, 242, 254, 0.4));
}

.header-logo h1 {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -0.5px;
}

.header-logo h1 span {
  font-weight: 300;
  font-size: 14px;
  background: rgba(255, 255, 255, 0.15);
  padding: 2px 8px;
  border-radius: 20px;
  margin-left: 4px;
  color: var(--text-secondary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Dashboard Body Layout */
.dashboard-layout {
  display: flex;
  gap: 24px;
  flex: 1;
  overflow: hidden;
}

/* Sidebar Styling */
.sidebar {
  width: 320px;
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  padding: 20px;
}

.sidebar-search {
  position: relative;
  margin-bottom: 20px;
}

.sidebar-search i {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.sidebar-search input {
  padding-left: 40px;
  font-size: 13px;
}

.sidebar-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 12px;
  padding-left: 6px;
}

.set-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
}

.set-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
}

.set-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.set-item.active {
  background: rgba(0, 242, 254, 0.08);
  border-color: rgba(0, 242, 254, 0.2);
}

.set-item-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.set-char-avatar {
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 16px;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: var(--transition);
}

.set-item.active .set-char-avatar {
  background: var(--accent-primary);
  border-color: transparent;
  box-shadow: 0 4px 10px rgba(0, 242, 254, 0.2);
}

.set-info {
  display: flex;
  flex-direction: column;
}

.set-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
}

.set-code {
  font-size: 11px;
  color: var(--text-muted);
}

.audio-count-badge {
  font-size: 11px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 8px;
  border-radius: 12px;
}

.set-item.active .audio-count-badge {
  background: rgba(0, 242, 254, 0.15);
  color: var(--accent-cyan);
}

/* Main Content Area */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

/* Welcome Card */
.welcome-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 40px;
  margin-top: 40px;
}

.welcome-icon {
  font-size: 64px;
  margin-bottom: 24px;
  color: var(--text-muted);
  background: linear-gradient(135deg, rgba(0, 242, 254, 0.4) 0%, rgba(79, 172, 254, 0.4) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.welcome-card h2 {
  font-family: var(--font-heading);
  font-weight: 700;
  margin-bottom: 12px;
}

.welcome-card p {
  color: var(--text-secondary);
  max-width: 500px;
  line-height: 1.6;
}

/* Set Info Card Detail */
.info-card {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.info-header {
  display: flex;
  align-items: center;
  gap: 20px;
}

.character-circle {
  width: 72px;
  height: 72px;
  background: var(--accent-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: #fff;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(0, 242, 254, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.character-text h2 {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 22px;
  margin-bottom: 6px;
}

.romanization-badges {
  display: flex;
  gap: 8px;
}

.info-body {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding-top: 16px;
}

.info-row {
  margin-bottom: 8px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
}

.info-row strong {
  color: var(--text-secondary);
  min-width: 140px;
  display: inline-block;
}

.distractor-row {
  margin-top: 12px;
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
}

.distractor-row code {
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text-secondary);
}

/* ==========================================================================
   3. AUDIO MANAGEMENT & TABS
   ========================================================================== */
.audio-management-section {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.tab-header {
  display: flex;
  border-radius: var(--radius-md);
  padding: 4px;
  margin-bottom: 20px;
  width: max-content;
}

.tab-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 8px;
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.tab-content {
  display: none;
}

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

.action-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.action-bar h3 {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 16px;
  color: var(--text-secondary);
}

/* Tables styling */
.table-container {
  border-radius: var(--radius-md);
  overflow: hidden;
  width: 100%;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

th {
  background: rgba(0, 0, 0, 0.2);
  color: var(--text-secondary);
  font-weight: 600;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

td {
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  vertical-align: middle;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.empty-table-state {
  text-align: center;
  color: var(--text-muted);
  padding: 40px !important;
  font-style: italic;
}

/* Play button custom styling */
.play-btn-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--accent-cyan);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

.play-btn-circle:hover {
  background: var(--accent-primary);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 10px rgba(0, 242, 254, 0.3);
  transform: scale(1.05);
}

.play-btn-circle.playing {
  background: var(--color-success);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 10px rgba(16, 185, 129, 0.3);
}

/* Provider/License Details */
.source-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 250px;
}

.source-details .attribution {
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.source-details .license-link {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}

.source-details .license-link:hover {
  color: var(--accent-cyan);
}

/* Extension Cards (Tab 2) */
.extension-card {
  margin-bottom: 24px;
  border-radius: var(--radius-md);
  padding: 20px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.ext-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding-bottom: 12px;
}

.ext-char-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ext-char-circle {
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.ext-char-desc {
  display: flex;
  flex-direction: column;
}

.ext-char-desc h4 {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 14px;
}

.ext-char-desc p {
  font-size: 11px;
  color: var(--text-secondary);
}

/* ==========================================================================
   4. MODAL POPUP STYLING
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal {
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  border-radius: 20px;
  position: relative;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 14px;
  margin-bottom: 20px;
}

.modal-header h3 {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 18px;
}

.close-modal-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 24px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
}

.close-modal-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 16px;
}

/* Wikimedia Assistant Tool inside Modal */
.wiki-assistant {
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 24px;
  border-color: rgba(0, 242, 254, 0.15);
}

.wiki-assistant h4 {
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-cyan);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.wiki-assistant p {
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  line-height: 1.5;
}

.input-group {
  display: flex;
  gap: 8px;
}

.input-group input {
  flex: 1;
}

.feedback-box {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  line-height: 1.5;
}

.feedback-box.success {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.2);
  color: #a7f3d0;
}

.feedback-box.error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: #fca5a5;
}

/* ==========================================================================
   ANIMATIONS & TRANSITIONS
   ========================================================================== */
.hidden {
  display: none !important;
}

.animate-fade-in {
  animation: fadeIn 0.3s ease-out forwards;
}

.animate-scale-up {
  animation: scaleUp 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

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

@keyframes scaleUp {
  from { opacity: 0; transform: scale(0.95) translateY(15px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

/* Loading spin helper */
.loading-spinner {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 14px;
}

.loading-spinner i {
  font-size: 18px;
  color: var(--accent-cyan);
}
