/* ========================================
   VietDE Admin Panel — Stylesheet
   ======================================== */

:root {
  --bg-primary: #0a0a0c;
  --bg-secondary: #121216;
  --bg-tertiary: #1b1b22;
  --bg-card: rgba(18, 18, 22, 0.7);
  --bg-elevated: #1e1e24;
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-tertiary: #64748b;
  
  --accent: #10b981;
  --accent-hover: #059669;
  --accent-dim: rgba(16, 185, 129, 0.1);
  --accent-glow: rgba(16, 185, 129, 0.25);
  
  --danger: #f43f5e;
  --danger-hover: #e11d48;
  --danger-dim: rgba(244, 63, 94, 0.1);
  
  --border: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(16, 185, 129, 0.4);
  
  --font-family: 'Satoshi', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-cinematic: cubic-bezier(0.22, 1, 0.36, 1);
  
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 15px rgba(16, 185, 129, 0.15);
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

body.no-scroll {
  overflow: hidden;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent-dim);
}

/* Typography */
h1 {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* ========================================
   COMPONENTS & UTILITIES
   ======================================== */
.brand-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
  margin-right: 8px;
  box-shadow: var(--shadow-glow);
  animation: pulse 2s infinite ease-in-out;
}

@keyframes pulse {
  0%, 100% { opacity: 0.5; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.1); }
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-family);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s var(--ease-smooth);
  border: 1px solid transparent;
}

.btn-primary {
  background: var(--accent);
  color: #052e16;
  font-weight: 600;
}
.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.4);
  transform: translateY(-1px);
}
.btn-primary:active {
  transform: translateY(0);
}

.btn-outline {
  background: transparent;
  color: var(--text-primary);
  border-color: var(--border);
}
.btn-outline:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--text-secondary);
}

.btn-danger-outline {
  background: transparent;
  color: var(--danger);
  border-color: rgba(244, 63, 94, 0.2);
}
.btn-danger-outline:hover {
  background: var(--danger-dim);
  border-color: var(--danger);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.btn-block {
  display: flex;
  width: 100%;
}

/* Input Fields & Forms */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

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

.input-wrapper i {
  position: absolute;
  left: 14px;
  color: var(--text-tertiary);
  font-size: 1.1rem;
  pointer-events: none;
  transition: color 0.2s ease;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
textarea {
  width: 100%;
  padding: 12px 14px 12px 42px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 0.95rem;
  transition: all 0.2s var(--ease-smooth);
}

/* Textareas don't need padding-left for icon */
textarea {
  padding-left: 14px;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.05);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

input:focus + i,
.input-wrapper:focus-within i {
  color: var(--accent);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* Card */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-lg);
}

.card-header {
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}

.card-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
}

/* ========================================
   LOADER & TOAST
   ======================================== */
.loader {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.5s var(--ease-cinematic), visibility 0.5s;
}

.loader.fade-out {
  opacity: 0;
  visibility: hidden;
}

.loader-inner {
  text-align: center;
  width: 200px;
}

.loader-brand {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loader-bar {
  height: 2px;
  background: var(--bg-tertiary);
  border-radius: 2px;
  overflow: hidden;
}

.loader-bar-fill {
  height: 100%;
  width: 30%;
  background: var(--accent);
  border-radius: 2px;
  animation: loading-pulse 1.5s infinite ease-in-out;
}

@keyframes loading-pulse {
  0% { transform: translateX(-100%); }
  50% { width: 60%; }
  100% { transform: translateX(250%); }
}

/* Toast System */
.toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 10000;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: #1e1e24;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  color: var(--text-primary);
  font-size: 0.9rem;
  transform: translateX(120%);
  transition: transform 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast.show {
  transform: translateX(0);
}

.toast-success {
  border-left: 4px solid var(--accent);
}
.toast-success i {
  color: var(--accent);
}

.toast-error {
  border-left: 4px solid var(--danger);
}
.toast-error i {
  color: var(--danger);
}

/* ========================================
   AUTH SECTION
   ======================================== */
.auth-section {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(circle at 10% 20%, rgba(16, 185, 129, 0.05) 0%, transparent 40%),
              radial-gradient(circle at 90% 80%, rgba(13, 148, 136, 0.03) 0%, transparent 50%),
              var(--bg-primary);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(20px);
}

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

.auth-header .brand-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-tertiary);
  margin-bottom: 12px;
}

.auth-header h1 {
  margin-bottom: 6px;
}

/* ========================================
   ADMIN DASHBOARD WRAPPER
   ======================================== */
.dashboard-wrapper {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
}

/* Sidebar */
.sidebar {
  width: 280px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px;
  flex-shrink: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  font-weight: 700;
  font-size: 1.25rem;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.brand-logo {
  display: flex;
  align-items: center;
}

.mobile-menu-btn {
  display: none;
}

.sidebar-mobile-wrapper {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.user-profile-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.user-avatar-mini {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
}

.user-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.user-name {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.user-role {
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-grow: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 16px;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--text-secondary);
  font-family: var(--font-family);
  font-size: 0.95rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent);
}

/* Main Content Section */
.main-content {
  flex-grow: 1;
  padding: 40px;
  background: var(--bg-primary);
  overflow-y: auto;
}

.tab-content {
  display: none;
  animation: fadeIn 0.4s var(--ease-cinematic);
}

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

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

.content-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 30px;
}

