/* =============================================
   MIVA INTELLIGENCE — Admin Panel Styles
   POW-02 Premium Redesign
   ============================================= */

/* ── LOGIN SCREEN ── */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  background: var(--bg-primary);
}
.login-bg {
  position: absolute; inset: 0;
  overflow: hidden;
}
.login-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  animation: breathe 10s ease-in-out infinite;
}
.login-orb.orb-a {
  width: 500px; height: 500px;
  background: var(--miva-blue);
  opacity: 0.12;
  top: -150px; left: -100px;
}
.login-orb.orb-b {
  width: 400px; height: 400px;
  background: var(--miva-teal);
  opacity: 0.1;
  bottom: -100px; right: -80px;
  animation-delay: 3s;
}
.login-box {
  width: 100%;
  max-width: 420px;
  padding: 40px;
  position: relative;
  z-index: 2;
  animation: fadeInScale 0.6s ease forwards;
}
.login-logo {
  height: 48px;
  margin: 0 auto 20px;
}
.login-title {
  font-size: 1.5rem;
  font-weight: 800;
  text-align: center;
  margin-bottom: 4px;
}
.login-sub {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 28px;
}
.login-links {
  text-align: center;
  margin-top: 16px;
}
.login-links a {
  font-size: 0.82rem;
  color: var(--miva-blue);
  font-weight: 500;
}
.login-links a:hover { text-decoration: underline; }
.login-footer-link {
  text-align: center;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border-light);
}
.login-footer-link a {
  font-size: 0.82rem;
  color: var(--text-muted);
}
.login-footer-link a:hover { color: var(--miva-blue); }

/* 2FA */
.twofa-info {
  text-align: center;
  margin-bottom: 24px;
}
.twofa-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
}
.twofa-info p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
}
.twofa-info small {
  font-size: 0.78rem;
  color: var(--text-muted);
}
.otp-inputs {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 8px;
}
.otp-digit {
  width: 48px; height: 56px;
  border: 1.5px solid var(--input-border);
  border-radius: var(--radius-md);
  background: var(--input-bg);
  color: var(--text-primary);
  font-size: 1.4rem;
  font-weight: 700;
  text-align: center;
  font-family: inherit;
  transition: var(--transition-fast);
}
.otp-digit:focus {
  outline: none;
  border-color: var(--miva-blue);
  box-shadow: 0 0 0 3px var(--input-focus);
}

/* ── ADMIN LAYOUT ── */
.admin-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

/* ── SIDEBAR ── */
.admin-sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
}
.sidebar-header {
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border-subtle);
}
.sidebar-logo {
  height: auto;
  width: 170px;
  max-width: 85%;
  display: block;
  margin: 6px auto;
}
.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-fast);
  position: relative;
}
.sidebar-link:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}
.sidebar-link.active {
  background: var(--miva-gradient-soft);
  color: var(--miva-blue);
  font-weight: 600;
}
.sidebar-link.active::before {
  content: '';
  position: absolute;
  left: 0; top: 6px; bottom: 6px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--miva-gradient-v);
}
.sidebar-link.sub { padding-left: 26px; }
.slink-icon { font-size: 1.05rem; width: 22px; text-align: center; flex-shrink: 0; }
.slink-label { flex: 1; }
.slink-badge {
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.68rem;
  font-weight: 700;
  background: var(--info-bg);
  color: var(--info);
}
.sidebar-group-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 20px 14px 6px;
}
.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border-subtle);
}
.admin-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.admin-av {
  width: 36px; height: 36px;
  border-radius: var(--radius-md);
  background: var(--miva-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}
.admin-profile strong { font-size: 0.82rem; display: block; }
.admin-profile span { font-size: 0.7rem; color: var(--text-muted); }
.sidebar-footer-links {
  display: flex;
  gap: 6px;
}

/* ── MAIN CONTENT ── */
.admin-main {
  background: var(--bg-secondary);
  padding: 0;
  overflow-y: auto;
  height: 100vh;
}

/* Topbar */
.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-left { display: flex; align-items: center; gap: 14px; }
.module-title { font-size: 1.2rem; font-weight: 700; }
.topbar-date { font-size: 0.78rem; color: var(--text-muted); }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-avatar {
  width: 34px; height: 34px;
  border-radius: var(--radius-md);
  background: var(--miva-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
}

/* Module Views */
.module-view {
  display: none;
  padding: 24px 28px;
  animation: fadeIn 0.3s ease;
}
.module-view.active { display: block; }

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

/* Charts Row */
.charts-row {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  margin-bottom: 24px;
}
.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px;
}
.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.chart-header h3 { font-size: 0.95rem; font-weight: 600; }

/* Plan Legend */
.plan-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
  justify-content: center;
}
.plan-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  color: var(--text-secondary);
}
.plan-legend-item span {
  width: 10px; height: 10px;
  border-radius: 3px;
  display: inline-block;
}

