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

/* Bloqueo preventivo de Tawk.to para evitar parpadeo */
body:not(.chat-active) #tawk-chat-messenger-container,
body:not(.chat-active) .tawk-min-container, 
body:not(.chat-active) .tawk-widget, 
body:not(.chat-active) iframe[title="chat widget"],
body:not(.chat-active) #tawk-chat-widget-container,
body:not(.chat-active) [class*="tawk-"],
body:not(.chat-active) iframe[src*="tawk.to"] { 
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

:root {
  /* Colors - Modern Dark Palette (Default) */
  --page-bg: #171728;
  --box-bg: rgba(255, 255, 255, 0.05);
  --text-color: #ffffff;
  --text-muted: rgba(255, 255, 255, 0.6);
  --link-color: #246BFF;
  --brand-primary: #246BFF;
  --brand-primary-text: #ffffff;
  --brand-secondary: #2c2c3e;
  --brand-accent: #3b82f6;
  --border-color: rgba(255, 255, 255, 0.1);
  --input-border: rgba(255, 255, 255, 0.2);
  --input-bg: #1f1f32;
  --input-color: #ffffff;
  --input-focus-bg: #28283e;
  --card-bg: rgba(255, 255, 255, 0.03);
  
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
  
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.1);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.2);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.3);
  
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  
  --header-logo-height: 36px;
  --login-logo-height: 80px;
}

body.theme-light {
  /* Colors - Modern Light Palette */
  --page-bg: #f8fafc;
  --box-bg: #ffffff;
  --text-color: #1e293b;
  --text-muted: #64748b;
  --link-color: #246BFF;
  --brand-secondary: #f1f5f9;
  --border-color: #e2e8f0;
  --input-border: #cbd5e1;
  --input-bg: #f8fafc;
  --input-color: #1e293b;
  --input-focus-bg: #ffffff;
  --card-bg: #ffffff;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}

/* Force dark text in light theme for login boxes */
body.theme-light .login-box,
body.theme-light .box,
body.theme-light .login-box h1,
body.theme-light .box h1,
body.theme-light .login-box h2,
body.theme-light .box h2,
body.theme-light .login-box label,
body.theme-light .box label,
body.theme-light .login-box p,
body.theme-light .box p,
body.theme-light .login-box span,
body.theme-light .box span,
body.theme-light .login-box .muted,
body.theme-light .box .muted,
body.theme-light .login-box .login-lang-switcher,
body.theme-light .login-box .login-footer,
body.theme-light .login-box .login-footer span {
  color: #1e293b !important;
}

/* Ensure buttons keep their contrast in light mode */
body.theme-light .button,
body.theme-light .button span,
body.theme-light .admin-corner-button,
body.theme-light .admin-corner-button span,
body.theme-light .admin-corner-button svg,
body.theme-light .login-box button:not(.toggle-password),
body.theme-light .login-box button:not(.toggle-password) span {
  color: #ffffff !important;
}

/* Force white text/icons for blue buttons (repo-link, logout-button, btn-primary) in light theme */
body.theme-light .repo-link,
body.theme-light .repo-link *,
body.theme-light .repo-link span,
body.theme-light .repo-link svg,
body.theme-light .logout-button,
body.theme-light .logout-button *,
body.theme-light .logout-button span,
body.theme-light .logout-button .logout-text,
body.theme-light .logout-button svg,
body.theme-light .btn-primary,
body.theme-light .btn-primary *,
body.theme-light .btn-primary span,
body.theme-light .btn-primary svg,
body.theme-light .box .repo-link,
body.theme-light .box .repo-link span,
body.theme-light .box .repo-link svg,
body.theme-light .box .logout-button,
body.theme-light .box .logout-button span,
body.theme-light .box .logout-button .logout-text,
body.theme-light .box .logout-button svg,
body.theme-light .box .btn-primary,
body.theme-light .box .btn-primary span,
body.theme-light .box .btn-primary svg {
  color: #ffffff !important;
  stroke: #ffffff !important;
}

body.theme-light .admin-corner-button {
  background: #1e293b !important;
  border-color: #1e293b !important;
}

body.theme-light .btn-secondary,
body.theme-light .btn-secondary svg {
  color: #1e293b !important;
  stroke: #1e293b !important;
}

body.theme-light .btn-secondary {
  background: #f8fafc !important;
  border: 1px solid #e2e8f0 !important;
}

body.theme-light .btn-secondary:hover {
  background: #f1f5f9 !important;
  border-color: #cbd5e1 !important;
}

body.theme-light .login-box button:not(.toggle-password) {
  background: var(--brand-primary) !important;
}

body.theme-light .toggle-password {
  background: transparent !important;
  border: none !important;
  color: #64748b !important;
  box-shadow: none !important;
}

body.theme-light .login-box .password-toggle {
  color: #64748b !important;
}

body.theme-light .login-box input {
  background-color: #f8fafc !important;
  border-color: #e2e8f0 !important;
  color: #1e293b !important;
}

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--page-bg);
  background-image: radial-gradient(at 0% 0%, rgba(36, 107, 255, 0.02) 0px, transparent 50%),
                    radial-gradient(at 100% 100%, rgba(59, 130, 246, 0.02) 0px, transparent 50%);
  color: var(--text-color);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

