/* ============================================================
   MATH QUIZ APP - ADMIN PANEL STYLES (FINAL)
   ============================================================
   Sidebar collapsible, header 2-row, filter modal, form standardization
   ============================================================ */

/* ------------------------------------------------------------
   1. ADMIN LAYOUT
   ------------------------------------------------------------ */
.admin-layout {
  display: flex;
  min-height: 100vh;
}

/* ------------------------------------------------------------
   2. SIDEBAR (LEFT, COLLAPSIBLE)
   ------------------------------------------------------------ */
.admin-sidebar {
  width: 260px;
  background: #1a1a2e;
  color: #fff;
  transition: width 0.3s ease;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 1000;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

.admin-sidebar.collapsed {
  width: 64px;
}

.admin-sidebar .sidebar-header {
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  min-height: 60px;
}

.admin-sidebar .sidebar-brand {
  font-weight: 700;
  font-size: 1.1rem;
  white-space: nowrap;
  overflow: hidden;
}

.admin-sidebar.collapsed .sidebar-brand {
  display: none;
}

.sidebar-toggle {
  background: none;
  border: none;
  color: #ffc107;
  cursor: pointer;
  font-size: 1.25rem;
  padding: 0.25rem;
  flex-shrink: 0;
}

.admin-sidebar .sidebar-nav {
  flex: 1;
  padding: 0.75rem 0;
}

.admin-sidebar .sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  transition: all 0.2s;
  white-space: nowrap;
  overflow: hidden;
  font-size: 0.9rem;
}

.admin-sidebar .sidebar-link:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
}

.admin-sidebar .sidebar-link.active {
  background: rgba(255,193,7,0.15);
  color: #ffc107;
  border-right: 3px solid #ffc107;
}

.admin-sidebar .sidebar-link i {
  font-size: 1.1rem;
  width: 22px;
  text-align: center;
  flex-shrink: 0;
}

.admin-sidebar.collapsed .sidebar-link span {
  display: none;
}

.admin-sidebar .sidebar-footer {
  padding: 0.75rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,0.1);
}

/* ------------------------------------------------------------
   3. MAIN CONTENT AREA
   ------------------------------------------------------------ */
.admin-main {
  flex: 1;
  margin-left: 260px;
  transition: margin-left 0.3s ease;
  min-width: 0;
  background: #f5f6fa;
}

.admin-main.expanded {
  margin-left: 64px;
}

/* ------------------------------------------------------------
   4. HEADER (2 ROWS)
   ------------------------------------------------------------ */
.admin-header {
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.admin-header-row1 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  flex-wrap: wrap;
  min-height: 56px;
}

.admin-page-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #1a1a2e;
  margin: 0;
  white-space: nowrap;
}

.admin-search-group {
  display: flex;
  align-items: center;
  flex: 1;
  max-width: 400px;
  min-width: 200px;
}

.admin-search-group input {
  height: 42px;
  border: 1px solid #e0e0e0;
  border-radius: 12px 0 0 12px;
  padding: 0.5rem 1rem;
  flex: 1;
  font-size: 0.85rem;
  font-family: 'Roboto Slab', serif;
  background: #fafbfc;
}

.admin-search-group input:focus {
  outline: none;
  border-color: #0b5ed7;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(11,94,215,0.06);
}

.admin-search-btn {
  height: 42px;
  background: #0b5ed7;
  color: #fff;
  border: none;
  border-radius: 0 12px 12px 0;
  padding: 0 1rem;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.2s;
  display: flex;
  align-items: center;
}

.admin-search-btn:hover {
  background: #0a4fa8;
}

.admin-filter-btn {
  background: #fafbfc;
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  height: 42px;
  padding: 0 1rem;
  cursor: pointer;
  color: #555;
  transition: all 0.2s;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
}

.admin-filter-btn:hover {
  background: #f0f3f8;
  border-color: #0b5ed7;
}

.admin-header-actions {
  margin-left: auto;
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
  align-items: center;
}

.admin-header-row2 {
  padding: 0 1rem;
  border-top: 1px solid #f0f0f0;
}

