/* ======================================
   AUTOMATE SOLUTIONS — ADMIN DASHBOARD
   Premium Dark Design System
   ====================================== */

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

/* ---- CSS Variables ---- */
:root {
  /* Palette */
  --brand-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);
  --brand-primary: #6366f1;
  --brand-primary-hover: #4f46e5;
  --brand-secondary: #8b5cf6;
  --brand-glow: rgba(99, 102, 241, 0.3);

  /* Surfaces */
  --bg-base: #0d0f14;
  --bg-surface: #13161f;
  --bg-elevated: #1a1e2e;
  --bg-hover: #1f2435;
  --bg-card: #161922;

  /* Sidebar */
  --sidebar-bg: #0f1117;
  --sidebar-width: 240px;

  /* Borders */
  --border-subtle: rgba(255, 255, 255, 0.05);
  --border-default: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);

  /* Text */
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #4b5563;
  --text-accent: #a5b4fc;

  /* Status */
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.12);
  --success-border: rgba(16, 185, 129, 0.25);

  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.12);
  --warning-border: rgba(245, 158, 11, 0.25);

  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.12);
  --danger-border: rgba(239, 68, 68, 0.25);

  --info: #3b82f6;
  --info-bg: rgba(59, 130, 246, 0.12);
  --info-border: rgba(59, 130, 246, 0.25);

  --purple: #a855f7;
  --purple-bg: rgba(168, 85, 247, 0.12);

  /* Topbar */
  --topbar-height: 64px;

  /* Misc */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 24px var(--brand-glow);
  --transition: 0.18s ease;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  display: flex;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ======================================
   SIDEBAR
   ====================================== */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 100;
  transition: width 0.25s ease, transform 0.25s ease;
  overflow: hidden;
}

/* Collapsed state on desktop */
.sidebar.collapsed {
  width: 64px;
}

.sidebar.collapsed .brand-text,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .sidebar-status span,
.sidebar.collapsed .sidebar-collapse-label {
  opacity: 0;
  width: 0;
  overflow: hidden;
  white-space: nowrap;
}

.sidebar.collapsed .sidebar-brand {
  justify-content: center;
  padding: 20px 12px;
}

.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 10px 0;
}

.sidebar.collapsed .sidebar-footer {
  padding: 16px 12px;
  justify-content: center;
}

.sidebar.collapsed .sidebar-status {
  justify-content: center;
}

.sidebar.collapsed .collapse-btn {
  justify-content: center;
}

.sidebar.collapsed .collapse-btn svg {
  transform: rotate(180deg);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 18px;
  border-bottom: 1px solid var(--border-subtle);
  transition: padding 0.25s ease, justify-content 0.25s ease;
}

.brand-icon {
  width: 40px; height: 40px;
  background: var(--brand-gradient);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  flex-shrink: 0;
  box-shadow: var(--shadow-glow);
}

.brand-text {
  transition: opacity 0.2s ease;
}

.brand-name {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.brand-sub {
  display: block;
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 400;
}

/* Sidebar Nav */
.sidebar-nav {
  padding: 16px 10px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  text-align: left;
  position: relative;
  white-space: nowrap;
}

.nav-item span {
  transition: opacity 0.2s ease;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: rgba(99, 102, 241, 0.15);
  color: var(--text-accent);
  box-shadow: inset 0 0 0 1px rgba(99, 102, 241, 0.2);
}

.nav-item.active .nav-icon {
  color: var(--brand-primary);
}

.nav-icon {
  width: 18px; height: 18px;
  flex-shrink: 0;
  transition: color var(--transition);
}

/* Collapse button */
.collapse-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  margin-top: 8px;
  white-space: nowrap;
  overflow: hidden;
}

.collapse-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.collapse-btn svg {
  flex-shrink: 0;
  transition: transform 0.25s ease;
}

.sidebar-collapse-label {
  transition: opacity 0.2s ease;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 16px 18px;
  border-top: 1px solid var(--border-subtle);
  transition: padding 0.25s ease;
}

.sidebar-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
  flex-shrink: 0;
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 99;
  backdrop-filter: blur(2px);
  animation: fadeIn 0.2s ease;
}

.sidebar-overlay.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ======================================
   MAIN WRAPPER
   ====================================== */
.main-wrapper {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left 0.25s ease;
}