/* Typography */
h1, h2, h3, .admin-card strong {
  font-family: 'Outfit', sans-serif;
}

h1 {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 8px 0;
}

h2 {
  font-size: 18px;
  font-weight: 500;
  color: var(--text-muted);
  margin: 0 0 24px 0;
}

/* Layout */
.top-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 40px;
  gap: 20px;
}

.header-left {
  flex: 1;
  display: flex;
  align-items: center;
  min-width: 0;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .top-header {
    padding: 12px 20px;
    gap: 12px;
  }
  .header-right {
    gap: 12px;
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-end !important;
  }
  .top-header .lang-switcher {
    order: 1 !important; /* Las banderas primero (arriba) */
    transform: translateY(21px) !important; /* Bajar las banderas para alinear con la base del texto del logo */
  }
  .top-header .user-actions, .top-header .user-actions-container {
    order: 2 !important; /* Los botones después (abajo) */
    transform: translateY(34px) !important; /* Desplazar los botones hacia abajo de forma contundente para evitar solapamientos con las banderas */
  }
  .user-actions .logout-button span, .user-actions-container .logout-button span, .user-actions-container .logout-button .logout-text {
    display: none !important;
  }
  .user-actions .logout-button, .user-actions-container .logout-button {
    padding: 0 !important;
    width: 32px !important;
    height: 32px !important;
    justify-content: center !important;
    border-radius: 50% !important;
  }
}

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

.top-header img {
  max-height: var(--header-logo-height);
  width: auto;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.05));
  display: block;
  visibility: visible;
}

.header-logo {
  max-width: 100%;
  height: auto;
}

.logo-light { display: none !important; }
.logo-dark { display: block !important; }
body.theme-light .logo-light { display: block !important; }
body.theme-light .logo-dark { display: none !important; }

.lang-switcher {
  display: flex;
  gap: 12px;
  align-items: center;
}

.lang-switcher a {
  display: flex;
  align-items: center;
  opacity: 0.5;
  transition: all 0.3s ease;
  text-decoration: none;
}

.lang-switcher a:hover, .lang-switcher a.active {
  opacity: 1;
  transform: scale(1.1);
}

.lang-switcher img {
  width: 20px;
  height: auto;
  border-radius: 2px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

body.theme-light .lang-switcher img {
  border-color: rgba(0, 0, 0, 0.05);
}

.box {
  position: relative;
  background: var(--box-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 32px;
  margin: 0 40px 24px 40px;
  box-shadow: var(--shadow-lg);
}

@media (max-width: 768px) {
  .box {
    margin: 0 15px 20px 15px;
    padding: 24px 20px;
  }
  h1 { font-size: 24px; }
}

.box-actions-top {
  position: absolute;
  top: 32px;
  right: 32px;
  display: flex;
  gap: 12px;
  z-index: 10;
}

.box-actions-top .btn-text {
  display: inline;
}

.icon-svg {
  width: 16px;
  height: 16px;
}

.stats-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 32px;
  gap: 20px;
}

.stats-header-left {
  flex: 1;
}

.stats-header-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}

/* Components */
.item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  margin: 0 -16px;
  border-radius: var(--radius-md);
  transition: var(--transition);
  border-bottom: 1px solid transparent;
  cursor: pointer;
}

.item:hover {
  background: rgba(0, 0, 0, 0.08);
  transform: translateY(-1px);
}

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

