/*
 * Solverly Component Styles
 * =========================
 * Reusable component classes using design tokens
 */

/* ========================
 * BUTTONS
 * ======================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1.5;
  border-radius: var(--border-radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
  min-height: 40px;
}

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

.btn-primary {
  background: var(--gradient-cta);
  color: var(--text-inverse);
  border-color: transparent;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  box-shadow: var(--shadow-glow-accent);
}

.btn-secondary {
  background: var(--accent-secondary);
  color: var(--text-primary);
  border-color: transparent;
}

.btn-secondary:hover:not(:disabled) {
  background: var(--accent-secondary-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.btn-danger {
  background: var(--danger);
  color: var(--text-primary);
  border-color: transparent;
}

.btn-danger:hover:not(:disabled) {
  background: #dc2626;
  box-shadow: var(--shadow-glow-danger);
}

.btn-warning {
  background: var(--warning);
  color: var(--text-inverse);
  border-color: transparent;
}

.btn-warning:hover:not(:disabled) {
  background: #d97706;
}

/* Button Sizes */
.btn-sm {
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--text-xs);
  min-height: 32px;
}

.btn-lg {
  padding: var(--space-md) var(--space-lg);
  font-size: var(--text-base);
  min-height: 48px;
}

.btn-icon {
  padding: var(--space-sm);
  min-height: 40px;
  min-width: 40px;
}

.btn-icon.btn-sm {
  padding: var(--space-xs);
  min-height: 32px;
  min-width: 32px;
}

/* ========================
 * INPUTS
 * ======================== */

.input-field,
.textarea-field,
.select-field {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  transition: all var(--transition-fast);
  outline: none;
}

.input-field:focus,
.textarea-field:focus,
.select-field:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.input-field::placeholder,
.textarea-field::placeholder {
  color: var(--text-muted);
}

.textarea-field {
  min-height: 100px;
  resize: vertical;
}

.select-field {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 40px;
}

/* Input with icon */
.input-wrapper {
  position: relative;
}

.input-wrapper .input-icon {
  position: absolute;
  left: var(--space-md);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.input-wrapper .input-field {
  padding-left: 40px;
}

/* ========================
 * CARDS
 * ======================== */

.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--border-radius-lg);
  padding: var(--space-md);
  transition: all var(--transition-fast);
}

.card:hover {
  border-color: var(--border);
}

.card-elevated {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--border-radius-lg);
  padding: var(--space-md);
  box-shadow: var(--shadow);
}

.card-clickable {
  cursor: pointer;
}

.card-clickable:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-lg);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--border-subtle);
}

.card-title {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text-primary);
}

.card-body {
  color: var(--text-secondary);
}

/* ========================
 * BADGES
 * ======================== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 2px 8px;
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1.5;
  border-radius: 9999px;
  white-space: nowrap;
}

.badge-high {
  background: var(--priority-high-soft);
  color: var(--priority-high);
  border: 1px solid var(--priority-high-border);
}

.badge-medium {
  background: var(--priority-medium-soft);
  color: var(--priority-medium);
  border: 1px solid var(--priority-medium-border);
}

.badge-low {
  background: var(--priority-low-soft);
  color: var(--priority-low);
  border: 1px solid var(--priority-low-border);
}

.badge-project {
  background: var(--priority-project-soft);
  color: var(--priority-project);
  border: 1px solid var(--priority-project-border);
}

.badge-status {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.badge-status-open {
  background: var(--status-open-soft);
  color: var(--status-open);
  border: 1px solid rgba(0, 212, 170, 0.3);
}

.badge-status-pending {
  background: var(--status-pending-soft);
  color: var(--status-pending);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-status-closed {
  background: var(--status-closed-soft);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.badge-status-escalated {
  background: var(--status-escalated-soft);
  color: var(--status-escalated);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Role badges */
.badge-reporter {
  background: var(--reporter-soft);
  color: var(--reporter);
  border: 1px solid var(--reporter-border);
}

.badge-controller {
  background: var(--controller-soft);
  color: var(--controller);
  border: 1px solid var(--controller-border);
}

.badge-solver {
  background: var(--solver-soft);
  color: var(--solver);
  border: 1px solid var(--solver-border);
}

.badge-system {
  background: var(--system-soft);
  color: var(--text-secondary);
  border: 1px solid var(--system-border);
}

