/* --- THEME VARIABLES --- */
:root {
  /* Brand Colors */
  --brand-primary: #2962FF;       /* Electric Royal */
  --brand-primary-hover: #1c4fd8; 
  --brand-glow: rgba(41, 98, 255, 0.2);
  
  /* Backgrounds */
  --bg-sidebar: #050A19;          /* Midnight Blue */
  --bg-workspace: #F8F9FC;        /* Very Light Blue/Grey */
  --bg-white: #FFFFFF;
  
  /* Text */
  --text-main: #334155;           /* Slate Grey */
  --text-head: #0F172A;           /* Dark Navy */
  --text-white: #FFFFFF;
  
  /* Fonts - Standardized Brand Fonts */
  --font-stack: var(--font-body);
}

/* Top bar styles */
.top-bar {
  background-color: var(--bg-white);
  color: var(--text-head);
  height: 60px; /* Fixed height */
  padding: 0 24px;
  /* Subtle separator instead of heavy shadow */
  border-bottom: 1px solid #E2E8F0; 
  box-shadow: 0 1px 2px rgba(0,0,0,0.03); 
  display: flex;
  align-items: center;
  position: relative;
  z-index: 20; /* Ensure it stays above content scrolling */
}

.top-bar h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
}

/* Main container for sidebar and content */
.main-container {
  display: flex;
  height: calc(100vh - 60px); /* Account for top bar height */
}

/* Sidebar nav styles */
#navbar-container {
  width: 240px; 
  background-color: var(--bg-sidebar); /* Midnight Blue */
  height: 100%;
  overflow-y: auto;
  box-shadow: 3px 0 10px rgba(0,0,0,0.3);
  z-index: 10;
}

nav {
  padding: 20px 10px; /* Side padding for floating pill effect */
}

nav ul {
  list-style-type: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px; /* Spacing between menu items */
}

nav ul li {
  margin: 0;
}

nav ul li a {
  color: rgba(255, 255, 255, 0.7); /* Dim white text */
  text-decoration: none;
  display: block;
  padding: 12px 16px;
  transition: all 0.2s ease;
  font-weight: 500;
  background-color: transparent;
  border-radius: 8px; /* Rounded corners */
  font-family: var(--font-stack);
  font-size: 14px;
  letter-spacing: 0.3px;
  border: none;
}

/* Hover State - Electric Royal */
nav ul li a:hover {
  background-color: var(--brand-primary); 
  color: white;
  transform: translateX(4px); 
  box-shadow: 0 4px 12px var(--brand-glow);
}

/* Remove old pseudo-elements */
nav ul li a::before,
nav ul li a::after {
  display: none;
}

nav ul li a:active {
  transform: scale(0.98);
}

/* Main content area */
#content-container {
  /* Subtract header height to prevent double scrollbars */
  height: calc(100vh - 60px); 
  overflow-y: auto;
  background-color: var(--bg-workspace);
  color: var(--text-main);
  position: relative;
}

/* Make loading text visible on the light background */
.loading {
  color: var(--text-main);
  font-family: var(--font-stack);
  font-size: 1.1rem;
  font-weight: 600;
  text-align: center;
  padding-top: 50px;
  opacity: 0.7;
}

/* Remove navbar type specific background colors since we're using white sidebar */
.admin-nav, .user-nav {
  background-color: transparent;
}

/* Styles from admin/management/users/index.html */
.user-table-container {
  overflow-x: auto;
}

.user-table {
  width: 100%;
}

.user-table th {
  background-color: #f5f5f5;
  font-weight: 600;
}

.user-table tr:hover {
  background-color: #f9f9f9;
}

.subscription-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 500;
}

.subscription-trial {
  background-color: #e8f4ff;
  color: #1e88e5;
}

.subscription-starter {
  background-color: #e0f2fe;
  color: #0288d1;
}

.subscription-growth {
  background-color: #d1fae5;
  color: #10b981;
}

.subscription-pro {
  background-color: #ede9fe;
  color: #8b5cf6;
}

.subscription-scale {
  background-color: #ffedd5;
  color: #f97316;
}

.subscription-enterprise {
  background-color: #fce7f3;
  color: #ec4899;
}