.item-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--brand-secondary);
  color: var(--text-muted);
  transition: var(--transition);
}

.item:hover .item-icon {
  background: var(--box-bg);
  box-shadow: var(--shadow-sm);
  color: var(--brand-accent);
}

.item-main-link {
  font-weight: 500;
  color: var(--text-color);
  text-decoration: none;
  font-size: 15px;
}

.item-main-link:hover {
  color: var(--link-color);
  text-decoration: none;
}

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

.muted {
  font-size: 13px;
  color: var(--text-muted);
}

/* Buttons */
.button, button, .logout-button, .admin-corner-button {
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  height: 42px;
  box-sizing: border-box;
  background: var(--brand-accent);
  color: #ffffff;
  text-decoration: none;
}

.inline-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-primary {
  background: var(--brand-primary);
  color: var(--brand-primary-text, #fff);
  border: 1px solid var(--brand-primary);
}

.btn-primary:hover {
  filter: brightness(0.9);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: var(--brand-secondary);
  color: var(--text-color);
  border: 1px solid var(--border-color);
  text-decoration: none;
}

.btn-secondary:hover {
  background: #e2e8f0;
  border-color: #cbd5e1;
}

/* Specific Action Buttons */
.btn-filter {
  background: #0ea5e9 !important;
  color: #fff !important;
  border: 1px solid #0284c7 !important;
}

.btn-filter:hover {
  background: #0284c7 !important;
  box-shadow: 0 4px 12px rgba(14, 165, 233, 0.2);
}

.btn-clear {
  background: #f97316 !important;
  color: #ffffff !important;
  border: 1px solid #ea580c !important;
}

.btn-clear:hover {
  background: #ea580c !important;
  border-color: #c2410c !important;
  color: #ffffff !important;
}

.btn-detail {
  background: #6366f1 !important;
  color: #fff !important;
  border: 1px solid #4f46e5 !important;
  background-image: linear-gradient(135deg, #6366f1 0%, #a855f7 100%) !important;
}

.btn-detail:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
  filter: brightness(1.1);
}

.inline-form {
  display: inline-block;
  margin: 0;
}

.danger-button {
  background: #fee2e2;
  color: #991b1b;
  padding: 8px 16px;
  font-size: 13px;
}

.danger-button:hover {
  background: #fecaca;
  color: #7f1d1d;
  box-shadow: 0 2px 8px rgba(153, 27, 27, 0.1);
}

.logout-button {
  background: var(--brand-primary);
  color: #ffffff !important;
  padding: 6px 14px;
  font-size: 12px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
}

.logout-button span, .logout-button svg, .logout-button .logout-text {
  color: #ffffff !important;
  stroke: #ffffff !important;
}

.logout-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(226, 63, 46, 0.2);
}

.admin-corner-button {
  background: #1e293b;
  color: #fff;
  position: absolute;
  top: 32px;
  right: 32px;
  text-decoration: none;
  gap: 8px;
}

.admin-corner-button:hover {
  background: #0f172a;
}

.admin-section {
  margin-bottom: 40px;
}

.admin-section h3 {
  margin-bottom: 24px;
  font-size: 20px;
  color: var(--text-color);
}

/* Action Icons */
.icon-action-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: var(--box-bg);
  color: var(--text-muted);
  transition: var(--transition);
}

.icon-action-button:hover {
  border-color: var(--brand-accent);
  color: var(--brand-accent);
  background: #eff6ff;
  transform: scale(1.05);
}

.item-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.item-icon svg {
  width: 18px;
  height: 18px;
}

.icon-action-button svg {
  width: 18px;
  height: 18px;
  display: block;
  stroke: currentColor;
}

.play-button {
  background: var(--brand-primary);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--brand-primary-text);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
  transition: var(--transition);
}

.play-button:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 15px rgba(0, 0, 0, 0.2);
}

.play-button .play-icon {
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 10px solid var(--brand-primary-text);
  margin-left: 3px;
}

/* Admin Cards & Grid */
.admin-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: stretch;
  gap: 20px;
  margin-top: 24px;
}

