/* TextBrew Modern SaaS Component Library */

/* ============================================
   DESIGN TOKENS & CSS VARIABLES
   ============================================ */
:root {
  /* Brand Colors - Dark Blue as Primary */
  --tb-primary-50: #f0e6ff;
  --tb-primary-100: #d9ccff;
  --tb-primary-200: #b399ff;
  --tb-primary-300: #8c66ff;
  --tb-primary-400: #6633ff;
  --tb-primary-500: #4000ff;
  --tb-primary-600: #3a0084;
  --tb-primary-700: #26005b;
  --tb-primary-800: #1a003d;
  --tb-primary-900: #0d001f;
  
  /* Accent Colors - Pink Based (matching brand) */
  --tb-accent-pink: #ff446c;    /* Pink accent color from logo */
  --tb-accent-medium: #ff5a7f;  /* Medium pink accent */
  --tb-accent-dark: #e63355;    /* Dark pink accent for better contrast */
  --tb-accent-light: #ffe5ec;   /* Light pink background */
  
  /* White Accent Colors */
  --tb-accent-50: #ffffff;
  --tb-accent-100: #fafafa;
  --tb-accent-200: #f5f5f5;
  --tb-accent-300: #e5e5e5;
  --tb-accent-400: #d4d4d4;
  --tb-accent-500: #a3a3a3;
  --tb-accent-600: #737373;
  --tb-accent-700: #525252;
  --tb-accent-800: #404040;
  --tb-accent-900: #262626;
  
  /* Neutral Colors */
  --tb-gray-50: #f9fafb;
  --tb-gray-100: #f3f4f6;
  --tb-gray-200: #e5e7eb;
  --tb-gray-300: #d1d5db;
  --tb-gray-400: #9ca3af;
  --tb-gray-500: #6b7280;
  --tb-gray-600: #4b5563;
  --tb-gray-700: #374151;
  --tb-gray-800: #1f2937;
  --tb-gray-900: #111827;
  
  /* Status Colors */
  --tb-success: #10b981;
  --tb-warning: #f59e0b;
  --tb-error: #ef4444;
  --tb-info: #3b82f6;
  
  /* Spacing */
  --tb-spacing-xs: 0.25rem;
  --tb-spacing-sm: 0.5rem;
  --tb-spacing-md: 1rem;
  --tb-spacing-lg: 1.5rem;
  --tb-spacing-xl: 2rem;
  --tb-spacing-2xl: 3rem;
  
  /* Border Radius */
  --tb-radius-sm: 0.375rem;
  --tb-radius-md: 0.5rem;
  --tb-radius-lg: 0.75rem;
  --tb-radius-xl: 1rem;
  --tb-radius-2xl: 1.5rem;
  --tb-radius-full: 9999px;
  
  /* Shadows */
  --tb-shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --tb-shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --tb-shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --tb-shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  
  /* Transitions */
  --tb-transition-fast: 150ms ease-in-out;
  --tb-transition-base: 200ms ease-in-out;
  --tb-transition-slow: 300ms ease-in-out;
}

/* ============================================
   MODERN BUTTONS
   ============================================ */
.tb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  font-weight: 500;
  font-size: 0.875rem;
  line-height: 1.25rem;
  border-radius: var(--tb-radius-md);
  transition: all var(--tb-transition-base);
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

.tb-btn:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgb(38 0 91 / 0.1);
}

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

/* Primary Button */
.tb-btn-primary {
  background: linear-gradient(135deg, var(--tb-primary-600), var(--tb-primary-700));
  color: white;
  border-color: var(--tb-primary-700);
  box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
}

.tb-btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--tb-primary-700), var(--tb-primary-800));
  transform: translateY(-1px);
  box-shadow: var(--tb-shadow-md);
}

.tb-btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

/* Secondary Button */
.tb-btn-secondary {
  background: white;
  color: var(--tb-primary-700);
  border-color: var(--tb-primary-300);
  box-shadow: var(--tb-shadow-sm);
}

