/* ============================================
   KENTUNEZ DISTRIBUTION - Base & Reset
   ============================================ */

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-base);
  color: var(--gray-800);
  background: var(--gray-50);
  line-height: 1.5;
  overflow-x: hidden;
}

a {
  text-decoration: none;
  color: inherit;
}

img {
  max-width: 100%;
  display: block;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
  font-size: inherit;
}

input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  border: none;
  outline: none;
}

ul, ol {
  list-style: none;
}

table {
  border-collapse: collapse;
  width: 100%;
}

/* Scrollbar Styling */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* ============================================
   UTILITY CLASSES
   ============================================ */

.text-xs { font-size: var(--font-xs); }
.text-sm { font-size: var(--font-sm); }
.text-base { font-size: var(--font-base); }
.text-md { font-size: var(--font-md); }
.text-lg { font-size: var(--font-lg); }
.text-xl { font-size: var(--font-xl); }
.text-2xl { font-size: var(--font-2xl); }
.text-3xl { font-size: var(--font-3xl); }

.font-normal { font-weight: 400; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

.text-muted { color: var(--gray-500); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }

.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ============================================
   COMPONENT: Buttons
   ============================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0.5rem 1rem;
  font-size: var(--font-sm);
  font-weight: 500;
  border-radius: var(--border-radius);
  transition: all var(--transition-fast);
  white-space: nowrap;
  line-height: 1;
}

.btn-primary {
  background: var(--primary);
  color: var(--white);
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary {
  background: var(--gray-100);
  color: var(--gray-700);
  border: 1px solid var(--gray-200);
}
.btn-secondary:hover { background: var(--gray-200); }

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
}
.btn-outline:hover { background: var(--primary-bg); }

.btn-ghost {
  background: transparent;
  color: var(--gray-600);
}
.btn-ghost:hover { background: var(--gray-100); }

.btn-danger {
  background: var(--danger);
  color: var(--white);
}
.btn-danger:hover { background: #DC2626; }

.btn-sm { padding: 0.375rem 0.75rem; font-size: var(--font-xs); }
.btn-lg { padding: 0.625rem 1.25rem; font-size: var(--font-md); }
.btn-icon { padding: 0.5rem; }

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ============================================
   COMPONENT: Form Controls
   ============================================ */

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.form-label {
  font-size: var(--font-xs);
  font-weight: 500;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: var(--font-sm);
  color: var(--gray-800);
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--border-radius);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(232, 97, 26, 0.1);
}

.form-input::placeholder { color: var(--gray-400); }

.form-textarea {
  resize: vertical;
  min-height: 80px;
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2rem;
}

.form-check {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-sm);
}

.form-check input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--primary);
}

.form-error {
  font-size: var(--font-xs);
  color: var(--danger);
}

/* ============================================
   COMPONENT: Cards
   ============================================ */

.card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--border-radius-lg);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--gray-100);
}

.card-title {
  font-size: var(--font-sm);
  font-weight: 600;
  color: var(--gray-800);
}

.card-body {
  padding: var(--space-5);
}

.card-footer {
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--gray-100);
  background: var(--gray-50);
}

/* ============================================
   COMPONENT: Badges
   ============================================ */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  font-size: var(--font-xs);
  font-weight: 500;
  border-radius: var(--border-radius-full);
  line-height: 1.5;
}

.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-neutral { background: var(--gray-100); color: var(--gray-600); }
.badge-primary { background: var(--primary-bg); color: var(--primary); }

/* ============================================
   COMPONENT: Tables
   ============================================ */

.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  font-size: var(--font-sm);
}

.data-table th {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  font-size: var(--font-xs);
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--gray-200);
  background: var(--gray-50);
  white-space: nowrap;
}

.data-table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}

.data-table tbody tr:hover {
  background: var(--gray-50);
}

/* ============================================
   COMPONENT: Tabs
   ============================================ */

.tabs {
  display: flex;
  border-bottom: 1px solid var(--gray-200);
  gap: 0;
}

.tab-btn {
  padding: var(--space-3) var(--space-5);
  font-size: var(--font-xs);
  font-weight: 500;
  color: var(--gray-500);
  border-bottom: 2px solid transparent;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  transition: all var(--transition-fast);
}

.tab-btn:hover { color: var(--gray-700); }

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: var(--primary-bg);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ============================================
   COMPONENT: Modal
   ============================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-base);
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--white);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-xl);
  max-width: 500px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  transform: translateY(10px);
  transition: transform var(--transition-base);
}

.modal-overlay.open .modal {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--gray-100);
}

.modal-body { padding: var(--space-5); }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--gray-100);
}

/* ============================================
   COMPONENT: Stat Cards
   ============================================ */

.stat-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--border-radius-lg);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.stat-card .stat-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--border-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-lg);
}

.stat-card .stat-value {
  font-size: var(--font-2xl);
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1;
}

.stat-card .stat-label {
  font-size: var(--font-xs);
  color: var(--gray-500);
}

.stat-card .stat-change {
  font-size: var(--font-xs);
  font-weight: 500;
}

.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ============================================
   COMPONENT: Avatar
   ============================================ */

.avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--border-radius-full);
  object-fit: cover;
  background: var(--gray-200);
}

.avatar-sm { width: 24px; height: 24px; }
.avatar-lg { width: 40px; height: 40px; }
.avatar-xl { width: 56px; height: 56px; }

/* ============================================
   COMPONENT: Dropdown
   ============================================ */

.dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 180px;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  display: none;
  padding: var(--space-1) 0;
}

.dropdown.open .dropdown-menu { display: block; }

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  font-size: var(--font-sm);
  color: var(--gray-700);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.dropdown-item:hover { background: var(--gray-50); }
.dropdown-divider { height: 1px; background: var(--gray-100); margin: var(--space-1) 0; }

/* ============================================
   COMPONENT: Progress Bar
   ============================================ */

.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--gray-200);
  border-radius: var(--border-radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: var(--border-radius-full);
  transition: width var(--transition-slow);
}

/* ============================================
   COMPONENT: Toast / Notification
   ============================================ */

.toast-container {
  position: fixed;
  top: var(--space-4);
  right: var(--space-4);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.toast {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-lg);
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--font-sm);
  min-width: 280px;
  animation: slideIn 0.3s ease;
}

.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); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ============================================
   COMPONENT: Empty State
   ============================================ */

.empty-state {
  text-align: center;
  padding: var(--space-12) var(--space-8);
  color: var(--gray-500);
}

.empty-state svg { margin: 0 auto var(--space-4); opacity: 0.4; }
.empty-state h3 { font-size: var(--font-md); font-weight: 600; color: var(--gray-700); margin-bottom: var(--space-1); }
.empty-state p { font-size: var(--font-sm); }

/* ============================================
   LOADING SPINNER
   ============================================ */

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================
   RESPONSIVE GRID
   ============================================ */

.grid { display: grid; gap: var(--space-4); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
}