.admin-card {
  flex: 0 1 30%;
  min-width: 260px;
  max-width: 360px;
  padding: 24px;
  background: var(--box-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  transition: var(--transition);
  text-decoration: none;
  color: var(--text-color);
  display: block;
  box-sizing: border-box;
}

/* Forzar distribución balanceada según el número de elementos */
/* 4 items -> 2 arriba, 2 abajo (45% cada uno) */
.admin-grid:has(> *:nth-child(4):last-child) > * {
  flex: 0 1 45% !important;
}

/* 5 items -> 3 arriba, 2 abajo (30% cada uno, centrados por justify-content) */
.admin-grid:has(> *:nth-child(5):last-child) > * {
  flex: 0 1 30% !important;
}

@media (max-width: 900px) {
  .admin-card {
    flex: 0 1 45% !important;
  }
}

@media (max-width: 600px) {
  .admin-card {
    flex: 0 1 100% !important;
  }
}

.admin-card:hover {
  border-color: var(--brand-accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-4px);
}

.card-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--brand-secondary);
  color: var(--brand-accent);
  margin-bottom: 16px;
  transition: var(--transition);
}

.admin-card:hover .card-icon {
  background: var(--brand-accent);
  color: #fff;
}

.card-icon svg {
  width: 24px;
  height: 24px;
}

.admin-card strong {
  font-size: 18px;
  display: block;
  margin-bottom: 8px;
  color: var(--text-color);
}

.admin-card span {
  font-size: 14px;
  color: var(--text-muted);
}

/* Breadcrumbs Modernized */
.breadcrumbs-container {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card-bg);
  padding: 8px 16px;
  border-radius: 30px;
  border: 1px solid var(--border-color);
  backdrop-filter: blur(4px);
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
  scroll-behavior: smooth;
}

.breadcrumbs-container::-webkit-scrollbar {
  display: none;
}

.breadcrumb-up-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--brand-secondary);
  border-radius: 50%;
  color: var(--brand-accent);
  transition: var(--transition);
  flex-shrink: 0;
  border: 1px solid var(--border-color);
}

.breadcrumb-up-btn:hover {
  background: var(--brand-accent);
  color: #fff;
  transform: translateX(-2px);
}

.breadcrumb-up-btn svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.5;
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 15px;
  color: var(--text-muted);
  font-family: 'Outfit', sans-serif;
  white-space: nowrap;
}

/* Permitir que el nombre de archivo haga wrap */
.item-name-text {
  white-space: normal !important;
  word-break: break-word;
  line-height: 1.3;
  padding: 4px 0;
}

/* Estilos para el nuevo Modal de Detalle */
.modal-metadata-line {
    display: flex;
    justify-content: center;
    gap: 12px;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 24px;
    opacity: 0.8;
}

.modal-actions-row {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.modal-actions-row .button {
    min-width: 120px;
}

.edit-mode-container {
    display: none;
    text-align: left;
    background: rgba(255,255,255,0.05);
    padding: 20px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.edit-mode-container.active {
    display: block;
}

.detail-mode-container.hidden {
    display: none;
}

.breadcrumbs a {
  color: var(--text-color);
  font-weight: 600;
  text-decoration: none;
  transition: var(--transition);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}

.breadcrumbs a:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--brand-accent);
}

.breadcrumb-separator {
  display: flex;
  align-items: center;
  color: var(--text-muted);
  opacity: 0.4;
}

.breadcrumb-separator svg {
  width: 14px;
  height: 14px;
}

body.theme-light .breadcrumbs-container {
  background: #f1f5f9;
}

body.theme-light .breadcrumbs a:hover {
  background: rgba(0, 0, 0, 0.05);
}

/* Password Wrapper & Toggle */
.password-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  margin-bottom: 0;
  max-width: 480px;
}

.password-wrapper input {
  padding-right: 40px !important;
  width: 100% !important;
  margin-bottom: 0 !important;
}

.password-toggle {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
  z-index: 5;
  padding: 5px;
  line-height: 0;
}

.password-toggle:hover {
  color: var(--brand-accent);
}

.password-toggle svg {
  width: 20px;
  height: 20px;
}

.password-wrapper + label {
  margin-top: 16px;
}

.admin-form .password-wrapper + label {
  margin-top: 16px;
}

/* Forms */
.form-group {
  margin-bottom: 24px;
}

label {
  display: block;
  margin-bottom: 4px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-color);
}

input:not([type="checkbox"]):not([type="radio"]), select, textarea {
  display: block;
  width: 100%;
  max-width: 480px;
  box-sizing: border-box;
  background: var(--input-bg);
  color: var(--input-color);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 15px;
  transition: var(--transition);
  margin-bottom: 12px;
}

