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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #f5f5f5;
    height: 100vh;
    overflow: hidden;
}

.hidden {
    display: none !important;
}

.error {
    color: #d32f2f;
    font-size: 13px;
    margin-top: 10px;
    min-height: 20px;
}

/* Login Screen */
#login-screen {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-container {
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 400px;
}

.login-container h1 {
    margin-bottom: 30px;
    color: #333;
    text-align: center;
}

#login-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

#login-form input {
    padding: 14px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
}

#login-form input:focus {
    outline: none;
    border-color: #667eea;
}

#login-form button {
    padding: 14px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

#login-form button:hover {
    background: #5568d3;
}

/* Header */
.header {
    background: white;
    padding: 16px 24px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 30px;
}

.header-left h1 {
    font-size: 20px;
    color: #333;
}

.status-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .3s;
    border-radius: 26px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #4caf50;
}

input:checked + .slider:before {
    transform: translateX(24px);
}

#status-text {
    font-size: 14px;
    color: #666;
    font-weight: 500;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

#operator-name {
    font-weight: 500;
    color: #333;
}

.header-right button {
    padding: 8px 16px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.header-right button:hover {
    background: #f5f5f5;
}

#admin-btn {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

#admin-btn:hover {
    background: #5568d3;
}

/* Main Container */
.main-container {
    display: flex;
    height: calc(100vh - 65px);
}

/* Sidebar */
.sidebar {
    width: 320px;
    background: white;
    border-right: 1px solid #e0e0e0;
    overflow-y: auto;
}

.sidebar-section {
    padding: 16px;
    border-bottom: 1px solid #e0e0e0;
}

.sidebar-section h3 {
    font-size: 14px;
    color: #666;
    margin-bottom: 12px;
    text-transform: uppercase;
    font-weight: 600;
}

.conversation-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.conversation-item {
    padding: 12px;
    background: #f5f5f5;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.conversation-item:hover {
    background: #e8e8e8;
}

.conversation-item.waiting {
    border-left: 4px solid #ff9800;
}

.conversation-item.active {
    border-left: 4px solid #4caf50;
}

.conversation-item.my-conversation {
    background: #e3f2fd;
    border-left: 4px solid #2196f3;
}

