/* Admin Panel Styles */

.admin-login {
  display: flex; align-items: center; justify-content: center; min-height: 100vh;
  background: var(--bg-primary);
}
.login-card {
  background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 20px;
  padding: 2.5rem; width: 100%; max-width: 400px; text-align: center;
  box-shadow: var(--shadow); animation: modalIn 0.5s var(--ease-out);
}
.login-icon { font-size: 3rem; margin-bottom: 1rem; }
.login-card h2 { margin-bottom: 1.5rem; font-size: 1.5rem; }
.login-error { color: #ef4444; font-size: 0.85rem; margin-top: 0.75rem; min-height: 1.2em; }

/* Admin Layout */
#admin-dashboard { display: flex; min-height: 100vh; background: var(--bg-primary); }

.admin-sidebar {
  width: 240px; background: var(--bg-secondary); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0;
  z-index: 100; transition: transform 0.3s var(--ease-out);
}
.sidebar-header {
  padding: 1.25rem; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.sidebar-header h2 { font-size: 1.1rem; background: linear-gradient(135deg, var(--accent), var(--accent2)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.sidebar-toggle { display: none; background: none; border: none; color: var(--text-primary); font-size: 1.3rem; cursor: pointer; }

.sidebar-nav { list-style: none; padding: 0.75rem 0; flex: 1; overflow-y: auto; }
.sidebar-nav li { padding: 0 0.5rem; }
.nav-item {
  display: flex; align-items: center; gap: 0.75rem; padding: 0.6rem 0.75rem;
  border-radius: 10px; color: var(--text-secondary); font-size: 0.88rem; font-weight: 500;
  transition: all 0.2s; cursor: pointer; text-decoration: none;
}
.nav-item:hover { background: rgba(var(--accent-rgb), 0.08); color: var(--text-primary); }
.nav-item.active { background: rgba(var(--accent-rgb), 0.12); color: var(--accent); }
.nav-icon { font-size: 1.1rem; }

.sidebar-footer { padding: 0.75rem 0.5rem; border-top: 1px solid var(--border); }

/* Main Content */
.admin-main { flex: 1; margin-left: 240px; padding: 2rem; }

.admin-section { display: none; }
.admin-section.active { display: block; animation: pageEnter 0.3s var(--ease-out); }

.admin-section h2 { font-size: 1.6rem; margin-bottom: 1.5rem; }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.section-header h2 { margin-bottom: 0; }

/* Stats Grid */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; }
.stat-card {
  background: var(--glass-bg); border: 1px solid var(--border); border-radius: 16px; padding: 1.5rem;
  text-align: center; transition: all 0.3s var(--ease-out);
}
.stat-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.stat-icon { font-size: 1.8rem; margin-bottom: 0.5rem; }
.stat-value { font-size: 2rem; font-weight: 700; font-family: var(--font-heading); background: linear-gradient(135deg, var(--accent), var(--accent2)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.stat-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.25rem; text-transform: uppercase; letter-spacing: 0.05em; }

/* Settings Grid */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.5rem; margin-bottom: 1.5rem; }
.setting-card {
  background: var(--glass-bg); border: 1px solid var(--border); border-radius: 16px; padding: 1.5rem;
}
.setting-card h3 { font-size: 1rem; margin-bottom: 1rem; color: var(--text-primary); }
.setting-card.full-width { grid-column: 1 / -1; }

/* Project List */
.admin-projects-list { display: flex; flex-direction: column; gap: 0.75rem; }
.admin-project-item {
  display: flex; align-items: center; gap: 1rem; padding: 1rem 1.25rem;
  background: var(--glass-bg); border: 1px solid var(--border); border-radius: 12px;
  transition: all 0.2s;
}
.admin-project-item:hover { border-color: var(--border-hover); }
.admin-project-item .project-info { flex: 1; }
.admin-project-item .project-info h4 { font-size: 0.95rem; margin-bottom: 0.2rem; }
.admin-project-item .project-info p { font-size: 0.8rem; color: var(--text-muted); }
.admin-project-item .project-actions { display: flex; gap: 0.5rem; }
.admin-project-item .status-badge {
  font-size: 0.7rem; padding: 2px 8px; border-radius: 10px;
  text-transform: uppercase; font-weight: 600; letter-spacing: 0.03em;
}
.status-badge.active { background: rgba(34,197,94,0.15); color: #22c55e; }
.status-badge.draft { background: rgba(234,179,8,0.15); color: #eab308; }
.status-badge.archived { background: rgba(107,114,128,0.15); color: #6b7280; }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; }
.modal-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); }
.modal-content {
  position: relative; background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: 20px; padding: 2rem; width: 100%; max-width: 600px; max-height: 90vh;
  overflow-y: auto; z-index: 1;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.modal-header h3 { font-size: 1.3rem; }
.modal-close { background: none; border: none; color: var(--text-muted); font-size: 1.5rem; cursor: pointer; transition: color 0.2s; }
.modal-close:hover { color: var(--text-primary); }
.form-actions { display: flex; gap: 0.75rem; justify-content: flex-end; margin-top: 1.5rem; }

/* Drop Zone */
.drop-zone {
  border: 2px dashed var(--border); border-radius: 12px; padding: 2rem; text-align: center;
  transition: all 0.3s; cursor: pointer;
}
.drop-zone:hover, .drop-zone.drag-over { border-color: var(--accent); background: rgba(var(--accent-rgb), 0.05); }
.drop-zone svg { width: 40px; height: 40px; color: var(--text-muted); margin-bottom: 0.75rem; }
.drop-zone p { font-size: 0.88rem; color: var(--text-secondary); }
.browse-link { color: var(--accent); cursor: pointer; }
.file-info { font-size: 0.85rem; color: var(--accent); margin-top: 0.5rem; font-weight: 500; }

/* Upload Progress */
.upload-progress { margin-top: 0.75rem; }
.progress-text { font-size: 0.8rem; color: var(--text-muted); display: block; margin-top: 0.5rem; }

/* Secret Path */
.secret-path-display {
  display: flex; align-items: center; gap: 0.75rem; margin: 1rem 0;
  padding: 0.75rem 1rem; background: var(--bg-primary); border: 1px solid var(--border); border-radius: 10px;
}
.secret-path-display code { flex: 1; font-size: 0.85rem; color: var(--accent); word-break: break-all; }

/* Analytics */
.analytics-chart {
  background: var(--glass-bg); border: 1px solid var(--border); border-radius: 16px;
  padding: 1.5rem; margin-bottom: 1.5rem; min-height: 200px;
}
.analytics-table {
  background: var(--glass-bg); border: 1px solid var(--border); border-radius: 16px; overflow: hidden;
}
.analytics-table table { width: 100%; border-collapse: collapse; }
.analytics-table th {
  padding: 0.75rem 1rem; text-align: left; font-size: 0.8rem; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--text-muted); border-bottom: 1px solid var(--border);
}
.analytics-table td { padding: 0.75rem 1rem; font-size: 0.9rem; border-bottom: 1px solid var(--border); }
.analytics-table tr:last-child td { border-bottom: none; }
.analytics-table tr:hover td { background: rgba(var(--accent-rgb), 0.03); }
.analytics-bar {
  height: 8px; border-radius: 4px; background: linear-gradient(90deg, var(--accent), var(--accent2));
  transition: width 0.6s var(--ease-out);
}

/* Admin Project Search */
.admin-search-bar {
  margin-bottom: 1rem;
}

.admin-search-bar input {
  width: 100%;
  padding: 0.7rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--glass-bg);
  color: var(--text-primary);
  font-size: 0.88rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.admin-search-bar input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.15);
}

/* Drag and Drop */
.drag-handle {
  cursor: grab;
  color: var(--text-muted);
  font-size: 1.2rem;
  user-select: none;
  opacity: 0.5;
  transition: opacity 0.2s;
}

.drag-handle:hover {
  opacity: 1;
  color: var(--accent);
}

.admin-project-item.dragging {
  opacity: 0.4;
  background: rgba(var(--accent-rgb), 0.1);
  border-style: dashed;
}

.admin-project-item.drag-over {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.2);
}

.admin-project-item[draggable="true"] {
  cursor: default;
}

/* Responsive */
@media (max-width: 768px) {
  .admin-sidebar { transform: translateX(-100%); width: 260px; }
  .admin-sidebar.open { transform: translateX(0); }
  .sidebar-toggle { display: block; }
  .admin-main { margin-left: 0; padding: 1rem; }
  .settings-grid { grid-template-columns: 1fr; }
  .modal-content { margin: 1rem; padding: 1.5rem; }

  /* Login card responsive */
  .login-card {
    margin: 1rem;
    padding: 2rem 1.5rem;
  }

  /* Section header wraps */
  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  /* Project list items stack actions below info */
  .admin-project-item {
    flex-wrap: wrap;
  }

  .admin-project-item .project-actions {
    width: 100%;
    justify-content: flex-end;
  }

  /* Analytics table horizontal scroll */
  .analytics-table {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .analytics-table table {
    min-width: 500px;
  }

  /* Secret path display wrap */
  .secret-path-display {
    flex-wrap: wrap;
  }

  .secret-path-display code {
    font-size: 0.78rem;
  }

  /* Stats grid smaller cards */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .admin-main {
    padding: 0.75rem;
  }

  .admin-section h2 {
    font-size: 1.3rem;
  }

  /* Modal nearly full-screen on small phones */
  .modal-content {
    margin: 0.5rem;
    padding: 1.25rem;
    border-radius: 16px;
    max-height: 95vh;
  }

  .modal-header h3 {
    font-size: 1.1rem;
  }

  /* Stats stack to single column */
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .stat-card {
    padding: 1rem;
  }

  .stat-value {
    font-size: 1.5rem;
  }

  /* Setting cards tighter */
  .setting-card {
    padding: 1rem;
  }

  /* Login card compact */
  .login-card {
    padding: 1.5rem 1.25rem;
    border-radius: 16px;
  }

  .login-card h2 {
    font-size: 1.25rem;
  }

  /* Form actions stack */
  .form-actions {
    flex-direction: column;
  }

  .form-actions button {
    width: 100%;
  }

  /* Drop zone compact */
  .drop-zone {
    padding: 1.25rem;
  }

  .drop-zone svg {
    width: 32px;
    height: 32px;
  }

  .drop-zone p {
    font-size: 0.82rem;
  }
}