.admin-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  background-color: #d1fae5;
  color: #065f46;
  font-size: 0.8rem;
  font-weight: 500;
}

.modal-card {
  max-width: 500px;
  width: 90%;
}

.delete-confirm {
  max-width: 400px;
}

.status-tag {
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 500;
}

.status-active {
  background-color: #d1fae5;
  color: #065f46;
}

.status-inactive {
  background-color: #e5e7eb;
  color: #4b5563;
}

.status-suspended {
  background-color: #fee2e2;
  color: #b91c1c;
}

.status-pending-cancellation {
  background-color: #ffedd5;
  color: #c2410c;
}

.status-canceled {
  background-color: #fee2e2;
  color: #b91c1c;
}

/* Styles from pages/user/bot-settings.html */
.tabs {
    display: flex;
    border-bottom: 1px solid #ddd;
    margin-bottom: 20px;
}

.tab-button {
    padding: 10px 20px;
    background: #f1f1f1;
    border: none;
    cursor: pointer;
    border: 1px solid #ddd;
    border-bottom: none;
    border-radius: 5px 5px 0 0;
    margin-right: 5px;
    font-weight: 600;
    transition: background 0.3s;
}

.tab-button.active {
    background: #fff;
    border-bottom: 1px solid #fff;
    margin-bottom: -1px;
    color: #007bff;
}

.tab-button:hover:not(.active) {
    background: #e9ecef;
}

.tab-pane {
    display: none;
    padding: 20px;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 5px 5px;
    min-height: 150px;
}

.tab-pane.active {
    display: block;
}

/* API Key Management Styles */
.api-key-section {
    margin-top: 20px;
}

.api-key-generator {
    margin: 30px 0;
}

