:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --secondary: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --bg: #0f172a;
    --bg-card: #1e293b;
    --bg-hover: #334155;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #334155;
    --shadow: rgba(0, 0, 0, 0.3);
}

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

/* Шрифт Inter будет загружен через системные шрифты, если Google Fonts недоступен */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* Loading Screen */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    gap: 20px;
}

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

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

/* Layout */
.admin-container {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    padding: 24px 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-header {
    padding: 0 24px 32px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
}

.sidebar-header h1 {
    font-size: 24px;
    font-weight: 700;
    background: linear-gradient(135deg, #2563eb, #10b981);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-header p {
    color: var(--text-muted);
    font-size: 14px;
    margin-top: 4px;
}

.sidebar-nav {
    list-style: none;
    padding: 0 12px;
}

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

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

.sidebar-nav a:hover {
    background: var(--bg-hover);
    color: var(--text);
}

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

.sidebar-nav a i {
    width: 20px;
    text-align: center;
}

/* Main Content */
.main-content {
    padding: 32px;
    overflow-y: auto;
}

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

.page-header h2 {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 8px;
}

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

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

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    transition: all 0.3s;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px var(--shadow);
    border-color: var(--primary);
}

.stat-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.stat-card-header h3 {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-card-header i {
    font-size: 24px;
    opacity: 0.5;
}

.stat-card-value {
    font-size: 36px;
    font-weight: 700;
    color: var(--text);
}

.stat-card-change {
    font-size: 14px;
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.stat-card-change.positive {
    color: var(--secondary);
}

.stat-card-change.negative {
    color: var(--danger);
}

/* Content Card */
.content-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
}

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

.content-card-header h3 {
    font-size: 20px;
    font-weight: 600;
}

/* Table */
.table-container {
    overflow-x: auto;
}

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

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

table tbody td {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

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

table tbody tr:last-child td {
    border-bottom: none;
}

/* Badge */
.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-success {
    background: rgba(16, 185, 129, 0.2);
    color: var(--secondary);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.2);
    color: var(--warning);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

.badge-info {
    background: rgba(37, 99, 235, 0.2);
    color: var(--primary);
}

/* Button */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

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

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

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

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

.btn-icon {
    padding: 8px;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.btn-icon:hover {
    background: var(--bg-hover);
    color: var(--text);
}

/* Form */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
}

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

/* Alert */
.alert {
    padding: 16px 20px;
    border-radius: 8px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid var(--secondary);
    color: var(--secondary);
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--danger);
    color: var(--danger);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid var(--warning);
    color: var(--warning);
}

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

.empty-state i {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-state h3 {
    font-size: 20px;
    margin-bottom: 8px;
    color: var(--text);
}

.empty-state p {
    font-size: 14px;
}

/* Chart Container */
.chart-container {
    position: relative;
    height: 400px;
    margin-top: 24px;
}

.chart-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chart-controls select {
    padding: 8px 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.chart-controls select:hover {
    border-color: var(--primary);
}

.chart-controls select:focus {
    outline: none;
    border-color: var(--primary);
}

.content-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Doctor Cabinet Styles */
.doctor-cabinet {
    min-height: 100vh;
    background: var(--bg);
}

.auth-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

.auth-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 48px;
    max-width: 400px;
    width: 100%;
    text-align: center;
}

.auth-header h1 {
    font-size: 28px;
    margin-bottom: 8px;
}

.auth-header p {
    color: var(--text-muted);
    margin-bottom: 32px;
}

.telegram-login-widget {
    margin: 32px 0;
    display: flex;
    justify-content: center;
}

.auth-footer {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.auth-footer p {
    color: var(--text-muted);
    font-size: 14px;
}

.cabinet-screen {
    padding: 32px;
    max-width: 1400px;
    margin: 0 auto;
}

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

.cabinet-header h1 {
    font-size: 32px;
    margin-bottom: 8px;
}

.cabinet-header p {
    color: var(--text-muted);
    font-size: 16px;
}

.consultations-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.consultation-item {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    transition: all 0.2s;
}

.consultation-item:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow);
}

.consultation-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.consultation-info h4 {
    font-size: 18px;
    margin-bottom: 8px;
}

.consultation-info p {
    color: var(--text-muted);
    font-size: 14px;
    margin: 4px 0;
}

.consultation-info i {
    margin-right: 8px;
    width: 16px;
}

.consultation-message {
    margin-bottom: 16px;
    padding: 12px;
    background: var(--bg-card);
    border-radius: 8px;
}

.consultation-message p {
    color: var(--text);
    font-size: 14px;
    line-height: 1.6;
}

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

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    width: 100%;
    max-width: 800px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

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

.modal-header h3 {
    font-size: 20px;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.dialog-messages {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-height: 500px;
    overflow-y: auto;
}

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

.message.client {
    align-self: flex-start;
    background: var(--bg);
    border: 1px solid var(--border);
}

.message.doctor {
    align-self: flex-end;
    background: var(--primary);
    color: white;
}

.message.ai {
    align-self: flex-start;
    background: var(--bg-card);
    border: 1px solid var(--border);
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 12px;
    opacity: 0.8;
}

.message-sender {
    font-weight: 600;
}

.message-time {
    margin-left: 12px;
}

.message-text {
    line-height: 1.6;
    word-wrap: break-word;
}

.filter-controls {
    display: flex;
    gap: 12px;
}

.filter-controls select {
    padding: 8px 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
    cursor: pointer;
}

/* Responsive */
@media (max-width: 768px) {
    .admin-container {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        position: fixed;
        left: -260px;
        transition: left 0.3s;
        z-index: 1000;
    }
    
    .sidebar.open {
        left: 0;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .chart-container {
        height: 300px;
    }
    
    .content-card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    
    .cabinet-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    
    .consultation-header {
        flex-direction: column;
        gap: 12px;
    }
    
    .consultation-actions {
        flex-direction: column;
    }
    
    .message {
        max-width: 90%;
    }
    
    .auth-container {
        padding: 32px 24px;
    }
}

/* Consultation Details Styles */
.consultation-details {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.consultation-info-section,
.consultation-question-section,
.consultation-response-section,
.consultation-messages-section {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
}

.consultation-info-section h4,
.consultation-question-section h4,
.consultation-response-section h4,
.consultation-messages-section h4 {
    margin-bottom: 16px;
    font-size: 18px;
    color: var(--text);
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 12px;
}

.info-item {
    padding: 8px 0;
    color: var(--text);
}

.info-item strong {
    color: var(--text-muted);
    margin-right: 8px;
}

.text-muted {
    color: var(--text-muted);
}

.question-text,
.response-text {
    padding: 16px;
    background: var(--bg-card);
    border-radius: 8px;
    color: var(--text);
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.messages-container {
    max-height: 500px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

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

.consultation-message-client {
    align-self: flex-start;
    background: var(--bg-card);
    border: 1px solid var(--border);
}

.consultation-message-doctor {
    align-self: flex-end;
    background: var(--primary);
    color: white;
}

.consultation-message-ai {
    align-self: flex-start;
    background: var(--bg);
    border: 1px solid var(--border);
}

.consultation-message-admin {
    align-self: flex-start;
    background: rgba(245, 158, 11, 0.2);
    border: 1px solid var(--warning);
}

.consultation-message .message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 12px;
    opacity: 0.8;
}

.consultation-message .message-sender {
    font-weight: 600;
}

.consultation-message .message-time {
    margin-left: 12px;
}

.consultation-message .message-text {
    line-height: 1.6;
    word-wrap: break-word;
}

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