input[type="checkbox"], input[type="radio"] {
  width: auto;
  margin-right: 8px;
  cursor: pointer;
  accent-color: var(--brand-accent);
}

.checkbox-line {
  display: flex;
  align-items: center;
  margin-bottom: 24px;
  cursor: pointer;
}

.checkbox-line span {
  font-size: 14px;
  font-weight: 500;
}

input[type="color"] {
  height: 44px;
  padding: 4px;
  max-width: 120px;
  cursor: pointer;
}

.form-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 32px;
}

.help-text {
  display: block;
  margin-top: -6px;
  margin-bottom: 24px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}


.nav-actions-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand-accent);
  background: var(--input-focus-bg);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

.project-logo-preview {
  margin-bottom: 24px;
  padding: 16px;
  background: var(--brand-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 480px;
  height: 160px;
  box-sizing: border-box;
}

.project-logo-preview img {
  display: block;
  max-width: 100%;
  max-height: 120px;
  width: auto;
  object-fit: contain;
}

.filters-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--border-color);
}

.filters-actions > div {
  display: flex;
  gap: 16px;
  align-items: center;
}

.export-excel-link, 
body.theme-light .export-excel-link {
  color: #ffffff !important;
  background: #16a34a !important;
  border: 1px solid #15803d !important;
}

.export-excel-link:hover,
body.theme-light .export-excel-link:hover {
  background: #15803d !important;
  border-color: #166534 !important;
  color: #ffffff !important;
  box-shadow: 0 4px 12px rgba(22, 163, 74, 0.15) !important;
}

.export-excel-link {
  margin-left: auto;
}

.export-excel-link svg {
  width: 16px;
  height: 16px;
  vertical-align: middle;
  margin-right: 6px;
}