.generate-btn {
    position: relative;
    padding: 15px 30px;
    background: linear-gradient(135deg, #28a745 0%, #218838 100%); /* Green gradient */
    color: white;
    border: none;
    border-radius: 8px; /* More rectangular */
    cursor: pointer;
    font-weight: 600;
    font-size: 18px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(40, 167, 69, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 250px;
    height: 60px;
}

.generate-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(40, 167, 69, 0.4);
}

.generate-btn:active {
    transform: translateY(1px);
}

.spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
    margin-left: 10px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.key-display {
    display: flex;
    margin-top: 25px;
    max-width: 600px;
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.key-input {
    flex: 1;
    padding: 15px;
    border: 2px solid #28a745; /* Green border */
    border-radius: 8px 0 0 8px;
    background-color: #f8f9fa;
    font-size: 16px;
    font-family: monospace;
}

.copy-btn {
    padding: 0 20px;
    background: linear-gradient(135deg, #28a745 0%, #218838 100%); /* Green gradient */
    color: white;
    border: none;
    border-radius: 0 8px 8px 0;
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    transition: background 0.3s;
}

.copy-btn:hover {
    background: linear-gradient(135deg, #218838 0%, #1e7e34 100%);
}

.copy-icon {
    margin-right: 8px;
    font-size: 18px;
}

.hidden {
    display: none;
}

.success-msg {
    margin-top: 15px;
    padding: 12px;
    background-color: #d4edda;
    color: #155724;
    border-radius: 8px;
    display: flex;
    align-items: center;
    animation: fadeIn 0.3s;
}

.checkmark {
    font-size: 20px;
    margin-right: 10px;
}

.error-message {
    margin-top: 20px;
    padding: 12px;
    background-color: #f8d7da;
    color: #721c24;
    border-radius: 8px;
    border: 1px solid #f5c6cb;
}

/* --- NEW DASHBOARD COMPONENTS --- */

/* 1. The Header is now just Text (No Background/Card) */
.dashboard-hero {
  background: transparent;
  padding: 10px 0 30px 0; /* Spacing below title */
  border: none;
  box-shadow: none;
  margin-bottom: 0;
}

.dashboard-hero h2 {
  color: var(--text-head);
  font-family: var(--font-head);
  font-weight: 800; /* Extra Bold */
  font-size: 2rem;
  margin-bottom: 8px;
  line-height: 1.1;
  letter-spacing: -0.5px;
}

.dashboard-hero p {
  color: var(--text-main);
  font-size: 1.05rem;
  opacity: 0.8;
}

/* 2. Flex Layout for Fixed-Width Cards */
.dashboard-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 25px;
  margin-bottom: 30px;
}

/* 3. Card styling - High Contrast on Light Background */
.stat-card {
  flex: 1;
  min-width: 280px;
  max-width: 400px;
  background: var(--bg-white);
  padding: 25px;
  border-radius: 12px;
  
  /* Solid border to separate from light background */
  border: 1px solid #E2E8F0; 
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  
  transition: all 0.2s ease;
  display: block;
  text-decoration: none;
  cursor: default;
}

.stat-card:hover {
  /* Removed translateY to prevent distracting lift effect */
  box-shadow: 0 12px 20px -5px rgba(41, 98, 255, 0.15); 
  border-color: var(--brand-primary);
}

.icon-box-small {
  width: 45px;
  height: 45px;
  background: rgba(41, 98, 255, 0.08);
  color: var(--brand-primary);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  margin-bottom: 15px;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-head);
  line-height: 1.1;
  margin-bottom: 5px;
}

.stat-label {
  color: var(--text-main);
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.8;
}

/* --- LAYOUT (Bulma Overrides) --- */
/* Ensure the grid container fills the screen below the header */
.columns.is-gapless {
  height: calc(100vh - 60px); /* 100vh minus Header Height */
  margin: 0 !important;
}

/* Sidebar Column - Force Height & Background */
.column.is-one-fifth {
  background-color: var(--bg-sidebar); /* Midnight Blue matches Navbar */
  height: 100%;
  overflow-y: auto;
  padding: 0 !important; /* Remove Bulma padding */
}

/* Main Content Column */
.column {
  padding: 0 !important; /* Reset padding, let #content-container handle it */
}

/* Improve visibility of placeholder text globally */
::placeholder {
  color: #64748B !important; /* A darker slate grey for better contrast */
  opacity: 1; /* Ensures opacity is consistent across browsers */
}

/* Ensure inputs always have dark text regardless of browser theme */
.input, .select select, .textarea {
  color: var(--text-main) !important;
  background-color: var(--bg-white) !important;
}

/* Mini usage component for the user management table */
.mini-usage-wrapper {
    min-width: 120px;
}

.mini-usage-text {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 4px;
    text-align: left;
}

.mini-bar-bg {
    background: #E2E8F0;
    height: 6px;
    border-radius: 10px;
    width: 100%;
    overflow: hidden;
}

.mini-bar-fill {
    height: 100%;
    background: #4caf50; /* Green for healthy credit levels */
    transition: width 0.4s ease;
}

.mini-bar-fill.is-critical {
    background: #ef4444; /* Red when less than 10% credit remains */
}

/* --- USAGE METRICS CARD STYLES --- */
.stat-card.usage-card {
  display: block;
  padding: 25px;
}

.usage-header {
  margin-bottom: 20px;
  border-bottom: 1px solid #edf2f7;
  padding-bottom: 15px;
}

.usage-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-head);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 5px;
}

.usage-plan-display {
  font-size: 1.1rem;
  color: var(--brand-primary);
  font-weight: 700;
}

.usage-progress-bg {
  background: #e2e8f0;
  border-radius: 6px;
  height: 12px;
  width: 100%;
  margin: 20px 0 15px 0;
  overflow: hidden;
}

.usage-progress-fill {
  background: #4caf50;
  height: 100%;
  width: 0%;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.usage-meta {
  display: flex;
  justify-content: space-between;
  font-size: 14px; /* Global card font size */
  color: #4a5568;
  margin-bottom: 8px;
}

.usage-meta strong {
  color: #0F172A; /* High contrast dark navy for numbers */
  font-weight: 700;
}

.usage-meta .label-text {
  font-weight: 500;
}

/* Mini Usage Component for Tables */
.mini-usage-wrapper {
    min-width: 120px;
}

.mini-usage-text {
    display: block;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 3px;
    text-align: right;
}

.mini-bar-bg {
    background: #E2E8F0;
    height: 6px;
    border-radius: 10px;
    width: 100%;
    overflow: hidden;
}

.mini-bar-fill {
    height: 100%;
    background: #4caf50; /* Default Green */
    transition: width 0.4s ease;
}

.mini-bar-fill.is-critical {
    background: #ef4444; /* Red for <10% credit */
}

/* --- RADIO GROUP COMPONENTS --- */
.that-ai-bot-radio-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 10px;
}

