/* =============================================
   ПОЧИНИ БОТ — CSS Дизайн-система
   На основе референсов: Cognify, Flowio, Synchro
   ============================================= */

/* =============================================
   CSS ПЕРЕМЕННЫЕ
   ============================================= */
:root {
    /* Цвета */
    --color-bg: #f5f6f8;
    --color-bg-card: #ffffff;
    --color-bg-sidebar: #ffffff;
    --color-bg-hover: #f0f2f5;
    
    /* Акцентные цвета */
    --color-primary: #22c55e;
    --color-primary-light: #dcfce7;
    --color-primary-dark: #16a34a;
    
    --color-blue: #3b82f6;
    --color-blue-light: #dbeafe;
    
    --color-orange: #f97316;
    --color-orange-light: #ffedd5;
    
    --color-red: #ef4444;
    --color-red-light: #fee2e2;
    
    --color-purple: #a855f7;
    --color-purple-light: #f3e8ff;
    
    /* Текст */
    --color-text: #1f2937;
    --color-text-secondary: #6b7280;
    --color-text-muted: #9ca3af;
    
    /* Границы */
    --color-border: #e5e7eb;
    --color-border-light: #f3f4f6;
    
    /* Тени */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    
    /* Скругления */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    
    /* Размеры */
    --sidebar-width: 260px;
    --sidebar-collapsed: 80px;
    --header-height: 64px;
    
    /* Шрифты */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 2rem;
    
    /* Переходы */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
}

/* =============================================
   СБРОС И БАЗОВЫЕ СТИЛИ
   ============================================= */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    color: var(--color-text);
    background-color: var(--color-bg);
    line-height: 1.5;
    min-height: 100vh;
}

/* =============================================
   ТИПОГРАФИКА
   ============================================= */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
    color: var(--color-text);
}

h1 { font-size: var(--font-size-3xl); }
h2 { font-size: var(--font-size-2xl); }
h3 { font-size: var(--font-size-xl); }
h4 { font-size: var(--font-size-lg); }

.text-secondary { color: var(--color-text-secondary); }
.text-muted { color: var(--color-text-muted); }
.text-success { color: var(--color-primary); }
.text-danger { color: var(--color-red); }
.text-warning { color: var(--color-orange); }

/* =============================================
   LAYOUT: SIDEBAR + MAIN
   ============================================= */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--color-bg-sidebar);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    transition: transform var(--transition-normal);
}

.sidebar-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--color-border-light);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--color-text);
    font-size: var(--font-size-lg);
    font-weight: 700;
}

.sidebar-logo-icon {
    width: 36px;
    height: 36px;
    background: var(--color-primary-light);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-primary);
    font-size: 20px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.sidebar-section {
    margin-bottom: 24px;
}

.sidebar-section-title {
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0 12px;
    margin-bottom: 8px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    color: var(--color-text-secondary);
    text-decoration: none;
    font-size: var(--font-size-sm);
    font-weight: 500;
    transition: all var(--transition-fast);
}

.sidebar-link:hover {
    background: var(--color-bg-hover);
    color: var(--color-text);
}

.sidebar-link.active {
    background: var(--color-primary-light);
    color: var(--color-primary-dark);
}

.sidebar-link-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-badge {
    margin-left: auto;
    background: var(--color-primary);
    color: white;
    font-size: var(--font-size-xs);
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-weight: 600;
}

/* Main content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

.main-header {
    height: var(--header-height);
    background: var(--color-bg-card);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.main-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.main-header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.page-content {
    padding: 32px;
}

.page-title {
    font-size: var(--font-size-2xl);
    font-weight: 600;
    margin-bottom: 24px;
}

/* =============================================
   КАРТОЧКИ
   ============================================= */
