/* ===================================================================
   tsPanel — style.css
   Font: Source Sans Pro | Icons: Lucide | Framework: Bootstrap 4

   STRUCTURE:
   Section 1: Root color overrides
   Section 2: Global overrides (not Bootstrap, not page-specific)
   Section 3: Bootstrap overrides
   Section 4: Page-specific rules
   =================================================================== */


/* ===================================================================
   Section 1: ROOT COLOR OVERRIDES
   Change colors in one central place. Use var() everywhere else.
   =================================================================== */

:root {
  /* Brand */
  --color-primary: #326b9b;
  --color-primary-dark: #2a5a85;

  /* Sidebar */
  --sidebar-width: 230px;
  --sidebar-bg: #2c3e50;
  --sidebar-brand-bg: #1a252f;
  --sidebar-text: #bdc3c7;
  --sidebar-text-hover: #ecf0f1;
  --sidebar-active-bg: var(--color-primary);
  --sidebar-divider: rgba(255,255,255,0.1);
  --overlay-bg: #7777;
  --text-white: #FFF;
  --accent: #3080a7;
  --danger: #dc3545;
  --bg-white: #FFF;
  --border: #dee2e6;
  --text-primary: #212529;
  --accent: #3080a7;
  --danger: #dc3545;
  --bg-white: #FFF;
  --border: #dee2e6;
  --text-primary: #212529;
  --sidebar-label-color: rgba(255,255,255,0.35);

  /* Login */
  --login-bg: #f5f6fa;

  /* Content */
  --content-bg: #f5f6fa;

  /* Cards */
  --card-header-bg: #f8f9fa;
  --card-border: #e9ecef;

  /* Text */
  --text-heading: #2c3e50;

  /* Log viewer */
  --log-bg: #1e1e1e;
  --log-text: #d4d4d4;
}


/* ===================================================================
   Section 2: GLOBAL OVERRIDES
   Not Bootstrap-specific. Not page-specific.
   =================================================================== */

html, body {
  font-family: 'Source Sans Pro', sans-serif;
}

code {
  font-size: 0.8rem;
}

.progress {
  border-radius: 3px;
}

.badge {
  font-weight: 600;
  font-size: 0.75rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.spin {
  animation: spin 1s linear infinite;
}

/* Bootstrap label margin override */
label {
  margin-bottom: .1rem;
}

/* Lucide icon sizing */
svg.lucide {
  width: 16px;
  height: 16px;
  vertical-align: middle;
}

svg.lucide.icon-sm {
  width: 14px;
  height: 14px;
}

svg.lucide.icon-md {
  width: 16px;
  height: 16px;
}

svg.lucide.icon-lg {
  width: 18px;
  height: 18px;
}

svg.lucide.icon-xl {
  width: 32px;
  height: 32px;
}

svg.lucide.icon-xxl {
  width: 48px;
  height: 48px;
}


/* ===================================================================
   Section 3: BOOTSTRAP OVERRIDES
   Customize Bootstrap defaults.
   =================================================================== */

.card {
  border: 1px solid var(--card-border);
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.card-header {
  background: var(--card-header-bg);
  border-bottom: 1px solid var(--card-border);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-heading);
  padding: 10px 16px;
}

.card-body {
  padding: 16px;
}

.table {
  font-size: 0.85rem;
}

.table th {
  font-weight: 600;
  color: var(--text-heading);
  border-top: none;
  white-space: nowrap;
}

.table td {
  vertical-align: middle;
}


/* ===================================================================
   Section 4: PAGE-SPECIFIC RULES
   Organized by page ID: #pgX
   =================================================================== */

/* --- Login page --- */

#pglogin
{
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--login-bg);
}

#pglogin .login-box
{
  width: 100%;
  max-width: 360px;
  padding: 16px;
}

#pglogin .login-logo
{
  text-align: center;
  margin-bottom: 1.5rem;
}

#pglogin .login-logo svg
{
  width: 48px;
  height: 48px;
  color: var(--color-primary);
}

#pglogin .login-logo h2
{
  margin: .5rem 0 0;
  font-weight: 700;
  color: var(--text-heading);
}

#pglogin .login-logo p
{
  margin: 0;
  color: #6c757d;
}


/* --- Sidebar layout --- */

.admin-wrap
{
  display: flex;
  min-height: 100vh;
}

.admin-sidebar
{
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 1000;
  overflow-y: auto;
}

.sidebar-brand
{
  padding: 16px 20px;
  background: var(--sidebar-brand-bg);

  text-align: center;
}

.sidebar-brand h2
{
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  text-align: left;
}


.sidebar-brand a
{
  color: var(--sidebar-text-hover);
  text-decoration: none;
}

