/* ============================================
   Design System - Inspired by ShadCN UI
   Light & Dark mode via CSS custom properties
   ============================================ */

:root {
  /* Background */
  --background: 0 0% 100%;
  --foreground: 240 10% 3.9%;

  /* Card */
  --card: 0 0% 100%;
  --card-foreground: 240 10% 3.9%;

  /* Popover */
  --popover: 0 0% 100%;
  --popover-foreground: 240 10% 3.9%;

  /* Primary */
  --primary: 262 83% 58%;
  --primary-foreground: 0 0% 98%;

  /* Secondary */
  --secondary: 240 4.8% 95.9%;
  --secondary-foreground: 240 5.9% 10%;

  /* Muted */
  --muted: 240 4.8% 95.9%;
  --muted-foreground: 240 3.8% 46.1%;

  /* Accent */
  --accent: 240 4.8% 95.9%;
  --accent-foreground: 240 5.9% 10%;

  /* Destructive */
  --destructive: 0 84% 60%;
  --destructive-foreground: 0 0% 98%;

  /* Success */
  --success: 142 76% 36%;
  --success-foreground: 0 0% 98%;

  /* Warning */
  --warning: 38 92% 50%;
  --warning-foreground: 0 0% 98%;

  /* Border / Input / Ring */
  --border: 240 5.9% 90%;
  --input: 240 5.9% 90%;
  --ring: 262 83% 58%;

  /* Sidebar */
  --sidebar: 240 5% 97%;
  --sidebar-foreground: 240 5.9% 10%;
  --sidebar-border: 240 5.9% 90%;
  --sidebar-active: 262 83% 58%;

  /* Radius */
  --radius: 0.5rem;
}

.dark {
  --background: 240 10% 3.9%;
  --foreground: 0 0% 98%;

  --card: 240 10% 6%;
  --card-foreground: 0 0% 98%;

  --popover: 240 10% 6%;
  --popover-foreground: 0 0% 98%;

  --primary: 262 83% 65%;
  --primary-foreground: 0 0% 98%;

  --secondary: 240 3.7% 15.9%;
  --secondary-foreground: 0 0% 98%;

  --muted: 240 3.7% 15.9%;
  --muted-foreground: 240 5% 64.9%;

  --accent: 240 3.7% 15.9%;
  --accent-foreground: 0 0% 98%;

  --destructive: 0 62% 50%;
  --destructive-foreground: 0 0% 98%;

  --success: 142 70% 45%;
  --success-foreground: 0 0% 98%;

  --warning: 38 92% 50%;
  --warning-foreground: 0 0% 98%;

  --border: 240 3.7% 15.9%;
  --input: 240 3.7% 15.9%;
  --ring: 262 83% 65%;

  --sidebar: 240 10% 5.5%;
  --sidebar-foreground: 0 0% 98%;
  --sidebar-border: 240 3.7% 15.9%;
  --sidebar-active: 262 83% 65%;
}

/* ============================================
   Base Styles
   ============================================ */

* {
  border-color: hsl(var(--border));
}

body {
  background-color: hsl(var(--background));
  color: hsl(var(--foreground));
  font-feature-settings: "rlig" 1, "calt" 1;
}

/* ============================================
   Scrollbar
   ============================================ */

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: hsl(var(--muted-foreground) / 0.3);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: hsl(var(--muted-foreground) / 0.5);
}

/* ============================================
   Utility Classes
   ============================================ */

.bg-background { background-color: hsl(var(--background)); }
.bg-card { background-color: hsl(var(--card)); }
.bg-primary { background-color: hsl(var(--primary)); }
.bg-secondary { background-color: hsl(var(--secondary)); }
.bg-muted { background-color: hsl(var(--muted)); }
.bg-accent { background-color: hsl(var(--accent)); }
.bg-destructive { background-color: hsl(var(--destructive)); }
.bg-success { background-color: hsl(var(--success)); }
.bg-warning { background-color: hsl(var(--warning)); }
.bg-sidebar { background-color: hsl(var(--sidebar)); }