.filter-button-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.filter-button-row .repo-link,
.filter-button-row button {
  height: 42px;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

@media (max-width: 768px) {
  .filter-button-row {
    flex-direction: column;
    align-items: stretch !important;
    gap: 12px;
  }

  .filter-button-row .repo-link {
    display: block;
    padding: 12px;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    text-align: center;
  }
}

.stats-kpi-grid {
  margin-top: 32px;
  margin-bottom: 32px;
}

.stats-mini-table-wrap {
  margin-top: 16px;
}

.path-cell {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats-ranking-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 24px;
  margin-top: 32px;
}

/* Sections & Actions */
.repo-selector {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.portal-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.repo-link {
  white-space: nowrap;
  padding: 8px 20px;
  border-radius: 24px;
  background: var(--brand-primary);
  color: #ffffff;
  font-weight: 600;
  font-size: 14px;
  transition: var(--transition);
  text-decoration: none;
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.repo-link:hover {
  opacity: 0.9;
  transform: translateY(-1px);
  color: #ffffff;
  text-decoration: none;
}

.repo-link.active {
  background: var(--brand-accent);
  color: #fff;
  border-color: var(--brand-accent);
}

.up-level-box {
  display: none; /* Replaced by breadcrumb-up-btn */
}

/* Captcha */
.captcha-container {
  margin-bottom: 24px;
}

.captcha-flex {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

.captcha-img {
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: #fff;
  height: 42px;
  display: block;
}

.captcha-input {
  width: 80px !important;
  margin-bottom: 0 !important;
  text-align: center;
  font-weight: 600;
}

/* Pagination & Stats */
.pagination-bar, .stats-actions-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-top: 24px;
  flex-wrap: wrap;
}

.pagination-actions {
  display: flex;
  gap: 8px;
}

.stats-kpi-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  margin-bottom: 32px;
}

.admin-user-card {
  background: var(--box-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
}

.admin-user-card .inline-actions {
  margin-top: auto;
  padding-top: 16px;
}

.stats-kpi-card {
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.stats-kpi-label {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.stats-kpi-value {
  font-size: 32px;
  font-weight: 700;
  font-family: 'Outfit', sans-serif;
  color: var(--text-color);
}

.stats-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  background: var(--box-bg);
  color: var(--text-color);
}

.stats-table th {
  background: var(--brand-secondary);
  color: var(--text-color);
  padding: 12px 16px;
  font-weight: 600;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

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

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

/* Responsive */
@media (min-width: 1280px) {
  .top-header, .box {
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
  }
  
  .top-header {
    padding-left: 0;
    padding-right: 0;
  }
}

@media (max-width: 1100px) {
  .top-header, .box {
    margin-left: 20px;
    margin-right: 20px;
  }
}

@media (max-width: 768px) {
  .top-header {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas: 
      "logo logout"
      "logo lang";
    align-items: center;
    gap: 8px 12px;
    padding: 16px 20px;
  }

  .header-left {
    grid-area: logo;
  }
  
  .header-right {
    grid-area: logout;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
  }

  .header-logo {
    height: auto;
  }

  .project-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
  }

  .project-title-row h1 {
    margin: 0;
    flex: 1;
  }

  .admin-corner-button, .logout-button {
    padding: 6px;
    min-width: 32px;
    height: 32px;
    position: static;
    margin: 0;
    flex-shrink: 0;
  }

  .admin-corner-button .icon-svg, .logout-button .icon-svg {
    width: 14px;
    height: 14px;
  }

  @media (max-width: 480px) {
    .logout-button .btn-text, .admin-corner-button .btn-text {
      display: none;
    }
  }
  
  .item {
    flex-direction: column;
    align-items: flex-start;
    padding: 6px 16px;
    margin: 0 -16px;
    border-bottom: 1px solid var(--border-color);
    border-radius: var(--radius-md);
  }
  
  .item:last-child {
    border-bottom: none;
  }

  .item-left {
    width: 100%;
    margin-bottom: 0;
  }
  
  .item-icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
  }

  .item {
    display: grid;
    grid-template-columns: 28px 1fr auto;
    grid-template-rows: auto auto;
    column-gap: 12px;
    row-gap: 2px;
    align-items: center;
    padding: 12px 10px;
  }

  .item-left, .item-right {
    display: contents;
  }

  .item-icon {
    grid-column: 1;
    grid-row: 1;
    justify-self: center;
    align-self: center;
    margin-right: 0;
    margin-top: 0;
  }

  .item-main-link {
    grid-column: 2 / 4;
    grid-row: 1;
    align-self: center;
    line-height: 1.3;
    padding-bottom: 0;
    font-size: 14px;
    min-width: 0;
    word-break: break-word;
  }

  .item-metadata {
    grid-column: 2;
    grid-row: 2;
    align-self: center;
    line-height: 1.2;
    font-size: 11px;
    margin-top: 0 !important;
    min-width: 0;
  }

  .item-actions, .item-actions:has(.play-button) {
    display: flex !important;
    flex-direction: row !important;
    grid-column: 3;
    grid-row: 2;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding-left: 0;
    transform: none !important;
  }

  .play-button {
    grid-column: auto !important;
    margin-bottom: 0 !important;
  }

  .icon-action-button {
    padding: 6px;
  }

  .metadata-sep {
    display: inline;
    margin: 0 2px;
  }
}

/* Modal Styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-content {
  background: var(--box-bg);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.modal-content h3 {
  margin-top: 0;
  margin-bottom: 20px;
  font-size: 1.1rem;
  color: var(--text-color);
  word-break: break-all;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-actions .button {
  text-align: center;
  padding: 12px;
  font-weight: 600;
  width: 100%;
  box-sizing: border-box;
}

.button:hover, button:hover {
  opacity: 0.9;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(36, 107, 255, 0.2);
}

.button.danger {
  background: #ef4444;
  color: #fff;
}

.button.danger:hover {
  background: #dc2626;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}

body.theme-light .button.secondary {
  background: var(--brand-secondary) !important;
  color: #1e293b !important;
}

.button.secondary {
  background: var(--brand-secondary);
  color: var(--text-color);
}

.button.accent {
  background: #2563eb !important;
  color: #fff !important;
}

.button.accent:hover {
  background: #1d4ed8 !important;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3) !important;
}

/* Login Page */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  background-image: radial-gradient(at 100% 0%, rgba(226, 63, 46, 0.03) 0px, transparent 50%),
                    radial-gradient(at 0% 100%, rgba(59, 130, 246, 0.03) 0px, transparent 50%);
}

.logo-light { display: none; }
.logo-dark { display: block; }

body.theme-light .logo-light { display: block; }
body.theme-light .logo-dark { display: none; }

.login-box .logo img {
  display: block;
  margin: 0 auto 24px;
  max-width: 100%;
}

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

.password-wrapper .toggle-password,
.password-wrapper .password-toggle {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent !important;
  border: none !important;
  color: #64748b !important;
  cursor: pointer;
  z-index: 5;
  padding: 4px;
  line-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

body.theme-light .password-wrapper .toggle-password,
body.theme-light .password-wrapper .password-toggle {
  color: #64748b !important;
}

.password-wrapper .eye-icon,
.password-wrapper svg {
  width: 18px;
  height: 18px;
}

.login-box {
  background: var(--box-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 32px 32px 24px 32px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
  position: relative;
}

.login-lang-switcher {
  position: absolute;
  top: 15px;
  right: 20px;
  display: flex;
  gap: 10px;
}

.login-lang-switcher a {
  display: flex;
  align-items: center;
  opacity: 0.5;
  transition: all 0.3s ease;
}

.login-lang-switcher a:hover, .login-lang-switcher a.active {
  opacity: 1;
  transform: scale(1.1);
}

.login-lang-switcher img {
  width: 20px;
  height: auto;
  border-radius: 2px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.login-box .logo {
  text-align: center;
  margin-bottom: 12px;
}

.login-box .logo img {
  max-width: 100%;
  height: auto !important;
  max-height: var(--login-logo-height) !important;
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.05));
}

.login-box h1 {
  font-size: 24px;
  text-align: center;
  margin-bottom: 8px;
}

.login-box label {
  font-size: 13px;
  color: var(--text-color);
  opacity: 0.9;
}

.login-box input {
  max-width: 100% !important;
}

.login-box button {
  width: 100%;
  margin-top: 10px;
  background: var(--brand-primary);
  color: #fff;
  padding: 12px;
}

.item:hover {
  background: rgba(0, 0, 0, 0.06);
  transform: translateY(-1px);
}

.login-box button:hover {
  background: var(--link-color);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.success-box, .error {
  padding: 16px 20px;
  border-radius: var(--radius-md);
  margin-bottom: 32px;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
}

.success-box {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}
/* Custom Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-card {
  background: var(--box-bg);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  transform: translateY(20px);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.active .modal-card {
  transform: translateY(0);
}

.modal-card h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 20px;
  margin-bottom: 12px;
  color: #1e293b;
}

.modal-card p {
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1.6;
  margin-bottom: 32px;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.modal-btn {
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
}

.modal-btn-cancel {
  background: var(--brand-secondary);
  color: var(--text-muted);
}

.modal-btn-cancel:hover {
  background: #e2e8f0;
}

.btn-primary, .btn-submit {
  background: var(--brand-primary);
  color: #ffffff;
  text-decoration: none;
}

.modal-btn-confirm {
  background: var(--brand-primary);
  color: #fff;
}

.modal-btn-confirm:hover {
  background: #b91c1c;
  transform: scale(1.02);
}

/* Custom File Picker */
.custom-file-picker {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--brand-secondary);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--input-border);
  margin-bottom: 20px;
  max-width: 480px;
  box-sizing: border-box;
}

.custom-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.custom-file-button {
  background: #fff;
  color: var(--text-color);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--input-border);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.custom-file-name {
  font-size: 13px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-back-link {
  margin-bottom: 32px;
}

.footer-credit {
  text-align: center;
  padding: 40px;
  font-size: 13px;
  color: var(--text-muted);
}

.footer-credit a {
  color: var(--brand-primary);
  text-decoration: none;
  font-weight: 500;
  transition: var(--transition);
  margin: 0 2px;
}

.footer-credit a:hover {
  color: #fff;
}

body.theme-light .footer-credit a:hover {
  color: var(--brand-accent);
}

/* Responsive Logo Grid */
.admin-logo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-top: 20px;
}

@media (max-width: 768px) {
  .admin-logo-grid {
    grid-template-columns: 1fr;
  }
}
/* Statistics Page Fixes */
.filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.stats-checkbox-row {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--border-color);
}

.stats-checkbox-line {
  display: flex;
  align-items: center;
  cursor: pointer;
}

.stats-checkbox-line input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin-right: 12px;
  flex-shrink: 0;
}

