/* ==========================================================================
   Shadcn UI + Tailwind CSS Design System for IT Repair Web (พี่โจ้)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Kanit:wght@300;400;500;600;700&family=Prompt:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  /* Fluent 2 & Windows 11 Light Theme Palette */
  --bg-page: #f3f5f9;
  --bg-card: #ffffff;
  --text-main: #191b22;
  --text-muted: #5c5e66;
  --border-color: rgba(0, 0, 0, 0.08);
  --primary-color: #8b1e2d;
  --primary-hover: #701825;
  --primary-active: #561320;

  --font-sans: 'Sarabun', 'Segoe UI Variable Text', 'Segoe UI', 'Sarabun', -apple-system, sans-serif;
  --font-heading: 'Sarabun', 'Segoe UI Variable Text', 'Segoe UI', 'Sarabun', sans-serif;
  --font-mono: 'Cascadia Code', 'Consolas', 'JetBrains Mono', monospace;
}

.dark {
  /* Fluent Dark Mode Palette */
  --bg-page: #1a1114;
  --bg-card: #261a1e;
  --text-main: #ffffff;
  --text-muted: #b39ca2;
  --border-color: rgba(255, 255, 255, 0.08);
  --primary-color: #e48a96;
  --primary-hover: #a3283a;
}

html {
  font-family: var(--font-sans);
  scroll-behavior: smooth;
}

body {
  background-color: var(--bg-page);
  color: var(--text-main);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  letter-spacing: -0.01em;
}

code, kbd, samp, pre {
  font-family: var(--font-mono);
}

/* Fluent Card Primitive (8px Radius with Specular Top Highlight) */
.ui-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 0.5rem; /* 8px WinUI 3 card radius */
  box-shadow: inset 0 1px 0 0 rgba(255, 255, 255, 0.75), 0 2px 6px rgba(0, 0, 0, 0.04);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.ui-card-hover:hover {
  border-color: rgba(139, 30, 45, 0.35);
  box-shadow: inset 0 1px 0 0 rgba(255, 255, 255, 0.9), 0 6px 16px rgba(0, 0, 0, 0.06);
  transform: translateY(-1px);
}

/* Fluent Button Primitives (4px Radius) */
.ui-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  border-radius: 0.25rem; /* 4px WinUI 3 control radius */
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 600;
  transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  outline: none;
  gap: 0.375rem;
  height: 2.125rem;
  padding-left: 0.875rem;
  padding-right: 0.875rem;
  cursor: pointer;
}

.ui-btn-primary {
  background-color: var(--primary-color) !important;
  color: #ffffff !important;
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: inset 0 1px 0 0 rgba(255, 255, 255, 0.35), 0 2px 4px rgba(0, 0, 0, 0.08);
}
.ui-btn-primary:hover {
  background-color: var(--primary-hover) !important;
  box-shadow: inset 0 1px 0 0 rgba(255, 255, 255, 0.45), 0 3px 6px rgba(0, 0, 0, 0.12);
}
.ui-btn-primary:active {
  background-color: var(--primary-active) !important;
}

.ui-btn-secondary {
  background-color: #f1f5f9;
  color: #0f172a;
}
.dark .ui-btn-secondary {
  background-color: #3a272d;
  color: #f7eef0;
}

.ui-btn-outline {
  border: 1px solid var(--border-color);
  background-color: var(--bg-card);
  color: var(--text-main);
}
.ui-btn-outline:hover {
  background-color: #f1f5f9;
}
.dark .ui-btn-outline:hover {
  background-color: #3a272d;
}

/* Fluent Input & Select & Textarea Primitives */
.ui-input {
  display: flex;
  height: 2.25rem;
  width: 100%;
  border-radius: 0.25rem; /* 4px WinUI 3 radius */
  border: 1px solid rgba(0, 0, 0, 0.14);
  border-bottom: 1px solid rgba(0, 0, 0, 0.40);
  background-color: var(--bg-card);
  padding: 0 0.75rem;
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  color: var(--text-main);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.02);
  transition: all 0.15s ease-in-out;
  outline: none;
}

.ui-input:hover {
  border-color: rgba(0, 0, 0, 0.25);
  border-bottom-color: rgba(0, 0, 0, 0.60);
}

.ui-input:focus-visible,
.ui-input:focus {
  outline: none;
  border-color: rgba(0, 0, 0, 0.14);
  border-bottom: 2px solid var(--primary-color);
  box-shadow: 0 1px 3px rgba(139, 30, 45, 0.15);
}

.ui-input::placeholder {
  color: var(--text-muted);
}

/* Fluent Select Primitive (Custom Chevron Icon) */
select.ui-input,
.ui-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23414750' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1rem;
  padding-right: 2.25rem;
  cursor: pointer;
}

.dark select.ui-input,
.dark .ui-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23a0a0a0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

/* Fluent Textarea Primitive */
.ui-textarea {
  display: flex;
  min-height: 4.5rem;
  width: 100%;
  border-radius: 0.25rem;
  border: 1px solid rgba(0, 0, 0, 0.14);
  border-bottom: 1px solid rgba(0, 0, 0, 0.40);
  background-color: var(--bg-card);
  padding: 0.5rem 0.75rem;
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  color: var(--text-main);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.02);
  transition: all 0.15s ease-in-out;
  resize: vertical;
  outline: none;
}

.ui-textarea:focus-visible,
.ui-textarea:focus {
  outline: none;
  border-color: rgba(0, 0, 0, 0.14);
  border-bottom: 2px solid var(--primary-color);
  box-shadow: 0 1px 3px rgba(139, 30, 45, 0.15);
}

/* Shadcn Tabs Primitive */
.ui-tabs-list {
  display: inline-flex;
  height: 2.25rem;
  align-items: center;
  justify-content: center;
  border-radius: 0.5rem;
  background-color: #f1f5f9;
  padding: 0.25rem;
  color: #64748b;
}

.dark .ui-tabs-list {
  background-color: #3a272d;
  color: #b39ca2;
}

.ui-tabs-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  border-radius: 0.375rem;
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  transition: all 0.15s ease-in-out;
  text-decoration: none;
}

.ui-tabs-trigger.active {
  background-color: var(--bg-card);
  color: var(--text-main);
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

/* Shadcn Table Primitives */
.ui-table-container {
  width: 100%;
  overflow-x: auto;
  border-radius: 0.75rem;
  border: 1px solid var(--border-color);
  background-color: var(--bg-card);
}

.ui-table {
  width: 100%;
  caption-side: bottom;
  font-size: 0.8125rem;
  border-collapse: collapse;
}

.ui-table thead tr {
  border-bottom: 1px solid var(--border-color);
  background-color: rgba(248, 250, 252, 0.6);
}

.dark .ui-table thead tr {
  background-color: rgba(58, 39, 45, 0.4);
}

.ui-table th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.75rem;
  letter-spacing: 0.025em;
}

.ui-table tbody tr {
  border-bottom: 1px solid var(--border-color);
  transition: background-color 0.15s ease-in-out;
}

.ui-table tbody tr:last-child {
  border-bottom: 0;
}

.ui-table tbody tr:hover {
  background-color: rgba(241, 245, 249, 0.5);
}

.dark .ui-table tbody tr:hover {
  background-color: rgba(58, 39, 45, 0.3);
}

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

/* Smooth micro-animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-in-fade {
  animation: fadeIn 0.2s ease-in-out;
}

/* Custom Sleek Scrollbar */
::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 9999px;
}
.dark ::-webkit-scrollbar-thumb {
  background: #4d353c;
}