.text-foreground { color: hsl(var(--foreground)); }
.text-card-foreground { color: hsl(var(--card-foreground)); }
.text-primary { color: hsl(var(--primary)); }
.text-primary-foreground { color: hsl(var(--primary-foreground)); }
.text-secondary-foreground { color: hsl(var(--secondary-foreground)); }
.text-muted-foreground { color: hsl(var(--muted-foreground)); }
.text-accent-foreground { color: hsl(var(--accent-foreground)); }
.text-destructive { color: hsl(var(--destructive)); }
.text-success { color: hsl(var(--success)); }

.border-border { border-color: hsl(var(--border)); }
.border-input { border-color: hsl(var(--input)); }
.ring-ring { --tw-ring-color: hsl(var(--ring)); }

/* ============================================
   Component: Button Base Styles
   ============================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  white-space: nowrap;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.15s ease;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  line-height: 1.25rem;
}

.btn:focus-visible {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
}

.btn:disabled {
  pointer-events: none;
  opacity: 0.5;
}

/* Button variants */
.btn-primary {
  background-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}
.btn-primary:hover { opacity: 0.9; }

.btn-secondary {
  background-color: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
}
.btn-secondary:hover { opacity: 0.8; }

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

.btn-destructive {
  background-color: hsl(var(--destructive));
  color: hsl(var(--destructive-foreground));
}
.btn-destructive:hover { opacity: 0.9; }

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

/* Button sizes */
.btn-sm { height: 2rem; padding: 0 0.75rem; font-size: 0.75rem; }
.btn-md { height: 2.5rem; padding: 0 1rem; }
.btn-lg { height: 2.75rem; padding: 0 2rem; font-size: 1rem; }
.btn-icon { height: 2.5rem; width: 2.5rem; padding: 0; }

/* ============================================
   Component: Card
   ============================================ */

.card {
  background-color: hsl(var(--card));
  color: hsl(var(--card-foreground));
  border-radius: var(--radius);
  border: 1px solid hsl(var(--border));
}

.card-header {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.card-title {
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.025em;
}

.card-description {
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
}

.card-body {
  padding: 0 1.5rem 1.5rem;
}

.card-footer {
  padding: 0 1.5rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ============================================
   Component: Badge
   ============================================ */

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 9999px;
  padding: 0.125rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.25rem;
  transition: colors 0.15s;
}

.badge-draft {
  background-color: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
}

.badge-scheduled {
  background-color: hsl(217 91% 60% / 0.15);
  color: hsl(217 91% 60%);
}

.badge-published {
  background-color: hsl(var(--success) / 0.15);
  color: hsl(var(--success));
}

.badge-primary {
  background-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}

.badge-destructive {
  background-color: hsl(var(--destructive) / 0.15);
  color: hsl(var(--destructive));
}

/* ============================================
   Component: Form Inputs
   ============================================ */

.form-input,
.form-textarea,
.form-select {
  display: block;
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid hsl(var(--input));
  background-color: transparent;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  line-height: 1.25rem;
  color: hsl(var(--foreground));
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: hsl(var(--muted-foreground));
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  outline: none;
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 2px hsl(var(--ring) / 0.2);
}

.form-input:disabled,
.form-textarea:disabled,
.form-select:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.375rem;
  color: hsl(var(--foreground));
}

.form-error {
  font-size: 0.75rem;
  color: hsl(var(--destructive));
  margin-top: 0.25rem;
}

.form-group {
  margin-bottom: 1rem;
}

/* ============================================
   Component: Table
   ============================================ */

.data-table {
  width: 100%;
  caption-side: bottom;
  font-size: 0.875rem;
}

.data-table thead tr {
  border-bottom: 1px solid hsl(var(--border));
}

.data-table th {
  height: 3rem;
  padding: 0 1rem;
  text-align: left;
  vertical-align: middle;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
}

