/* --- ADMIN PORTAL CUSTOM STYLES --- */

/* Scope wrapper for admin styles to avoid breaking base resets if needed, but styling is tailored */
.admin-body {
  background-color: var(--bg-color);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Glassmorphic Base Class */
.glass-panel {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.08);
  transition: transform var(--transition-normal), box-shadow var(--transition-normal), border-color var(--transition-normal);
}

[data-theme="dark"] .glass-panel {
  background: rgba(30, 41, 59, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

.glass-panel:hover {
  border-color: var(--border-color-hover);
  box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.12);
}

/* --- LOCK / LOGIN SCREEN --- */
.admin-lock-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: radial-gradient(circle at center, #1e293b, #0f172a);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  transition: opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.5s;
}

.admin-lock-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.lock-card {
  width: 100%;
  max-width: 440px;
  padding: 2.5rem;
  text-align: center;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(20px);
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
  transform: translateY(0);
  transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.admin-lock-screen.hidden .lock-card {
  transform: translateY(-30px);
}

.lock-logo {
  margin-bottom: 1.5rem;
  display: inline-block;
  animation: pulse-glow 3s infinite alternate;
}

@keyframes pulse-glow {
  0% { transform: scale(1); filter: drop-shadow(0 0 5px rgba(59, 130, 246, 0.4)); }
  100% { transform: scale(1.05); filter: drop-shadow(0 0 15px rgba(59, 130, 246, 0.8)); }
}

.lock-title {
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
  color: #fff;
  letter-spacing: -0.5px;
}

.lock-subtitle {
  color: #94a3b8;
  font-size: 0.9rem;
  margin-bottom: 2rem;
}

/* Custom Admin Inputs */
.admin-input-group {
  margin-bottom: 1.25rem;
  text-align: left;
}

.admin-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
}

.admin-input {
  width: 100%;
  padding: 0.85rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--card-bg);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  transition: all var(--transition-fast);
}

.admin-input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-light);
}

