/* 
 * ДИЗАЙН ПО ПРИНЦИПАМ ДОНАЛЬДА НОРМАНА
 * "The Design of Everyday Things" применён к веб-дизайну
 */

/* ==========================================
   1. VISIBILITY (Видимость)
   Всё важное должно быть видно сразу
   ========================================== */

/* Чёткая типографика - без лишних украшений */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    font-size: 18px; /* Увеличен для читаемости */
    line-height: 1.7; /* Комфортное чтение */
    letter-spacing: 0.01em;
}

/* Контрастные заголовки - чёткая иерархия */
h1, h2, h3 {
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 0.75em;
    color: var(--text-color);
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }

/* Кнопки с явным affordance (понятно что кликабельно) */
button, .btn, a.btn {
    /* Явная кнопка - выглядит как кнопка */
    padding: 16px 32px;
    border-radius: 12px;
    border: 2px solid transparent;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    
    /* Тень показывает что это поднято и кликабельно */
    box-shadow: 
        0 2px 8px rgba(0, 0, 0, 0.1),
        0 1px 3px rgba(0, 0, 0, 0.06);
}

/* Первичная кнопка - явная */
.btn-primary {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* ==========================================
   2. FEEDBACK (Обратная связь)
   Мгновенная реакция на каждое действие
   ========================================== */

/* Hover - показываем что элемент интерактивный */
button:hover, .btn:hover {
    transform: translateY(-2px);
    box-shadow: 
        0 4px 16px rgba(0, 0, 0, 0.15),
        0 2px 6px rgba(0, 0, 0, 0.08);
}

/* Active - показываем нажатие */
button:active, .btn:active {
    transform: translateY(0);
    box-shadow: 
        0 1px 4px rgba(0, 0, 0, 0.1),
        0 0px 2px rgba(0, 0, 0, 0.06);
}

/* Focus - показываем фокус для клавиатуры */
button:focus, .btn:focus, input:focus, textarea:focus {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

/* Disabled - явно показываем недоступность */
button:disabled, .btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* Loading state - показываем процесс */
.btn-loading {
    position: relative;
    color: transparent !important;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    margin-left: -10px;
    margin-top: -10px;
    border: 3px solid white;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 0.6s linear infinite;
}

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

/* ==========================================
   3. AFFORDANCE (Предоставление возможностей)
   Элементы показывают как их использовать
   ========================================== */

/* Ссылки - подчёркнуты и цветные */
a {
    color: var(--primary-color);
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
    transition: all 0.2s;
}

a:hover {
    text-decoration-thickness: 3px;
    color: var(--fair-rust);
}

/* Поля ввода - явная рамка и метки */
input, textarea, select {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px;
    font-family: inherit;
    transition: all 0.2s;
    background: white;
}

input:hover, textarea:hover, select:hover {
    border-color: var(--primary-color);
}

input:focus, textarea:focus, select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(216, 67, 21, 0.1);
}

/* Метки всегда видны */
label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 15px;
    color: var(--text-color);
}

/* Плейсхолдеры - подсказки */
::placeholder {
    color: var(--text-muted);
    opacity: 0.7;
}

/* ==========================================
   4. MAPPING (Соответствие)
   Логичная связь между действием и результатом
   ========================================== */

/* Карточки товаров - вертикальный layout */
.product-card {
    display: flex;
    flex-direction: column;
    background: white;
    border: 2px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
    transition: all 0.3s ease;
    cursor: pointer;
}

.product-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-4px);
    box-shadow: 
        0 12px 24px rgba(0, 0, 0, 0.1),
        0 4px 8px rgba(0, 0, 0, 0.06);
}

/* Фото сверху - логично */
.product-image {
    width: 100%;
    aspect-ratio: 4/3;
    object-fit: cover;
    background: var(--bg-canvas);
}

/* Информация снизу - логично */
.product-info {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Цена - крупная и заметная */
.product-price {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-color);
}