.admin-tabs {
  display: flex;
  gap: 0;
  border-bottom: none;
  margin-bottom: 0;
}

.admin-tabs .nav-link {
  padding: 0.65rem 1rem;
  color: #666;
  font-weight: 600;
  border: none;
  border-bottom: 3px solid transparent;
  font-size: 0.85rem;
  white-space: nowrap;
  transition: all 0.2s;
  border-radius: 0 !important;
}

.admin-tabs .nav-link:hover {
  color: #0b5ed7;
  background: transparent;
}

.admin-tabs .nav-link.active {
  color: #0b5ed7;
  border-bottom-color: #0b5ed7;
  background: transparent;
}

/* ------------------------------------------------------------
   5. CONTENT BODY
   ------------------------------------------------------------ */
.admin-content {
  padding: 1.25rem;
}

/* ------------------------------------------------------------
   6. FORM STANDARDIZATION (Stylish like old input)
   ------------------------------------------------------------ */
.form-control,
.form-select {
  height: 42px;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  font-family: 'Roboto Slab', serif;
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  transition: all 0.2s ease;
  background: #fafbfc;
  color: #333;
}

.form-control:hover,
.form-select:hover {
  border-color: #c0c0c0;
}

.form-control:focus,
.form-select:focus {
  border-color: #0b5ed7;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(11, 94, 215, 0.06);
  outline: none;
}

.form-control-sm,
.form-select-sm {
  height: 48px;
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  border-radius: 10px;
}

.form-control-lg {
  height: 50px;
  padding: 0.65rem 1.25rem;
  font-size: 1rem;
  border-radius: 14px;
}

textarea.form-control {
  height: auto;
  min-height: 80px;
  padding: 0.65rem 1rem;
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23888' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 16px;
  padding-right: 2.5rem;
}

input[type="date"].form-control,
input[type="date"].form-control-sm {
  padding-right: 0.75rem;
}

.form-control::placeholder {
  color: #bbb;
}

.form-control:disabled,
.form-select:disabled {
  background: #f0f0f0;
  color: #999;
  cursor: not-allowed;
  border-color: #e0e0e0;
}

.form-label {
  margin-bottom: 0.3rem;
  font-size: 0.82rem;
  color: #555;
}

/* ------------------------------------------------------------
   7. CHECKBOX
   ------------------------------------------------------------ */
table .form-check-input {
  width: 16px;
  height: 16px;
  margin-top: 0;
  cursor: pointer;
}

thead .form-check-input {
  width: 16px;
  height: 16px;
}

/* ------------------------------------------------------------
   8. ACTION ICON BUTTONS (COMPACT)
   ------------------------------------------------------------ */
.btn-action-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 0.8rem;
  transition: all 0.15s;
  line-height: 1;
}

.btn-action-icon i {
  font-size: 0.85rem;
}

.btn-action-icon:hover {
  transform: scale(1.08);
}

/* ------------------------------------------------------------
   9. STAT CARDS
   ------------------------------------------------------------ */
.admin-stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ------------------------------------------------------------
   10. STATUS BADGES
   ------------------------------------------------------------ */
.badge-active {
  background: #e6f4ea;
  color: #2e7d32;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
}

.badge-inactive {
  background: #f5f5f5;
  color: #999;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
}

/* ------------------------------------------------------------
   11. PAGINATION
   ------------------------------------------------------------ */
.pagination-btn {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #ddd;
  border-radius: 8px;
  background: #fff;
  color: #555;
  cursor: pointer;
  font-size: 0.85rem;
  font-family: 'Roboto Slab', serif;
  transition: all 0.15s;
}

.pagination-btn:hover:not(.active):not(:disabled) {
  background: #f0f0f0;
  border-color: #0b5ed7;
  color: #0b5ed7;
}

.pagination-btn.active {
  background: #0b5ed7;
  border-color: #0b5ed7;
  color: #fff;
}

.pagination-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ------------------------------------------------------------
   12. FILTER MODAL
   ------------------------------------------------------------ */
.filter-modal .modal-content {
  border-radius: 16px;
  border: none;
}