/* Channel badges */
.badge-channel {
  background: var(--bg-elevated);
  color: var(--text-muted);
  border: 1px solid var(--border);
  font-size: 10px;
  padding: 1px 6px;
}

.badge-channel-whatsapp {
  background: rgba(37, 211, 102, 0.15);
  color: #25d366;
  border-color: rgba(37, 211, 102, 0.3);
}

.badge-channel-email {
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
  border-color: rgba(59, 130, 246, 0.3);
}

.badge-channel-portal {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: rgba(0, 212, 170, 0.3);
}

/* ========================
 * CHAT BUBBLES
 * ======================== */

.bubble {
  display: flex;
  flex-direction: column;
  padding: var(--space-md);
  border-radius: var(--border-radius-lg);
  background: var(--bg-secondary);
  border-left: 3px solid var(--border);
  margin-bottom: var(--space-md);
  transition: all var(--transition-fast);
}

.bubble:hover {
  background: var(--bg-elevated);
}

.bubble-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
  flex-wrap: wrap;
}

.bubble-author {
  font-weight: 600;
  font-size: var(--text-sm);
}

.bubble-timestamp {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.bubble-content {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.6;
}

.bubble-content p {
  margin: 0 0 var(--space-sm) 0;
}

.bubble-content p:last-child {
  margin-bottom: 0;
}

.bubble-actions {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
  flex-wrap: wrap;
}

/* Role-specific bubbles */
.bubble-reporter {
  border-left-color: var(--reporter);
}

.bubble-reporter .bubble-author {
  color: var(--reporter);
}

.bubble-controller {
  border-left-color: var(--controller);
}

.bubble-controller .bubble-author {
  color: var(--controller);
}

.bubble-solver {
  border-left-color: var(--solver);
}

.bubble-solver .bubble-author {
  color: var(--solver);
}

.bubble-system {
  border-left-color: var(--system);
  background: var(--system-soft);
}

.bubble-system .bubble-author {
  color: var(--text-muted);
}

.bubble-system .bubble-content {
  color: var(--text-muted);
  font-size: var(--text-xs);
}

/* Internal note bubble */
.bubble-internal {
  border-left-color: var(--warning);
  background: var(--warning-soft);
}

.bubble-internal .bubble-author::after {
  content: "Internal";
  margin-left: var(--space-sm);
  font-size: var(--text-xs);
  font-weight: 500;
  padding: 1px 6px;
  background: var(--warning);
  color: var(--text-inverse);
  border-radius: 4px;
}

/* ========================
 * TABS
 * ======================== */

.tabs {
  display: flex;
  gap: var(--space-xs);
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 0;
  margin-bottom: var(--space-md);
  overflow-x: auto;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  margin-bottom: -1px;
}

.tab:hover {
  color: var(--text-secondary);
}

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* ========================
 * SCROLLBAR
 * ======================== */

.custom-scroll {
  scrollbar-width: thin;
  scrollbar-color: var(--accent) transparent;
}

.custom-scroll::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.custom-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.custom-scroll::-webkit-scrollbar-thumb {
  background: rgba(0, 212, 170, 0.4);
  border-radius: 3px;
}

.custom-scroll::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 212, 170, 0.6);
}

/* Subtle scrollbar variant */
.scroll-subtle::-webkit-scrollbar-thumb {
  background: var(--border);
}

.scroll-subtle::-webkit-scrollbar-thumb:hover {
  background: var(--border-hover);
}

/* ========================
 * MODALS
 * ======================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-base);
}

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

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--border-radius-xl);
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
  transform: scale(0.95);
  transition: transform var(--transition-base);
}

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

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border-subtle);
}

.modal-title {
  font-size: var(--text-lg);
  font-weight: 600;
}

.modal-close {
  padding: var(--space-xs);
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  border-radius: var(--border-radius);
  transition: all var(--transition-fast);
}

.modal-close:hover {
  color: var(--text-primary);
  background: var(--bg-elevated);
}

.modal-body {
  padding: var(--space-lg);
  overflow-y: auto;
}

.modal-footer {
  display: flex;
  gap: var(--space-sm);
  justify-content: flex-end;
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--border-subtle);
}

/* ========================
 * TOASTS
 * ======================== */

.toast-container {
  position: fixed;
  top: var(--space-lg);
  right: var(--space-lg);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  max-width: 400px;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  padding: var(--space-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-lg);
  animation: slideIn var(--transition-base) ease-out;
}

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

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

