/* =====================================================
   ГОФФЗНАК — Платформа обзвона
   Стили интерфейса — боковая навигация
   ===================================================== */

:root {
    --primary: #1a5276;
    --primary-light: #2980b9;
    --primary-dark: #0e3a55;
    --danger: #e74c3c;
    --danger-light: #fadbd8;
    --warning: #f39c12;
    --warning-light: #fdebd0;
    --success: #27ae60;
    --success-light: #d5f5e3;
    --gray-50: #f8f9fa;
    --gray-100: #ecf0f1;
    --gray-200: #d5dbdb;
    --gray-600: #7f8c8d;
    --gray-800: #2c3e50;
    --white: #ffffff;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.15);
    --radius: 12px;
    --radius-sm: 8px;
    --sidebar-width: 240px;
}

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

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    line-height: 1.6;
}

/* ===== LAYOUT: САЙДБАР + КОНТЕНТ ===== */

.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ===== БОКОВАЯ ПАНЕЛЬ ===== */

.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--primary-dark), var(--primary));
    color: var(--white);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 200;
    overflow-y: auto;
}

.sidebar-logo {
    padding: 24px 20px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-logo .brand {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 1px;
}

.sidebar-logo .subtitle {
    font-size: 12px;
    opacity: 0.6;
    margin-top: 2px;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: rgba(255,255,255,0.75);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.sidebar-nav a:hover {
    background: rgba(255,255,255,0.08);
    color: var(--white);
}

.sidebar-nav a.active {
    background: rgba(255,255,255,0.12);
    color: var(--white);
    border-left-color: var(--white);
    font-weight: 600;
}

.sidebar-nav a .nav-icon {
    width: 20px;
    text-align: center;
    font-size: 16px;
    flex-shrink: 0;
}

.sidebar-nav .nav-section {
    padding: 16px 20px 6px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: rgba(255,255,255,0.35);
    font-weight: 700;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
    font-size: 11px;
    opacity: 0.4;
}

/* ===== ОСНОВНОЙ КОНТЕНТ ===== */

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

.page-header {
    background: var(--white);
    padding: 20px 32px;
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.page-header h1 {
    font-size: 20px;
    font-weight: 600;
}

.page-header .page-subtitle {
    font-size: 13px;
    color: var(--gray-600);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 32px;
}

/* ===== ГЛАВНАЯ СТРАНИЦА ===== */

.welcome {
    text-align: center;
    padding: 60px 20px;
}

.welcome h1 {
    font-size: 32px;
    margin-bottom: 8px;
    color: var(--primary);
}

.welcome p {
    font-size: 16px;
    color: var(--gray-600);
    margin-bottom: 40px;
}

.manager-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    max-width: 900px;
    margin: 0 auto;
}

.manager-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 28px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    text-decoration: none;
    color: var(--gray-800);
    display: block;
    border: 2px solid transparent;
}

.manager-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-light);
}

.manager-card .name { font-size: 20px; font-weight: 600; margin-bottom: 4px; }
.manager-card .position { font-size: 14px; color: var(--gray-600); }

/* ===== КАРТОЧКА ЗВОНКА ===== */

.call-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    margin-bottom: 24px;
}