.filter-modal .modal-header {
  background: #1a1a2e;
  color: #fff;
  border-radius: 16px 16px 0 0;
}

.filter-modal .modal-body {
  padding: 1.25rem;
}

/* ------------------------------------------------------------
   13. FUNCTION CODE DISPLAY
   ------------------------------------------------------------ */
.function-code {
  background: #1a1a2e;
  color: #a8d8ea;
  padding: 0.75rem;
  border-radius: 8px;
  font-family: 'Courier New', monospace;
  font-size: 0.78rem;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre-wrap;
  max-height: 400px;
  overflow-y: auto;
  margin-bottom: 0;
}

.function-code-editor {
  background: #1a1a2e;
  color: #a8d8ea;
  font-family: 'Courier New', monospace;
  font-size: 0.78rem;
  line-height: 1.5;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 0.75rem;
  resize: vertical;
  min-height: 300px;
}

.function-code-editor:focus {
  border-color: #0b5ed7;
  box-shadow: 0 0 0 3px rgba(11,94,215,0.1);
  outline: none;
}

/* ------------------------------------------------------------
   14. LOG ENTRIES
   ------------------------------------------------------------ */
.log-entry {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid #f0f0f0;
  transition: background 0.15s;
}

.log-entry:hover {
  background: #fafafa;
}

.log-entry:last-child {
  border-bottom: none;
}

.log-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.85rem;
}

.log-icon.login { background: #e6f4ea; color: #2e7d32; }
.log-icon.logout { background: #f5f5f5; color: #999; }
.log-icon.update { background: #e8f0fe; color: #0b5ed7; }
.log-icon.delete { background: #fde8e8; color: #c62828; }
.log-icon.create { background: #e6f4ea; color: #2e7d32; }

/* ------------------------------------------------------------
   15. CUSTOM SCROLLBAR
   ------------------------------------------------------------ */
.modal-body::-webkit-scrollbar,
.modal-content::-webkit-scrollbar,
.function-code::-webkit-scrollbar,
.function-code-editor::-webkit-scrollbar,
.table-responsive::-webkit-scrollbar,
.admin-content::-webkit-scrollbar,
.admin-sidebar::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

.modal-body::-webkit-scrollbar-track,
.modal-content::-webkit-scrollbar-track,
.function-code::-webkit-scrollbar-track,
.function-code-editor::-webkit-scrollbar-track,
.table-responsive::-webkit-scrollbar-track,
.admin-content::-webkit-scrollbar-track,
.admin-sidebar::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 10px;
}

.modal-body::-webkit-scrollbar-thumb,
.modal-content::-webkit-scrollbar-thumb,
.function-code::-webkit-scrollbar-thumb,
.function-code-editor::-webkit-scrollbar-thumb,
.table-responsive::-webkit-scrollbar-thumb,
.admin-content::-webkit-scrollbar-thumb {
  background: #d0d0d0;
  border-radius: 10px;
}

.modal-body::-webkit-scrollbar-thumb:hover,
.modal-content::-webkit-scrollbar-thumb:hover,
.function-code::-webkit-scrollbar-thumb:hover,
.function-code-editor::-webkit-scrollbar-thumb:hover,
.table-responsive::-webkit-scrollbar-thumb:hover,
.admin-content::-webkit-scrollbar-thumb:hover {
  background: #aaa;
}

.admin-sidebar::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.2);
}

.admin-sidebar::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.35);
}

.modal-body,
.modal-content,
.function-code,
.function-code-editor,
.table-responsive,
.admin-content,
.admin-sidebar {
  scrollbar-width: thin;
  scrollbar-color: #d0d0d0 transparent;
}

.admin-sidebar {
  scrollbar-color: rgba(255,255,255,0.2) transparent;
}

/* ------------------------------------------------------------
   16. MODAL
   ------------------------------------------------------------ */
.modal-body {
  scroll-behavior: smooth;
  max-height: 70vh;
  overflow-y: auto;
  padding: 1.25rem;
}

.modal.fade .modal-dialog {
  transition: transform 0.25s ease-out, opacity 0.2s ease-out;
}

.modal.show .modal-dialog {
  transform: translateY(0);
}