.card {
    background: var(--color-bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border-light);
    box-shadow: var(--shadow-sm);
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title {
    font-size: var(--font-size-base);
    font-weight: 600;
}

.card-body {
    padding: 20px;
}

/* Статистические карточки */
.stat-card {
    background: var(--color-bg-card);
    border-radius: var(--radius-lg);
    padding: 24px;
    border: 1px solid var(--color-border-light);
}

.stat-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.stat-card-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.stat-card-icon.green {
    background: var(--color-primary-light);
    color: var(--color-primary);
}

.stat-card-icon.blue {
    background: var(--color-blue-light);
    color: var(--color-blue);
}

.stat-card-icon.orange {
    background: var(--color-orange-light);
    color: var(--color-orange);
}

.stat-card-value {
    font-size: var(--font-size-3xl);
    font-weight: 700;
    margin-bottom: 4px;
}

.stat-card-label {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
}

.stat-card-change {
    font-size: var(--font-size-sm);
    font-weight: 500;
}

.stat-card-change.positive {
    color: var(--color-primary);
}

.stat-card-change.negative {
    color: var(--color-red);
}

/* =============================================
   КНОПКИ
   ============================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: var(--font-size-sm);
    font-weight: 500;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.btn-primary {
    background: var(--color-text);
    color: white;
}

.btn-primary:hover {
    background: #374151;
}

.btn-success {
    background: var(--color-primary);
    color: white;
}

.btn-success:hover {
    background: var(--color-primary-dark);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text);
}

.btn-outline:hover {
    background: var(--color-bg-hover);
}

.btn-ghost {
    background: transparent;
    color: var(--color-text-secondary);
}

.btn-ghost:hover {
    background: var(--color-bg-hover);
    color: var(--color-text);
}

.btn-sm {
    padding: 6px 12px;
    font-size: var(--font-size-xs);
}

.btn-lg {
    padding: 14px 28px;
    font-size: var(--font-size-base);
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: var(--radius-md);
}

/* =============================================
   ФОРМЫ
   ============================================= */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--color-text);
    margin-bottom: 8px;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    font-size: var(--font-size-sm);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-bg-card);
    color: var(--color-text);
    transition: border-color var(--transition-fast);
}

.form-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}

.form-input::placeholder {
    color: var(--color-text-muted);
}

.form-select {
    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='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 40px;
}

/* =============================================
   KANBAN ДОСКА
   ============================================= */
.kanban-board {
    display: flex;
    gap: 20px;
    overflow-x: auto;
    padding-bottom: 20px;
}

.kanban-column {
    flex: 0 0 320px;
    background: var(--color-bg);
    border-radius: var(--radius-lg);
    padding: 16px;
}

.kanban-column-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.kanban-column-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: var(--font-size-sm);
    font-weight: 600;
}

.kanban-column-count {
    background: var(--color-bg-card);
    padding: 2px 10px;
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    color: var(--color-text-secondary);
}

.kanban-card {
    background: var(--color-bg-card);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 12px;
    border: 1px solid var(--color-border-light);
    cursor: pointer;
    transition: box-shadow var(--transition-fast);
}

.kanban-card:hover {
    box-shadow: var(--shadow-md);
}

.kanban-card-title {
    font-size: var(--font-size-sm);
    font-weight: 500;
    margin-bottom: 8px;
}

.kanban-card-meta {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
}

/* Статусные бейджи */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    font-weight: 500;
}

.status-badge.new {
    background: var(--color-blue-light);
    color: var(--color-blue);
}

.status-badge.in-progress {
    background: var(--color-orange-light);
    color: var(--color-orange);
}

.status-badge.complete {
    background: var(--color-primary-light);
    color: var(--color-primary);
}

.status-badge.cancel {
    background: var(--color-red-light);
    color: var(--color-red);
}

/* =============================================
   ТАБЛИЦЫ
   ============================================= */
.table-container {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--color-border-light);
}

.table th {
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--color-bg);
}

.table tbody tr:hover {
    background: var(--color-bg-hover);
}

/* =============================================
   МОДАЛЬНЫЕ ОКНА
   ============================================= */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--color-bg-card);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(20px);
    transition: transform var(--transition-normal);
}

.modal-overlay.active .modal {
    transform: translateY(0);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--color-border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: var(--font-size-lg);
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
}

.modal-close:hover {
    background: var(--color-bg-hover);
    color: var(--color-text);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--color-border-light);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* =============================================
   АВАТАРЫ
   ============================================= */
.avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: var(--color-primary-light);
    color: var(--color-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: var(--font-size-sm);
}

.avatar-sm {
    width: 32px;
    height: 32px;
    font-size: var(--font-size-xs);
}

.avatar-lg {
    width: 56px;
    height: 56px;
    font-size: var(--font-size-lg);
}

/* =============================================
   УТИЛИТЫ
   ============================================= */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }

.grid { display: grid; }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }

.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }

.p-4 { padding: 16px; }
.p-6 { padding: 24px; }

.w-full { width: 100%; }
.hidden { display: none; }

/* =============================================
   АДАПТИВНОСТЬ
   ============================================= */
.mobile-menu-btn {
    display: none;
}

@media (max-width: 1024px) {
    .grid-cols-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-cols-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .mobile-menu-btn {
        display: flex;
    }
    
    .page-content {
        padding: 16px;
    }
    
    .grid-cols-2,
    .grid-cols-3,
    .grid-cols-4 {
        grid-template-columns: 1fr;
    }
    
    .kanban-board {
        flex-direction: column;
    }
    
    .kanban-column {
        flex: none;
        width: 100%;
    }
    
    .main-header {
        padding: 0 16px;
    }
}

/* Overlay для мобильного меню */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
}

@media (max-width: 768px) {
    .sidebar-overlay.active {
        display: block;
    }
}