.call-card-header {
    padding: 20px 28px;
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.call-card-header.priority-red { background: linear-gradient(135deg, #c0392b, #e74c3c); }
.call-card-header.priority-yellow { background: linear-gradient(135deg, #e67e22, #f39c12); }
.call-card-header.priority-blue { background: linear-gradient(135deg, var(--primary), var(--primary-light)); }
.call-card-header .priority-badge { font-size: 14px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; }
.call-card-header .remaining { font-size: 13px; opacity: 0.85; }
.call-card-body { padding: 28px; }

.client-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.client-info .label { font-size: 12px; color: var(--gray-600); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.client-info .value { font-size: 16px; font-weight: 500; }
.client-info .value.phone { font-size: 20px; color: var(--primary); font-weight: 700; }
.client-info .value.amount { font-size: 20px; color: var(--danger); font-weight: 700; }

/* ===== ИСТОРИЯ ===== */

.section-title {
    font-size: 14px; font-weight: 700; color: var(--gray-600);
    text-transform: uppercase; letter-spacing: 1px;
    margin-bottom: 12px; padding-bottom: 8px;
    border-bottom: 2px solid var(--gray-100);
}

.history-list { list-style: none; margin-bottom: 24px; }
.history-list li { padding: 10px 0; border-bottom: 1px solid var(--gray-100); font-size: 14px; display: flex; gap: 12px; }
.history-list li:last-child { border-bottom: none; }
.history-date { color: var(--gray-600); min-width: 80px; font-size: 13px; }
.history-direction { font-size: 11px; padding: 2px 8px; border-radius: 4px; background: var(--gray-100); color: var(--gray-600); min-width: 80px; text-align: center; }

/* ===== СКРИПТ-ПОДСКАЗКА ===== */

.script-hint {
    background: #eaf2f8;
    border-left: 4px solid var(--primary-light);
    padding: 16px 20px;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    margin-bottom: 24px;
    font-size: 15px;
    line-height: 1.7;
}

.call-restriction {
    background: var(--danger-light);
    border-left: 4px solid var(--danger);
    padding: 12px 20px;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    margin-bottom: 24px;
    font-size: 14px;
    color: var(--danger);
    font-weight: 600;
}

/* ===== КНОПКИ ===== */

.actions { display: flex; gap: 12px; flex-wrap: wrap; }

.btn {
    padding: 12px 24px; border: none; border-radius: var(--radius-sm);
    font-size: 15px; font-weight: 600; cursor: pointer;
    transition: all 0.2s; display: inline-flex; align-items: center; gap: 8px;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--primary); color: var(--white); }
.btn-success { background: var(--success); color: var(--white); }
.btn-warning { background: var(--warning); color: var(--white); }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-secondary { background: var(--gray-200); color: var(--gray-800); }
.btn-outline { background: transparent; border: 2px solid var(--gray-200); color: var(--gray-800); }
.btn-outline:hover { border-color: var(--primary-light); color: var(--primary); }
.btn-lg { padding: 16px 32px; font-size: 17px; }
.btn-sm { padding: 6px 14px; font-size: 13px; }

/* ===== МОДАЛЬНОЕ ОКНО ===== */

.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5); display: none;
    align-items: center; justify-content: center; z-index: 1000;
}
.modal-overlay.active { display: flex; }

.modal {
    background: var(--white); border-radius: var(--radius);
    padding: 32px; max-width: 600px; width: 90%; box-shadow: var(--shadow-lg);
    max-height: 90vh; overflow-y: auto;
}
.modal h3 { font-size: 20px; margin-bottom: 20px; color: var(--primary); }
.modal .form-group { margin-bottom: 16px; }
.modal label {
    display: block; font-size: 13px; font-weight: 600;
    color: var(--gray-600); margin-bottom: 6px;
    text-transform: uppercase; letter-spacing: 0.5px;
}
.modal select, .modal input, .modal textarea {
    width: 100%; padding: 10px 14px; border: 2px solid var(--gray-200);
    border-radius: var(--radius-sm); font-size: 15px; font-family: inherit;
}
.modal select:focus, .modal input:focus, .modal textarea:focus {
    outline: none; border-color: var(--primary-light);
}
.modal textarea { resize: vertical; min-height: 100px; }
.modal-actions { display: flex; gap: 12px; margin-top: 24px; justify-content: flex-end; }

/* ===== ФОРМЫ (вне модалок) ===== */

.form-group { margin-bottom: 16px; }
.form-group label {
    display: block; font-size: 13px; font-weight: 600;
    color: var(--gray-600); margin-bottom: 6px;
    text-transform: uppercase; letter-spacing: 0.5px;
}
.form-group select, .form-group input, .form-group textarea {
    width: 100%; padding: 10px 14px; border: 2px solid var(--gray-200);
    border-radius: var(--radius-sm); font-size: 15px; font-family: inherit;
}
.form-group select:focus, .form-group input:focus, .form-group textarea:focus {
    outline: none; border-color: var(--primary-light);
}
.form-group textarea { resize: vertical; min-height: 100px; }

/* ===== ДАШБОРД ===== */

.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px; margin-bottom: 32px;
}

.stat-card { background: var(--white); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); text-align: center; }
.stat-card .stat-value { font-size: 36px; font-weight: 700; line-height: 1; margin-bottom: 8px; }
.stat-card .stat-label { font-size: 13px; color: var(--gray-600); text-transform: uppercase; letter-spacing: 0.5px; }
.stat-card.red .stat-value { color: var(--danger); }
.stat-card.yellow .stat-value { color: var(--warning); }
.stat-card.green .stat-value { color: var(--success); }
.stat-card.blue .stat-value { color: var(--primary-light); }

/* ===== ТАБЛИЦА ФЛАГОВ ===== */

.flags-section { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; margin-bottom: 24px; }
.flags-section-header { padding: 16px 24px; font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.flags-section-header.red { background: var(--danger-light); color: var(--danger); }
.flags-section-header.yellow { background: var(--warning-light); color: #d68910; }

.flags-table { width: 100%; border-collapse: collapse; }
.flags-table th { text-align: left; padding: 12px 16px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--gray-600); background: var(--gray-50); border-bottom: 2px solid var(--gray-100); }
.flags-table td { padding: 14px 16px; font-size: 14px; border-bottom: 1px solid var(--gray-100); }
.flags-table tr:hover td { background: var(--gray-50); }
.flags-table .amount { font-weight: 700; color: var(--danger); }
.flags-table .days { font-weight: 600; }

/* ===== ОЧЕРЕДЬ ===== */

.queue-list { display: flex; flex-direction: column; gap: 12px; }

.queue-item {
    background: var(--white); border-radius: var(--radius-sm);
    padding: 16px 20px; box-shadow: var(--shadow);
    display: grid; grid-template-columns: auto 1fr auto auto;
    align-items: center; gap: 16px; cursor: pointer;
    transition: box-shadow 0.2s; border-left: 4px solid transparent;
}
.queue-item:hover { box-shadow: var(--shadow-lg); }
.queue-item.priority-red { border-left-color: var(--danger); }
.queue-item.priority-yellow { border-left-color: var(--warning); }
.queue-item.priority-blue { border-left-color: var(--primary-light); }
.queue-item .priority-dot { width: 12px; height: 12px; border-radius: 50%; }
.queue-item .priority-dot.red { background: var(--danger); }
.queue-item .priority-dot.yellow { background: var(--warning); }
.queue-item .priority-dot.blue { background: var(--primary-light); }
.queue-item .info .title { font-weight: 600; font-size: 15px; }
.queue-item .info .subtitle { font-size: 13px; color: var(--gray-600); }
.queue-item .amount-col { font-size: 15px; font-weight: 700; color: var(--gray-800); text-align: right; }
.queue-item .days-col { font-size: 13px; color: var(--gray-600); text-align: right; min-width: 80px; }

/* ===== ШАБЛОНЫ ===== */

.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 20px;
}

.template-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: box-shadow 0.2s;
}