.conversation-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.conversation-client-name {
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.conversation-time {
    font-size: 11px;
    color: #999;
}

.conversation-support-type {
    font-size: 12px;
    color: #666;
    background: white;
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
    margin-top: 4px;
}

.conversation-operator {
    font-size: 12px;
    color: #4caf50;
    margin-top: 4px;
}

/* Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #fafafa;
}

#conversation-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.no-conversation {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: #999;
}

.no-conversation svg {
    margin-bottom: 20px;
    opacity: 0.3;
}

.no-conversation p {
    font-size: 18px;
    margin-bottom: 8px;
}

.no-conversation .subtitle {
    font-size: 14px;
}

.conversation-header {
    background: white;
    padding: 16px 24px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.client-name {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
}

.support-type {
    font-size: 13px;
    color: #666;
}

#close-conversation-btn {
    padding: 8px 16px;
    background: #f44336;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}

#close-conversation-btn:hover {
    background: #d32f2f;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: 0;
}

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

.message-client {
    align-self: flex-start;
    background: white;
    color: #333;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.message-operator {
    align-self: flex-end;
    background: #667eea;
    color: white;
}

.message-content {
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 6px;
}

.message-image {
    max-width: 100%;
    border-radius: 8px;
    margin-top: 8px;
    cursor: pointer;
}

.message-file {
    display: inline-block;
    background: #f0f0f0;
    color: #0066cc;
    padding: 8px 12px;
    border-radius: 6px;
    margin-top: 8px;
    text-decoration: none;
    font-size: 13px;
    transition: background 0.2s;
}

.message-file:hover {
    background: #e0e0e0;
    text-decoration: underline;
}

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

.input-area {
    background: white;
    padding: 16px 24px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 12px;
}

.input-area button {
    padding: 10px 16px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s;
}

.input-area button:hover {
    background: #f5f5f5;
}

#send-btn {
    background: #667eea;
    color: white;
    border-color: #667eea;
    font-weight: 600;
    font-size: 14px;
}

#send-btn:hover {
    background: #5568d3;
}

.input-area input[type="text"] {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
}

.input-area input[type="text"]:focus {
    outline: none;
    border-color: #667eea;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Conversation Actions */
.conversation-actions {
    display: flex;
    gap: 12px;
}

.transfer-btn {
    padding: 8px 16px;
    background: #ff9800;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}

.transfer-btn:hover {
    background: #f57c00;
}

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

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

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

.modal-header h2 {
    font-size: 18px;
    color: #333;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: #999;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s;
}

.modal-close:hover {
    background: #f5f5f5;
    color: #333;
}

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

.modal-body p {
    margin-bottom: 16px;
    color: #666;
}

/* Operators List */
.operators-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.operator-item {
    padding: 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.operator-item:hover {
    border-color: #667eea;
    background: #f5f7ff;
}

.operator-info {
    flex: 1;
}

.operator-name {
    font-weight: 600;
    color: #333;
    font-size: 15px;
    margin-bottom: 4px;
}

.operator-specialties {
    font-size: 13px;
    color: #666;
}

.operator-status {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.operator-status.free {
    background: #e8f5e9;
    color: #2e7d32;
}

.operator-status.busy {
    background: #fff3e0;
    color: #e65100;
}

.message-system {
    align-self: center;
    background: #e3f2fd;
    color: #1565c0;
    padding: 10px 16px;
    border-radius: 20px;
    font-size: 13px;
    max-width: 80%;
    text-align: center;
    box-shadow: none;
}

/* History Toggle Button */
.history-btn {
    width: 100%;
    padding: 12px;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.history-btn:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

#history-toggle-icon {
    transition: transform 0.3s;
    font-size: 12px;
}

#history-toggle-icon.open {
    transform: rotate(90deg);
}

/* Operators List */
.operators-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.operator-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: #f5f5f5;
    border-radius: 6px;
}

.operator-name {
    font-size: 14px;
    color: #333;
}

.operator-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
}

.operator-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.operator-status.online .operator-status-dot {
    background: #4caf50;
}

.operator-status.busy .operator-status-dot {
    background: #ff9800;
}

.operator-status.offline .operator-status-dot {
    background: #999;
}

.operator-status.online {
    color: #4caf50;
}

.operator-status.busy {
    color: #ff9800;
}

.operator-status.offline {
    color: #999;
}

/* History Panel */
.history-panel {
    width: 380px;
    background: white;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.3s;
}

.history-panel.hidden {
    width: 0;
    border-right: none;
}

.history-panel-header {
    padding: 16px 20px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f5f5f5;
}

.history-panel-header h3 {
    font-size: 16px;
    color: #333;
    font-weight: 600;
}

.history-close-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: #999;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.history-close-btn:hover {
    background: #e0e0e0;
    color: #333;
}

.history-panel .history-search {
    padding: 16px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-panel .history-search input,
.history-panel .history-search select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
}

.history-panel .history-search input:focus,
.history-panel .history-search select:focus {
    outline: none;
    border-color: #667eea;
}

.history-panel .history-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

/* Modal Large */
.modal-large {
    max-width: 900px;
    width: 90%;
    max-height: 90vh;
}

/* History Search */
.history-search {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.history-search input,
.history-search select {
    flex: 1;
    min-width: 200px;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
}

.history-search input:focus,
.history-search select:focus {
    outline: none;
    border-color: #667eea;
}

/* History List */
.history-list {
    max-height: 500px;
    overflow-y: auto;
}

.history-panel .history-item {
    padding: 12px;
    background: #f5f5f5;
    border-radius: 6px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border-left: 3px solid #ccc;
}

.history-panel .history-item:hover {
    background: #e3f2fd;
    border-left-color: #667eea;
}

.history-item {
    padding: 16px;
    background: #f5f5f5;
    border-radius: 8px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.2s;
    border-left: 4px solid #ccc;
}

.history-item:hover {
    background: #e8e8e8;
    border-left-color: #667eea;
}

.history-item-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    align-items: center;
}

.history-item-client {
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.history-panel .history-item-client {
    font-size: 13px;
}

.history-item-date {
    font-size: 11px;
    color: #999;
}

.history-item-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
    color: #666;
}

.history-panel .history-item-details {
    font-size: 11px;
}

.history-item-type,
.history-item-operator {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Conversation Detail */
.conversation-detail-info {
    background: #f5f5f5;
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.conversation-detail-info div {
    font-size: 14px;
    color: #333;
}

.conversation-detail-info strong {
    color: #666;
    font-weight: 500;
}

.conversation-detail-messages {
    max-height: 400px;
    overflow-y: auto;
    padding: 16px;
    background: #fafafa;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