.tb-btn-secondary:hover:not(:disabled) {
  background: var(--tb-primary-50);
  border-color: var(--tb-primary-600);
  color: var(--tb-primary-700);
  transform: translateY(-1px);
  box-shadow: var(--tb-shadow-md);
}

/* Secondary button with transparency override */
.tb-btn-secondary.bg-white\/20 {
  background: rgba(255, 255, 255, 0.9) !important;
  backdrop-filter: blur(10px);
  color: var(--tb-primary-700) !important;
  border-color: var(--tb-primary-600) !important;
}

.tb-btn-secondary.bg-white\/20:hover {
  background: white !important;
  color: var(--tb-primary-700) !important;
}

/* Accent Button */
.tb-btn-accent {
  background: var(--tb-accent-50);
  color: var(--tb-primary-700);
  border-color: var(--tb-gray-300);
  box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
}

.tb-btn-accent:hover:not(:disabled) {
  background: var(--tb-accent-100);
  transform: translateY(-1px);
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.15);
  border-color: var(--tb-gray-400);
}

/* Ghost Button */
.tb-btn-ghost {
  background: transparent;
  color: var(--tb-gray-600);
  border-color: transparent;
}

.tb-btn-ghost:hover:not(:disabled) {
  background: var(--tb-gray-100);
  color: var(--tb-gray-700);
}

/* Danger Button */
.tb-btn-danger {
  background: var(--tb-error);
  color: white;
  border-color: var(--tb-error);
}

.tb-btn-danger:hover:not(:disabled) {
  background: #dc2626;
  transform: translateY(-1px);
  box-shadow: var(--tb-shadow-md);
}

/* Button Sizes */
.tb-btn-sm {
  padding: 0.375rem 0.875rem;
  font-size: 0.8125rem;
}

.tb-btn-lg {
  padding: 0.875rem 1.75rem;
  font-size: 1rem;
  border-radius: var(--tb-radius-lg);
}

/* Button Icon Only */
.tb-btn-icon {
  padding: 0.625rem;
  min-width: 2.5rem;
  min-height: 2.5rem;
}

.tb-btn-icon.tb-btn-sm {
  padding: 0.375rem;
  min-width: 2rem;
  min-height: 2rem;
}

/* ============================================
   MODERN CARDS
   ============================================ */
.tb-card {
  background: white;
  border-radius: var(--tb-radius-lg);
  box-shadow: var(--tb-shadow-sm);
  border: 1px solid var(--tb-gray-200);
  overflow: hidden;
  transition: all var(--tb-transition-base);
}

.tb-card:hover {
  box-shadow: var(--tb-shadow-md);
}

.tb-card-header {
  padding: var(--tb-spacing-lg) var(--tb-spacing-xl);
  border-bottom: 1px solid var(--tb-gray-200);
  background: var(--tb-gray-50);
}

.tb-card-body {
  padding: var(--tb-spacing-xl);
}

.tb-card-footer {
  padding: var(--tb-spacing-lg) var(--tb-spacing-xl);
  border-top: 1px solid var(--tb-gray-200);
  background: var(--tb-gray-50);
}

/* Clickable Card */
.tb-card-clickable {
  cursor: pointer;
  position: relative;
}

.tb-card-clickable::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent, rgba(38, 0, 91, 0.05));
  opacity: 0;
  transition: opacity var(--tb-transition-base);
}

.tb-card-clickable:hover::before {
  opacity: 1;
}

.tb-card-clickable:hover {
  transform: translateY(-2px);
  box-shadow: var(--tb-shadow-lg);
  border-color: #b399ff;
}

/* ============================================
   MODERN FORMS
   ============================================ */
.tb-form-group {
  margin-bottom: var(--tb-spacing-lg);
}

.tb-form-label {
  display: block;
  margin-bottom: var(--tb-spacing-sm);
  font-weight: 500;
  font-size: 0.875rem;
  color: var(--tb-gray-700);
}

