/* ==========================================================================
   PremiumX Admin Dashboard CSS — Matching apkzone/admin Layout & EncRep Royal Aesthetics
   ========================================================================== */

:root {
  --primary:        #141F91;
  --primary-hover:  #0A1466;
  --primary-light:  #3B47D9;
  --primary-dark:   #0A1466;
  --primary-deeper: #050A3D;
  --accent-gold:    #D4A574;
  --accent-gold-deep:#B8894F;

  --bg-base:        #F5F7FC;
  --bg-primary:     #FFFFFF;
  --bg-secondary:   #F1F3FB;
  --bg-card:        #FFFFFF;

  --border:         #C8CDF5;
  --border-light:   #E3E6F3;
  --border-card:    #E3E6F3;

  --text:           #0A0F2E;
  --text-secondary: #475069;
  --text-muted:     #6B7494;

  --grad-primary: linear-gradient(135deg, #0A1466 0%, #141F91 100%);
  --grad-gold:    linear-gradient(135deg, #B8894F 0%, #D4A574 100%);
  --grad-indigo:  linear-gradient(135deg, #0A1466 0%, #141F91 100%);
  --grad-emerald: linear-gradient(135deg, #059669 0%, #10B981 100%);
  --grad-cyan:    linear-gradient(135deg, #0891B2 0%, #06B6D4 100%);

  --r: 14px;
  --r-lg: 18px;
  --font: 'Cairo', 'Tajawal', sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font);
  background: var(--bg-base);
  color: var(--text);
  direction: rtl;
  line-height: 1.7;
}

/* Admin Header */
.admin-header {
  background: linear-gradient(135deg, var(--primary-deeper), var(--primary-dark));
  color: #FFFFFF;
  padding: 10px 20px;
  border-bottom: 2px solid var(--accent-gold-deep);
  box-shadow: 0 4px 20px rgba(5, 10, 61, 0.3);
}

.admin-header-container {
  max-width: 1400px; margin: 0 auto;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
}

.brand { display: flex; align-items: center; gap: 10px; }
.admin-logo-icon {
  width: 36px; height: 36px;
  background: var(--grad-gold);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: #FFFFFF; font-size: 18px;
}

.brand-text h1 { font-size: 17px; font-weight: 900; line-height: 1; }
.brand-gold { color: var(--accent-gold); }
.brand-text p { font-size: 10px; color: #A8B0E5; margin-top: 1px; }

.admin-nav-links { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.admin-nav-links a {
  color: #C8CDF5; font-size: 12px; font-weight: 700; text-decoration: none;
  display: inline-flex; align-items: center; gap: 4px; padding: 5px 10px; border-radius: 8px;
  transition: all 0.2s ease;
}

.admin-nav-links a .material-icons {
  font-size: 16px;
}

.admin-nav-links a.active, .admin-nav-links a:hover {
  color: #FFFFFF; background: rgba(255, 255, 255, 0.15);
}

.admin-role-tag {
  background: rgba(212, 165, 116, 0.2); border: 1px solid var(--accent-gold);
  color: var(--accent-gold); padding: 4px 10px; border-radius: 16px;
  font-size: 11px; font-weight: 800; display: flex; align-items: center; gap: 4px;
}

/* Admin Layout */
.admin-layout { max-width: 1400px; margin: 32px auto; padding: 0 32px; }

/* Metrics Grid */
.metrics-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 20px; margin-bottom: 32px;
}

.metric-card {
  background: var(--bg-card); border-radius: var(--r-lg); padding: 22px;
  border: 1.5px solid var(--border-card); box-shadow: 0 4px 16px rgba(20,31,145,0.06);
  display: flex; align-items: center; gap: 16px;
}

.metric-icon {
  width: 54px; height: 54px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  color: #FFFFFF; font-size: 24px;
}

.metric-info span { font-size: 12px; color: var(--text-muted); font-weight: 700; }
.metric-info h3 { font-size: 24px; font-weight: 900; color: var(--primary-deeper); margin-top: 2px; }

/* Management Section */
.management-section {
  background: var(--bg-card); border-radius: var(--r-lg);
  border: 1.5px solid var(--border-card); padding: 28px;
  box-shadow: 0 4px 16px rgba(20,31,145,0.06);
}

.section-top-bar {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 24px; padding-bottom: 16px; border-bottom: 1px solid var(--border-light);
}

.top-title h2 { font-size: 20px; font-weight: 900; color: var(--primary-deeper); display: flex; align-items: center; gap: 8px; }
.top-title p { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

.btn-add-app {
  background: var(--grad-primary); color: #FFFFFF; border: none;
  padding: 12px 22px; border-radius: 12px; font-weight: 800; font-size: 14px;
  cursor: pointer; display: flex; align-items: center; gap: 8px;
  box-shadow: 0 4px 14px rgba(20, 31, 145, 0.3);
}

/* Table Controls */
.table-controls { display: flex; gap: 16px; margin-bottom: 20px; }
.search-input-box { flex: 1; position: relative; }
.search-input-box input {
  width: 100%; padding: 10px 42px 10px 16px; border: 1.5px solid var(--border-light);
  border-radius: 10px; font-size: 13px;
}
.search-input-box span { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }

.select-category {
  padding: 10px 16px; border: 1.5px solid var(--border-light); border-radius: 10px;
  font-size: 13px; font-weight: 700; color: var(--text); background: #FFFFFF;
}

/* Admin Table */
.table-responsive { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th {
  background: var(--bg-secondary); color: var(--primary-deeper);
  padding: 14px; text-align: right; font-weight: 800; border-bottom: 2px solid var(--border-light);
}
.admin-table td { padding: 14px; border-bottom: 1px solid var(--border-light); vertical-align: middle; }
.admin-table tr:hover { background: #F8FAFC; }

.table-app-cell { display: flex; align-items: center; gap: 12px; }
.table-app-icon { width: 46px; height: 46px; border-radius: 12px; object-fit: cover; border: 1px solid var(--border-light); }
.table-app-info h5 { font-size: 14px; font-weight: 800; color: var(--primary-deeper); }
.table-app-info span { font-size: 11px; color: var(--text-muted); }

.badge-status { padding: 3px 8px; border-radius: 6px; font-size: 11px; font-weight: 800; }
.badge-vip { background: #FEF3C7; color: #92400E; }
.badge-featured { background: #E0E7FF; color: #3730A3; }

.action-btns { display: flex; gap: 8px; }
.btn-edit { background: #E0F2FE; color: #0369A1; border: none; padding: 6px 12px; border-radius: 8px; font-weight: 800; cursor: pointer; display: flex; align-items: center; gap: 4px; }
.btn-delete { background: #FEE2E2; color: #B91C1C; border: none; padding: 6px 12px; border-radius: 8px; font-weight: 800; cursor: pointer; display: flex; align-items: center; gap: 4px; }

/* Modal Form */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(5, 10, 61, 0.8); backdrop-filter: blur(6px);
  display: none; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity 0.3s ease;
}
.modal-overlay.active { display: flex; opacity: 1; pointer-events: auto; }

.admin-modal-card {
  background: #FFFFFF; border-radius: var(--r-lg); width: 92%; max-width: 820px;
  max-height: 90vh; overflow-y: auto; padding: 32px; position: relative;
  box-shadow: 0 25px 50px rgba(0,0,0,0.4);
}

.modal-close {
  position: absolute; top: 16px; left: 16px; background: var(--bg-secondary);
  border: none; width: 36px; height: 36px; border-radius: 50%; cursor: pointer;
}

.modal-title-bar { margin-bottom: 24px; padding-bottom: 12px; border-bottom: 2px solid var(--bg-secondary); }
.modal-title-bar h3 { font-size: 20px; font-weight: 900; color: var(--primary-deeper); display: flex; align-items: center; gap: 8px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full-width { grid-column: 1 / -1; margin-top: 8px; }
.form-group label { font-size: 12px; font-weight: 800; color: var(--text); }
.form-group input, .form-group select, .form-group textarea {
  padding: 10px 14px; border: 1.5px solid var(--border-light); border-radius: 10px; font-size: 13px;
}

.form-checkboxes { display: flex; gap: 24px; margin: 20px 0; }
.checkbox-label { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; cursor: pointer; }

.form-actions { display: flex; gap: 12px; margin-top: 24px; }
.btn-submit { flex: 1; background: var(--grad-primary); color: #FFFFFF; border: none; padding: 12px; border-radius: 10px; font-weight: 800; font-size: 14px; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; }
.btn-cancel { background: var(--bg-secondary); border: 1px solid var(--border-light); padding: 12px 24px; border-radius: 10px; font-weight: 700; cursor: pointer; }

/* Rich Text Editor Toolbar Styling */
.rich-editor-wrapper {
  border: 1.5px solid var(--border-light);
  border-radius: 12px;
  overflow: hidden;
  background: #FFFFFF;
  margin-top: 6px;
}

.rich-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border-bottom: 1.5px solid var(--border-light);
  flex-wrap: wrap;
}

.tb-btn {
  background: #FFFFFF;
  border: 1px solid var(--border);
  color: var(--text);
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tb-btn:hover {
  background: var(--primary-light);
  color: #FFFFFF;
  border-color: var(--primary-light);
}

.tb-select {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 700;
  background: #FFFFFF;
  color: var(--text);
  cursor: pointer;
}

.tb-separator {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 4px;
}

.rich-editor-content {
  min-height: 180px;
  max-height: 400px;
  overflow-y: auto;
  padding: 16px;
  font-size: 14px;
  line-height: 1.8;
  outline: none;
  color: var(--text);
}

.rich-editor-content:focus {
  background: #FAFAFE;
}

.rich-editor-content blockquote {
  border-right: 4px solid var(--primary-light);
  background: var(--bg-secondary);
  padding: 10px 16px;
  margin: 10px 0;
  font-style: italic;
  border-radius: 6px;
}

.rich-editor-content pre {
  font-family: monospace;
  background: #1E293B;
  color: #38BDF8;
  padding: 12px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 10px 0;
  direction: ltr;
  text-align: left;
}

.rich-editor-content .spoiler {
  background: #0F172A;
  color: #0F172A;
  padding: 2px 8px;
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
}

.rich-editor-content .spoiler:hover {
  color: #FFFFFF;
}

/* Mobile & Android Responsiveness for Admin Dashboard */
@media (max-width: 900px) {
  .admin-header {
    padding: 16px;
  }

  .admin-header-container {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
  }

  .admin-nav-links {
    overflow-x: auto;
    white-space: nowrap;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }

  .form-grid {
    grid-template-columns: 1fr !important;
  }

  .table-controls {
    flex-direction: column;
  }

  .admin-layout {
    padding: 0 14px;
    margin: 16px auto;
  }

  .management-section {
    padding: 18px !important;
  }

  .rich-toolbar {
    gap: 4px;
  }

  .tb-btn {
    width: 32px;
    height: 32px;
  }
}

/* ============================================================
   Admin Modal Styling (Fixes Modal Display & Overlay)
============================================================ */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeInModal 0.2s ease-out;
}

.modal-overlay.active {
  display: flex !important;
}

.admin-modal-card {
  background: #FFFFFF;
  border-radius: 18px;
  box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(0, 0, 0, 0.05);
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  animation: slideUpModal 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-close {
  position: absolute;
  top: 18px;
  left: 18px;
  background: #F1F5F9;
  border: 1px solid #E2E8F0;
  color: #64748B;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  z-index: 10;
}

.modal-close:hover {
  background: #EF4444;
  color: #FFFFFF;
  border-color: #EF4444;
  transform: rotate(90deg);
}

.modal-title-bar {
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1.5px solid #F1F5F9;
}

.modal-title-bar h3 {
  font-size: 18px;
  font-weight: 800;
  color: #0F172A;
  display: flex;
  align-items: center;
  gap: 10px;
}

@keyframes fadeInModal {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUpModal {
  from { transform: translateY(20px) scale(0.97); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}


