/**
 * Design Kit — UI Kit на базе дизайн-системы мобильного приложения
 * Mobile-first, CSS Custom Properties
 */

/* ============================================
   DESIGN TOKENS (CSS Custom Properties)
   ============================================ */

:root {
  /* Colors */
  --color-primary: #E15016;
  --color-primary-dark: #B44012;
  --color-secondary: #4496EB;
  --color-neutral-white: #FFFFFF;
  --color-neutral-black: #0F0F0F;
  --color-error: #D1342B;
  --color-success: #73CA34;

  /* Semantic colors */
  --color-bg: #0F0F0F;
  --color-bg-elevated: #1A1A1A;
  --color-bg-input: #252525;
  --color-text: #FFFFFF;
  --color-text-secondary: rgba(255, 255, 255, 0.7);
  --color-text-muted: rgba(255, 255, 255, 0.5);
  --color-border: rgba(255, 255, 255, 0.15);
  --color-border-focus: #E15016;

  /* Typography */
  --font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", Roboto, sans-serif;

  --font-size-xs: 0.75rem;   /* 12px */
  --font-size-sm: 0.875rem;  /* 14px */
  --font-size-base: 1rem;    /* 16px */
  --font-size-lg: 1.125rem;  /* 18px */
  --font-size-xl: 1.25rem;  /* 20px */
  --font-size-2xl: 1.5rem;  /* 24px */
  --font-size-3xl: 1.875rem; /* 30px */
  --font-size-4xl: 2.25rem; /* 36px */

  --font-weight-regular: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;

  --line-height-tight: 1.2;
  --line-height-normal: 1.5;
  --line-height-relaxed: 1.6;

  /* Spacing */
  --space-xs: 0.25rem;   /* 4px */
  --space-sm: 0.5rem;    /* 8px */
  --space-md: 1rem;      /* 16px */
  --space-lg: 1.5rem;    /* 24px */
  --space-xl: 2rem;      /* 32px */
  --space-2xl: 3rem;     /* 48px */

  /* Border radius */
  --radius-sm: 8px;
  --radius-base: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
}

/* ============================================
   BASE STYLES
   ============================================ */

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-regular);
  line-height: var(--line-height-normal);
  color: var(--color-text);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   TYPOGRAPHY
   ============================================ */

.dk-h1,
h1.dk {
  font-size: var(--font-size-4xl);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
  margin: 0 0 var(--space-md);
  letter-spacing: -0.02em;
}

.dk-h2,
h2.dk {
  font-size: var(--font-size-3xl);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
  margin: 0 0 var(--space-md);
  letter-spacing: -0.01em;
}

.dk-h3,
h3.dk {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-tight);
  margin: 0 0 var(--space-sm);
}

.dk-h4,
h4.dk {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-normal);
  margin: 0 0 var(--space-sm);
}

.dk-body,
.dk-p {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-regular);
  line-height: var(--line-height-relaxed);
  margin: 0 0 var(--space-md);
  color: var(--color-text-secondary);
}

.dk-caption {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-regular);
  line-height: var(--line-height-normal);
  margin: 0;
  color: var(--color-text-muted);
}

.dk-label {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  line-height: var(--line-height-normal);
  margin: 0 0 var(--space-xs);
  color: var(--color-text);
}

/* ============================================
   BUTTONS
   ============================================ */

.dk-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  font-family: inherit;
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  line-height: 1;
  text-decoration: none;
  border: none;
  border-radius: var(--radius-base);
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast),
    border-color var(--transition-fast), opacity var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.dk-btn:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

/* Primary */
.dk-btn--primary {
  background-color: var(--color-primary);
  color: var(--color-neutral-white);
}

.dk-btn--primary:hover:not(:disabled) {
  background-color: var(--color-primary-dark);
}

.dk-btn--primary:active:not(:disabled) {
  background-color: var(--color-primary-dark);
}

/* Secondary */
.dk-btn--secondary {
  background-color: var(--color-secondary);
  color: var(--color-neutral-white);
}

.dk-btn--secondary:hover:not(:disabled) {
  background-color: #3a82d4;
}

/* Outline */
.dk-btn--outline {
  background-color: transparent;
  color: var(--color-text);
  border: 2px solid var(--color-border);
}

.dk-btn--outline:hover:not(:disabled) {
  border-color: var(--color-text-muted);
  background-color: rgba(255, 255, 255, 0.05);
}

/* Ghost */
.dk-btn--ghost {
  background-color: transparent;
  color: var(--color-text-secondary);
}

.dk-btn--ghost:hover:not(:disabled) {
  background-color: rgba(255, 255, 255, 0.08);
  color: var(--color-text);
}

/* Sizes */
.dk-btn--sm {
  padding: var(--space-sm) var(--space-md);
  font-size: var(--font-size-sm);
  min-height: 36px;
}

.dk-btn--md {
  padding: var(--space-md) var(--space-lg);
  min-height: 48px;
}

.dk-btn--lg {
  padding: var(--space-md) var(--space-xl);
  font-size: var(--font-size-lg);
  min-height: 56px;
}

.dk-btn--full {
  width: 100%;
}

/* Icon button */
.dk-btn--icon {
  padding: var(--space-md);
  min-width: 48px;
  min-height: 48px;
}

.dk-btn--icon.dk-btn--sm {
  min-width: 36px;
  min-height: 36px;
  padding: var(--space-sm);
}

