/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft YaHei', Arial, sans-serif;
    background-color: #f5f7fa;
    color: #333;
    line-height: 1.6;
}

/* 容器样式 */
.container {
    display: flex;
    min-height: 100vh;
}

/* 侧边栏样式 */
.sidebar {
    width: 240px;
    background-color: #2c3e50;
    color: #ecf0f1;
    height: 100vh;
    position: fixed;
    overflow-y: auto;
    transition: all 0.3s ease;
}

.sidebar.collapsed {
    width: 0;
    overflow: hidden;
}

.sidebar-header {
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid #34495e;
}

.sidebar-header h2 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 5px;
}

.sidebar-header p {
    font-size: 12px;
    color: #bdc3c7;
}

/* 导航菜单样式 */
.nav-menu {
    padding: 20px 0;
}

.nav-item {
    margin-bottom: 5px;
}

.nav-link {
    display: block;
    padding: 12px 20px;
    color: #ecf0f1;
    text-decoration: none;
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
}

.nav-link:hover {
    background-color: #34495e;
    border-left-color: #3498db;
}

.nav-link.active {
    background-color: #34495e;
    border-left-color: #3498db;
}

.nav-link i {
    margin-right: 10px;
    font-size: 16px;
    display: inline-block;
    width: 20px;
    text-align: center;
}

/* 表单样式 */
.form-row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -10px;
}

.form-col {
    flex: 1;
    min-width: 250px;
    padding: 0 10px;
    margin-bottom: 15px;
}

@media (max-width: 768px) {
    .form-col {
        flex: 100%;
    }
}

.nav-child {
    padding-left: 20px;
    display: none;
}

.nav-item.open .nav-child {
    display: block;
}

/* 主内容区样式 */
.main-content {
    flex: 1;
    margin-left: 240px;
    transition: all 0.3s ease;
}

.main-content.expanded {
    margin-left: 0;
}

/* 顶部导航栏样式 */
.top-nav {
    background-color: #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    z-index: 1001;
}

.top-nav-left {
    display: flex;
    align-items: center;
}

.toggle-btn {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    margin-right: 20px;
    color: #333;
}

.page-title {
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.top-nav-right {
    display: flex;
    align-items: center;
}

.user-info {
    display: flex;
    align-items: center;
    margin-right: 20px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: #3498db;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 10px;
    font-size: 14px;
    font-weight: 600;
}

.user-info.dropdown {
    cursor: pointer;
    position: relative;
}

.user-info-content {
    display: flex;
    align-items: center;
}

.user-info span {
    margin-right: 5px;
}

.user-info i {
    font-size: 12px;
    transition: transform 0.3s ease;
}

.user-info.dropdown:hover i {
    transform: rotate(180deg);
}

/* 下拉菜单样式 */
.user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 10px;
    background-color: #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border-radius: 4px;
    min-width: 180px;
    display: none;
    z-index: 1002;
}

.user-dropdown.show {
    display: block;
}

.dropdown-item {
    display: block;
    padding: 10px 15px;
    color: #333;
    text-decoration: none;
    transition: background-color 0.3s ease;
    border-bottom: 1px solid #f0f0f0;
}

.dropdown-item:last-child {
    border-bottom: none;
}

.dropdown-item:hover {
    background-color: #f5f5f5;
}

.dropdown-item i {
    margin-right: 8px;
    font-size: 14px;
}

/* 内容区域样式 */
.content {
    padding: 20px;
}

/* 卡片样式 */
.card {
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    padding: 20px;
    margin-bottom: 20px;
}

.card-header {
    border-bottom: 1px solid #eee;
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.card-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin: 0;
}

/* 表单样式 */
.form-group {
    margin-bottom: 15px;
}

.form-label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #555;
}

