/* =========================================================
   TPS BILLIARDS — ADMIN CMS STYLES
   Layout: Sidebar + Main content
   ========================================================= */
:root {
  --primary: #111111;
  --primary-dark: #000000;
  --primary-light: #FDE8E8;
  --accent: #DC2626;
  --success: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;
  --white: #FFFFFF;
  --gray-50: #F9FAFB;
  --gray-100: #F3F4F6;
  --gray-200: #E5E7EB;
  --gray-300: #D1D5DB;
  --gray-400: #9CA3AF;
  --gray-500: #6B7280;
  --gray-700: #374151;
  --gray-900: #111827;
  --sidebar-w: 240px;
  --topbar-h: 60px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

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

body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--gray-700);
  background: var(--gray-50);
  line-height: 1.5;
}

/* ===== LAYOUT ===== */
.admin-layout {
  display: flex;
  min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--primary);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform .25s ease;
}

.sidebar-brand {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.12);
}
.sidebar-brand .logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
}
.sidebar-brand .logo-icon {
  width: 34px; height: 34px;
  background: rgba(255,255,255,.2);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}
.sidebar-brand .badge-admin {
  font-size: 10px;
  background: var(--accent);
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
  margin-left: 4px;
  vertical-align: middle;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}

.nav-section {
  padding: 12px 16px 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(255,255,255,.45);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  color: rgba(255,255,255,.8);
  text-decoration: none;
  border-radius: 6px;
  margin: 1px 8px;
  font-size: 14px;
  transition: background .15s, color .15s;
}
.nav-link i { width: 18px; text-align: center; font-size: 14px; }
.nav-link:hover { background: rgba(255,255,255,.1); color: #fff; }
.nav-link.active { background: rgba(255,255,255,.18); color: #fff; font-weight: 600; }

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,.12);
}
.btn-logout {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  color: rgba(255,255,255,.7);
  background: none; border: none;
  cursor: pointer; font-size: 14px; width: 100%;
  border-radius: 6px;
  transition: background .15s, color .15s;
}
.btn-logout:hover { background: rgba(255,255,255,.1); color: #fff; }

/* ===== MAIN CONTENT ===== */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ===== TOPBAR ===== */
.topbar {
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 50;
}
.topbar-title { font-size: 16px; font-weight: 600; color: var(--gray-900); }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar-user {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--gray-500);
}
.topbar-user .avatar {
  width: 32px; height: 32px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}

/* ===== PAGE CONTENT ===== */
.page-content { padding: 24px; }

/* ===== STATS CARDS ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 16px;
}
.stat-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.stat-icon.blue   { background: var(--primary-light); color: var(--primary); }
.stat-icon.green  { background: #D1FAE5; color: var(--success); }
.stat-icon.orange { background: #FEF3C7; color: var(--warning); }
.stat-icon.red    { background: #FEE2E2; color: var(--danger); }
.stat-label { font-size: 12px; color: var(--gray-500); margin-bottom: 2px; }
.stat-value { font-size: 22px; font-weight: 700; color: var(--gray-900); }

/* ===== CARD ===== */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.card-title { font-size: 15px; font-weight: 600; color: var(--gray-900); }
.card-body { padding: 20px; }
.card-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ===== TABLE ===== */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
thead th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--gray-500);
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}
tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--gray-50); }

.td-img { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; }
.td-name { font-weight: 500; color: var(--gray-900); max-width: 220px; }
.td-name small { display: block; font-weight: 400; color: var(--gray-500); font-size: 11px; margin-top: 1px; }

/* ===== BADGES / STATUS ===== */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-success { background: #D1FAE5; color: #065F46; }
.badge-warning { background: #FEF3C7; color: #92400E; }
.badge-danger  { background: #FEE2E2; color: #991B1B; }
.badge-info    { background: #DBEAFE; color: #1E40AF; }
.badge-gray    { background: var(--gray-100); color: var(--gray-600); }
.badge-primary { background: var(--primary-light); color: var(--primary); }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: opacity .15s, background .15s, transform .1s;
  white-space: nowrap;
}
.btn:hover { opacity: .88; }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-accent  { background: var(--accent); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-outline {
  background: transparent;
  color: var(--gray-700);
  border: 1px solid var(--gray-300);
}
.btn-outline:hover { background: var(--gray-100); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon {
  width: 30px; height: 30px;
  padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 6px;
}

/* ===== FORM CONTROLS ===== */
.form-group { margin-bottom: 16px; }
label { display: block; font-size: 12px; font-weight: 600; color: var(--gray-700); margin-bottom: 4px; }
input[type="text"], input[type="number"], input[type="url"], input[type="email"],
select, textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-size: 13px;
  font-family: var(--font);
  background: var(--white);
  color: var(--gray-900);
  transition: border .15s, box-shadow .15s;
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,35,126,.12);
}
textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }

/* ===== SEARCH BAR ===== */
.search-box {
  position: relative;
  min-width: 200px;
}
.search-box input {
  padding-left: 32px;
}
.search-box i {
  position: absolute; left: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
  font-size: 13px;
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--white);
  border-radius: 12px;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(.95) translateY(-10px);
  transition: transform .2s;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.modal-overlay.open .modal { transform: scale(1) translateY(0); }
.modal-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 15px; font-weight: 600; }
.modal-close {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border: none; background: none; cursor: pointer;
  color: var(--gray-500);
  border-radius: 6px;
  font-size: 16px;
}
.modal-close:hover { background: var(--gray-100); color: var(--gray-900); }
.modal-body { padding: 20px; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--gray-100);
  display: flex; justify-content: flex-end; gap: 8px;
}

