/* ok-bot Dashboard — Стили */
/* Цвета: фон #faf9f5, акцент #d97757 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Nunito:wght@400;600;700;800&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #faf9f5;
    --accent: #d97757;
    --accent-hover: #c4623f;
    --accent-light: rgba(217, 119, 87, 0.1);
    --accent-border: rgba(217, 119, 87, 0.3);
    --text: #2d2d2d;
    --text-light: #6b6b6b;
    --white: #ffffff;
    --card-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    --card-shadow-hover: 0 4px 20px rgba(0, 0, 0, 0.1);
    --border: #e8e5e0;
    --border-radius: 12px;
    --success: #4caf50;
    --error: #e74c3c;
    --warning: #f39c12;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
}

/* ===== САЙДБАР ===== */
.sidebar {
    width: 260px;
    background: #f9f8f3;
    border-right: 1px solid var(--border);
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}

.sidebar-logo {
    font-family: 'Nunito', sans-serif;
    font-size: 22px;
    font-weight: 800;
    color: var(--accent);
    text-align: center;
    padding: 12px 0 24px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
    text-decoration: none;
    display: block;
}

.sidebar-logo .logo-image {
    max-width: 100%;
    height: auto;
    max-height: 50px;
    object-fit: contain;
    display: block;
    margin: 0 auto;
    padding: 8px 0;
}

.sidebar-nav {
    list-style: none;
    flex: 1;
}

.sidebar-nav li {
    margin-bottom: 4px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text);
    text-decoration: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.sidebar-nav a:hover {
    background: var(--accent-light);
    border-color: var(--accent-border);
    color: var(--accent);
}

.sidebar-nav a.active {
    background: var(--accent);
    color: var(--white);
    border-color: var(--accent);
    font-weight: 600;
}

.sidebar-nav a .icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.sidebar-footer {
    padding-top: 16px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-light);
    text-align: center;
}

/* ===== ОСНОВНОЙ КОНТЕНТ ===== */
.main {
    margin-left: 260px;
    flex: 1;
    padding: 32px;
    min-height: 100vh;
}

.page-header {
    margin-bottom: 32px;
}

.page-header h1 {
    font-family: 'Nunito', sans-serif;
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
}

.page-header p {
    color: var(--text-light);
    font-size: 14px;
}

/* ===== КАРТОЧКИ ===== */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    padding: 24px;
    box-shadow: var(--card-shadow);
    transition: all 0.2s ease;
}

.card:hover {
    box-shadow: var(--card-shadow-hover);
    border-color: var(--accent-border);
}

.card-stat {
    text-align: center;
}

.card-stat .icon {
    font-size: 32px;
    margin-bottom: 8px;
}

.card-stat .value {
    font-family: 'Nunito', sans-serif;
    font-size: 36px;
    font-weight: 800;
    color: var(--accent);
    line-height: 1;
}

.card-stat .label {
    font-size: 13px;
    color: var(--text-light);
    margin-top: 4px;
    font-weight: 500;
}

/* ===== ПАНЕЛЬ ===== */
.panel {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    padding: 24px;
    box-shadow: var(--card-shadow);
    margin-bottom: 24px;
}

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

.panel-header h2 {
    font-family: 'Nunito', sans-serif;
    font-size: 18px;
    font-weight: 700;
}

/* ===== КНОПКИ ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: 2px solid var(--accent);
    border-radius: 10px;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-primary {
    background: var(--accent);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(217, 119, 87, 0.3);
}

.btn-outline {
    background: transparent;
    color: var(--accent);
}

.btn-outline:hover {
    background: var(--accent-light);
}

.btn-danger {
    background: var(--error);
    border-color: var(--error);
    color: var(--white);
}

.btn-danger:hover {
    background: #c0392b;
    border-color: #c0392b;
}

.btn-success {
    background: var(--success);
    border-color: var(--success);
    color: var(--white);
}

.btn-success:hover {
    background: #43a047;
    border-color: #43a047;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
    border-radius: 8px;
}

/* ===== ФОРМЫ ===== */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--border);
    border-radius: 10px;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    transition: border-color 0.2s ease;
    outline: none;
}

.form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

textarea.form-control {
    resize: vertical;
    min-height: 120px;
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b6b6b' 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 12px center;
    background-size: 16px;
    padding-right: 40px;
}

/* ===== ТАБЛИЦА ===== */
.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table th {
    text-align: left;
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-light);
    border-bottom: 2px solid var(--border);
}

table td {
    padding: 12px 16px;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
}

table tr:hover td {
    background: var(--accent-light);
}

/* ===== БЕЙДЖИ ===== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid;
}

.badge-success {
    background: rgba(76, 175, 80, 0.1);
    color: var(--success);
    border-color: rgba(76, 175, 80, 0.3);
}

.badge-error {
    background: rgba(231, 76, 60, 0.1);
    color: var(--error);
    border-color: rgba(231, 76, 60, 0.3);
}

.badge-warning {
    background: rgba(243, 156, 18, 0.1);
    color: var(--warning);
    border-color: rgba(243, 156, 18, 0.3);
}

/* ===== ЧАТВИДЖЕТ ===== */
.chat-messages {
    height: 400px;
    overflow-y: auto;
    padding: 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 16px;
}

