/* ==========================================================================
   FLIPVIEW MASTER ADMIN STUDIO — PREMIUM DESIGN SYSTEM
   ========================================================================== */

:root {
  --font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  --bg-app: #090d16;
  --bg-sidebar: #0d131f;
  --bg-card: #121a2a;
  --bg-card-hover: #182338;
  --bg-surface: #1e293b;
  --bg-input: #0b111c;

  --border-color: rgba(255, 255, 255, 0.08);
  --border-subtle: rgba(255, 255, 255, 0.04);
  --border-focus: rgba(56, 189, 248, 0.4);

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --primary: #38bdf8;
  --primary-hover: #0ea5e9;
  --primary-glow: rgba(56, 189, 248, 0.25);
  --primary-gradient: linear-gradient(135deg, #38bdf8 0%, #6366f1 100%);

  --accent: #f59e0b;
  --accent-purple: #a855f7;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 30px rgba(56, 189, 248, 0.2);

  --transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

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

body {
  font-family: var(--font-body);
  background-color: var(--bg-app);
  color: var(--text-main);
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   ADMIN LOGIN OVERLAY / GATE
   ========================================================================== */
.login-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at center, #131d31 0%, #070a12 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  max-width: 440px;
  width: 100%;
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  text-align: center;
  animation: fvPopIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fvPopIn {
  from { opacity: 0; transform: scale(0.92) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.brand-logo-glow {
  font-size: 2.6rem;
  width: 68px;
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.25);
  box-shadow: var(--shadow-glow);
  margin-bottom: 4px;
}

.login-brand h2 {
  font-family: var(--font-family);
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text-main);
}

.brand-badge-pill {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 3px 12px;
  background: var(--primary-gradient);
  color: #070a12;
  border-radius: var(--radius-full);
}

.login-subtitle {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 24px;
}

.login-form {
  text-align: left;
}

.input-icon-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 14px;
  font-size: 1.1rem;
  pointer-events: none;
  opacity: 0.7;
}

.input-icon-wrap .form-input {
  padding-left: 44px;
}

.btn-toggle-pwd {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.15s;
}

.btn-toggle-pwd:hover {
  opacity: 1;
}

.login-error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  line-height: 1.4;
}

.login-footer {
  margin-top: 24px;
  font-size: 0.76rem;
  color: var(--text-dim);
}

/* ==========================================================================
   APP LAYOUT & SIDEBAR
   ========================================================================== */
.app-layout {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

.sidebar {
  width: 270px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  padding: 24px 16px;
  user-select: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 10px 24px 10px;
  border-bottom: 1px solid var(--border-color);
}

.brand-logo {
  font-size: 1.8rem;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: var(--radius-sm);
}

.brand-name {
  font-family: var(--font-family);
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.5px;
}

.brand-badge {
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--primary);
}

.nav-menu {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 20px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
}

.nav-icon {
  font-size: 1.15rem;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
}

.nav-item.active {
  background: rgba(56, 189, 248, 0.1);
  color: var(--primary);
  border-color: rgba(56, 189, 248, 0.25);
  font-weight: 700;
}

.sidebar-footer {
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
  font-size: 0.8rem;
}

.admin-user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}

.admin-avatar {
  font-size: 1.2rem;
}

.admin-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.admin-email {
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-main);
}

.admin-role {
  font-size: 0.68rem;
  color: var(--primary);
  font-weight: 800;
  text-transform: uppercase;
}

.version {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-align: center;
  margin-top: 12px;
}

/* ==========================================================================
   MAIN CONTENT & TOPBAR
   ========================================================================== */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-app);
  overflow-y: auto;
  padding: 28px 36px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.topbar-title {
  font-family: var(--font-family);
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text-main);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ==========================================================================
   STATS CARDS GRID
   ========================================================================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.stat-card:hover {
  border-color: rgba(255, 255, 255, 0.16);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-icon {
  font-size: 2rem;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-sm);
}

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

.stat-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.stat-value {
  font-family: var(--font-family);
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.1;
}

.stat-sub {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-top: 4px;
}

/* ==========================================================================
   OVERVIEW & PLAN DISTRIBUTION
   ========================================================================== */
.overview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.plan-breakdown-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 14px;
}

.plan-bar-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.plan-bar-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.86rem;
  font-weight: 600;
}

.plan-bar-track {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 4px;
  overflow: hidden;
}

.plan-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.35s ease;
}

.fill-free { background: #94a3b8; }
.fill-pro { background: var(--primary); }
.fill-business { background: var(--accent-purple); }

.quick-actions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 14px;
}

.quick-btn {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: left;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.quick-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--primary);
  transform: translateY(-2px);
}

.qb-icon {
  font-size: 1.4rem;
  margin-bottom: 4px;
}

.qb-title {
  font-weight: 700;
  font-size: 0.94rem;
  color: var(--text-main);
}

.qb-desc {
  font-size: 0.76rem;
  color: var(--text-muted);
  line-height: 1.35;
}