.toast-error {
  border-left: 3px solid var(--danger);
}

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

.toast-info {
  border-left: 3px solid var(--info);
}

/* ========================
 * TABLES
 * ======================== */

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.table th,
.table td {
  padding: var(--space-sm) var(--space-md);
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}

.table th {
  font-weight: 600;
  color: var(--text-muted);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.table tr:hover td {
  background: var(--bg-elevated);
}

/* ========================
 * LOADING STATES
 * ======================== */

.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-secondary) 25%,
    var(--bg-elevated) 50%,
    var(--bg-secondary) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--border-radius);
}

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

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ========================
 * PANEL LAYOUT
 * ======================== */

.panel-container {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.panel-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  transition: width var(--transition-panel), transform var(--transition-panel);
  overflow: hidden;
}

.panel-sidebar.collapsed {
  width: 0;
  border-left: none;
}

/* Mobile sidebar overlay */
@media (max-width: 768px) {
  .panel-sidebar {
    position: fixed;
    top: var(--header-height);
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 360px;
    transform: translateX(100%);
    z-index: var(--z-overlay);
    box-shadow: var(--shadow-xl);
  }

  .panel-sidebar.open {
    transform: translateX(0);
  }

  .panel-sidebar-backdrop {
    position: fixed;
    inset: 0;
    top: var(--header-height);
    background: rgba(0, 0, 0, 0.5);
    z-index: calc(var(--z-overlay) - 1);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base);
  }

  .panel-sidebar-backdrop.visible {
    opacity: 1;
    visibility: visible;
  }
}

/* Toggle button */
.panel-toggle {
  position: fixed;
  right: var(--space-md);
  bottom: var(--space-md);
  z-index: calc(var(--z-overlay) + 1);
  display: none;
}

@media (max-width: 768px) {
  .panel-toggle {
    display: flex;
  }
}

/* ========================
 * TICKET CARD
 * ======================== */

.ticket-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding: var(--space-md);
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--border-radius-lg);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.ticket-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-soft);
}

.ticket-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
}

.ticket-card-ref {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.ticket-card-title {
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--text-primary);
  line-height: 1.4;
}

.ticket-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* ========================
 * QUICK ACTIONS
 * ======================== */

.quick-actions {
  display: flex;
  gap: var(--space-sm);
  padding: var(--space-md);
  background: var(--bg-primary);
  border-top: 1px solid var(--border-subtle);
}

.quick-action-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.quick-action-btn:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.quick-action-btn.sow {
  border-color: var(--controller-border);
  color: var(--controller);
}

.quick-action-btn.sow:hover {
  background: var(--controller-soft);
}

.quick-action-btn.rfq {
  border-color: var(--accent-secondary);
  color: var(--accent-secondary);
}

.quick-action-btn.rfq:hover {
  background: var(--accent-secondary-soft);
}

.quick-action-btn.schedule {
  border-color: var(--warning);
  color: var(--warning);
}

.quick-action-btn.schedule:hover {
  background: var(--warning-soft);
}

/* ========================
 * MESSAGE COMPOSER
 * ======================== */

.composer {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding: var(--space-md);
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-subtle);
}

.composer-options {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  font-size: var(--text-xs);
}

.composer-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  cursor: pointer;
}

.composer-toggle input {
  accent-color: var(--accent);
}

.composer-input-row {
  display: flex;
  gap: var(--space-sm);
}

.composer-textarea {
  flex: 1;
  min-height: 60px;
  max-height: 150px;
  padding: var(--space-sm) var(--space-md);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--text-primary);
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  resize: none;
  outline: none;
  transition: all var(--transition-fast);
}

.composer-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.composer-send {
  align-self: flex-end;
  padding: var(--space-sm) var(--space-md);
  font-weight: 600;
  background: var(--gradient-cta);
  color: var(--text-inverse);
  border: none;
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.composer-send:hover {
  box-shadow: var(--shadow-glow-accent);
}

.composer-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ========================
 * SLA TIMER
 * ======================== */

.sla-timer-display {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: var(--text-sm);
}

.sla-timer-paused {
  color: var(--text-muted);
}

/* ========================
 * EMPTY STATE
 * ======================== */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl);
  text-align: center;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: var(--space-md);
  opacity: 0.5;
}

.empty-state-title {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
}

.empty-state-text {
  font-size: var(--text-sm);
  max-width: 300px;
}
