/**
 * SaleSimulator - Admin Panel Styles
 */

:root {
    --bg: #f5f7fb;
    --primary: #2563eb;
    --primary-soft: #dbeafe;
    --text: #111827;
    --muted: #6b7280;
    --border: #e5e7eb;
    --danger: #ef4444;
    --success: #16a34a;
    --warning: #f59e0b;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
}

/* ================================
   Основной контейнер
   ================================ */
.app {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.app-title { font-size: 1.5rem; font-weight: 600; }
.app-subtitle { font-size: 0.875rem; color: var(--muted); }

.header-actions { display: flex; align-items: center; gap: 12px; }

/* ================================
   Кнопки
   ================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    gap: 6px;
    text-decoration: none;
    transition: all 0.15s;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-outline { background: #fff; color: var(--muted); border: 1px solid var(--border); }
.btn-outline:hover { background: #f9fafb; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ================================
   Вкладки
   ================================ */
.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0;
}

.tab {
    padding: 12px 20px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all 0.15s;
}

.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 500; }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ================================
   Карточки статистики
   ================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: #fff;
    border-radius: 12px;
    padding: 16px;
    border: 1px solid var(--border);
}

.stat-label { font-size: 0.8rem; color: var(--muted); margin-bottom: 4px; }
.stat-value { font-size: 1.75rem; font-weight: 600; }
.stat-value.good { color: var(--success); }

/* ================================
   Секции
   ================================ */
.section {
    background: #fff;
    border-radius: 12px;
    border: 1px solid var(--border);
    margin-bottom: 24px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 12px;
}

.section-title { font-size: 1rem; font-weight: 600; }
.section-body { padding: 0; }

/* ================================
   Таблица
   ================================ */
.table-wrapper { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }

th, td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); }

th {
    background: #f9fafb;
    font-weight: 600;
    color: var(--muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

tr:hover { background: #f9fafb; }
tr:last-child td { border-bottom: none; }

/* ================================
   Бейджи
   ================================ */
.score-badge {
    display: inline-flex;
    padding: 4px 10px;
    border-radius: 999px;
    font-weight: 500;
    font-size: 0.8rem;
}

.score-badge.good { background: #dcfce7; color: #166534; }
.score-badge.medium { background: #fef3c7; color: #92400e; }
.score-badge.bad { background: #fee2e2; color: #991b1b; }
.score-badge.none { background: #f3f4f6; color: var(--muted); }

.behavior-badge {
    display: inline-flex;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    background: #f3f4f6;
}

.behavior-badge.rational { background: #dbeafe; color: #1e40af; }
.behavior-badge.emotional { background: #fce7f3; color: #9d174d; }
.behavior-badge.aggressive { background: #fee2e2; color: #991b1b; }
.behavior-badge.neutral { background: #f3f4f6; color: #374151; }

/* ================================
   Модальное окно
   ================================ */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active { display: flex; }

.modal-content {
    background: #fff;
    border-radius: 16px;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

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

.modal-title { font-size: 1.125rem; font-weight: 600; }

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--muted);
    line-height: 1;
}

.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 16px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

/* ================================
   Формы
   ================================ */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 6px; }

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
    font-family: inherit;
}

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

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ================================
   Уведомления
   ================================ */
#notifications { position: fixed; top: 16px; right: 16px; z-index: 2000; }

.notification {
    padding: 12px 16px;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    margin-bottom: 8px;
    font-size: 0.875rem;
}

.notification-error { border-left: 4px solid var(--danger); }
.notification-success { border-left: 4px solid var(--success); }

/* ================================
   Утилиты
   ================================ */
.empty-state { text-align: center; padding: 40px; color: var(--muted); }
.loading { text-align: center; padding: 40px; color: var(--muted); }

.actions-cell { white-space: nowrap; }
.actions-cell .btn { margin-left: 4px; }

/* ================================
   Адаптивность
   ================================ */
@media (max-width: 768px) {
    .form-row { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
}