.stats-checkbox-line span {
  font-size: 15px;
  font-weight: 500;
  line-height: 1.4;
}

@media (max-width: 768px) {
  .filters-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  
  .filter-button-row {
    flex-direction: column;
    align-items: stretch !important;
    gap: 20px;
  }
  
  .filter-button-row > div {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }
  
  .filter-button-row .repo-link {
    display: block;
    padding: 12px;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    text-align: center;
    margin-left: 0 !important;
  }
  
  .export-excel-link {
    justify-content: center;
    padding: 12px !important;
  }
}
/* Upload Area & Drag-n-Drop */
.upload-zone {
  position: relative;
  border: 2px dashed var(--input-border);
  border-radius: var(--radius-lg);
  padding: 40px 20px;
  text-align: center;
  background: rgba(255, 255, 255, 0.5);
  transition: var(--transition);
  cursor: pointer;
  margin-bottom: 24px;
  overflow: hidden;
}

.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--brand-accent);
  background: rgba(59, 130, 246, 0.04);
  transform: translateY(-1px);
}

.upload-zone.drag-over {
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

.upload-zone input[type="file"] {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.upload-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  color: var(--brand-accent);
  opacity: 0.8;
}

.upload-text {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-color);
  margin-bottom: 4px;
}

.upload-hint {
  font-size: 14px;
  color: var(--text-muted);
}