/* ============================================
   FORMS
   ============================================ */

.dk-form-group {
  margin-bottom: var(--space-lg);
}

.dk-input,
.dk-select {
  display: block;
  width: 100%;
  font-family: inherit;
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-regular);
  color: var(--color-text);
  background-color: var(--color-bg-input);
  border: 2px solid transparent;
  border-radius: var(--radius-base);
  padding: var(--space-md) var(--space-lg);
  min-height: 52px;
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
  -webkit-appearance: none;
  appearance: none;
}

.dk-input::placeholder {
  color: var(--color-text-muted);
}

.dk-input:hover,
.dk-select:hover {
  background-color: #2a2a2a;
}

.dk-input:focus,
.dk-select:focus {
  outline: none;
  border-color: var(--color-border-focus);
  background-color: var(--color-bg-input);
}

.dk-input:disabled,
.dk-select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.dk-input--error {
  border-color: var(--color-error);
}

.dk-input--error:focus {
  border-color: var(--color-error);
}

.dk-select {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' 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 var(--space-md) center;
  background-size: 20px;
  padding-right: 48px;
}

/* Checkbox */
.dk-checkbox {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  cursor: pointer;
  user-select: none;
}

.dk-checkbox__input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.dk-checkbox__box {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  background-color: var(--color-bg-input);
  border: 2px solid var(--color-border);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
}

.dk-checkbox__input:checked + .dk-checkbox__box {
  background-color: var(--color-primary);
  border-color: var(--color-primary);
}

.dk-checkbox__input:focus-visible + .dk-checkbox__box {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.dk-checkbox__box::after {
  content: '';
  width: 6px;
  height: 10px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) scale(0);
  margin-bottom: 4px;
  transition: transform var(--transition-fast);
}

.dk-checkbox__input:checked + .dk-checkbox__box::after {
  transform: rotate(45deg) scale(1);
}

.dk-checkbox__label {
  font-size: var(--font-size-base);
  color: var(--color-text);
  line-height: 1.5;
}

/* Form error message */
.dk-form-error {
  font-size: var(--font-size-sm);
  color: var(--color-error);
  margin-top: var(--space-xs);
}

/* ============================================
   CARDS
   ============================================ */

.dk-card {
  background-color: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-base);
  padding: var(--space-lg);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.dk-card:hover {
  border-color: rgba(255, 255, 255, 0.25);
}

.dk-card__title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  margin: 0 0 var(--space-sm);
}

.dk-card__content {
  font-size: var(--font-size-base);
  color: var(--color-text-secondary);
  margin: 0;
  line-height: var(--line-height-relaxed);
}

.dk-card--interactive {
  cursor: pointer;
}

.dk-card--interactive:hover {
  box-shadow: var(--shadow-md);
}

/* ============================================
   BADGES
   ============================================ */

.dk-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  line-height: 1;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.dk-badge--primary {
  background-color: rgba(225, 80, 22, 0.25);
  color: var(--color-primary);
}

.dk-badge--secondary {
  background-color: rgba(68, 150, 235, 0.25);
  color: var(--color-secondary);
}

.dk-badge--success {
  background-color: rgba(115, 202, 52, 0.25);
  color: var(--color-success);
}

.dk-badge--error {
  background-color: rgba(209, 52, 43, 0.25);
  color: var(--color-error);
}

.dk-badge--neutral {
  background-color: rgba(255, 255, 255, 0.15);
  color: var(--color-text-secondary);
}

.dk-badge--outline {
  background-color: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
}

/* ============================================
   ICONS (Utility classes for inline SVG)
   ============================================ */

.dk-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.dk-icon svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
  stroke: currentColor;
}

.dk-icon--sm {
  width: 20px;
  height: 20px;
}

.dk-icon--lg {
  width: 32px;
  height: 32px;
}

/* ============================================
   UTILITIES
   ============================================ */

.dk-section {
  margin-bottom: var(--space-2xl);
}

.dk-section__title {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-semibold);
  margin: 0 0 var(--space-lg);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--color-border);
}

.dk-grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
}

.dk-flex {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.dk-flex--column {
  flex-direction: column;
  align-items: stretch;
}

.dk-color-swatch {
  width: 100%;
  min-height: 80px;
  border-radius: var(--radius-base);
  border: 1px solid var(--color-border);
}

/* ============================================
   SLIDER (Range input)
   ============================================ */

.dk-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  background: var(--color-bg-input);
  border-radius: var(--radius-full);
  outline: none;
}

.dk-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  background: var(--color-neutral-white);
  border: 3px solid var(--color-primary);
  border-radius: 50%;
  cursor: pointer;
  transition: transform var(--transition-fast);
}

.dk-slider::-webkit-slider-thumb:hover {
  transform: scale(1.1);
}

.dk-slider::-moz-range-thumb {
  width: 24px;
  height: 24px;
  background: var(--color-neutral-white);
  border: 3px solid var(--color-primary);
  border-radius: 50%;
  cursor: pointer;
}

/* ============================================
   LOADER
   ============================================ */

.dk-loader {
  width: 48px;
  height: 48px;
  border: 4px solid var(--color-bg-input);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: dk-spin 0.8s linear infinite;
}

@keyframes dk-spin {
  to {
    transform: rotate(360deg);
  }
}
