/* Internal Pattern Library - Shadcn Inspired Styles */

/* Scoped Dashboard Wrapper */
.ipl-dashboard {
  --background: 0 0% 100%;
  --foreground: 222.2 84% 4.9%;
  --card: 0 0% 100%;
  --card-foreground: 222.2 84% 4.9%;
  --popover: 0 0% 100%;
  --popover-foreground: 222.2 84% 4.9%;
  --primary: 222.2 47.4% 11.2%;
  --primary-foreground: 210 40% 98%;
  --secondary: 210 40% 96.1%;
  --secondary-foreground: 222.2 47.4% 11.2%;
  --muted: 210 40% 96.1%;
  --muted-foreground: 215.4 16.3% 46.9%;
  --accent: 210 40% 96.1%;
  --accent-foreground: 222.2 47.4% 11.2%;
  --destructive: 0 84.2% 60.2%;
  --destructive-foreground: 210 40% 98%;
  --border: 214.3 31.8% 91.4%;
  --input: 214.3 31.8% 91.4%;
  --ring: 222.2 84% 4.9%;
  --radius: 0.5rem;

  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: hsl(var(--foreground));
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
}

/* Header Section */
.ipl-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid hsl(var(--border));
  flex-wrap: wrap;
  gap: 1rem;
}

.ipl-title {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.025em;
  margin: 0;
}

.ipl-description {
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
  margin: 0.25rem 0 0 0;
}

.ipl-controls {
  display: flex;
  gap: 1rem;
  align-items: center;
}

/* Inputs & Forms */
.ipl-search-wrapper {
  position: relative;
  width: 250px;
}

.ipl-search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: hsl(var(--muted-foreground));
  pointer-events: none;
}

.ipl-input,
.ipl-select {
  width: 100%;
  height: 2.5rem;
  padding: 0.5rem 0.75rem;
  padding-left: 2.25rem;
  /* Space for icon */
  font-size: 0.875rem;
  line-height: 1.25rem;
  border-radius: var(--radius);
  border: 1px solid hsl(var(--input));
  background-color: transparent;
  color: hsl(var(--foreground));
  transition: all 0.15s ease;
}

.ipl-select {
  padding-left: 0.75rem;
  cursor: pointer;
  min-width: 160px;
}

.ipl-input:focus,
.ipl-select:focus {
  outline: none;
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 1px hsl(var(--ring));
}

/* Masonry Layout */
.ipl-grid {
  column-count: 3;
  column-gap: 1.5rem;
}

@media (max-width: 1024px) {
  .ipl-grid {
    column-count: 2;
  }
}

@media (max-width: 640px) {
  .ipl-grid {
    column-count: 1;
  }
}

/* Card Component */
.ipl-card {
  break-inside: avoid;
  /* Prevent card from splitting across columns */
  margin-bottom: 1.5rem;
  /* Gap at the bottom of each card */
  border-radius: var(--radius);
  border: 1px solid hsl(var(--border));
  background-color: hsl(var(--card));
  color: hsl(var(--card-foreground));
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: all 0.2s ease;
}

.ipl-card:hover {
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.ipl-card-header {
  padding: 1rem;
  border-bottom: 1px solid hsl(var(--border));
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: hsl(var(--secondary) / 0.5);
}

.ipl-card-title {
  font-weight: 600;
  font-size: 0.925rem;
}

.ipl-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 9999px;
  border: 1px solid transparent;
  background-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  line-height: normal;
}

/* Preview Area */
.ipl-preview-container {
  padding: 1.5rem;
  background-color: #f8fafc;
  /* Neutral background to check isolation */
  background-image: radial-gradient(#cbd5e1 1px, transparent 1px);
  background-size: 20px 20px;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
}

/* 
 * CRITICAL: The content inside here inherits global theme styles.
 * We reset only the wrapper margins to avoid layout breakage.
 */
.ipl-preview-content {
  width: 100%;
  /* Optional: Reset base styles if needed, but User wanted Theme styles */
}

/* Card Footer */
.ipl-card-footer {
  padding: 1rem;
  border-top: 1px solid hsl(var(--border));
  background-color: hsl(var(--card));
  display: flex;
  justify-content: flex-end;
}

/* Buttons */
.ipl-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  height: 2.25rem;
  padding: 0 1rem;
  cursor: pointer;
  transition: background-color 0.15s ease;
  border: 1px solid transparent;
  gap: 0.5rem;
}

.ipl-btn-outline {
  border: 1px solid hsl(var(--input));
  background-color: transparent;
  color: hsl(var(--foreground));
}

.ipl-btn-outline:hover {
  background-color: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
}

.ipl-hidden {
  display: none !important;
}

/* Toast Notification (Simple) */
.ipl-toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  font-size: 0.875rem;
  z-index: 9999;
  opacity: 0;
  transform: translateY(1rem);
  transition: all 0.3s ease;
}

.ipl-toast.show {
  opacity: 1;
  transform: translateY(0);
}