.selected-files-list {
  margin-top: 24px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--box-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-10px); }
  to { opacity: 1; transform: translateX(0); }
}

.file-info {
  display: flex;
  align-items: center;
  gap: 12px;
  overflow: hidden;
}

.file-name {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-size {
  font-size: 12px;
  color: var(--text-muted);
}

.remove-file {
  background: none;
  border: none;
  color: #ef4444;
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.remove-file:hover {
  background: rgba(239, 68, 68, 0.1);
}

.upload-progress-container {
    margin-top: 20px;
    display: none;
}

.progress-bar-bg {
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--brand-accent);
    width: 0%;
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 12px;
    margin-top: 6px;
    text-align: center;
    color: var(--text-muted);
}

/* Custom Modals (Confirmation) */
.custom-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.custom-modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.custom-modal {
  background: var(--box-bg);
  padding: 32px;
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 40px rgba(0,0,0,0.2);
  max-width: 400px;
  width: 90%;
  text-align: center;
  transform: translateY(20px) scale(0.95);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
  border: 1px solid var(--border-color);
}

.custom-modal-overlay.active .custom-modal {
  transform: translateY(0);
}

.custom-modal h3 {
  margin-top: 0;
  font-size: 1.5rem;
  color: var(--text-color);
}

.custom-modal p {
  color: var(--text-muted);
  margin: 16px 0 32px;
  line-height: 1.5;
}

.custom-modal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.custom-modal-actions button, 
.custom-modal-actions .modal-btn {
  padding: 12px 24px;
  border-radius: var(--radius-md);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  min-width: 120px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-cancel {
  background: var(--brand-secondary);
  color: var(--text-color);
  text-decoration: none;
}

.btn-cancel:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn-confirm-danger {
  background: var(--brand-primary);
  color: white;
  text-decoration: none;
}

.btn-confirm-danger:hover {
  filter: brightness(1.1);
  box-shadow: 0 4px 12px rgba(36, 107, 255, 0.3);
}

.btn-confirm-primary {
  background: var(--brand-accent);
  color: white;
}

.btn-confirm-primary:hover {
  background: var(--brand-primary);
  box-shadow: 0 4px 12px rgba(0, 106, 216, 0.2);
}

.password-wrapper {
  position: relative;
  width: 100%;
  display: block;
}

.password-wrapper input {
  padding-right: 48px !important;
  width: 100% !important;
  box-sizing: border-box !important;
  display: block;
}

.toggle-password, .password-toggle {
  position: absolute;
  right: -14px;
  top: 0;
  bottom: 0;
  width: 44px !important;
  height: auto !important;
  background: none !important;
  border: none !important;
  padding: 0 !important;
  cursor: pointer;
  color: #64748b;
  display: flex !important;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  z-index: 10;
  line-height: 0;
  margin: 0 !important;
}

.toggle-password:hover, .password-toggle:hover {
  color: var(--brand-primary);
  opacity: 1;
  box-shadow: none !important;
}

.toggle-password svg, .password-toggle svg {
  width: 20px;
  height: 20px;
  display: block;
}