.template-card:hover { box-shadow: var(--shadow-lg); }

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

.template-card-header .template-name {
    font-size: 16px;
    font-weight: 600;
}

.template-card-header .template-category {
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.template-category.cat-postpayment { background: var(--danger-light); color: var(--danger); }
.template-category.cat-reactivation { background: var(--warning-light); color: #d68910; }
.template-category.cat-upsell { background: var(--success-light); color: var(--success); }
.template-category.cat-followup { background: #d6eaf8; color: var(--primary); }
.template-category.cat-other { background: var(--gray-100); color: var(--gray-600); }

.template-card-body {
    padding: 16px 20px;
}

.template-card-body .template-text {
    font-size: 14px;
    color: var(--gray-600);
    line-height: 1.6;
    max-height: 100px;
    overflow: hidden;
    position: relative;
}

.template-card-body .template-text::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 30px;
    background: linear-gradient(transparent, var(--white));
}

.template-card-actions {
    padding: 12px 20px;
    border-top: 1px solid var(--gray-100);
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* ===== ПУСТОЕ СОСТОЯНИЕ ===== */

.empty-state { text-align: center; padding: 80px 20px; color: var(--gray-600); }
.empty-state .icon { font-size: 64px; margin-bottom: 16px; }
.empty-state h2 { font-size: 24px; margin-bottom: 8px; color: var(--gray-800); }

/* ===== УВЕДОМЛЕНИЯ ===== */

.toast {
    position: fixed; bottom: 24px; right: 24px;
    background: var(--gray-800); color: var(--white);
    padding: 16px 24px; border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg); font-size: 14px; z-index: 2000;
    transform: translateY(100px); opacity: 0; transition: all 0.3s;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* ===== ЗАГРУЗКА ===== */

.loading { text-align: center; padding: 60px 20px; }
.spinner { width: 40px; height: 40px; border: 4px solid var(--gray-200); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; margin: 0 auto 16px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== АДАПТИВ ===== */

@media (max-width: 768px) {
    .sidebar {
        width: 60px;
        overflow: hidden;
    }
    .sidebar-logo .brand { display: none; }
    .sidebar-logo .subtitle { display: none; }
    .sidebar-nav a span:not(.nav-icon) { display: none; }
    .sidebar-nav .nav-section { display: none; }
    .sidebar-footer { display: none; }
    .sidebar-nav a { justify-content: center; padding: 14px 0; border-left: none; }
    .main-content { margin-left: 60px; }
    .container { padding: 16px; }
    .client-info { grid-template-columns: 1fr; }
    .actions { flex-direction: column; }
    .btn { justify-content: center; }
    .queue-item { grid-template-columns: auto 1fr; }
    .queue-item .amount-col, .queue-item .days-col { display: none; }
    .dashboard-stats { grid-template-columns: repeat(2, 1fr); }
    .template-grid { grid-template-columns: 1fr; }
}
