/* Modern Bootstrap Customization */

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

/* Root variables for consistency and scalability */
:root {
  /* Core colors - Modern palette inspired by Tailwind */
  --bs-primary: #6366f1; /* Indigo-500 */
  --bs-primary-hover: #4f46e5; /* Indigo-600 */
  --bs-secondary: #64748b; /* Slate-500 */
  --bs-success: #10b981; /* Emerald-500 */
  --bs-danger: #ef4444; /* Red-500 */
  --bs-warning: #f59e0b; /* Amber-500 */
  --bs-info: #3b82f6; /* Blue-500 */
  --bs-light: #f8fafc; /* Slate-50 */
  --bs-dark: #111827; /* Gray-900 */
  --bs-gray: #d1d5db; /* Gray-300 for borders */
  
  /* Shadows - Tailwind-inspired */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
  
  /* Transitions */
  --transition-default: all 0.2s ease;
}

/* Base styles */
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
  -webkit-font-smoothing: antialiased;
  background-color: var(--bs-light);
  color: var(--bs-dark);
}

/* Modernized components */
.card {
  border: none;
  border-radius: 0.5rem;
  box-shadow: var(--shadow-md);
  transition: var(--transition-default);
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

/* Buttons - Modernized with gradients and better focus */
.btn {
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 0.375rem;
  transition: var(--transition-default);
}

.btn-sm {
  padding: 0.25rem 0.5rem;
  font-size: 0.875rem;
}

.btn-lg {
  padding: 0.5rem 1rem;
  font-size: 1rem;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: linear-gradient(135deg, var(--bs-primary), var(--bs-primary-hover));
  border: none;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background: var(--bs-primary-hover);
  box-shadow: var(--shadow-md);
}

.btn:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.3);
}

/* Form controls - Cleaner, modern look */
.form-control {
  border-radius: 0.375rem;
  border: 1px solid var(--bs-gray);
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  transition: var(--transition-default);
}