/* ===== TOGGLE SWITCH ===== */
.toggle-wrap { display: flex; align-items: center; gap: 8px; }
.toggle {
  position: relative;
  width: 40px; height: 22px;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: var(--gray-300);
  border-radius: 22px;
  cursor: pointer;
  transition: background .2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
}
.toggle input:checked + .toggle-slider { background: var(--success); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--gray-400);
}
.empty-state i { font-size: 48px; margin-bottom: 16px; }
.empty-state p { font-size: 14px; }

/* ===== PAGINATION ===== */
.pagination {
  display: flex; align-items: center; gap: 4px;
  justify-content: center;
  padding: 16px 0;
}
.page-btn {
  min-width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px;
  border: 1px solid var(--gray-200);
  background: var(--white);
  cursor: pointer;
  font-size: 13px;
  color: var(--gray-700);
  transition: all .15s;
  padding: 0 8px;
}
.page-btn:hover { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ===== LOGIN PAGE ===== */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}
.login-card {
  background: var(--white);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.login-logo {
  text-align: center; margin-bottom: 28px;
}
.login-logo .icon {
  width: 64px; height: 64px;
  background: var(--primary-light);
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; color: var(--primary);
  margin: 0 auto 12px;
}
.login-logo h1 { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.login-logo p  { font-size: 13px; color: var(--gray-500); }
.login-error {
  background: #FEE2E2;
  color: #991B1B;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}
.login-error.show { display: block; }

/* ===== TOAST ===== */
.toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 9999;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  background: var(--gray-900);
  color: #fff;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: var(--shadow-md);
  animation: toastIn .25s ease;
  max-width: 320px;
}
.toast.success i { color: var(--success); }
.toast.error i   { color: var(--danger); }
.toast.warning i { color: var(--warning); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ===== RESPONSIVE ===== */
.menu-toggle-btn {
  display: none;
  background: none; border: none;
  color: var(--gray-700); font-size: 18px; cursor: pointer;
}

@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .menu-toggle-btn { display: flex; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .page-content { padding: 16px; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
}

/* ===== MISC ===== */
.text-muted  { color: var(--gray-500); }
.text-sm     { font-size: 12px; }
.text-right  { text-align: right; }
.fw-600      { font-weight: 600; }
.mt-4        { margin-top: 4px; }
.mt-8        { margin-top: 8px; }
.mt-16       { margin-top: 16px; }
.mt-24       { margin-top: 24px; }
.gap-8       { gap: 8px; }
.d-flex      { display: flex; }
.align-center { align-items: center; }
.flex-wrap   { flex-wrap: wrap; }
.img-preview {
  width: 100%; max-height: 160px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--gray-200);
  margin-top: 6px;
  display: none;
}
.img-preview.show { display: block; }
.color-dot {
  display: inline-block;
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,.15);
  vertical-align: middle;
}

/* ===== IMAGE UPLOAD WIDGET ===== */
.upload-zone {
  border: 2px dashed var(--gray-300);
  border-radius: 8px;
  padding: 18px 14px;
  text-align: center;
  cursor: pointer;
  transition: border-color .18s, background .18s;
  background: var(--gray-50);
  position: relative;
  user-select: none;
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--primary);
  background: #EEF2FF;
}
.upload-zone.loading {
  opacity: .6;
  pointer-events: none;
}
.upload-zone input[type="file"] {
  position: absolute; inset: 0; opacity: 0;
  cursor: pointer; width: 100%; height: 100%; z-index: 1;
}
.upload-zone-icon { font-size: 22px; color: var(--gray-400); margin-bottom: 6px; }
.upload-zone-text { font-size: 13px; color: var(--gray-500); line-height: 1.4; }
.upload-zone-text strong { color: var(--primary); }
.upload-zone-sub  { font-size: 11px; color: var(--gray-400); margin-top: 3px; }

.img-thumbs {
  display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px;
}
.img-thumb {
  position: relative; width: 76px; height: 76px;
  border-radius: 6px; overflow: hidden;
  border: 1px solid var(--gray-200); flex-shrink: 0;
  background: var(--gray-100);
}
.img-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.img-thumb-del {
  position: absolute; top: 3px; right: 3px;
  width: 20px; height: 20px; border-radius: 50%;
  background: rgba(0,0,0,.55); color: #fff; border: none;
  cursor: pointer; display: flex; align-items: center;
  justify-content: center; font-size: 9px; padding: 0;
  transition: background .15s;
}
.img-thumb-del:hover { background: #EF4444; }
.upload-url-row {
  display: flex; gap: 6px; align-items: center; margin-top: 8px;
}
.upload-url-row input {
  flex: 1; font-size: 12px !important; padding: 6px 10px !important;
}
.upload-spinner {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid var(--gray-300); border-top-color: var(--primary);
  border-radius: 50%; animation: upSpin .6s linear infinite; vertical-align: middle;
}
@keyframes upSpin { to { transform: rotate(360deg); } }