.form-control {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

.form-control:focus {
    border-color: #3498db;
    outline: none;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

/* 响应式表单布局 */
.form-row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -10px;
}

.form-col {
    flex: 1;
    min-width: 250px;
    padding: 0 10px;
    margin-bottom: 15px;
}

/* 适配layui表单的响应式布局 */
.layui-form-item {
    margin-bottom: 15px;
}

@media (min-width: 768px) {
    .form-row-2 .form-col {
        flex: 0 0 50%;
        max-width: 50%;
    }
    
    .form-row-3 .form-col {
        flex: 0 0 33.333%;
        max-width: 33.333%;
    }
}

@media (max-width: 767px) {
    .form-col {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* 按钮样式 */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    text-align: center;
}

.btn-primary {
    background-color: #3498db;
    color: #fff;
}

.btn-primary:hover {
    background-color: #2980b9;
}

.btn-success {
    background-color: #27ae60;
    color: #fff;
}

.btn-success:hover {
    background-color: #229954;
}

.btn-danger {
    background-color: #e74c3c;
    color: #fff;
}

.btn-danger:hover {
    background-color: #c0392b;
}

.btn-default {
    background-color: #95a5a6;
    color: #fff;
}

.btn-default:hover {
    background-color: #7f8c8d;
}

/* 表格样式 */
.table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

.table th,
.table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

.table th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: #333;
}

.table tr:hover {
    background-color: #f5f5f5;
}

/* 分页样式 */
.pagination {
    display: flex;
    justify-content: center;
    margin-top: 20px;
}

.pagination li {
    list-style: none;
    margin: 0 5px;
}

.pagination li a {
    display: block;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    color: #333;
    text-decoration: none;
    transition: all 0.3s ease;
}

.pagination li a:hover {
    background-color: #f5f5f5;
    border-color: #3498db;
}

.pagination li.active a {
    background-color: #3498db;
    color: #fff;
    border-color: #3498db;
}

/* 状态标签样式 */
.status-tag {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.status-pending {
    background-color: #f39c12;
    color: #fff;
}

.status-confirmed {
    background-color: #27ae60;
    color: #fff;
}

.status-completed {
    background-color: #3498db;
    color: #fff;
}

.status-cancelled {
    background-color: #e74c3c;
    color: #fff;
}

/* 响应式设计 */
@media (max-width: 768px) {
    /* 基础布局优化 */
    html, body {
        width: 100%;
        overflow-x: hidden;
    }
    
    .sidebar {
        transform: translateX(-100%);
        z-index: 1000;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
        width: 100%;
        overflow-x: hidden;
    }
    
    .main-content.expanded {
        margin-left: 0;
    }
    
    /* 顶部导航优化 */
    .top-nav {
        flex-direction: row;
        align-items: center;
        padding: 10px;
        width: 100%;
        box-sizing: border-box;
    }
    
    .top-nav-left {
        flex-direction: row;
        align-items: center;
        flex: 1;
        margin-bottom: 0;
    }
    
    .toggle-btn {
        margin-right: 10px;
        margin-bottom: 0;
    }
    
    .page-title {
        font-size: 16px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .top-nav-right {
        flex-direction: row;
        align-items: center;
        justify-content: flex-end;
    }
    
    .user-info {
        margin-right: 10px;
    }
    
    .user-info span {
        display: none;
    }
    
    /* 内容区域优化 */
    .content {
        padding: 10px;
        width: 100%;
        box-sizing: border-box;
    }
    
    /* 卡片样式优化 */
    .card {
        padding: 15px;
        width: 100%;
        box-sizing: border-box;
        overflow: hidden;
    }
    
    /* 表格样式优化 */
    .table-responsive {
        width: 100%;
        overflow-x: auto;
        margin-bottom: 15px;
    }
    
    .table-responsive table {
        min-width: 600px;
        width: 100%;
    }
    
    .table {
        font-size: 14px;
        width: 100%;
    }
    
    .table th,
    .table td {
        padding: 8px;
        font-size: 13px;
    }
    
    /* 按钮样式优化 */
    .btn {
        padding: 8px 16px;
        font-size: 13px;
        white-space: nowrap;
    }
    
    /* 表单样式优化 */
    .layui-form {
        width: 100%;
        overflow: hidden;
    }
    
    .layui-form-item {
        margin-bottom: 15px;
        width: 100%;
        box-sizing: border-box;
    }
    
    .layui-form-label {
        width: 90px;
        font-size: 13px;
        white-space: nowrap;
    }
    
    .layui-input-block {
        margin-left: 90px;
        width: calc(100% - 90px);
    }
    
    .layui-input,
    .layui-select,
    .layui-textarea {
        font-size: 13px;
        padding: 8px 10px;
        width: 100%;
        box-sizing: border-box;
    }
    
    /* 侧边栏头部样式调整 */
    .sidebar-header h2 {
        font-size: 20px;
    }
    
    .sidebar-header p {
        font-size: 14px;
    }
    
    /* 弹窗样式优化 */
    [id$="Modal"] {
        max-width: 95vw !important;
        width: 100% !important;
        margin: 0 10px;
        box-sizing: border-box;
    }
    
    /* 网格系统优化 */
    .layui-row {
        width: 100%;
        box-sizing: border-box;
    }
    
    .layui-col-md12 {
        width: 100%;
        box-sizing: border-box;
    }
    
    /* 确保所有元素都不会溢出 */
    * {
        max-width: 100%;
        box-sizing: border-box;
    }
}

/* 平板设备优化 */
@media (min-width: 769px) and (max-width: 1024px) {
    .sidebar {
        width: 200px;
    }
    
    .main-content {
        margin-left: 200px;
    }
    
    .main-content.expanded {
        margin-left: 0;
    }
    
    .sidebar.collapsed {
        width: 0;
        overflow: hidden;
    }
    
    .content {
        padding: 15px;
    }
    
    .card {
        padding: 15px;
    }
    
    .table th,
    .table td {
        padding: 10px;
    }
}

/* 小屏幕手机优化 */
@media (max-width: 480px) {
    .sidebar-header h2 {
        font-size: 16px;
    }
    
    .nav-link {
        padding: 10px 15px;
    }
    
    .nav-link i {
        margin-right: 8px;
        font-size: 14px;
    }
    
    .card-header h3 {
        font-size: 14px;
    }
    
    .table {
        font-size: 12px;
    }
    
    .table th,
    .table td {
        padding: 6px;
    }
    
    .btn {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .layui-form-label {
        width: 70px;
        font-size: 12px;
    }
    
    .layui-input-block {
        margin-left: 80px;
    }
    
    .layui-input,
    .layui-select,
    .layui-textarea {
        font-size: 12px;
        padding: 6px 8px;
    }
}

/* 确保表格在小屏幕上可以横向滚动 */
.table-responsive {
    overflow-x: auto;
    margin-bottom: 15px;
}

.table-responsive table {
    min-width: 600px;
}

/* 动画效果 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card {
    animation: fadeIn 0.3s ease;
}

/* 工具类 */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.mt-10 {
    margin-top: 10px;
}

.mt-20 {
    margin-top: 20px;
}

.mb-10 {
    margin-bottom: 10px;
}

.mb-20 {
    margin-bottom: 20px;
}

.p-10 {
    padding: 10px;
}

.p-20 {
    padding: 20px;
}

/* 心理咨询系统特定样式 */
.psychology-theme {
    --primary-color: #3498db;
    --secondary-color: #27ae60;
    --accent-color: #9b59b6;
    --text-color: #333;
    --text-light: #777;
    --bg-light: #f5f7fa;
    --bg-white: #fff;
    --border-color: #ddd;
    --success-color: #27ae60;
    --warning-color: #f39c12;
    --danger-color: #e74c3c;
}

/* 数据统计卡片样式 */
.stats-card {
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    padding: 20px;
    text-align: center;
    transition: all 0.3s ease;
}

.stats-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.stats-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 15px;
    font-size: 24px;
    color: #fff;
}

.stats-icon.customers {
    background-color: #3498db;
}

.stats-icon.counselors {
    background-color: #27ae60;
}

.stats-icon.appointments {
    background-color: #f39c12;
}

.stats-icon.revenue {
    background-color: #9b59b6;
}

.stats-value {
    font-size: 24px;
    font-weight: 600;
    color: #333;
    margin-bottom: 5px;
}

.stats-label {
    font-size: 14px;
    color: #777;
}

/* 加载动画 */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 错误提示样式 */
.error-message {
    background-color: #fee;
    border: 1px solid #fcc;
    color: #c00;
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 15px;
}

/* 成功提示样式 */
.success-message {
    background-color: #efe;
    border: 1px solid #cfc;
    color: #0c0;
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 15px;
}

/* AI咨询样式 */
.chat-container {
    max-width: 1000px;
    margin: 0 auto;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    overflow: hidden;
    display: flex;
    min-height: 600px;
}

/* 对话列表侧边栏 */
.conversation-sidebar {
    width: 280px;
    background: #f8f9fa;
    border-right: 1px solid #e9ecef;
    display: flex;
    flex-direction: column;
}

.conversation-sidebar .sidebar-header {
    padding: 15px;
    border-bottom: 1px solid #e9ecef;
    background: white;
}

.conversation-sidebar .sidebar-header h3 {
    margin: 0 0 10px 0;
    font-size: 16px;
    font-weight: bold;
    color: #333;
}

.new-conversation-btn {
    width: 100%;
    padding: 8px 12px;
    background: #4A90E2;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s;
}

.new-conversation-btn:hover {
    background: #357ABD;
}

.conversation-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.conversation-item {
    padding: 12px;
    margin-bottom: 8px;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    border-left: 4px solid transparent;
}

.conversation-item:hover {
    background: #f0f4f8;
}

.conversation-item.active {
    background: #e3f2fd;
    border-left-color: #4A90E2;
}

.conversation-title {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-time {
    font-size: 12px;
    color: #999;
}

/* 聊天区域 */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.chat-header {
    background: #4A90E2;
    color: white;
    padding: 15px;
    font-size: 18px;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f5f7fa;
}

.chat-message {
    margin-bottom: 20px;
    display: flex;
}

.user-message {
    justify-content: flex-end;
}

.ai-message {
    justify-content: flex-start;
}

.message-content {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 18px;
    line-height: 1.4;
}

.user-message .message-content {
    background: #4A90E2;
    color: white;
    border-bottom-right-radius: 4px;
}

.ai-message .message-content {
    background: white;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.message-time {
    font-size: 12px;
    color: #999;
    margin-top: 5px;
}

.user-message .message-time {
    text-align: right;
}

.ai-message .message-time {
    text-align: left;
}

.chat-input {
    padding: 20px;
    background: white;
    border-top: 1px solid #eee;
}

.input-container {
    display: flex;
    gap: 10px;
}

.chat-input textarea {
    flex: 1;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 24px;
    resize: none;
    height: 60px;
    font-size: 14px;
}

.chat-input button {
    padding: 0 24px;
    background: #4A90E2;
    color: white;
    border: none;
    border-radius: 24px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s;
}

.chat-input button:hover {
    background: #357ABD;
}

.chat-input button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.chat-input .error-message {
    color: #e74c3c;
    padding: 10px;
    background: #fadbd8;
    border-radius: 4px;
    margin-bottom: 10px;
}

.typing-indicator {
    display: inline-flex;
    align-items: center;
}

.typing-indicator span {
    height: 8px;
    width: 8px;
    margin: 0 1px;
    background-color: #4A90E2;
    border-radius: 50%;
    display: inline-block;
    animation: bounce 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-indicator span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

/* 新对话模态框 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.4);
}

.modal-content {
    background-color: #fefefe;
    margin: 15% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 300px;
    border-radius: 8px;
}

.modal-header {
    margin-bottom: 15px;
}

.modal-header h3 {
    margin: 0;
    font-size: 16px;
    color: #333;
}

.modal-body {
    margin-bottom: 15px;
}

.modal-body input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.modal-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.modal-footer button {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.btn-primary {
    background: #4A90E2;
    color: white;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

/* AI咨询响应式设计 */
@media (max-width: 768px) {
    .chat-container {
        flex-direction: column;
        margin: 0 10px;
    }
    
    .conversation-sidebar {
        width: 100%;
        max-height: 200px;
        border-right: none;
        border-bottom: 1px solid #e9ecef;
    }
    
    .chat-body {
        height: 400px;
    }
    
    .message-content {
        max-width: 85%;
    }
    
    .modal-content {
        width: 90%;
        margin: 30% auto;
    }
}