.form-control:focus {
  border-color: var(--bs-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
  outline: none;
}

/* Navigation - Modern navbar and tabs */
.navbar {
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(229, 231, 235, 0.08);
  padding: 0.5rem 1rem;
}

.nav-tabs .nav-item {
  margin-right: 0.5rem;
}

.nav-tabs .nav-link {
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  transition: var(--transition-default);
}

.nav-tabs .nav-link:hover {
  background-color: rgba(99, 102, 241, 0.05);
}

.nav-tabs .nav-link.active {
  background: linear-gradient(135deg, var(--bs-primary), var(--bs-primary-hover));
  color: #ffffff !important;
  box-shadow: var(--shadow-sm);
}

/* Tables - Sleek and minimal */
.table {
  border-radius: 0.5rem;
  overflow: hidden;
}

.table thead th {
  background-color: var(--bs-light);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  padding: 0.75rem;
}

/* Modals - Modern pop-up style */
.modal-content {
  border: none;
  border-radius: 0.75rem;
  box-shadow: var(--shadow-lg);
}

/* Badges - Compact and bold */
.badge {
  padding: 0.25em 0.5em;
  font-weight: 500;
  font-size: 0.75rem;
  border-radius: 0.25rem;
}

/* List groups - Clean and modern */
.list-group-item {
  border: 1px solid var(--bs-gray);
  padding: 0.75rem 1rem;
  transition: var(--transition-default);
}

.list-group-item:hover {
  background-color: var(--bs-light);
}

.list-group-item:first-child {
  border-top-left-radius: 0.375rem;
  border-top-right-radius: 0.375rem;
}

.list-group-item:last-child {
  border-bottom-left-radius: 0.375rem;
  border-bottom-right-radius: 0.375rem;
}

/* Input groups */
.input-group-text {
  font-size: 0.875rem;
  padding: 0.375rem 0.75rem;
  border-radius: 0.375rem;
  background-color: var(--bs-light);
}

/* Dark mode enhancements */
[data-bs-theme="dark"] {
  --bs-light: #1f2937; /* Gray-800 */
  --bs-dark: #f8fafc; /* Slate-50 */
  --bs-gray: #4b5563; /* Gray-600 */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.15);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.2), 0 2px 4px -2px rgba(0, 0, 0, 0.16);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.2), 0 4px 6px -4px rgba(0, 0, 0, 0.15);
}

/* Responsive utilities */
.text-responsive {
  font-size: 0.875rem;
}

@media (min-width: 576px) {
  .text-responsive {
    font-size: 1rem;
  }
}

.responsive-container {
  padding: 1rem;
}

@media (min-width: 576px) {
  .responsive-container {
    padding: 1.5rem;
  }
}

@media (min-width: 768px) {
  .responsive-container {
    padding: 2rem;
  }
}

.card-responsive {
  margin: 0.5rem 0;
  padding: 1rem;
}

@media (min-width: 576px) {
  .card-responsive {
    margin: 1rem;
    padding: 1.5rem;
  }
}

/* Sidebar - Modern and responsive */
.sidebar {
  width: 4.5rem !important;
  transition: width 0.3s ease;
  background-color: var(--bs-dark);
}

@media (min-width: 576px) {
  .sidebar {
    width: 16rem !important;
  }
}

.sidebar + .col {
  transition: margin-left 0.3s ease;
}

.sidebar .nav-link {
  display: flex;
  align-items: center;
  padding: 0.5rem 1rem !important;
  transition: var(--transition-default);
  color: inherit;
  width: 100%;
  min-width: 0;
}

.sidebar .nav-link i {
  margin-right: 0.5rem;
  font-size: 1.25rem;
}

.sidebar .nav-link span {
  flex-grow: 1;
  min-width: 0;
}

.sidebar .nav-link:hover {
  background-color: rgba(13, 110, 253, 0.05);
}

.sidebar .nav-link.active {
  background-color: rgba(13, 110, 253, 0.1) !important;
  color: #ffffff !important;
  border-radius: 0.375rem;
}

.sidebar .nav-link.active i,
.sidebar .nav-link.active .text-primary-emphasis {
  color: #ffffff !important;
}

/* Sidebar navigation items */
.sidebar .nav-item {
  width: auto;
}

.sidebar .nav-pills {
  width: 100%;
  align-items: flex-start !important;
}

/* Sidebar buttons (network selector) */
.sidebar .btn-dark {
  color: #ffffff;
  font-weight: 500;
  padding: 0.5rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: var(--transition-default);
  width: 100%;
  min-width: 0;
  border-radius: 9999px;
  border-width: 2px;
  border-color: var(--bs-primary);
}

.sidebar .btn-dark:hover {
  background-color: rgba(13, 110, 253, 0.05);
}

.sidebar .btn-dark i {
  color: var(--bs-primary);
  margin-right: 0.5rem;
  font-size: 1.25rem;
}

.sidebar .btn-dark span {
  flex-grow: 1;
  min-width: 0;
  display: inline;
  text-overflow: ellipsis;
}

/* Create Network button */
.sidebar .btn-primary {
  padding: 0.5rem 1rem;
  border-radius: 9999px;
  width: 100%;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-default);
}

.sidebar .btn-primary i {
  font-size: 1.25rem;
}

.sidebar .btn-primary:hover {
  background: var(--bs-primary-hover);
}

/* Sidebar alignment */
.sidebar .d-flex.flex-column {
  align-items: flex-start !important;
}

.sidebar .dropdown {
  width: 100%;
}

.sidebar .nav-link,
.sidebar .dropdown-toggle,
.sidebar .dropdown > a,
.sidebar .dropdown > button {
  justify-content: flex-start !important;
  text-align: left !important;
  width: 100%;
}