.tb-form-control {
  width: 100%;
  padding: 0.625rem 0.875rem;
  font-size: 0.875rem;
  line-height: 1.25rem;
  color: var(--tb-gray-900);
  background-color: white;
  border: 1px solid var(--tb-gray-300);
  border-radius: var(--tb-radius-md);
  transition: all var(--tb-transition-fast);
  appearance: none;
}

.tb-form-control:focus {
  outline: none;
  border-color: var(--tb-primary-600);
  box-shadow: 0 0 0 3px rgb(38 0 91 / 0.1);
}

.tb-form-control::placeholder {
  color: var(--tb-gray-400);
}

/* Form Control with Icon */
.tb-form-icon-wrapper {
  position: relative;
}

.tb-form-icon {
  position: absolute;
  left: 0.875rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--tb-gray-400);
  pointer-events: none;
}

.tb-form-icon-wrapper .tb-form-control {
  padding-left: 2.5rem;
}

/* Form Help Text */
.tb-form-help {
  margin-top: var(--tb-spacing-xs);
  font-size: 0.8125rem;
  color: var(--tb-gray-500);
}

/* Form Error */
.tb-form-error {
  margin-top: var(--tb-spacing-xs);
  font-size: 0.8125rem;
  color: var(--tb-error);
}

.tb-form-control.tb-error {
  border-color: var(--tb-error);
}

.tb-form-control.tb-error:focus {
  box-shadow: 0 0 0 3px rgb(239 68 68 / 0.1);
}

/* Select */
.tb-form-select {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 0.5rem center;
  background-repeat: no-repeat;
  background-size: 1.5em 1.5em;
  padding-right: 2.5rem;
}

/* Textarea */
.tb-form-textarea {
  min-height: 6rem;
  resize: vertical;
}

/* ============================================
   MODERN TABLES
   ============================================ */
.tb-table-wrapper {
  background: white;
  border-radius: var(--tb-radius-lg);
  box-shadow: var(--tb-shadow-sm);
  border: 1px solid var(--tb-gray-200);
  overflow: hidden;
  width: 100%;
  max-width: 100%;
}

/* Container for table with proper overflow handling */
.tb-table-wrapper .overflow-x-auto {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}

.tb-table {
  width: 100%;
  border-collapse: collapse;
}

.tb-table thead {
  background: var(--tb-primary-700);
  border-bottom: 1px solid var(--tb-primary-800);
}

.tb-table th {
  padding: var(--tb-spacing-md) var(--tb-spacing-lg);
  text-align: left;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: white;
}

.tb-table td {
  padding: var(--tb-spacing-md) var(--tb-spacing-lg);
  border-bottom: 1px solid var(--tb-gray-100);
  color: var(--tb-gray-700);
  font-size: 0.875rem;
}

.tb-table tbody tr {
  transition: background-color var(--tb-transition-fast);
}

.tb-table tbody tr:hover {
  background-color: var(--tb-gray-50);
}

.tb-table tbody tr:last-child td {
  border-bottom: none;
}

/* Table Actions */
.tb-table-actions {
  display: flex;
  gap: var(--tb-spacing-xs);
  align-items: center;
  flex-wrap: nowrap;
  min-width: 0; /* Allow shrinking */
}

/* Ensure actions don't cause table overflow */
.tb-table td:last-child {
  white-space: nowrap;
  width: 1%;
}

/* ============================================
   MODERN BADGES & PILLS
   ============================================ */
.tb-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1rem;
  border-radius: var(--tb-radius-full);
  transition: all var(--tb-transition-fast);
}

.tb-badge-primary {
  background: #f0e6ff;
  color: var(--tb-primary-700);
}

.tb-badge-success {
  background: #d1fae5;
  color: #065f46;
}

.tb-badge-warning {
  background: #fef3c7;
  color: #92400e;
}

.tb-badge-error {
  background: #fee2e2;
  color: #991b1b;
}

.tb-badge-info {
  background: #dbeafe;
  color: #1e40af;
}