[data-theme="dark"] .admin-input {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

[data-theme="dark"] .admin-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

.lock-btn {
  width: 100%;
  padding: 0.9rem;
  margin-top: 1rem;
  font-weight: 600;
  font-size: 1rem;
  border: none;
  background: linear-gradient(135deg, var(--accent-primary), #1d4ed8);
  color: #fff;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.lock-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.4);
}

.lock-btn:active {
  transform: translateY(1px);
}

.error-hint {
  color: #ef4444;
  font-size: 0.85rem;
  margin-top: 0.5rem;
  display: none;
}

/* --- MAIN DASHBOARD LAYOUT --- */
.admin-header {
  padding: 3rem 0 2rem 0;
  border-bottom: 1px solid var(--border-color);
  background: linear-gradient(to bottom, var(--nav-bg), transparent);
}

.admin-header-flex {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1.5rem;
}

.admin-title-area h1 {
  font-size: 2.25rem;
  letter-spacing: -0.75px;
}

.admin-title-area p {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

.admin-header-actions {
  display: flex;
  gap: 0.75rem;
}

/* --- DASHBOARD STATS --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0 3rem 0;
}

.stat-card {
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.stat-icon {
  width: 50px;
  height: 50px;
  border-radius: 12px;
  background: var(--accent-light);
  color: var(--accent-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

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

.stat-number {
  font-size: 1.5rem;
  font-weight: 800;
  font-family: var(--font-heading);
  line-height: 1.1;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  margin-top: 0.25rem;
  letter-spacing: 0.5px;
}

/* --- TABLE SECTION --- */
.dashboard-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}

.dashboard-section-header h2 {
  font-size: 1.35rem;
  letter-spacing: -0.25px;
}

.table-wrapper {
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid var(--border-color);
}

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

.admin-table th {
  background: var(--card-bg-hover);
  padding: 1rem 1.25rem;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

[data-theme="dark"] .admin-table th {
  background: rgba(30, 41, 59, 0.4);
}

.admin-table td {
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
  background: var(--card-bg);
}

[data-theme="dark"] .admin-table td {
  background: transparent;
}

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

.admin-table tr:hover td {
  background: var(--card-bg-hover);
}

[data-theme="dark"] .admin-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* Table app entry details */
.table-app-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.table-app-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: var(--card-bg-hover);
  object-fit: cover;
  border: 1px solid var(--border-color);
}

.table-app-name {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text-primary);
}

.table-app-tagline {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

/* Action button icons styling */
.action-btn-group {
  display: flex;
  gap: 0.5rem;
}

.btn-icon {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: var(--card-bg);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-icon:hover {
  background: var(--accent-light);
  color: var(--accent-primary);
  border-color: var(--accent-primary);
}

.btn-icon.btn-delete:hover {
  background: rgba(239, 68, 68, 0.08);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.2);
}

.btn-icon svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* --- SIDEBAR PANEL OR MODAL OVERLAYS --- */
.admin-modal {
  position: fixed;
  inset: 0;
  z-index: 1050;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: flex-end; /* Slides in from right */
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.4s var(--transition-normal), visibility 0.4s;
}

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

.modal-content {
  width: 100%;
  max-width: 650px;
  height: 100%;
  background: var(--card-bg);
  border-left: 1px solid var(--border-color);
  box-shadow: -10px 0 40px rgba(0,0,0,0.25);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="dark"] .modal-content {
  background: #151f32;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
}

.admin-modal.active .modal-content {
  transform: translateX(0);
}

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

.modal-header h3 {
  font-size: 1.35rem;
  letter-spacing: -0.25px;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.modal-close-btn:hover {
  background: var(--card-bg-hover);
  color: var(--text-primary);
}

.modal-close-btn svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

.modal-body {
  padding: 2rem;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 1.5rem 2rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  background: var(--card-bg-hover);
}

[data-theme="dark"] .modal-footer {
  background: rgba(30, 41, 59, 0.2);
}

/* Modal Form Grid Layout */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

@media (max-width: 580px) {
  .form-row {
    grid-template-columns: 1fr;
  }
}

/* Dynamic Lists (Features, changelogs, screenshots) */
.dynamic-list-container {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1rem;
  margin-top: 0.5rem;
  background: var(--bg-color);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

[data-theme="dark"] .dynamic-list-container {
  background: rgba(15, 23, 42, 0.4);
}

.dynamic-list-item {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.dynamic-list-item .admin-input {
  padding: 0.65rem 0.85rem;
  font-size: 0.9rem;
}

.btn-add-item {
  align-self: flex-start;
  font-size: 0.8rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.85rem;
  border-radius: 6px;
  border: 1px dashed var(--border-color);
  background: var(--card-bg);
  cursor: pointer;
  transition: all var(--transition-fast);
  color: var(--text-secondary);
}

.btn-add-item:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  background: var(--accent-light);
}

/* Nested Changelog Form styling */
.changelog-editor-item {
  border: 1px solid var(--border-color);
  background: var(--card-bg);
  border-radius: 8px;
  padding: 1rem;
  position: relative;
}

[data-theme="dark"] .changelog-editor-item {
  background: rgba(30, 41, 59, 0.3);
}

.changelog-editor-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.changelog-editor-item-title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--accent-primary);
  letter-spacing: 0.5px;
}

.btn-remove-changelog {
  background: transparent;
  border: none;
  color: #ef4444;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
}

/* --- EXPORTER AND CODE PANEL VIEW --- */
.code-panel-textarea {
  width: 100%;
  height: 250px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.85rem;
  background: #0f172a;
  color: #38bdf8;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 1rem;
  resize: vertical;
  margin-top: 0.5rem;
}

.code-panel-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
}

/* --- GITHUB SYNC WIDGET --- */
.github-sync-panel {
  padding: 1.75rem;
  margin-top: 3rem;
  border: 1px solid var(--border-color);
  border-radius: 16px;
  background: var(--card-bg);
}

.sync-status-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  margin-top: 0.5rem;
}

.sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  background: var(--text-muted);
}

.sync-dot.online {
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
  animation: pulse-dot 2s infinite;
}

.sync-dot.error {
  background: #ef4444;
  box-shadow: 0 0 8px #ef4444;
}

@keyframes pulse-dot {
  0% { opacity: 0.5; }
  50% { opacity: 1; }
  100% { opacity: 0.5; }
}

