* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f5f7fa;
    color: #333;
    line-height: 1.6;
}

.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Header */
.header {
    background: #fff;
    padding: 1rem 2rem;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.header h1 {
    font-size: 1.5rem;
    color: #2563eb;
}

.header-actions {
    display: flex;
    gap: 10px;
}

/* Main Content */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 320px;
    background: #fff;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 1rem;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h2 {
    font-size: 1.25rem;
}

.conversation-list {
    flex: 1;
    overflow-y: auto;
}

.conversation-item {
    padding: 1rem;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background 0.2s;
}

.conversation-item:hover {
    background: #f9fafb;
}

.conversation-item.active {
    background: #eff6ff;
    border-left: 3px solid #2563eb;
}

.conversation-item.unmatched {
    background: #fef3c7;
}

.conversation-header-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.conversation-name {
    font-weight: 600;
    color: #1f2937;
}

.conversation-time {
    font-size: 0.75rem;
    color: #9ca3af;
}

.conversation-preview {
    font-size: 0.875rem;
    color: #6b7280;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Messages Panel */
.messages-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #fff;
}

.empty-state {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
    font-size: 1.125rem;
}

.messages-container {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.conversation-header {
    padding: 1rem 2rem;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.conversation-info h3 {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
}

.phone-number {
    color: #6b7280;
    font-size: 0.875rem;
}

.messages-area {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
    background: #f9fafb;
}

.message {
    margin-bottom: 1rem;
    display: flex;
}

.message.inbound {
    justify-content: flex-start;
}

.message.outbound {
    justify-content: flex-end;
}

.message-bubble {
    max-width: 70%;
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    word-wrap: break-word;
}

.message.inbound .message-bubble {
    background: #e5e7eb;
    color: #1f2937;
    border-bottom-left-radius: 0.25rem;
}

.message.outbound .message-bubble {
    background: #2563eb;
    color: #fff;
    border-bottom-right-radius: 0.25rem;
}

.message-time {
    font-size: 0.75rem;
    opacity: 0.7;
    margin-top: 0.25rem;
}

/* Message Form */
.message-form {
    padding: 1rem 2rem;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 1rem;
}

.message-form textarea {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    resize: none;
    font-family: inherit;
    font-size: 1rem;
}

.message-form textarea:focus {
    outline: none;
    border-color: #2563eb;
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: #2563eb;
    color: #fff;
}

.btn-primary:hover {
    background: #1d4ed8;
}

.btn-secondary {
    background: #6b7280;
    color: #fff;
}

.btn-secondary:hover {
    background: #4b5563;
}

.btn-danger-outline {
    background: transparent;
    color: #dc2626;
    border: 1px solid #dc2626;
}

.btn-danger-outline:hover {
    background: #dc2626;
    color: #fff;
}

.btn-danger {
    background: #dc2626;
    color: #fff;
}

.btn-danger:hover {
    background: #b91c1c;
}

/* Badge */
.badge {
    background: #2563eb;
    color: #fff;
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: #fff;
    border-radius: 0.5rem;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.5rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: #6b7280;
    line-height: 1;
}

.modal-close:hover {
    color: #1f2937;
}

.modal-body {
    padding: 1.5rem;
}

/* Form */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #374151;
}

.form-group input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    font-size: 1rem;
}

.form-group input:focus {
    outline: none;
    border-color: #2563eb;
}

/* Patient List */
.patient-results {
    margin-top: 1.5rem;
}

.patient-results h3 {
    margin-bottom: 1rem;
    font-size: 1.125rem;
}

.patient-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.patient-item {
    padding: 1rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.2s;
}

.patient-item:hover {
    border-color: #2563eb;
    background: #eff6ff;
}

.patient-name {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.patient-details {
    font-size: 0.875rem;
    color: #6b7280;
}

/* Staff List */
.staff-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.staff-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.375rem;
}

.staff-name {
    font-weight: 500;
}

/* Loading State */
.loading {
    text-align: center;
    padding: 2rem;
    color: #6b7280;
}

/* Error State */
.error {
    padding: 1rem;
    background: #fee2e2;
    border: 1px solid #fca5a5;
    border-radius: 0.375rem;
    color: #991b1b;
    margin-bottom: 1rem;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}