.tb-badge-gray {
  background: var(--tb-gray-100);
  color: var(--tb-gray-600);
}

.tb-badge-secondary {
  background: var(--tb-gray-100);
  color: var(--tb-gray-600);
}

.tb-badge-danger {
  background: #fee2e2;
  color: #991b1b;
}

/* Badge with Dot */
.tb-badge-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: var(--tb-radius-full);
  background: currentColor;
}

/* ============================================
   MODERN ALERTS
   ============================================ */
.tb-alert {
  padding: var(--tb-spacing-md) var(--tb-spacing-lg);
  border-radius: var(--tb-radius-md);
  display: flex;
  align-items: flex-start;
  gap: var(--tb-spacing-md);
  margin-bottom: var(--tb-spacing-lg);
  font-size: 0.875rem;
  line-height: 1.25rem;
}

.tb-alert-icon {
  flex-shrink: 0;
  width: 1.25rem;
  height: 1.25rem;
}

.tb-alert-content {
  flex: 1;
}

.tb-alert-title {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.tb-alert-success {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.tb-alert-warning {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}

.tb-alert-error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.tb-alert-info {
  background: #dbeafe;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

/* ============================================
   MODERN MODALS
   ============================================ */
.tb-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--tb-spacing-lg);
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: all var(--tb-transition-base);
}

.tb-modal-overlay.tb-active {
  opacity: 1;
  visibility: visible;
}

.tb-modal {
  background: white;
  border-radius: var(--tb-radius-xl);
  box-shadow: var(--tb-shadow-xl);
  max-width: 32rem;
  width: 100%;
  max-height: 90vh;
  overflow: hidden;
  transform: scale(0.95);
  transition: transform var(--tb-transition-base);
}

.tb-modal-overlay.tb-active .tb-modal {
  transform: scale(1);
}

.tb-modal-header {
  padding: var(--tb-spacing-lg) var(--tb-spacing-xl);
  border-bottom: 1px solid var(--tb-gray-200);
}

.tb-modal-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--tb-gray-900);
  margin: 0;
}

.tb-modal-body {
  padding: var(--tb-spacing-xl);
  overflow-y: auto;
  max-height: calc(90vh - 8rem);
}

.tb-modal-footer {
  padding: var(--tb-spacing-lg) var(--tb-spacing-xl);
  border-top: 1px solid var(--tb-gray-200);
  display: flex;
  gap: var(--tb-spacing-md);
  justify-content: flex-end;
}

/* ============================================
   HERO SECTIONS
   ============================================ */
.tb-hero {
  background: linear-gradient(135deg, var(--tb-primary-700), var(--tb-primary-900));
  color: white;
  padding: var(--tb-spacing-2xl) 0;
  position: relative;
  overflow: hidden;
}

.tb-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle at 20% 80%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
                    radial-gradient(circle at 80% 20%, rgba(255, 255, 255, 0.1) 0%, transparent 50%);
}

.tb-hero-content {
  position: relative;
  z-index: 1;
  max-width: 72rem;
  margin: 0 auto;
  padding: 0 var(--tb-spacing-lg);
}

.tb-hero-title {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: var(--tb-spacing-md);
  line-height: 1.2;
  color: white;
}

.tb-hero-subtitle {
  font-size: 1.125rem;
  opacity: 0.9;
  margin-bottom: var(--tb-spacing-xl);
  max-width: 48rem;
}

.tb-hero-actions {
  display: flex;
  gap: var(--tb-spacing-md);
  flex-wrap: wrap;
}

/* ============================================
   LOADING STATES
   ============================================ */
.tb-spinner {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  border: 2px solid var(--tb-gray-300);
  border-top-color: var(--tb-primary-700);
  border-radius: 50%;
  animation: tb-spin 0.8s linear infinite;
}

.tb-spinner-lg {
  width: 2rem;
  height: 2rem;
  border-width: 3px;
}

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

