/* MCRM Styles */
:root {
    --primary: #3498db;
    --primary-dark: #2980b9;
    --success: #27ae60;
    --warning: #f39c12;
    --danger: #e74c3c;
    --info: #9b59b6;
    --dark: #2c3e50;
    --light: #ecf0f1;
    --gray: #95a5a6;
    --white: #ffffff;
    --bg: #f5f6fa;
    --shadow: 0 2px 10px rgba(0,0,0,0.1);
    --radius: 8px;
}

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

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

/* Layout */
.app {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 250px;
    background: var(--dark);
    color: var(--white);
    padding: 20px 0;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
}

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

.sidebar-header h1 {
    font-size: 24px;
    font-weight: 600;
}

.sidebar-header span {
    font-size: 12px;
    opacity: 0.7;
}

.nav-menu {
    list-style: none;
}

.nav-item {
    margin: 5px 10px;
}

.nav-item a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 15px;
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    border-radius: var(--radius);
    transition: all 0.2s;
}

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

.nav-item a.active {
    background: var(--primary);
    color: var(--white);
}

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

.main {
    flex: 1;
    margin-left: 250px;
    padding: 20px;
}

/* Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.page-title {
    font-size: 28px;
    font-weight: 600;
}

/* Cards */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 20px;
}

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

.card-title {
    font-size: 18px;
    font-weight: 600;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: var(--white);
}

.stat-icon.blue { background: var(--primary); }
.stat-icon.green { background: var(--success); }
.stat-icon.orange { background: var(--warning); }
.stat-icon.red { background: var(--danger); }
.stat-icon.purple { background: var(--info); }

.stat-info h3 {
    font-size: 24px;
    font-weight: 700;
}

.stat-info p {
    font-size: 14px;
    color: var(--gray);
}

/* Funnel */
.funnel {
    display: flex;
    gap: 15px;
    overflow-x: auto;
    padding-bottom: 10px;
}

.funnel-stage {
    flex: 1;
    min-width: 180px;
    background: var(--light);
    border-radius: var(--radius);
    padding: 15px;
}

.funnel-stage-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 3px solid;
}

.funnel-stage-name {
    font-weight: 600;
    font-size: 14px;
}

.funnel-stage-count {
    background: var(--white);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
}

.funnel-cards {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 300px;
}

.client-card {
    background: var(--white);
    border-radius: 6px;
    padding: 12px;
    cursor: grab;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    transition: transform 0.2s;
}

.client-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.client-card .name {
    font-weight: 600;
    margin-bottom: 5px;
}

.client-card .phone {
    font-size: 13px;
    color: var(--gray);
}

.client-card .sum {
    font-size: 13px;
    color: var(--success);
    font-weight: 500;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    text-decoration: none;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
}

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

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

.btn-outline {
    background: transparent;
    border: 1px solid var(--gray);
    color: var(--dark);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

/* Tables */
.table-wrapper {
    overflow-x: auto;
}

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

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

th {
    font-weight: 600;
    color: var(--gray);
    font-size: 13px;
    text-transform: uppercase;
}

tr:hover {
    background: var(--bg);
}

/* Forms */
.form-group {
    margin-bottom: 15px;
}

.form-label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

.form-input {
    width: 100%;
    padding: 10px 15px;
    border: 1px solid var(--light);
    border-radius: var(--radius);
    font-size: 14px;
    transition: border-color 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
}

.form-select {
    width: 100%;
    padding: 10px 15px;
    border: 1px solid var(--light);
    border-radius: var(--radius);
    font-size: 14px;
    background: var(--white);
}

/* Chat */
.chat-container {
    display: grid;
    grid-template-columns: 300px 1fr 300px;
    gap: 20px;
    height: calc(100vh - 140px);
}

.chat-list {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow-y: auto;
}

.chat-list-header {
    padding: 15px;
    border-bottom: 1px solid var(--light);
    font-weight: 600;
}

.chat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 15px;
    cursor: pointer;
    border-bottom: 1px solid var(--light);
    transition: background 0.2s;
}

.chat-item:hover {
    background: var(--bg);
}

.chat-item.active {
    background: rgba(52, 152, 219, 0.1);
    border-left: 3px solid var(--primary);
}

.chat-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.chat-preview {
    flex: 1;
    overflow: hidden;
}

.chat-preview .name {
    font-weight: 600;
    margin-bottom: 3px;
}

.chat-preview .last-msg {
    font-size: 13px;
    color: var(--gray);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-window {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
}

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

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.message {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 12px;
}

.message.in {
    background: var(--light);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.message.out {
    background: var(--primary);
    color: var(--white);
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.message .time {
    font-size: 11px;
    opacity: 0.7;
    margin-top: 5px;
}

.chat-input {
    padding: 15px 20px;
    border-top: 1px solid var(--light);
    display: flex;
    gap: 10px;
}

.chat-input input {
    flex: 1;
    padding: 12px 15px;
    border: 1px solid var(--light);
    border-radius: 20px;
    outline: none;
}

.chat-input button {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--white);
    border: none;
    cursor: pointer;
}

.client-info {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    overflow-y: auto;
}

.client-info h3 {
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--light);
}

.client-info .info-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
    font-size: 14px;
}

.client-info .label {
    color: var(--gray);
}

/* Badge */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.badge-vip { background: #fef3c7; color: #92400e; }
.badge-medium { background: #dbeafe; color: #1e40af; }
.badge-small { background: #d1fae5; color: #065f46; }
.badge-cold { background: #f3f4f6; color: #4b5563; }

/* Scenario Builder */
.scenario-builder {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 20px;
    height: calc(100vh - 140px);
}

.scenario-list {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow-y: auto;
}

.scenario-canvas {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    overflow: auto;
}

.scenario-step {
    background: var(--bg);
    border: 2px solid var(--light);
    border-radius: var(--radius);
    padding: 15px;
    margin-bottom: 15px;
    position: relative;
}

.scenario-step.message { border-left: 4px solid var(--primary); }
.scenario-step.question { border-left: 4px solid var(--warning); }
.scenario-step.action { border-left: 4px solid var(--success); }
.scenario-step.condition { border-left: 4px solid var(--info); }

.step-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
}

.step-type {
    font-size: 11px;
    text-transform: uppercase;
    font-weight: 600;
    color: var(--gray);
}

.step-content {
    font-size: 14px;
}

/* Charts */
.chart-container {
    position: relative;
    height: 300px;
}

/* Responsive */
@media (max-width: 1024px) {
    .sidebar {
        width: 70px;
    }

    .sidebar-header h1,
    .sidebar-header span,
    .nav-item span {
        display: none;
    }

    .main {
        margin-left: 70px;
    }

    .chat-container {
        grid-template-columns: 1fr;
    }

    .chat-list,
    .client-info {
        display: none;
    }
}

@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .funnel {
        flex-direction: column;
    }

    .funnel-stage {
        min-width: auto;
    }
}

/* Loading */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray);
}

.empty-state .icon {
    font-size: 48px;
    margin-bottom: 15px;
}

/* Toast notifications */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--dark);
    color: var(--white);
    padding: 15px 25px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    z-index: 1000;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateY(100px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}