@media (max-width: 575.98px) {
  .sidebar .d-flex.flex-column,
  .sidebar .nav-pills {
    align-items: center !important;
  }
  
  .sidebar .nav-link,
  .sidebar .dropdown-toggle,
  .sidebar .dropdown > a,
  .sidebar .dropdown > button {
    justify-content: center !important;
    text-align: center !important;
    flex-direction: column;
  }
  
  .sidebar .nav-link i,
  .sidebar .btn-dark i,
  .sidebar .btn-primary i {
    margin-right: 0;
    margin-bottom: 0.25rem;
  }
}

/* Layout fixes */
.container-fluid {
  padding-left: 0;
  padding-right: 0;
  overflow-x: hidden;
}

.row.flex-nowrap {
  margin-left: 0;
  margin-right: 0;
}

.col.py-3 {
  padding-left: 0.5rem;
  padding-right: 0.5rem;
}

@media (min-width: 576px) {
  .col.py-3 {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }
}

/* Dropdown menu - Modern and scrollable */
.dropdown-menu {
  max-height: 80vh;
  overflow-y: auto;
  border-radius: 0.375rem;
  box-shadow: var(--shadow-md);
}

.dropdown-item {
  transition: var(--transition-default);
}

.dropdown-item:hover {
  background-color: rgba(99, 102, 241, 0.1);
}

.dropdown-item.active {
  background-color: rgba(13, 110, 253, 0.8) !important;
}

@media (max-width: 576px) {
  .dropdown-menu {
    position: fixed !important;
    left: 4.5rem !important;
  }
}

@media (min-width: 576px) {
  .dropdown-menu {
    position: absolute !important;
    left: auto !important;
  }
}

/* Horizontal lines in sidebar */
.sidebar hr {
  width: 100%;
  border: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.1); /* Subtle white line for dark mode */
  margin: 0.5rem 0;
}

/* Ensure dynamically added content respects dark theme */
[data-bs-theme="dark"] .text-body,
[data-bs-theme="dark"] #recipient-count {
    color: var(--bs-body-color) !important;
}

/* Force theme colors for dynamically generated content */
[data-bs-theme="dark"] .modal-body .text-muted {
    color: var(--bs-gray-400) !important;
}

/* Fix for specific problematic fields */
[data-bs-theme="dark"] #recipient-count,
[data-bs-theme="dark"] #messageDetailsContent,
[data-bs-theme="dark"] #promo-preview,
[data-bs-theme="dark"] .text-muted,
[data-bs-theme="dark"] .form-text {
    color: #9ca3af !important; /* Force gray-400 */
}


/* Send SMS modal field fixes */
[data-bs-theme="dark"] #sendMessageModal .form-text,
[data-bs-theme="dark"] #sendMessageModal .text-muted,
[data-bs-theme="dark"] #sendMessageModal #char-count,
[data-bs-theme="dark"] #sendMessageModal #preview-text {
    color: #9ca3af !important;
}

/* Voucher SMS config modal fixes */
[data-bs-theme="dark"] #voucherConfigModal .form-text,
[data-bs-theme="dark"] #voucherConfigModal .text-muted,
[data-bs-theme="dark"] #voucherConfigModal #promo-char-count,
[data-bs-theme="dark"] #voucherConfigModal #promo-preview {
    color: #9ca3af !important;
}

/* Message preview and content areas */
[data-bs-theme="dark"] #message-preview,
[data-bs-theme="dark"] .card.border-info .card-body,
[data-bs-theme="dark"] .bg-light {
    background-color: #374151 !important; /* Force dark gray background */
    color: var(--bs-body-color) !important;
}

/* Ensure all text elements respect theme */
[data-bs-theme="dark"] div,
[data-bs-theme="dark"] span,
[data-bs-theme="dark"] small,
[data-bs-theme="dark"] p:not(.text-primary):not(.text-success):not(.text-danger):not(.text-warning):not(.text-info) {
    color: inherit;
}

/* Force dark theme on problematic backgrounds */
[data-bs-theme="dark"] .border.p-3.bg-light {
    background-color: #374151 !important;
    border-color: #4b5563 !important;
}