.modal-header {
  padding: 0.75rem 1.25rem;
}

.modal-footer {
  padding: 0.75rem 1.25rem;
}

/* Pricing Modal */
#pricing-modal .modal-header {
  border-radius: 12px 12px 0 0;
}

/* ------------------------------------------------------------
   17. DELETE CONFIRM INPUT
   ------------------------------------------------------------ */
#delete-confirm-input,
#delete-type-confirm {
  border: 2px dashed #e0e0e0;
  border-radius: 12px;
  padding: 0.65rem 1rem;
  font-size: 0.9rem;
  font-family: 'Courier New', monospace;
  letter-spacing: 1.5px;
  text-align: center;
  transition: all 0.25s;
  background: #fafbfc;
  height: 42px;
}

#delete-confirm-input:focus,
#delete-type-confirm:focus {
  border-color: #c62828;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(198,40,40,0.08);
  outline: none;
}

#delete-confirm-input.match,
#delete-type-confirm.match {
  border-color: #2e7d32;
  border-style: solid;
  background: #f1f8e9;
  box-shadow: 0 0 0 4px rgba(46,125,50,0.08);
}

/* ------------------------------------------------------------
   18. RESPONSIVE
   ------------------------------------------------------------ */
@media (max-width: 992px) {
  .admin-sidebar { width: 64px; }
  .admin-sidebar .sidebar-brand,
  .admin-sidebar .sidebar-link span { display: none; }
  .admin-main { margin-left: 64px; }
  .admin-header-row1 { flex-direction: column; align-items: flex-start; }
  .admin-header-actions { margin-left: 0; }
}

@media (max-width: 768px) {
  .admin-sidebar { width: 0; overflow: hidden; }
  .admin-sidebar.mobile-open { width: 260px; }
  .admin-main { margin-left: 0; }
  .admin-search-group { max-width: 100%; }
}

/* ------------------------------------------------------------
   19. IMAGE UPLOAD AREA
   ------------------------------------------------------------ */
.image-upload-area {
  border: 2px dashed #d0d0d0;
  border-radius: 12px;
  padding: 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.25s;
  background: #fafbfc;
  min-height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-upload-area:hover {
  border-color: #0b5ed7;
  background: #f0f6ff;
}

.image-upload-area.dragover {
  border-color: #0b5ed7;
  background: #e8f0fe;
  box-shadow: 0 0 0 4px rgba(11,94,215,0.1);
}

.upload-placeholder p {
  margin: 0;
  color: #555;
}

/* Crop Container */
.crop-container {
  max-height: 50vh;
  background: #1a1a2e;
  border-radius: 8px;
  overflow: hidden;
}

.crop-container img {
  display: block;
  max-width: 100%;
  max-height: 50vh;
}

/* Image Preview Wrapper */
.image-preview-wrapper {
  position: relative;
  display: inline-block;
  width: 100%;
}

.image-remove-btn {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 0.7rem;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

/* ------------------------------------------------------------
   20. CAMPAIGN THUMBNAIL & ZOOM
   ------------------------------------------------------------ */
.campaign-thumb {
  width: 120px;
  height: 15px;
  object-fit: cover;
  border-radius: 4px;
  cursor: pointer;
  transition: transform 0.15s;
}

.campaign-thumb:hover {
  transform: scale(1.1);
}

.thumb-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 9998;
  cursor: pointer;
}

.thumb-preview {
  display: none;
  position: fixed;
  z-index: 9999;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  max-width: 90vw;
  max-height: 80vh;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

/* ------------------------------------------------------------
   ADD BUTTON (for dropdown inline add)
   ------------------------------------------------------------ */
.btn-add-inline {
    border: 2px solid #ced4da;
    background: #f8f9fa;
    color: #495057;
    font-weight: 700;
    font-size: 0.9rem;
    padding: 4px 10px;
    border-radius: 0 8px 8px 0;
    transition: all 0.2s ease;
}

.btn-add-inline:hover {
    background: #e9ecef;
    border-color: #adb5bd;
    color: #212529;
}

.btn-add-inline i {
    font-size: 0.75rem;
}