.chat-msg {
    margin-bottom: 12px;
    display: flex;
}

.chat-msg.user {
    justify-content: flex-end;
}

.chat-msg .bubble {
    max-width: 70%;
    padding: 10px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
}

.chat-msg.user .bubble {
    background: var(--accent);
    color: var(--white);
    border-bottom-right-radius: 4px;
}

.chat-msg.bot .bubble {
    background: var(--white);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

.chat-input {
    display: flex;
    gap: 8px;
}

.chat-input input {
    flex: 1;
}

/* ===== УВЕДОМЛЕНИЯ ===== */
.toast {
    position: fixed;
    top: 24px;
    right: 24px;
    padding: 14px 24px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    transform: translateX(120%);
    transition: transform 0.3s ease;
    border: 1px solid;
}

.toast.show {
    transform: translateX(0);
}

.toast-success {
    background: var(--white);
    color: var(--success);
    border-color: var(--success);
}

.toast-error {
    background: var(--white);
    color: var(--error);
    border-color: var(--error);
}

/* ===== LOADING ===== */
.spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* Old responsive removed - see mobile styles at end of file */

/* ===== MOBILE RESPONSIVE ===== */
@media (max-width: 768px) {

    /* Сайдбар → нижний tab bar */
    .sidebar {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        top: auto !important;
        right: 0 !important;
        width: 100% !important;
        height: 56px !important;
        min-height: 56px !important;
        max-height: 56px !important;
        flex-direction: row !important;
        padding: 0 4px !important;
        z-index: 9999;
        overflow-x: auto;
        overflow-y: hidden;
        border-top: 1px solid var(--border-color);
        border-right: none;
    }

    /* Скрыть логотип и футер */
    .sidebar-logo,
    .sidebar-footer,
    .sidebar .logo-image {
        display: none !important;
    }

    /* Навигация горизонтальная */
    .sidebar-nav {
        display: flex !important;
        flex-direction: row !important;
        width: 100% !important;
        height: 100% !important;
        justify-content: space-around;
        align-items: center;
        gap: 0;
        padding: 0;
        margin: 0;
        overflow-x: auto;
    }

    .sidebar-nav li {
        flex: 0 0 auto;
        text-align: center;
        list-style: none;
    }

    .sidebar-nav a {
        padding: 6px 8px;
        justify-content: center;
        align-items: center;
        font-size: 11px;
        flex-direction: column;
        gap: 2px;
    }

    .sidebar-nav a span:not(.icon) {
        display: none !important;
    }

    .sidebar-nav a .icon {
        font-size: 20px;
        margin-right: 0 !important;
    }

    /* Контент — без отступа слева, с отступом снизу */
    .main {
        margin-left: 0 !important;
        margin-bottom: 60px !important;
        padding: 12px !important;
        width: 100% !important;
    }

    .main-content {
        margin-left: 0 !important;
        padding: 12px !important;
    }

    /* Заголовок */
    .main-header {
        flex-direction: column;
        gap: 8px;
    }

    .main-header h1 {
        font-size: 20px;
    }

    /* Карточки */
    .cards-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 8px;
    }

    .card {
        padding: 12px;
    }

    /* Формы */
    input,
    select,
    textarea,
    .form-control {
        width: 100% !important;
        box-sizing: border-box !important;
        font-size: 16px !important;
    }

    textarea {
        min-height: 80px;
    }

    .btn,
    button[type="submit"],
    .btn-primary,
    .btn-success,
    .btn-danger {
        width: 100% !important;
        padding: 12px !important;
        font-size: 16px !important;
        box-sizing: border-box !important;
    }

    /* Таблицы */
    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }

    /* Бейджи */
    .badge {
        font-size: 11px;
        padding: 2px 6px;
    }

    /* Flex-ряды в колонки */
    .row,
    .flex-row {
        flex-direction: column !important;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    /* Инструкция — компактнее */
    .info-box,
    .instruction {
        font-size: 13px;
        padding: 8px;
    }

    /* Логотип в контенте */
    .logo-image,
    img[src*="logo"] {
        max-width: 60px !important;
        height: auto !important;
    }
}

/* ===== МАЛЕНЬКИЙ МОБИЛЬНЫЙ ===== */
@media (max-width: 480px) {
    .cards-grid {
        grid-template-columns: 1fr !important;
    }

    .stats-grid {
        grid-template-columns: 1fr !important;
    }

    .main {
        padding: 8px !important;
    }

    .card {
        padding: 8px;
    }

    .main-header h1 {
        font-size: 18px;
    }

    .sidebar {
        height: 50px !important;
        max-height: 50px !important;
    }

    .sidebar-nav a .icon {
        font-size: 18px;
    }
}

/* Запрет горизонтального скролла */
html,
body {
    max-width: 100vw;
    overflow-x: hidden;
}