.sidebar-brand a:hover
{
  color: #fff;
}

.sidebar-nav
{
  list-style: none;
  padding: 0;

  margin: 0;
  flex: 1;
}

.sidebar-nav li a
{
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;

  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.85rem;
  transition: background 0.15s, color 0.15s;
}

.sidebar-nav li a:hover
{
  background: rgba(255,255,255,0.08);
  color: var(--sidebar-text-hover);
}

.sidebar-nav li a.active
{
  background: var(--sidebar-active-bg);
  color: #fff;
}

.sidebar-nav li a svg,
.sidebar-nav li a i
{
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.sidebar-divider
{
  height: 1px;
  background: var(--sidebar-divider);
  margin: 8px 0;
}

.sidebar-label
{
  padding: 8px 20px 4px;

  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--sidebar-label-color);
}

.sidebar-user
{
  padding: 12px 20px;

  border-top: 1px solid var(--sidebar-divider);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.8rem;
  color: rgba(255,255,255,0.5);
}

.sidebar-user svg,
.sidebar-user i
{
  width: 18px;
  height: 18px;
}

.sidebar-toggle
{
  display: none;
  background: none;
  border: none;
  color: var(--text-heading);
  font-size: 1.25rem;
  padding: 4px 8px;

  cursor: pointer;
}

.admin-main
{
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 0;

  min-height: 100vh;
}

.admin-header
{
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;

  background: #fff;
  border-bottom: 1px solid var(--card-border);
}

.admin-header h1
{
  margin: 0;
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--text-heading);
}

.header-actions
{
  display: flex;
  gap: 8px;
  align-items: center;
}

.admin-content
{
  padding: 20px 24px;

}


/* --- Log viewer --- */

.log-viewer
{
  min-height: 74vh;
  background: var(--log-bg);
  color: var(--log-text);
  padding: 16px;

  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 0.8rem;
  line-height: 1.6;
  overflow: auto;
  max-height: 500px;
  margin: 0;
  white-space: pre-wrap;
  word-wrap: break-word;
}


/* ===================================================================
   Section 5: UTILITY CLASSES
   Replaces common inline style patterns.
   =================================================================== */

/* Lucide icon sizes */
.icon-sm
{
  width: 14px;
  height: 14px;
}

.icon-md
{
  width: 16px;
  height: 16px;
}

.icon-lg
{
  width: 18px;
  height: 18px;
}

.icon-xl
{
  width: 32px;
  height: 32px;
}

.icon-xxl
{
  width: 48px;
  height: 48px;
}

/* Progress bar widths */
.progress-200
{
  max-width: 200px;
}

/* Search input */
.search-input
{
  width: 250px;
}

/* Adminer iframe */
.adminer-frame
{
  width: 100%;
  height: calc(100vh - 280px);
  border: none;
  display: block;
}

/* Spam score input */
.spam-score-input
{
  max-width: 200px;
}

.progress-thick
{
  height: 24px;
}
.hidden { display: none; }

/* Metric stat card values */
.stat-value {
  font-size: 18px;
  font-weight: bold;
}

/* ===================================================================
   Section 6: DRAWER / FLYOUT
   Slide-in drawers from the right side
   =================================================================== */

/* Overlay behind drawer */
.drawer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.45);
  z-index: 2000;
  transition: opacity 0.2s;
}

/* Drawer container */
.drawer {
  position: fixed;
  top: 0;
  right: -450px;
  width: 430px;
  max-width: 100vw;
  height: 100vh;
  background: #fff;
  z-index: 2001;
  box-shadow: -4px 0 16px rgba(0,0,0,0.15);
  transition: right 0.25s ease-in-out;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.drawer.open {
  right: 0;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--card-border);
  flex-shrink: 0;
}

.drawer-header h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-heading);
}

.drawer-header h3 svg.lucide {
  margin-right: 6px;
}

.drawer-close {
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: #6c757d;
  border-radius: 4px;
  line-height: 1;
  display: flex;
  align-items: center;
}

.drawer-close:hover {
  background: #f0f0f0;
  color: #212529;
}

.drawer-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

/* Row clickable — hand cursor */
.row-clickable {
  cursor: pointer;
}

.row-clickable:hover {
  background: #f0f4f8 !important;
}

/* Fix for datatables hover override */
.table-hover tbody tr.row-clickable:hover {
  background: #f0f4f8 !important;
}

/* Drawer form groups */
.drawer .form-group {
  margin-bottom: 1rem;
}

/* Drawer alerts */
.drawer .alert {
  padding: 8px 12px;
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

/* Responsive drawer */
@media (max-width: 576px) {
  .drawer {
    width: 100vw;
    right: -100vw;
  }
}