.sync-logs-wrapper {
  margin-top: 1.25rem;
  background: #090d16;
  border-radius: 8px;
  padding: 1rem;
  max-height: 150px;
  overflow-y: auto;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.sync-log-line {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.8rem;
  color: #94a3b8;
  margin-bottom: 0.35rem;
}

.sync-log-line.info { color: #3b82f6; }
.sync-log-line.success { color: #10b981; }
.sync-log-line.error { color: #ef4444; }

/* Custom global buttons */
.btn-success {
  background: var(--success);
  color: #fff;
  border: none;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
}

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

.btn-purple {
  background: linear-gradient(135deg, #8b5cf6, #6d28d9);
  color: #fff;
  border: none;
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.25);
}

.btn-purple:hover {
  background: linear-gradient(135deg, #7c3aed, #5b21b6);
  box-shadow: 0 6px 16px rgba(139, 92, 246, 0.35);
}

/* Toast Notification Overlay */
.admin-toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  z-index: 1100;
  padding: 0.85rem 1.5rem;
  border-radius: 30px;
  background: #1e293b;
  border: 1px solid rgba(255,255,255,0.1);
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
  box-shadow: 0 10px 25px rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  opacity: 0;
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.4s;
}

.admin-toast.active {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.admin-toast.toast-error {
  border-color: rgba(239, 68, 68, 0.4);
  background: #7f1d1d;
}

.admin-toast.toast-success {
  border-color: rgba(16, 185, 129, 0.4);
  background: #064e3b;
}

/* Empty portfolio placeholder */
.admin-empty-state {
  text-align: center;
  padding: 4rem 2rem;
}

.admin-empty-state svg {
  width: 60px;
  height: 60px;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

/* --- PREMIUM MIDNIGHT/DARK NIGHT MODE OVERRIDES --- */
[data-theme="dark"] .admin-body {
  /* Override CSS theme tokens to force deep dark night theme */
  --bg-color: #080c14;           /* Deep dark obsidian blue */
  --card-bg: #0f172a;            /* Midnight blue slate */
  --card-bg-hover: #1e293b;      /* Lighter hover slate */
  
  --border-color: #1e293b;       /* Dark slate border */
  --border-color-hover: #334155; /* Interactive hover border */
  
  --text-primary: #f8fafc;       /* Near pure white text */
  --text-secondary: #cbd5e1;     /* Highly readable grey-white */
  --text-muted: #64748b;         /* Muted metadata grey */
  
  --accent-primary: #3b82f6;     /* Glowing brand blue */
  --accent-hover: #60a5fa;
  --accent-light: rgba(59, 130, 246, 0.15);
  
  --nav-bg: rgba(8, 12, 20, 0.85);
  --success: #10b981;
}

/* Force theme body styles */
.admin-body {
  background-color: var(--bg-color);
  color: var(--text-primary);
}

/* Form inputs & controls visibility tweaks */
[data-theme="dark"] .admin-body .admin-input {
  background: #111827 !important;
  border: 1px solid #374151 !important;
  color: #f9fafb !important;
}

[data-theme="dark"] .admin-body .admin-input:focus {
  border-color: #3b82f6 !important;
  background: #0b0f19 !important;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25) !important;
}

[data-theme="dark"] .admin-body .admin-input::placeholder {
  color: #6b7280 !important;
}

/* Modal styling overrides */
[data-theme="dark"] .admin-body .modal-content {
  background: #0f172a !important;
  border-left: 1px solid #1e293b !important;
}

[data-theme="dark"] .admin-body .modal-footer {
  background: #0b0f19 !important;
  border-top: 1px solid #1e293b !important;
}

[data-theme="dark"] .admin-body .modal-header {
  border-bottom: 1px solid #1e293b !important;
}

/* Table styling overrides */
[data-theme="dark"] .admin-body .admin-table th {
  background: #111827 !important;
  color: #f8fafc !important;
  border-bottom: 1px solid #1e293b !important;
  font-weight: 700;
}

[data-theme="dark"] .admin-body .admin-table td {
  background: transparent !important;
  border-bottom: 1px solid #1e293b !important;
  color: #cbd5e1 !important;
}

[data-theme="dark"] .admin-body .admin-table tr:hover td {
  background: #1e293b !important;
}

/* Button overrides for dark mode readability */
[data-theme="dark"] .admin-body .btn-secondary {
  background: #1e293b !important;
  color: #f8fafc !important;
  border: 1px solid #334155 !important;
}

[data-theme="dark"] .admin-body .btn-secondary:hover {
  background: #334155 !important;
  border-color: #475569 !important;
  color: #ffffff !important;
}

[data-theme="dark"] .admin-body .btn-icon {
  background: #1e293b !important;
  border-color: #334155 !important;
  color: #cbd5e1 !important;
}

[data-theme="dark"] .admin-body .btn-icon:hover {
  background: rgba(59, 130, 246, 0.2) !important;
  border-color: #3b82f6 !important;
  color: #60a5fa !important;
}

[data-theme="dark"] .admin-body .btn-icon.btn-delete:hover {
  background: rgba(239, 68, 68, 0.2) !important;
  border-color: #ef4444 !important;
  color: #f87171 !important;
}

[data-theme="dark"] .admin-body .btn-icon[disabled],
[data-theme="dark"] .admin-body .btn-icon[disabled]:hover {
  background: #111827 !important;
  border-color: #1e293b !important;
  color: #475569 !important;
  opacity: 0.35 !important;
  cursor: not-allowed !important;
}

/* Dynamic list builders */
[data-theme="dark"] .admin-body .dynamic-list-container {
  background: #080c14 !important;
  border-color: #1e293b !important;
}

[data-theme="dark"] .admin-body .changelog-editor-item {
  background: #0f172a !important;
  border-color: #1e293b !important;
}

/* Code area */
[data-theme="dark"] .admin-body .code-panel-textarea {
  background: #05070a !important;
  border-color: #1e293b !important;
  color: #34d399 !important;
}