.data-table td {
  padding: 0.75rem 1rem;
  vertical-align: middle;
}

.data-table tbody tr {
  border-bottom: 1px solid hsl(var(--border));
  transition: background-color 0.15s;
}

.data-table tbody tr:hover {
  background-color: hsl(var(--muted) / 0.5);
}

/* ============================================
   Component: Sidebar
   ============================================ */

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 16rem;
  background-color: hsl(var(--sidebar));
  border-right: 1px solid hsl(var(--sidebar-border));
  display: flex;
  flex-direction: column;
  z-index: 40;
  transition: transform 0.3s ease;
}

.sidebar-nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  color: hsl(var(--sidebar-foreground));
  transition: all 0.15s;
  text-decoration: none;
}

.sidebar-nav-link:hover {
  background-color: hsl(var(--accent));
}

.sidebar-nav-link.active {
  background-color: hsl(var(--sidebar-active) / 0.1);
  color: hsl(var(--sidebar-active));
}

/* ============================================
   Component: Topbar
   ============================================ */

.topbar {
  position: fixed;
  top: 0;
  right: 0;
  left: 16rem;
  height: 4rem;
  background-color: hsl(var(--background));
  border-bottom: 1px solid hsl(var(--border));
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  z-index: 30;
}

/* ============================================
   Component: Avatar
   ============================================ */

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  overflow: hidden;
  flex-shrink: 0;
}

.avatar-sm { width: 2rem; height: 2rem; font-size: 0.75rem; }
.avatar-md { width: 2.5rem; height: 2.5rem; font-size: 0.875rem; }
.avatar-lg { width: 3rem; height: 3rem; font-size: 1rem; }

.avatar-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  font-weight: 600;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ============================================
   Component: Dropdown Menu
   ============================================ */

.dropdown-menu {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 0.25rem;
  min-width: 12rem;
  background-color: hsl(var(--popover));
  color: hsl(var(--popover-foreground));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 0.25rem;
  box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  z-index: 50;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.375rem 0.5rem;
  border-radius: calc(var(--radius) - 2px);
  font-size: 0.875rem;
  cursor: pointer;
  transition: background-color 0.15s;
  color: inherit;
  text-decoration: none;
  border: none;
  background: none;
}

.dropdown-item:hover {
  background-color: hsl(var(--accent));
}

.dropdown-separator {
  height: 1px;
  margin: 0.25rem -0.25rem;
  background-color: hsl(var(--border));
}

/* ============================================
   Component: Modal
   ============================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgb(0 0 0 / 0.5);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-content {
  background-color: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25);
  width: 100%;
  max-width: 32rem;
  max-height: 85vh;
  overflow-y: auto;
}

.modal-header {
  padding: 1.5rem;
  border-bottom: 1px solid hsl(var(--border));
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid hsl(var(--border));
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* ============================================
   Component: Toast
   ============================================ */

.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  border: 1px solid hsl(var(--border));
  background-color: hsl(var(--card));
  color: hsl(var(--card-foreground));
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 16rem;
  animation: toast-in 0.3s ease;
}

.toast-success { border-left: 3px solid hsl(var(--success)); }
.toast-error { border-left: 3px solid hsl(var(--destructive)); }
.toast-warning { border-left: 3px solid hsl(var(--warning)); }

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

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

/* ============================================
   Component: Calendar Grid
   ============================================ */

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  overflow: hidden;
}

.calendar-header-cell {
  padding: 0.75rem;
  text-align: center;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  color: hsl(var(--muted-foreground));
  background-color: hsl(var(--muted));
  border-bottom: 1px solid hsl(var(--border));
}

.calendar-day {
  min-height: 7rem;
  padding: 0.25rem;
  border-right: 1px solid hsl(var(--border));
  border-bottom: 1px solid hsl(var(--border));
  background-color: hsl(var(--card));
  position: relative;
}