/* Module Toolbar */
.module-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
}
.toolbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Table Pagination */
.table-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0 0;
  border-top: 1px solid var(--border-light);
  margin-top: 16px;
}
.pagination-btns {
  display: flex;
  gap: 4px;
}

/* Plans Admin Grid */
.plans-admin-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
.plan-admin-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative;
}
.plan-admin-card.popular-plan {
  border-color: rgba(37,99,235,0.3);
}
.plan-admin-badge {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--miva-blue);
  margin-bottom: 8px;
}
.plan-admin-name { font-size: 1.1rem; font-weight: 800; margin-bottom: 4px; }
.plan-admin-clients { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 16px; }
.plan-admin-field { margin-bottom: 12px; }
.plan-admin-field label { font-size: 0.72rem; color: var(--text-muted); font-weight: 600; margin-bottom: 4px; display: block; }
.price-input-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
}
.price-input-wrap span {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
}
.plan-price-input {
  width: 100px;
  padding: 6px 10px;
  font-size: 0.9rem;
  font-weight: 700;
}
.plan-admin-actions {
  display: flex;
  gap: 6px;
  margin-top: 16px;
}

/* Reports Grid */
.reports-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.report-card {
  cursor: pointer;
  padding: 24px;
}
.report-card:hover {
  transform: translateY(-2px);
}
.report-icon {
  font-size: 1.8rem;
  margin-bottom: 12px;
}
.report-card h4 { font-size: 0.95rem; margin-bottom: 6px; }
.report-card p { font-size: 0.78rem; color: var(--text-secondary); margin-bottom: 12px; line-height: 1.5; }

/* Maintenance Tabs */
.maint-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 4px;
  width: fit-content;
}
.maint-tab {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-fast);
  background: transparent;
  border: none;
}
.maint-tab:hover { color: var(--text-primary); }
.maint-tab.active {
  background: var(--bg-card);
  color: var(--text-primary);
  box-shadow: var(--shadow-xs);
}

/* ── RESPONSIVE ── */
@media (max-width: 1200px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .charts-row { grid-template-columns: 1fr; }
  .charts-row .chart-card { max-width: none !important; }
  .plans-admin-grid { grid-template-columns: repeat(2, 1fr); }
  .reports-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .admin-layout { grid-template-columns: 1fr; }
  .admin-sidebar {
    position: fixed;
    left: -280px;
    width: 260px;
    z-index: 100;
    transition: left 0.3s ease;
  }
  .admin-sidebar.open { left: 0; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .module-view { padding: 16px; }
  .admin-topbar { padding: 12px 16px; }
  .plans-admin-grid { grid-template-columns: 1fr; }
  .reports-grid { grid-template-columns: 1fr; }
}

/* ── Lucide Icon Overrides ── */
.admin-sidebar .nav-icon {
  width: 18px;
  height: 18px;
  stroke-width: 2.5px;
  color: var(--text-secondary);
  transition: var(--transition-fast);
  display: inline-block;
  vertical-align: middle;
}
.sidebar-link.active .nav-icon {
  color: var(--miva-blue);
}
.report-icon svg {
  width: 28px;
  height: 28px;
  color: var(--miva-blue);
  stroke-width: 2px;
}

/* ── Collapsible Submenu & Custom Sidebar Chevron ── */
.sidebar-sub-links {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-left: 10px;
  margin-bottom: 8px;
  border-left: 1.5px solid var(--border-subtle);
  margin-left: 24px;
}
.sidebar-link.parent {
  justify-content: space-between;
}
.nav-icon-chevron {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  stroke-width: 2.5px;
  transition: transform 0.3s ease;
  flex-shrink: 0;
}
.sidebar-link.parent.open .nav-icon-chevron {
  transform: rotate(180deg);
}

/* ── CRUD Modal Styles ── */
.miva-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
  animation: fadeIn 0.3s ease;
}
.miva-modal.show {
  display: flex;
}
.modal-content {
  width: 100%;
  max-width: 620px;
  max-height: 90vh;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  display: flex;
  flex-direction: column;
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}
.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition-fast);
  line-height: 1;
}
.modal-close:hover {
  color: var(--text-primary);
}
.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: var(--bg-secondary);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.modal-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.modal-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--miva-blue);
  margin: 16px 0 10px;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 4px;
}

/* ── Permissions Matrix Table ── */
.roles-matrix-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.72rem;
  margin-top: 10px;
}
.roles-matrix-table th, .roles-matrix-table td {
  border: 1px solid var(--border-subtle);
  padding: 6px 8px;
  text-align: center;
}
.roles-matrix-table th {
  background: var(--bg-secondary);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.65rem;
  color: var(--text-secondary);
  letter-spacing: 0.04em;
}
.roles-matrix-table td:first-child {
  text-align: left;
  font-weight: 600;
  color: var(--text-primary);
}
.roles-matrix-table input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--miva-blue);
}

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