/* ============================================================
   StockBot — Components: Cards, Tables, Badges, Alerts
   ============================================================ */

/* --- KPI Cards --- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.kpi-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.kpi-label {
  font-size: 0.75rem;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}

.kpi-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-text);
}

.kpi-delta {
  font-size: 0.75rem;
  margin-top: 0.25rem;
}

.kpi-delta.up { color: var(--color-success); }
.kpi-delta.down { color: var(--color-danger); }

/* --- Card --- */
.card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
}

/* --- Badge --- */
.badge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
}

.badge-ok     { background: #C6F6D5; color: #22543D; }
.badge-warn   { background: #FEFCBF; color: #744210; }
.badge-danger { background: #FED7D7; color: #9B2C2C; }

/* --- Alert / Toast --- */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  color: #fff;
  font-size: 0.875rem;
  box-shadow: var(--shadow-md);
  animation: slideIn 0.3s ease;
}

.toast-success { background: var(--color-success); }
.toast-error   { background: var(--color-danger); }
.toast-warning { background: var(--color-warning); }
.toast-info    { background: var(--color-info); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* --- Data Table --- */
.data-table-wrapper {
  overflow-x: auto;
}

.data-table th {
  position: sticky;
  top: 0;
  background: var(--color-surface);
}

.data-table tr:hover td {
  background: var(--color-bg);
}

/* --- Filter Bar --- */
.filter-bar {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.filter-bar input[type="search"] {
  min-width: 200px;
}

/* --- Empty State --- */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--color-muted);
}

.empty-state .icon {
  font-size: 3rem;
  margin-bottom: 0.5rem;
}

/* --- Header Buttons --- */
.btn-verify-line,
.btn-bot-setup {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem 0.75rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn-verify-line {
  background: linear-gradient(135deg, #06c755 0%, #00b900 100%);
  color: white;
}

.btn-verify-line:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(6, 199, 85, 0.3);
}

.btn-bot-setup {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.btn-bot-setup:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
}

#line-status-icon {
  font-size: 1rem;
  transition: transform 0.3s ease;
}

.btn-verify-line:active #line-status-icon {
  transform: rotate(360deg);
}

/* --- LINE Status Container --- */
.line-status-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.line-status-label {
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  font-weight: 500;
}

.btn-verify-line {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 0.75rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  background: #f8d7da;
  color: #721c24;
  text-decoration: none;
}

.btn-verify-line.connected {
  background: #d4edda;
  color: #155724;
  pointer-events: none;
  cursor: default;
}

.btn-verify-line.disconnected {
  background: #f8d7da;
  color: #721c24;
}

.btn-verify-line:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.btn-verify-line.connected:hover {
  transform: none;
  box-shadow: none;
}

#line-status-icon {
  font-size: 1rem;
  transition: transform 0.3s ease;
}

/* --- Success Button --- */
.btn-success {
  background: var(--color-success);
  color: white;
}

.btn-success:hover {
  background: #2f855a;
}

/* --- Modal --- */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 10000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-content {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  border-bottom: 1px solid var(--color-border);
}

.modal-body {
  padding: 1.5rem;
}

/* --- Logout Button --- */
.btn-logout {
  padding: 0.5rem 0.75rem;
  border: none;
  border-radius: var(--radius);
  background: #dc3545;
  color: white;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-logout:hover {
  background: #c82333;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(220, 53, 69, 0.3);
}

/* --- Login Button --- */
.btn-login {
  padding: 0.5rem 0.75rem;
  border: none;
  border-radius: var(--radius);
  background: #28a745;
  color: white;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn-login:hover {
  background: #218838;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(40, 167, 69, 0.3);
}

/* --- User Display --- */
.user-display {
  font-size: 0.875rem;
  color: var(--color-text);
  font-weight: 500;
}