.that-ai-bot-radio-group.is-row {
  flex-direction: row;
  flex-wrap: wrap;
}

.that-ai-bot-radio-label {
  background: var(--bg-white);
  border: 1px solid #E2E8F0;
  padding: 15px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: block;
  position: relative;
  flex: 1;
  min-width: 200px;
  user-select: none;
}

/* Ensure children don't intercept clicks away from the label */
.that-ai-bot-radio-label * {
  pointer-events: none;
}

/* Re-enable pointer events for the radio input itself if needed */
.that-ai-bot-radio-label input[type="radio"] {
  pointer-events: auto;
  cursor: pointer;
}

/* Segmented Control / Pill Toggle */
/* Scoped to #bot-modal to override WordPress default button styles */
#bot-modal .that-ai-bot-segmented-control {
  display: flex;
  background-color: #E2E8F0;
  padding: 4px;
  border-radius: 8px;
  gap: 4px;
  margin-top: 10px;
  border: 1px solid #cbd5e1;
}

#bot-modal .that-ai-bot-segmented-btn {
  flex: 1;
  border: 1px solid transparent; /* Reset WP border */
  background: transparent; /* Reset WP background */
  box-shadow: none; /* Reset WP shadow */
  padding: 10px 16px;
  border-radius: 6px;
  font-family: var(--font-stack);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  height: auto; /* Reset WP fixed height */
  line-height: 1.4; /* Reset WP line-height */
}

#bot-modal .that-ai-bot-segmented-btn:hover {
  color: var(--text-head);
  background-color: rgba(255, 255, 255, 0.5);
  transform: none; /* Reset WP transform */
}

#bot-modal .that-ai-bot-segmented-btn.active {
  background-color: var(--bg-white);
  color: var(--brand-primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  border-color: transparent;
}

.that-ai-bot-radio-label:hover {
  border-color: var(--brand-primary);
  background-color: #f8faff;
  box-shadow: 0 2px 8px rgba(41, 98, 255, 0.1);
}

/* Highlight the card if the radio inside is checked (supports .active class for JS fallback) */
.that-ai-bot-radio-label:has(input:checked),
.that-ai-bot-radio-label.active {
  border: 2px solid var(--brand-primary) !important;
  background-color: #f0f4ff !important;
  box-shadow: 0 0 0 1px var(--brand-primary), 0 4px 12px rgba(41, 98, 255, 0.15);
  padding: 14px; /* Maintain alignment with 15px unselected state */
}

/* Ensure the radio input itself doesn't block clicks but remains accessible */
.that-ai-bot-radio-label input[type="radio"] {
  cursor: pointer;
  z-index: 2;
}

.that-ai-bot-radio-label input[type="radio"] {
  margin-right: 10px;
}

.that-ai-bot-radio-label strong {
  display: inline-block;
  margin-bottom: 4px;
  color: var(--text-head);
  font-size: 14px;
}

.that-ai-bot-radio-description {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-main);
  opacity: 0.8;
  padding-left: 28px; /* Align description text below the title */
}

/* --- Center All User Table Content --- */
.user-table-container th,
.user-table-container td {
    text-align: center !important;
}

/* Center the Usage progress bar and its text inside the column */
.user-table-container .mini-usage-wrapper {
    margin: 0 auto; /* Centers the block itself */
}

.user-table-container .mini-usage-text {
    text-align: center !important; /* Centers the numbers above the bar */
}

/* Goal performance sub-header styles */
.goal-sub-header {
  font-size: 0.85rem;
  color: var(--text-main);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
  padding-top: 8px;
}

.goal-sub-header.has-divider {
  border-top: 1px solid #E2E8F0;
  margin-top: 12px;
  padding-top: 12px;
}