body.sidebar-collapsed .main-wrapper {
  margin-left: 64px;
}

/* ======================================
   TOPBAR
   ====================================== */
.topbar {
  height: var(--topbar-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(12px);
}

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

.topbar-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
}

.menu-toggle {
  display: none;
  width: 36px; height: 36px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

/* Login form in topbar */
.login-form {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

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

.input-icon {
  position: absolute;
  left: 10px;
  width: 15px; height: 15px;
  color: var(--text-muted);
  pointer-events: none;
}

.input-group input {
  padding-left: 34px;
  width: 180px;
}

/* ======================================
   FORM ELEMENTS
   ====================================== */
input, select, textarea {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13.5px;
  padding: 8px 12px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  min-height: 38px;
}

input::placeholder, textarea::placeholder { color: var(--text-muted); }

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

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

select option { background: var(--bg-elevated); }

textarea { resize: vertical; min-height: 80px; line-height: 1.5; }

/* ======================================
   BUTTONS
   ====================================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  min-height: 38px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-sm { padding: 7px 13px; font-size: 13px; min-height: 34px; }

.btn-primary {
  background: var(--brand-gradient);
  color: #fff;
  box-shadow: 0 2px 12px rgba(99, 102, 241, 0.35);
}
.btn-primary:hover:not(:disabled) {
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.55);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); }

.btn-success {
  background: var(--success-bg);
  color: var(--success);
  border-color: var(--success-border);
}
.btn-success:hover:not(:disabled) { background: rgba(16, 185, 129, 0.2); }

.btn-warning {
  background: var(--warning-bg);
  color: var(--warning);
  border-color: var(--warning-border);
}
.btn-warning:hover:not(:disabled) { background: rgba(245, 158, 11, 0.2); }

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: var(--danger-border);
}
.btn-danger:hover:not(:disabled) { background: rgba(239, 68, 68, 0.2); }

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-default);
}
.btn-outline:hover:not(:disabled) {
  border-color: var(--border-strong);
  color: var(--text-primary);
  background: var(--bg-hover);
}
.btn-outline.active-log-btn {
  border-color: var(--brand-primary);
  color: var(--text-accent);
  background: rgba(99, 102, 241, 0.1);
}

.btn-group {
  display: flex;
  gap: 6px;
}

/* ======================================
   CONTENT AREA
   ====================================== */
.content {
  padding: 28px 28px;
  flex: 1;
}

/* ======================================
   PANELS
   ====================================== */
.panel {
  display: none;
  animation: fadeSlideIn 0.22s ease both;
}

.panel.active { display: block; }

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

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.panel-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.panel-sub {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ======================================
   NOTICE / TOAST
   ====================================== */
.notice {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  font-weight: 500;
  animation: fadeSlideIn 0.2s ease;
}

.notice.notice-success {
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  color: #6ee7b7;
}

.notice.notice-error {
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: #fca5a5;
}

/* ======================================
   SEARCH INPUT
   ====================================== */
.search-input {
  min-width: 220px;
}

/* ======================================
   BROADCAST CARD
   ====================================== */
.broadcast-card {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(168, 85, 247, 0.05));
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  margin-bottom: 24px;
}

.broadcast-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-accent);
  margin-bottom: 14px;
}

.broadcast-form {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.broadcast-form textarea {
  flex: 1;
  min-height: 60px;
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(99, 102, 241, 0.2);
}

.broadcast-form textarea:focus {
  border-color: var(--brand-primary);
}

/* ======================================
   TABLE
   ====================================== */
.table-wrap {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 800px;
}

thead tr {
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-subtle);
}