/* Название - чёткое */
.product-name {
    font-size: 18px;
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-color);
}

/* ==========================================
   5. CONSTRAINTS (Ограничения)
   Предотвращение ошибок
   ========================================== */

/* Обязательные поля - явная маркировка */
.required::after {
    content: ' *';
    color: #e53e3e;
    font-weight: 700;
}

/* Сообщения об ошибках - явные и помогающие */
.error-message {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    background: #fee;
    border-left: 4px solid #e53e3e;
    border-radius: 8px;
    margin-top: 12px;
}

.error-message::before {
    content: '⚠️';
    font-size: 20px;
    flex-shrink: 0;
}

/* Успешные действия - зелёные */
.success-message {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    background: #f0fdf4;
    border-left: 4px solid #22c55e;
    border-radius: 8px;
    margin-top: 12px;
}

.success-message::before {
    content: '✅';
    font-size: 20px;
    flex-shrink: 0;
}

/* Подтверждение опасных действий */
.danger-action {
    background: #e53e3e;
    border-color: #c53030;
}

.danger-action::before {
    content: '⚠️ ';
}

/* ==========================================
   6. CONSISTENCY (Последовательность)
   Единообразие во всём интерфейсе
   ========================================== */

/* Единый spacing system */
.spacing-xs { padding: 8px; }
.spacing-sm { padding: 16px; }
.spacing-md { padding: 24px; }
.spacing-lg { padding: 32px; }
.spacing-xl { padding: 48px; }

/* Единые gap системы */
.gap-xs { gap: 8px; }
.gap-sm { gap: 16px; }
.gap-md { gap: 24px; }
.gap-lg { gap: 32px; }

/* Единая сетка */
.grid {
    display: grid;
    gap: 24px;
}

.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

/* ==========================================
   7. УСИЛЕНИЯ ПО НОРМАНУ
   Дополнительные улучшения UX
   ========================================== */

/* Подсказки при hover */
[data-tooltip] {
    position: relative;
}

[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    font-size: 14px;
    border-radius: 6px;
    white-space: nowrap;
    margin-bottom: 8px;
    z-index: 1000;
}

/* Индикаторы прогресса - показываем где пользователь */
.progress-bar {
    width: 100%;
    height: 8px;
    background: #e2e8f0;
    border-radius: 999px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary-color);
    transition: width 0.3s ease;
}

/* Хлебные крошки - показываем путь */
.breadcrumbs {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 24px;
}

.breadcrumbs a {
    color: var(--primary-color);
}

.breadcrumbs-separator::before {
    content: '/';
    margin: 0 8px;
}

/* Группировка связанных элементов */
.form-group {
    margin-bottom: 24px;
}

.form-group:last-child {
    margin-bottom: 0;
}

/* Визуальная группировка */
.section {
    background: white;
    padding: 32px;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    margin-bottom: 32px;
}

/* Состояния элементов - всегда видны */
.loading-state {
    opacity: 0.6;
    pointer-events: none;
    user-select: none;
}

/* Пустые состояния - помогающие */
.empty-state {
    text-align: center;
    padding: 64px 32px;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 64px;
    opacity: 0.3;
    margin-bottom: 16px;
}

.empty-state-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 8px;
}

.empty-state-description {
    font-size: 16px;
    margin-bottom: 24px;
}

/* ==========================================
   АДАПТИВНОСТЬ - По Норману
   ========================================== */

/* Минимальные touch targets - 44x44px */
@media (max-width: 768px) {
    button, .btn, a.btn {
        min-height: 48px;
        min-width: 48px;
        padding: 12px 24px;
    }
    
    /* Увеличенные отступы для touch */
    .product-card {
        margin-bottom: 16px;
    }
    
    /* Упрощённая сетка */
    .grid-2, .grid-3, .grid-4 {
        grid-template-columns: 1fr;
    }
}

/* Доступность */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