/* Members Table */
.card-table {
  padding: 0;
  overflow: hidden;
}

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

table, .members-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

table th, .members-table th {
  padding: 16px 24px;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  border-bottom: 1px solid var(--border);
}

table td, .members-table td {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

table tbody tr:hover, .members-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.01);
}

.table-empty {
  text-align: center;
  color: var(--text-tertiary);
  padding: 40px !important;
}


/* Member avatar in row */
.member-cell {
  display: flex;
  align-items: center;
  gap: 16px;
}

.member-avatar-row {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  border: 1px solid var(--border);
}

.member-avatar-row img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.member-name-text {
  font-weight: 600;
  font-size: 0.95rem;
}

.role-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.8rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  max-width: 250px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.role-badge-pair {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.role-lang {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
}

.lang-indicator {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 1px 4px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 3px;
  color: var(--text-tertiary);
}

/* Actions list */
.actions-cell {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

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

.btn-icon.btn-edit-member:hover {
  color: var(--accent);
  border-color: var(--accent-focus);
}

.btn-icon.btn-delete-member:hover {
  color: var(--danger);
  border-color: rgba(244, 63, 94, 0.3);
}

.sort-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.btn-sort {
  width: 26px;
  height: 22px;
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease;
}

.btn-sort:hover {
  color: var(--accent);
}

/* Profile forms layout */
.profile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

/* Social links icons */
.social-links-list {
  display: flex;
  gap: 8px;
}

.social-icon-badge {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.social-icon-badge.has-link {
  color: var(--accent);
  border-color: var(--accent-glow);
}

/* ========================================
   MODAL DIALOG
   ======================================== */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s var(--ease-cinematic);
}

.modal.open {
  opacity: 1;
  visibility: visible;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 12, 0.85);
  backdrop-filter: blur(8px);
}

.modal-container {
  position: relative;
  width: 100%;
  max-width: 800px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  transform: scale(0.95) translateY(10px);
  transition: transform 0.3s var(--ease-cinematic);
  overflow: hidden;
}

.modal.open .modal-container {
  transform: scale(1) translateY(0);
}

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

.modal-header h2 {
  font-size: 1.3rem;
  font-weight: 700;
}

.btn-close {
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  font-size: 1.4rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease;
}

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

.modal-body {
  padding: 24px;
  overflow-y: auto;
}

.modal-grid {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 32px;
}

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

/* Avatar Upload styling */
.avatar-upload-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.avatar-preview-container {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  border: 2px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.01);
  transition: border-color 0.2s ease;
}

.avatar-preview-container:hover {
  border-color: var(--accent);
}

.avatar-preview {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--text-tertiary);
  background: var(--bg-tertiary);
}

.avatar-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.upload-tip {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  text-align: center;
}

.subsection-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 1.5rem 0 1rem 0;
  color: var(--text-primary);
  border-left: 3px solid var(--accent);
  padding-left: 8px;
}

/* Responsive adjustments */
@media (max-width: 1024px) {
  .profile-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .auth-card {
    padding: 24px 20px;
  }

  .dashboard-wrapper {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    z-index: 201;
  }

  .sidebar-brand {
    padding-bottom: 0;
    border-bottom: none;
    margin-bottom: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
  }

  .mobile-menu-btn {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    padding: 6px;
    width: 38px;
    height: 38px;
    background: transparent;
    border: none;
    cursor: pointer;
    z-index: 200;
  }

  .mobile-menu-btn span {
    display: block;
    width: 100%;
    height: 2px;
    background: var(--text-primary);
    transition: all 0.4s var(--ease-cinematic);
    transform-origin: center;
  }

  .sidebar.menu-open .mobile-menu-btn span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
  }
  .sidebar.menu-open .mobile-menu-btn span:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
  }
  .sidebar.menu-open .mobile-menu-btn span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
  }

  .sidebar-mobile-wrapper {
    position: fixed;
    top: 61px;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-primary);
    z-index: 199;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.4s var(--ease-cinematic);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 24px 20px 40px;
    gap: 16px;
  }

  .sidebar.menu-open .sidebar-mobile-wrapper {
    transform: translateX(0);
  }

  .user-profile-summary {
    display: flex;
    padding: 0 0 20px 0;
    margin: 0;
  }

  .sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
  }

  .nav-item {
    width: 100%;
    padding: 12px 16px;
    font-size: 1.1rem;
    flex-shrink: 0;
  }

  .sidebar-footer {
    display: flex;
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid var(--border);
  }

  .sidebar-footer .btn {
    padding: 12px;
    font-size: 1rem;
    width: 100%;
  }

  .main-content {
    padding: 16px;
  }

  .content-header {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
  }

  .modal-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .modal-container {
    width: 95vw;
    max-height: 90vh;
    padding: 20px 16px;
    overflow-y: auto;
  }

  /* Prevent iOS Safari auto-zoom on inputs */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="url"],
  textarea,
  select {
    font-size: 16px;
  }

  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .table-responsive table {
    white-space: nowrap;
  }
}