.calendar-day:nth-child(7n) {
  border-right: none;
}

.calendar-day-number {
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.25rem;
  color: hsl(var(--muted-foreground));
}

.calendar-day.today .calendar-day-number {
  background-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  border-radius: 9999px;
  width: 1.5rem;
  height: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.calendar-day.other-month {
  background-color: hsl(var(--muted) / 0.3);
}

.calendar-day.other-month .calendar-day-number {
  opacity: 0.4;
}

.calendar-post {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.375rem;
  margin: 0.125rem 0;
  border-radius: calc(var(--radius) - 2px);
  font-size: 0.65rem;
  cursor: pointer;
  transition: opacity 0.15s;
  text-decoration: none;
  color: hsl(var(--foreground));
  background-color: hsl(var(--muted));
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.calendar-post:hover {
  opacity: 0.8;
}

.calendar-post .client-dot {
  width: 0.375rem;
  height: 0.375rem;
  border-radius: 9999px;
  flex-shrink: 0;
}

/* ============================================
   Component: Empty State
   ============================================ */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
  text-align: center;
}

.empty-state-icon {
  width: 3rem;
  height: 3rem;
  color: hsl(var(--muted-foreground));
  margin-bottom: 1rem;
}

.empty-state-title {
  font-size: 1rem;
  font-weight: 600;
  color: hsl(var(--foreground));
  margin-bottom: 0.5rem;
}

.empty-state-description {
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
  max-width: 24rem;
}

/* ============================================
   Component: Loading Spinner
   ============================================ */

.spinner {
  display: inline-block;
  border: 2px solid hsl(var(--muted));
  border-top-color: hsl(var(--primary));
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.spinner-sm { width: 1rem; height: 1rem; }
.spinner-md { width: 1.5rem; height: 1.5rem; }
.spinner-lg { width: 2rem; height: 2rem; }

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

/* ============================================
   Layout helpers
   ============================================ */

.main-content {
  margin-left: 16rem;
  margin-top: 4rem;
  padding: 1.5rem;
  min-height: calc(100vh - 4rem);
}

/* Responsive: sidebar collapses */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .topbar {
    left: 0;
  }
  .main-content {
    margin-left: 0;
  }
}

/* ============================================
   Notification badge
   ============================================ */

.notification-badge {
  position: absolute;
  top: -0.25rem;
  right: -0.25rem;
  min-width: 1.125rem;
  height: 1.125rem;
  padding: 0 0.25rem;
  border-radius: 9999px;
  background-color: hsl(var(--destructive));
  color: hsl(var(--destructive-foreground));
  font-size: 0.625rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ============================================
   Stats bar chart (CSS only)
   ============================================ */

.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  height: 8rem;
  padding-top: 0.5rem;
}

.bar-chart-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.bar-chart-bar {
  width: 100%;
  max-width: 3rem;
  background-color: hsl(var(--primary));
  border-radius: var(--radius) var(--radius) 0 0;
  transition: height 0.3s ease;
}

.bar-chart-label {
  font-size: 0.625rem;
  color: hsl(var(--muted-foreground));
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 4rem;
}

.bar-chart-value {
  font-size: 0.75rem;
  font-weight: 600;
  color: hsl(var(--foreground));
}

/* ============================================
   Pagination
   ============================================ */

.pagination {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.pagination-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.375rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  border: 1px solid hsl(var(--border));
  background-color: transparent;
  color: hsl(var(--foreground));
  cursor: pointer;
  transition: all 0.15s;
}

.pagination-btn:hover {
  background-color: hsl(var(--accent));
}

.pagination-btn.active {
  background-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  border-color: hsl(var(--primary));
}

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

/* ============================================
   Kanban: Assignment Pulse Animation
   ============================================ */

@keyframes pulse-border {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.5);
  }
  50% {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0);
  }
}

.assignment-pulse {
  animation: pulse-border 2s ease-in-out infinite;
}