th {
  text-align: left;
  padding: 12px 14px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

td {
  padding: 11px 14px;
  font-size: 13px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

tbody tr {
  transition: background var(--transition);
}

tbody tr:hover { background: var(--bg-hover); }
tbody tr:last-child td { border-bottom: none; }

/* ======================================
   STATUS PILLS
   ====================================== */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.pill::before {
  content: '';
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.pill-success { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }
.pill-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid var(--warning-border); }
.pill-danger  { background: var(--danger-bg);  color: var(--danger);  border: 1px solid var(--danger-border); }
.pill-info    { background: var(--info-bg);    color: var(--info);    border: 1px solid var(--info-border); }
.pill-purple  { background: var(--purple-bg);  color: var(--purple);  border: 1px solid rgba(168,85,247,0.25); }
.pill-default { background: var(--bg-elevated); color: var(--text-secondary); border: 1px solid var(--border-default); }

/* ======================================
   WALLET FORM
   ====================================== */
.movement-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.movement-form input {
  width: 160px;
}

/* ======================================
   FILTER SELECT
   ====================================== */
.filter-select {
  min-width: 160px;
}

/* ======================================
   HOT OFFER TOGGLE
   ====================================== */
.toggle-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
}

.toggle {
  position: relative;
  width: 40px;
  height: 22px;
  cursor: pointer;
}

.toggle input {
  opacity: 0;
  width: 0; height: 0;
  position: absolute;
  min-height: unset;
  border: none;
  background: none;
  padding: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: 999px;
  transition: all var(--transition);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 14px; height: 14px;
  top: 50%;
  left: 3px;
  transform: translateY(-50%);
  border-radius: 50%;
  background: var(--text-muted);
  transition: all var(--transition);
}

.toggle input:checked + .toggle-slider {
  background: rgba(245, 158, 11, 0.2);
  border-color: var(--warning);
}

.toggle input:checked + .toggle-slider::before {
  background: var(--warning);
  transform: translateY(-50%) translateX(18px);
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.5);
}

/* ======================================
   PLAN PRICE INPUT
   ====================================== */
.price-input {
  width: 100px !important;
  min-height: 32px !important;
  padding: 5px 8px !important;
  text-align: right;
  font-size: 12.5px !important;
}

/* ======================================
   EMPTY STATE
   ====================================== */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}
.empty-state svg { margin-bottom: 12px; opacity: 0.4; }
.empty-state p { font-size: 14px; }

/* ======================================
   SCROLLBAR
   ====================================== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ======================================
   RESPONSIVE
   ====================================== */

/* Tablet: force sidebar collapsed */
@media (max-width: 1100px) {
  .sidebar {
    width: 64px;
  }

  .sidebar .brand-text,
  .sidebar .nav-item span,
  .sidebar .sidebar-status span,
  .sidebar .sidebar-collapse-label {
    opacity: 0;
    width: 0;
    overflow: hidden;
  }

  .sidebar .sidebar-brand {
    justify-content: center;
    padding: 20px 12px;
  }

  .sidebar .nav-item {
    justify-content: center;
    padding: 10px 0;
  }

  .sidebar .sidebar-footer {
    padding: 16px 12px;
  }

  .sidebar .sidebar-status {
    justify-content: center;
  }

  .sidebar .collapse-btn {
    justify-content: center;
  }

  .sidebar .collapse-btn svg {
    transform: rotate(180deg);
  }

  .main-wrapper {
    margin-left: 64px;
  }
}

/* Mobile: off-canvas drawer */
@media (max-width: 768px) {
  .sidebar {
    width: var(--sidebar-width);
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-md);
  }

  /* Restore text labels in mobile drawer */
  .sidebar.open .brand-text,
  .sidebar.open .nav-item span,
  .sidebar.open .sidebar-status span,
  .sidebar.open .sidebar-collapse-label {
    opacity: 1;
    width: auto;
  }

  .sidebar.open .sidebar-brand {
    justify-content: flex-start;
    padding: 20px 18px;
  }

  .sidebar.open .nav-item {
    justify-content: flex-start;
    padding: 10px 12px;
  }

  .sidebar.open .sidebar-footer {
    padding: 16px 18px;
  }

  .sidebar.open .sidebar-status {
    justify-content: flex-start;
  }

  .sidebar.open .collapse-btn {
    display: none;
  }

  .main-wrapper {
    margin-left: 0;
  }

  body.sidebar-collapsed .main-wrapper {
    margin-left: 0;
  }

  .menu-toggle {
    display: inline-flex;
  }

  .content {
    padding: 20px 14px;
  }

  .login-form .input-group input {
    width: 130px;
  }

  .panel-header {
    flex-direction: column;
    gap: 12px;
  }

  .search-input {
    min-width: 100%;
  }

  table {
    min-width: 900px;
  }
}

@media (max-width: 580px) {
  .broadcast-form {
    flex-direction: column;
  }

  .movement-form input {
    width: 100%;
  }

  .login-form {
    gap: 6px;
  }

  .login-form .input-group input {
    width: 110px;
    font-size: 12px;
  }
}