/* ==========================================================================
   TAB CONTENTS & TOOLBARS
   ========================================================================== */
.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.table-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.search-input {
  flex: 1;
}

/* ==========================================================================
   CARDS & DATA TABLES
   ========================================================================== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.card h3 {
  font-family: var(--font-family);
  font-size: 1.18rem;
  font-weight: 800;
  color: var(--text-main);
}

.subtitle {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-top: 4px;
}

.table-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
}

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

.data-table th {
  background: rgba(255, 255, 255, 0.02);
  padding: 14px 16px;
  font-weight: 700;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
}

.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.data-table tbody tr {
  transition: background 0.15s ease;
}

.data-table tbody tr:hover {
  background: var(--bg-card-hover);
}

.user-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(56, 189, 248, 0.15);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.84rem;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.pub-thumb {
  width: 44px;
  height: 58px;
  object-fit: cover;
  border-radius: 4px;
  background: #ffffff;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.pub-id-tag {
  display: inline-block;
  font-family: monospace;
  font-size: 0.74rem;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.04);
  padding: 2px 6px;
  border-radius: 4px;
  margin-top: 2px;
}

/* ==========================================================================
   BUTTONS, BADGES, AND FORMS
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--transition);
  user-select: none;
  text-decoration: none;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.78rem;
  border-radius: 6px;
}

.btn-lg {
  padding: 12px 20px;
  font-size: 0.98rem;
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: var(--primary-gradient);
  color: #070a12;
  box-shadow: 0 2px 10px rgba(56, 189, 248, 0.25);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(56, 189, 248, 0.4);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--border-color);
  color: var(--text-main);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.18);
}

.btn-accent {
  background: var(--accent);
  color: #070a12;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-success { background: rgba(16, 185, 129, 0.15); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-danger { background: rgba(239, 68, 68, 0.15); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.3); }
.badge-primary { background: rgba(56, 189, 248, 0.15); color: #38bdf8; border: 1px solid rgba(56, 189, 248, 0.3); }
.badge-purple { background: rgba(168, 85, 247, 0.15); color: #c084fc; border: 1px solid rgba(168, 85, 247, 0.3); }

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.92rem;
  font-family: inherit;
  outline: none;
  transition: var(--transition);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

/* ==========================================================================
   DROPZONE & UPLOAD PROGRESS
   ========================================================================== */
.dropzone {
  border: 2px dashed rgba(56, 189, 248, 0.3);
  border-radius: var(--radius-md);
  padding: 36px 20px;
  text-align: center;
  background: rgba(56, 189, 248, 0.02);
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 24px;
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--primary);
  background: rgba(56, 189, 248, 0.06);
}

.drop-icon { font-size: 2.6rem; margin-bottom: 8px; }
.drop-text { font-size: 1.05rem; font-weight: 700; color: var(--text-main); }
.drop-text span { color: var(--primary); text-decoration: underline; }
.drop-sub { font-size: 0.8rem; color: var(--text-dim); margin-top: 4px; }

.progress-box {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 18px;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  font-size: 0.88rem;
  margin-bottom: 8px;
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary-gradient);
  width: 0%;
  transition: width 0.2s ease;
}

.progress-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 6px;
}

/* ==========================================================================
   MODAL DIALOGS
   ========================================================================== */
.admin-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(7, 10, 18, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1500;
  padding: 20px;
}

.admin-modal-overlay.open {
  display: flex;
}

.admin-modal {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 28px;
  max-width: 520px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  animation: fvPopIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  max-height: 90vh;
  overflow-y: auto;
}

.admin-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 1.2rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s;
}

.modal-close-btn:hover {
  color: var(--danger);
}

/* ==========================================================================
   MIGRATION & SETTINGS
   ========================================================================== */
.migration-panel {
  max-width: 600px;
  margin-top: 16px;
}

.log-terminal {
  margin-top: 20px;
  background: #000000;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.terminal-head {
  background: #111827;
  padding: 8px 14px;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
}

.terminal-body {
  padding: 14px;
  font-family: monospace;
  font-size: 0.8rem;
  color: #34d399;
  max-height: 280px;
  overflow-y: auto;
  white-space: pre-wrap;
}

.settings-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 16px;
}

.setting-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

/* ==========================================================================
   GLOBAL TOAST
   ========================================================================== */
.admin-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1e293b;
  border: 1px solid var(--primary);
  color: #ffffff;
  padding: 12px 22px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 700;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(15px);
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 2500;
}

.admin-toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* ==========================================================================
   RESPONSIVE LAYOUT
   ========================================================================== */
@media (max-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .overview-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .app-layout {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    height: auto;
    padding: 14px;
  }
  .nav-menu {
    flex-direction: row;
    overflow-x: auto;
    padding-bottom: 6px;
  }
  .nav-item {
    white-space: nowrap;
  }
  .main-content {
    padding: 16px;
  }
  .stats-grid {
    grid-template-columns: 1fr;
  }
}