.tb-skeleton {
  background: linear-gradient(90deg, var(--tb-gray-200) 25%, var(--tb-gray-100) 50%, var(--tb-gray-200) 75%);
  background-size: 200% 100%;
  animation: tb-skeleton 1.5s ease-in-out infinite;
  border-radius: var(--tb-radius-md);
}

@keyframes tb-skeleton {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ============================================
   EMPTY STATES
   ============================================ */
.tb-empty {
  text-align: center;
  padding: var(--tb-spacing-2xl) var(--tb-spacing-lg);
}

.tb-empty-icon {
  width: 4rem;
  height: 4rem;
  margin: 0 auto var(--tb-spacing-lg);
  color: var(--tb-gray-400);
}

.tb-empty-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--tb-gray-900);
  margin-bottom: var(--tb-spacing-sm);
}

.tb-empty-text {
  color: var(--tb-gray-500);
  margin-bottom: var(--tb-spacing-xl);
  max-width: 24rem;
  margin-left: auto;
  margin-right: auto;
}

/* ============================================
   TEXT & COLOR UTILITIES
   ============================================ */
.text-tb-main-dark { color: var(--tb-primary-700) !important; }
.text-tb-accent-pink { color: var(--tb-accent-pink) !important; }
.text-tb-accent-dark { color: var(--tb-accent-dark) !important; }
.text-tb-accent { color: var(--tb-accent-pink) !important; }
.text-tb-purple { color: var(--tb-accent-pink) !important; }

.bg-tb-accent-light { background-color: var(--tb-accent-light) !important; }
.bg-tb-accent-pink { background-color: var(--tb-accent-pink) !important; }

/* ============================================
   UTILITY CLASSES
   ============================================ */
.tb-container {
  max-width: 72rem;
  margin: 0 auto;
  padding: 0 var(--tb-spacing-lg);
}

.tb-section {
  padding: var(--tb-spacing-2xl) 0;
}

.tb-flex {
  display: flex;
}

.tb-flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.tb-flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tb-gap-sm { gap: var(--tb-spacing-sm); }
.tb-gap-md { gap: var(--tb-spacing-md); }
.tb-gap-lg { gap: var(--tb-spacing-lg); }

.tb-text-center { text-align: center; }
.tb-text-right { text-align: right; }

.tb-mb-sm { margin-bottom: var(--tb-spacing-sm); }
.tb-mb-md { margin-bottom: var(--tb-spacing-md); }
.tb-mb-lg { margin-bottom: var(--tb-spacing-lg); }
.tb-mb-xl { margin-bottom: var(--tb-spacing-xl); }

/* ============================================
   RESPONSIVE UTILITIES
   ============================================ */
@media (max-width: 768px) {
  .tb-hero-title {
    font-size: 2rem;
  }
  
  .tb-hero-actions {
    flex-direction: column;
    align-items: stretch;
  }
  
  .tb-table-wrapper {
    overflow-x: auto;
    /* Ensure table scrolls properly on mobile */
    -webkit-overflow-scrolling: touch;
  }
  
  /* Hide less important columns on small screens */
  .tb-table th:nth-child(6), /* Language */
  .tb-table td:nth-child(6),
  .tb-table th:nth-child(7), /* Tone of Voice */
  .tb-table td:nth-child(7),
  .tb-table th:nth-child(8), /* Created */
  .tb-table td:nth-child(8) {
    display: none;
  }
  
  /* Make action buttons smaller on mobile */
  .tb-table-actions .tb-btn {
    padding: 0.25rem;
    min-width: 2rem;
    height: 2rem;
  }
  
  .tb-modal {
    margin: var(--tb-spacing-md);
  }
}

/* ============================================
   ANIMATIONS
   ============================================ */
.tb-fade-in {
  animation: tb-fade-in var(--tb-transition-base) ease-out;
}

@keyframes tb-fade-in {
  from {
    opacity: 0;
    transform: translateY(0.5rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.tb-slide-in {
  animation: tb-slide-in var(--tb-transition-slow) ease-out;
}

@keyframes tb-slide-in {
  from {
    opacity: 0;
    transform: translateX(-1rem);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}