:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --background: #f8fafc;
    --surface: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--background);
}

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.login-box {
    background: var(--surface);
    border-radius: 12px;
    padding: 40px;
    box-shadow: var(--shadow-lg);
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-header h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.btn {
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-block {
    width: 100%;
    justify-content: center;
}

.error-message {
    padding: 12px;
    background: #fef2f2;
    color: var(--danger-color);
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 14px;
}

.success-message {
    padding: 12px;
    background: #f0fdf4;
    color: var(--success-color);
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 14px;
}

.dashboard {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.sidebar {
    width: 260px;
    background: var(--surface);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h2 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 4px;
}

.sidebar-header .user-info {
    font-size: 12px;
    color: var(--text-secondary);
}

.sidebar-nav {
    flex: 1;
    padding: 16px 0;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: var(--text-primary);
    text-decoration: none;
    transition: all 0.2s;
    gap: 12px;
    cursor: pointer;
}

.nav-item:hover {
    background: var(--background);
}

.nav-item.active {
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary-color);
    font-weight: 500;
}

.nav-item .badge {
    margin-left: auto;
    background: var(--danger-color);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.topbar {
    height: 64px;
    background: var(--surface);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
}

.topbar-title {
    font-size: 20px;
    font-weight: 600;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--background);
    border-radius: 6px;
    font-size: 13px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-dot.online {
    background: var(--success-color);
}

.status-dot.offline {
    background: var(--secondary-color);
}

.status-dot.busy {
    background: var(--warning-color);
}

.content-area {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.card {
    background: var(--surface);
    border-radius: 8px;
    padding: 24px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.card-title {
    font-size: 18px;
    font-weight: 600;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    text-align: left;
    padding: 12px;
    background: var(--background);
    font-weight: 600;
    font-size: 13px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}

.table td {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
}

.table tr:hover {
    background: var(--background);
}

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.badge-success {
    background: #d1fae5;
    color: #065f46;
}

.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-info {
    background: #dbeafe;
    color: #1e40af;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: var(--surface);
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
}

.modal-close:hover {
    background: var(--background);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.chat-layout {
    display: flex;
    height: calc(100vh - 64px);
}

.chat-list {
    width: 320px;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    background: var(--surface);
}

.chat-list-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

.chat-tabs {
    display: flex;
    gap: 8px;
}

.chat-tab {
    flex: 1;
    padding: 8px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
}

.chat-tab:hover {
    background: var(--background);
}

.chat-tab.active {
    background: var(--primary-color);
    color: white;
}

.chat-items {
    flex: 1;
    overflow-y: auto;
}

.chat-item {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s;
}

.chat-item:hover {
    background: var(--background);
}

.chat-item.active {
    background: rgba(37, 99, 235, 0.05);
    border-left: 3px solid var(--primary-color);
}

.chat-item.unread {
    background: rgba(37, 99, 235, 0.03);
}

.chat-item-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
}

.chat-item-name {
    font-weight: 600;
    font-size: 14px;
}

.chat-item-time {
    font-size: 12px;
    color: var(--text-secondary);
}

.chat-item-message {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item-badge {
    display: inline-block;
    background: var(--danger-color);
    color: white;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 11px;
    margin-left: 8px;
}

.chat-window {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--surface);
}

.chat-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-header-info h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
}

.chat-header-info p {
    font-size: 13px;
    color: var(--text-secondary);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: var(--background);
}

.message {
    margin-bottom: 16px;
    display: flex;
}

.message.visitor {
    justify-content: flex-start;
}

.message.operator {
    justify-content: flex-end;
}

.message.system {
    justify-content: center;
}

.message-content {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
}

.message.visitor .message-content {
    background: var(--surface);
    border: 1px solid var(--border-color);
}

.message.operator .message-content {
    background: var(--primary-color);
    color: white;
}

.message.system .message-content {
    background: var(--background);
    color: var(--text-secondary);
    font-size: 13px;
    text-align: center;
    max-width: 100%;
    border: none;
    padding: 8px 12px;
}

.message-time {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.message.operator .message-time {
    text-align: right;
    color: rgba(255, 255, 255, 0.8);
}

.chat-input {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    background: var(--surface);
}

.chat-input-form {
    display: flex;
    gap: 12px;
}

.chat-input-form textarea {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    resize: none;
    font-family: inherit;
    font-size: 14px;
    min-height: 40px;
    max-height: 120px;
}

.chat-input-form button {
    align-self: flex-end;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-secondary);
    text-align: center;
    padding: 40px;
}

.empty-state-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-state-text {
    font-size: 16px;
    margin-bottom: 8px;
}

.empty-state-subtext {
    font-size: 14px;
}

@media (max-width: 1024px) {
    .sidebar {
        width: 240px;
    }
    
    .chat-list {
        width: 280px;
    }
}

@media (max-width: 768px) {
    body {
        font-size: 13px;
    }
    
    .sidebar {
        position: fixed;
        left: -260px;
        height: 100vh;
        z-index: 100;
        transition: left 0.3s;
        width: 260px;
    }
    
    .sidebar.show {
        left: 0;
        box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    }
    
    .main-content {
        width: 100%;
    }
    
    .topbar {
        padding: 0 16px;
    }
    
    .topbar-title {
        font-size: 18px;
    }
    
    .content-area {
        padding: 16px;
    }
    
    .card {
        padding: 16px;
        margin-bottom: 16px;
    }
    
    .table {
        font-size: 12px;
    }
    
    .table th,
    .table td {
        padding: 8px;
    }
    
    .chat-layout {
        flex-direction: column;
    }
    
    .chat-list {
        width: 100%;
        height: 50vh;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    
    .chat-window {
        width: 100%;
        height: 50vh;
    }
    
    .chat-window.fullscreen {
        height: 100vh;
        position: fixed;
        top: 0;
        left: 0;
        z-index: 200;
    }
    
    .chat-header {
        padding: 12px 16px;
    }
    
    .chat-messages {
        padding: 12px;
    }
    
    .chat-input {
        padding: 12px;
    }
    
    .modal-content {
        width: 95%;
        margin: 10px;
    }
}

@media (max-width: 480px) {
    .login-box {
        padding: 24px;
    }
    
    .login-header h1 {
        font-size: 24px;
    }
    
    .topbar {
        height: 56px;
    }
    
    .topbar-title {
        font-size: 16px;
    }
    
    .btn {
        padding: 8px 12px;
        font-size: 13px;
    }
    
    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .card-header .btn {
        width: 100%;
    }
    
    .form-group label {
        font-size: 13px;
    }
    
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .table {
        min-width: 600px;
    }
    
    .chat-list {
        height: 40vh;
    }
    
    .chat-window {
        height: 60vh;
    }
    
    .chat-header h3 {
        font-size: 14px;
    }
    
    .chat-header p {
        font-size: 12px;
    }
    
    .chat-header .btn {
        padding: 6px 10px;
        font-size: 12px;
    }
    
    .message-content {
        max-width: 85%;
        font-size: 13px;
        padding: 10px 12px;
    }
    
    .chat-input-form textarea {
        font-size: 13px;
    }
    
    .sidebar-nav {
        font-size: 13px;
    }
    
    .nav-item {
        padding: 10px 16px;
    }
}

@media (max-width: 360px) {
    .login-box {
        padding: 20px;
    }
    
    .btn {
        padding: 8px 10px;
        font-size: 12px;
    }
    
    .topbar {
        padding: 0 12px;
    }
    
    .content-area {
        padding: 12px;
    }
    
    .card {
        padding: 12px;
    }
}

@media (orientation: landscape) and (max-height: 500px) {
    .chat-list {
        height: 100vh;
    }
    
    .chat-window {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        z-index: 300;
        display: none;
    }
    
    .chat-window.active {
        display: flex;
    }
}
