/* =============================================
   Agency Portal — Dark Glassmorphism Theme
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-body: #0f111a;
  --bg-panel: #161925;
  --bg-glass: rgba(22, 25, 37, 0.65);
  --border-glass: rgba(255, 255, 255, 0.08);
  --accent: #6c63ff;
  --accent-glow: rgba(108, 99, 255, 0.35);
  --text: #ffffff;
  --text-muted: #8b8fa3;
  --danger: #ff4d6a;
  --success: #00e676;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

html { font-size: 15px; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg-body);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }

/* ---- Animated Background ---- */
.bg-mesh {
  position: fixed; inset: 0; z-index: -1; overflow: hidden;
}
.bg-mesh .orb {
  position: absolute; border-radius: 50%; filter: blur(120px); opacity: 0.18; animation: orbFloat 18s ease-in-out infinite alternate;
}
.bg-mesh .orb:nth-child(1) { width: 600px; height: 600px; background: #6c63ff; top: -10%; left: -5%; }
.bg-mesh .orb:nth-child(2) { width: 500px; height: 500px; background: #00e676; bottom: -15%; right: -8%; animation-delay: -6s; }
.bg-mesh .orb:nth-child(3) { width: 400px; height: 400px; background: #ff4d6a; top: 40%; left: 50%; animation-delay: -12s; }

@keyframes orbFloat {
  0%   { transform: translate(0, 0) scale(1); }
  50%  { transform: translate(40px, -30px) scale(1.15); }
  100% { transform: translate(-20px, 20px) scale(0.95); }
}

/* ---- Login Page ---- */
.login-wrapper {
  display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px;
}
.login-card {
  background: var(--bg-glass);
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius);
  padding: 48px 40px;
  width: 100%; max-width: 420px;
  box-shadow: var(--shadow);
  animation: fadeSlideUp 0.6s ease-out;
}
.login-card h1 {
  font-size: 1.75rem; font-weight: 800; text-align: center; margin-bottom: 6px;
  background: linear-gradient(135deg, #6c63ff, #00e676);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.login-card .subtitle { text-align: center; color: var(--text-muted); margin-bottom: 32px; font-size: 0.9rem; }

/* ---- Form Elements ---- */
.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-muted); margin-bottom: 8px; }
.form-group input, .form-group textarea, .form-group select {
  width: 100%; padding: 14px 16px; border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04); border: 1px solid var(--border-glass);
  color: var(--text); font-family: inherit; font-size: 0.95rem;
  transition: var(--transition); outline: none;
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-group input:hover, .form-group textarea:hover {
  transform: scale(1.02); box-shadow: 0 4px 16px rgba(0,0,0,0.25);
}
.form-group textarea { resize: vertical; min-height: 80px; }

.form-error { color: var(--danger); font-size: 0.85rem; text-align: center; margin-bottom: 16px; min-height: 20px; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 28px; border: none; border-radius: var(--radius-sm);
  font-family: inherit; font-size: 0.9rem; font-weight: 600;
  cursor: pointer; transition: var(--transition); outline: none; white-space: nowrap;
}
.btn:hover { transform: scale(1.02); box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3); }
.btn:active { transform: scale(0.98); }

.btn-primary { background: linear-gradient(135deg, #6c63ff, #536dfe); color: #fff; }
.btn-primary:hover { box-shadow: 0 6px 28px var(--accent-glow); }

.btn-success { background: linear-gradient(135deg, #00c853, #00e676); color: #fff; }
.btn-danger  { background: linear-gradient(135deg, #ff1744, #ff4d6a); color: #fff; }
.btn-ghost   { background: rgba(255,255,255,0.06); color: var(--text-muted); border: 1px solid var(--border-glass); }
.btn-ghost:hover { background: rgba(255,255,255,0.1); color: var(--text); }

.btn-sm { padding: 8px 16px; font-size: 0.8rem; border-radius: 8px; }
.btn-block { width: 100%; }

.btn-icon {
  width: 36px; height: 36px; padding: 0; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.06); border: 1px solid var(--border-glass);
  color: var(--text-muted); cursor: pointer; transition: var(--transition);
}
.btn-icon:hover { background: rgba(255,255,255,0.12); color: var(--text); transform: scale(1.1); }
.btn-icon.edit:hover { color: #6c63ff; }
.btn-icon.delete:hover { color: #ff4d6a; }

/* ---- Dashboard Layout ---- */
.dashboard { padding: 24px 32px; max-width: 1400px; margin: 0 auto; animation: fadeSlideUp 0.5s ease-out; }

.top-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  margin-bottom: 28px; flex-wrap: wrap;
}
.top-bar .brand { font-size: 1.4rem; font-weight: 800; background: linear-gradient(135deg, #6c63ff, #00e676); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.top-bar .user-info { display: flex; align-items: center; gap: 12px; }
.top-bar .user-badge {
  padding: 6px 14px; border-radius: 20px; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
}
.user-badge.admin { background: rgba(108, 99, 255, 0.2); color: #a29bfe; border: 1px solid rgba(108,99,255,0.3); }
.user-badge.user  { background: rgba(0, 230, 118, 0.15); color: #69f0ae; border: 1px solid rgba(0,230,118,0.25); }

.btn-logout { background: rgba(255, 77, 106, 0.12); color: #ff4d6a; border: 1px solid rgba(255,77,106,0.2); padding: 8px 20px; border-radius: 10px; font-weight: 600; cursor: pointer; transition: var(--transition); font-family: inherit; font-size: 0.85rem; }
.btn-logout:hover { background: rgba(255,77,106,0.25); transform: scale(1.02); }

/* ---- Search & Actions Bar ---- */
.controls-bar {
  display: flex; align-items: center; gap: 16px; margin-bottom: 24px; flex-wrap: wrap;
}
.search-box {
  flex: 1; min-width: 280px; position: relative;
}
.search-box .search-icon {
  position: absolute; left: 18px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 1.1rem; pointer-events: none;
}
.search-box input {
  width: 100%; padding: 16px 20px 16px 50px;
  background: var(--bg-glass); backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass); border-radius: var(--radius);
  color: var(--text); font-size: 1rem; font-family: inherit;
  transition: var(--transition); outline: none;
}
.search-box input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.search-box input:hover { transform: scale(1.02); box-shadow: 0 4px 20px rgba(0,0,0,0.3); }
.search-box input::placeholder { color: var(--text-muted); }

/* ---- Data Table ---- */
.table-wrapper {
  background: var(--bg-glass);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.data-table { width: 100%; border-collapse: collapse; }
.data-table thead th {
  padding: 16px 18px; font-size: 0.75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted);
  background: rgba(0, 0, 0, 0.25); text-align: left;
  border-bottom: 1px solid var(--border-glass);
  position: sticky; top: 0; z-index: 2;
}

.data-table tbody tr {
  transition: var(--transition); cursor: default;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  background: transparent;
}
.data-table tbody tr:nth-child(even) { background: rgba(255, 255, 255, 0.02); }
.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.06);
  transform: scale(1.01); box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  z-index: 1; position: relative;
}
.data-table tbody tr:last-child { border-bottom: none; }

.data-table td {
  padding: 14px 18px; font-size: 0.9rem;
  color: var(--text);
  max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.data-table td.comment-cell { max-width: 260px; }

/* Clickable Cells */
.cell-copy, .cell-link {
  cursor: pointer; position: relative; border-radius: 6px; padding: 4px 8px; margin: -4px -8px;
  transition: var(--transition);
}
.cell-copy:hover { background: rgba(255, 255, 255, 0.1); }
.cell-link:hover { background: rgba(108, 99, 255, 0.2); text-decoration: underline; }

.actions-cell { display: flex; gap: 6px; white-space: nowrap; }

/* ---- Empty State ---- */
.empty-state {
  text-align: center; padding: 64px 24px; color: var(--text-muted);
}
.empty-state .icon { font-size: 3rem; margin-bottom: 16px; opacity: 0.4; }
.empty-state p { font-size: 1rem; }

/* ---- Stats ---- */
.stats-bar { display: flex; gap: 8px; align-items: center; color: var(--text-muted); font-size: 0.85rem; margin-bottom: 16px; }
.stats-bar .count { color: var(--accent); font-weight: 700; }

/* ---- Pagination ---- */
.pagination-bar {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 16px; padding: 0 8px; flex-wrap: wrap; gap: 16px;
}
.pagination-bar .rows-per-page {
  display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: 0.85rem;
}
.pagination-bar .rows-per-page select {
  background: var(--bg-glass); border: 1px solid var(--border-glass); color: var(--text);
  padding: 6px 12px; border-radius: var(--radius-sm); outline: none; font-family: inherit; font-size: 0.85rem;
}
.pagination-bar .page-controls {
  display: flex; align-items: center; gap: 12px; color: var(--text-muted); font-size: 0.85rem;
}
.pagination-bar .page-controls .btn-icon:disabled {
  opacity: 0.3; cursor: not-allowed; transform: none; background: transparent;
}

/* ---- Modal ---- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; visibility: hidden; transition: var(--transition); padding: 24px;
}
.modal-overlay.active { opacity: 1; visibility: visible; }

.modal {
  background: var(--bg-panel);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius);
  padding: 36px; width: 100%; max-width: 520px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
  transform: translateY(24px) scale(0.96);
  transition: var(--transition);
}
.modal-overlay.active .modal { transform: translateY(0) scale(1); }

.modal h2 {
  font-size: 1.3rem; font-weight: 700; margin-bottom: 24px;
  display: flex; align-items: center; gap: 10px;
}
.modal-actions {
  display: flex; justify-content: flex-end; gap: 12px; margin-top: 28px;
}

/* Delete Confirmation */
.delete-body { text-align: center; padding: 12px 0; }
.delete-body .warn-icon { font-size: 3rem; margin-bottom: 12px; }
.delete-body p { color: var(--text-muted); font-size: 0.95rem; }
.delete-body .record-name { color: var(--text); font-weight: 700; }

/* ---- Toast ---- */
.toast-container { position: fixed; bottom: 28px; right: 28px; z-index: 2000; display: flex; flex-direction: column; gap: 10px; }
.toast {
  padding: 14px 24px; border-radius: var(--radius-sm);
  background: var(--bg-panel); border: 1px solid var(--border-glass);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  color: var(--text); font-size: 0.9rem; font-weight: 500;
  display: flex; align-items: center; gap: 10px;
  animation: toastIn 0.35s ease-out;
  min-width: 220px;
}
.toast.success { border-left: 4px solid var(--success); }
.toast.error   { border-left: 4px solid var(--danger); }
.toast.info    { border-left: 4px solid var(--accent); }
.toast.fade-out { animation: toastOut 0.3s ease-in forwards; }

@keyframes toastIn  { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(40px); } }

/* ---- Loading Spinner ---- */
.spinner { display: inline-block; width: 20px; height: 20px; border: 2.5px solid rgba(255,255,255,0.2); border-top-color: #fff; border-radius: 50%; animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.page-loader {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 100vh; gap: 16px;
}
.page-loader .spinner { width: 40px; height: 40px; border-width: 3px; }

/* ---- Animations ---- */
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---- Responsive ---- */
@media (max-width: 900px) {
  .dashboard { padding: 16px; }
  .top-bar { flex-direction: column; align-items: flex-start; }
  .controls-bar { flex-direction: column; }
  .search-box { min-width: 100%; }
  .table-wrapper { overflow-x: auto; }
  .data-table { min-width: 800px; }
}

@media (max-width: 480px) {
  .login-card { padding: 32px 24px; }
  .modal { padding: 28px 20px; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }
